Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fuchsia.googlesource.com-third_party-rust-mirrors-rustyline
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
fuchsia.googlesource.com-third_party-rust-mirrors-rustyline
Commits
4eddf071
Commit
4eddf071
authored
8 years ago
by
gwenn
Browse files
Options
Downloads
Patches
Plain Diff
Handle more Vi cmds (#94)
Replace char ('r') KillWholeLine ('S', 'dd', 'cc')
parent
e56e5c9f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/example.rs
+2
-1
2 additions, 1 deletion
examples/example.rs
src/keymap.rs
+2
-2
2 additions, 2 deletions
src/keymap.rs
src/lib.rs
+26
-14
26 additions, 14 deletions
src/lib.rs
with
30 additions
and
17 deletions
examples/example.rs
+
2
−
1
View file @
4eddf071
...
...
@@ -2,7 +2,7 @@ extern crate rustyline;
use
rustyline
::
completion
::
FilenameCompleter
;
use
rustyline
::
error
::
ReadlineError
;
use
rustyline
::{
Config
,
CompletionType
,
Editor
};
use
rustyline
::{
Config
,
CompletionType
,
Editor
,
EditMode
};
// On unix platforms you can use ANSI escape sequences
#[cfg(unix)]
...
...
@@ -17,6 +17,7 @@ fn main() {
let
config
=
Config
::
builder
()
.history_ignore_space
(
true
)
.completion_type
(
CompletionType
::
List
)
.edit_mode
(
EditMode
::
Emacs
)
.build
();
let
c
=
FilenameCompleter
::
new
();
let
mut
rl
=
Editor
::
with_config
(
config
);
...
...
This diff is collapsed.
Click to expand it.
src/keymap.rs
+
2
−
2
View file @
4eddf071
...
...
@@ -27,7 +27,7 @@ pub enum Cmd {
ForwardWord
(
Word
),
// Command For Moving
Interrupt
,
KillLine
,
// Command For Killing
KillWholeLine
,
// Command For Killing
(TODO Delete current line)
KillWholeLine
,
// Command For Killing
KillWord
(
Word
),
// Command For Killing
NextHistory
,
// Command For History
Noop
,
...
...
@@ -313,7 +313,7 @@ impl EditState {
KeyPress
::
Esc
=>
{
// vi-movement-mode/vi-command-mode: Vi enter command mode (use alternative key bindings).
self
.insert
=
false
;
Cmd
::
Noop
Cmd
::
BackwardChar
}
KeyPress
::
UnknownEscSeq
=>
Cmd
::
Noop
,
_
=>
Cmd
::
Unknown
,
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
26
−
14
View file @
4eddf071
...
...
@@ -667,22 +667,22 @@ fn page_completions<R: RawReader>(rdr: &mut R,
for
row
in
0
..
num_rows
{
if
row
==
pause_row
{
try
!
(
write_and_flush
(
s
.out
,
b"
\n
--More--"
));
let
mut
key
=
KeyPress
::
Null
;
while
key
!=
KeyPress
::
Char
(
'y'
)
&&
key
!=
KeyPress
::
Char
(
'Y'
)
&&
key
!=
KeyPress
::
Char
(
'n'
)
&&
key
!=
KeyPress
::
Char
(
'N'
)
&&
key
!=
KeyPress
::
Char
(
'q'
)
&&
key
!=
KeyPress
::
Char
(
'Q'
)
&&
key
!=
KeyPress
::
Char
(
' '
)
&&
key
!=
KeyPress
::
Backspace
&&
key
!=
KeyPress
::
Enter
{
key
=
try
!
(
rdr
.next_
key
(
config
.keyseq_timeout
()
));
let
mut
cmd
=
Cmd
::
Noop
;
while
cmd
!=
Cmd
::
SelfInsert
(
'y'
)
&&
cmd
!=
Cmd
::
SelfInsert
(
'Y'
)
&&
cmd
!=
Cmd
::
SelfInsert
(
'n'
)
&&
cmd
!=
Cmd
::
SelfInsert
(
'N'
)
&&
cmd
!=
Cmd
::
SelfInsert
(
'q'
)
&&
cmd
!=
Cmd
::
SelfInsert
(
'Q'
)
&&
cmd
!=
Cmd
::
SelfInsert
(
' '
)
&&
cmd
!=
Cmd
::
BackwardDeleteChar
&&
cmd
!=
Cmd
::
AcceptLine
{
cmd
=
try
!
(
s
.next_
cmd
(
rdr
,
config
));
}
match
key
{
KeyPress
::
Char
(
'y'
)
|
KeyPress
::
Char
(
'Y'
)
|
KeyPress
::
Char
(
' '
)
=>
{
match
cmd
{
Cmd
::
SelfInsert
(
'y'
)
|
Cmd
::
SelfInsert
(
'Y'
)
|
Cmd
::
SelfInsert
(
' '
)
=>
{
pause_row
+=
s
.term
.get_rows
()
-
1
;
}
KeyPress
::
Enter
=>
{
Cmd
::
AcceptLine
=>
{
pause_row
+=
1
;
}
_
=>
break
,
...
...
@@ -859,6 +859,12 @@ fn readline_edit<C: Completer>(prompt: &str,
// Delete (forward) one character at point.
try
!
(
edit_delete
(
&
mut
s
))
}
Cmd
::
Replace
(
c
)
=>
{
editor
.kill_ring
.reset
();
try
!
(
edit_delete
(
&
mut
s
));
try
!
(
edit_insert
(
&
mut
s
,
c
));
try
!
(
edit_move_left
(
&
mut
s
))
}
Cmd
::
EndOfFile
=>
{
editor
.kill_ring
.reset
();
if
!
s
.edit_state
.is_emacs_mode
()
||
s
.line
.is_empty
()
{
...
...
@@ -888,6 +894,12 @@ fn readline_edit<C: Completer>(prompt: &str,
editor
.kill_ring
.kill
(
&
text
,
Mode
::
Append
)
}
}
Cmd
::
KillWholeLine
=>
{
try
!
(
edit_move_home
(
&
mut
s
));
if
let
Some
(
text
)
=
try
!
(
edit_kill_line
(
&
mut
s
))
{
editor
.kill_ring
.kill
(
&
text
,
Mode
::
Append
)
}
}
Cmd
::
ClearScreen
=>
{
// Clear the screen leaving the current line at the top of the screen.
try
!
(
s
.term
.clear_screen
(
&
mut
s
.out
));
...
...
@@ -1204,7 +1216,7 @@ mod test {
snapshot
:
LineBuffer
::
with_capacity
(
100
),
term
:
term
,
byte_buffer
:
[
0
;
4
],
edit_state
:
EditState
::
new
(
&
config
),
edit_state
:
EditState
::
new
(
&
config
),
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment