Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
liner
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AdminXVII
liner
Commits
43d81445
Commit
43d81445
authored
May 08, 2019
by
AdminXVII
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an init method to KeyMaps
parent
2240b579
Pipeline
#4324
passed with stage
in 1 minute and 56 seconds
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
231 additions
and
115 deletions
+231
-115
src/context.rs
src/context.rs
+2
-1
src/keymap/emacs.rs
src/keymap/emacs.rs
+2
-3
src/keymap/mod.rs
src/keymap/mod.rs
+4
-1
src/keymap/vi.rs
src/keymap/vi.rs
+223
-110
No files found.
src/context.rs
View file @
43d81445
...
...
@@ -110,7 +110,7 @@ impl Context {
let
mut
ed
=
Editor
::
new_with_init_buffer
(
stdout
,
prompt
,
f
,
self
,
buffer
)
?
;
match
self
.key_bindings
{
KeyBindings
::
Emacs
=>
Self
::
handle_keys
(
keymap
::
Emacs
::
new
(),
ed
,
handler
),
KeyBindings
::
Vi
=>
Self
::
handle_keys
(
keymap
::
Vi
::
new
(
&
mut
ed
),
ed
,
handler
),
KeyBindings
::
Vi
=>
Self
::
handle_keys
(
keymap
::
Vi
::
new
(),
ed
,
handler
),
}
};
...
...
@@ -123,6 +123,7 @@ impl Context {
mut
ed
:
Editor
<
'a
,
W
>
,
handler
:
&
mut
C
,
)
->
io
::
Result
<
String
>
{
keymap
.init
(
&
mut
ed
);
for
c
in
stdin
()
.keys
()
{
if
keymap
.handle_key
(
c
.unwrap
(),
&
mut
ed
,
handler
)
?
{
break
;
...
...
src/keymap/emacs.rs
View file @
43d81445
...
...
@@ -12,15 +12,14 @@ use KeyMap;
/// let mut context = Context::new();
/// context.key_bindings = KeyBindings::Emacs;
/// ```
#[derive(Default)]
pub
struct
Emacs
{
last_arg_fetch_index
:
Option
<
usize
>
,
}
impl
Emacs
{
pub
fn
new
()
->
Self
{
Emacs
{
last_arg_fetch_index
:
None
,
}
Self
::
default
()
}
fn
handle_ctrl_key
<
'a
,
W
:
Write
>
(
&
mut
self
,
c
:
char
,
ed
:
&
mut
Editor
<
'a
,
W
>
)
->
io
::
Result
<
()
>
{
...
...
src/keymap/mod.rs
View file @
43d81445
...
...
@@ -4,13 +4,15 @@ use std::io::{self, ErrorKind, Write};
use
termion
::
event
::
Key
;
use
Editor
;
pub
trait
KeyMap
{
pub
trait
KeyMap
:
Default
{
fn
handle_key_core
<
'a
,
W
:
Write
>
(
&
mut
self
,
key
:
Key
,
editor
:
&
mut
Editor
<
'a
,
W
>
,
)
->
io
::
Result
<
()
>
;
fn
init
<
'a
,
W
:
Write
>
(
&
mut
self
,
_
editor
:
&
mut
Editor
<
'a
,
W
>
)
{}
fn
handle_key
<
'a
,
W
:
Write
,
C
:
Completer
<
W
>>
(
&
mut
self
,
mut
key
:
Key
,
...
...
@@ -84,6 +86,7 @@ mod tests {
use
termion
::
event
::
Key
::
*
;
use
Context
;
#[derive(Default)]
struct
TestKeyMap
;
impl
KeyMap
for
TestKeyMap
{
...
...
src/keymap/vi.rs
View file @
43d81445
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment