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
dec0e7f5
Commit
dec0e7f5
authored
8 years ago
by
gwenn
Browse files
Options
Downloads
Patches
Plain Diff
Fix character transposition and add quoted insert
parent
aae5b080
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/completion.rs
+0
-1
0 additions, 1 deletion
src/completion.rs
src/consts.rs
+2
-0
2 additions, 0 deletions
src/consts.rs
src/lib.rs
+7
-1
7 additions, 1 deletion
src/lib.rs
src/line_buffer.rs
+11
-2
11 additions, 2 deletions
src/line_buffer.rs
with
20 additions
and
4 deletions
src/completion.rs
+
0
−
1
View file @
dec0e7f5
...
...
@@ -9,7 +9,6 @@ use line_buffer::LineBuffer;
// TODO: let the implementers choose/find word boudaries ???
// (line, pos) is like (rl_line_buffer, rl_point) to make contextual completion ("select t.na| from tbl as t")
// TOOD: make &self &mut self ???
// TODO: change update signature: _line: Into<String>
/// To be called for tab-completion.
pub
trait
Completer
{
...
...
This diff is collapsed.
Click to expand it.
src/consts.rs
+
2
−
0
View file @
dec0e7f5
...
...
@@ -22,6 +22,7 @@ pub enum KeyPress {
CTRL_S
,
CTRL_T
,
CTRL_U
,
CTRL_V
,
CTRL_W
,
CTRL_Y
,
CTRL_Z
,
...
...
@@ -62,6 +63,7 @@ pub fn char_to_key_press(c: char) -> KeyPress {
'\x13'
=>
KeyPress
::
CTRL_S
,
'\x14'
=>
KeyPress
::
CTRL_T
,
'\x15'
=>
KeyPress
::
CTRL_U
,
'\x16'
=>
KeyPress
::
CTRL_V
,
'\x17'
=>
KeyPress
::
CTRL_W
,
'\x19'
=>
KeyPress
::
CTRL_Y
,
'\x1a'
=>
KeyPress
::
CTRL_Z
,
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
7
−
1
View file @
dec0e7f5
...
...
@@ -833,7 +833,13 @@ fn readline_edit(prompt: &str,
kill_ring
.kill
(
&
text
,
false
)
}
}
// TODO CTRL_V // Quoted insert
KeyPress
::
CTRL_V
=>
{
// Quoted insert
kill_ring
.reset
();
let
c
=
chars
.next
()
.unwrap
();
let
ch
=
try
!
(
c
);
try
!
(
edit_insert
(
&
mut
s
,
ch
))
}
KeyPress
::
CTRL_W
=>
{
// Kill the word behind point, using white space as a word boundary
if
let
Some
(
text
)
=
try
!
(
edit_delete_prev_word
(
&
mut
s
,
char
::
is_whitespace
))
{
...
...
This diff is collapsed.
Click to expand it.
src/line_buffer.rs
+
11
−
2
View file @
dec0e7f5
...
...
@@ -225,10 +225,12 @@ impl LineBuffer {
/// Exchange the char before cursor with the character at cursor.
pub
fn
transpose_chars
(
&
mut
self
)
->
bool
{
if
self
.pos
==
0
||
self
.pos
==
self
.buf
.len
()
{
// TODO should work even if s.pos == s.buf.len()
if
self
.pos
==
0
||
self
.buf
.chars
()
.count
()
<
2
{
return
false
;
}
if
self
.pos
==
self
.buf
.len
()
{
self
.move_left
();
}
let
ch
=
self
.buf
.remove
(
self
.pos
);
let
size
=
ch
.len_utf8
();
let
other_ch
=
self
.char_before_cursor
()
.unwrap
();
...
...
@@ -502,6 +504,13 @@ mod test {
assert_eq!
(
"acß"
,
s
.buf
);
assert_eq!
(
2
,
s
.pos
);
assert_eq!
(
true
,
ok
);
s
.buf
=
String
::
from
(
"aßc"
);
s
.pos
=
4
;
let
ok
=
s
.transpose_chars
();
assert_eq!
(
"acß"
,
s
.buf
);
assert_eq!
(
2
,
s
.pos
);
assert_eq!
(
true
,
ok
);
}
#[test]
...
...
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