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
d23320eb
Commit
d23320eb
authored
Jun 10, 2019
by
AdminXVII
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace all movements
parent
751d4da7
Pipeline
#4513
passed with stage
in 1 minute and 54 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
29 deletions
+53
-29
src/editor.rs
src/editor.rs
+7
-15
src/keymap/emacs.rs
src/keymap/emacs.rs
+26
-6
src/keymap/mod.rs
src/keymap/mod.rs
+4
-2
src/keymap/vi.rs
src/keymap/vi.rs
+16
-6
No files found.
src/editor.rs
View file @
d23320eb
...
...
@@ -299,7 +299,7 @@ impl<'a, W: io::Write> Editor<'a, W> {
/// current_history_loc if set). If started with forward true then incremental search goes
/// forward (top to bottom) other wise reverse (bottom to top). It is valid to continue a
/// search with forward changed (i.e. reverse search direction for one result).
pub
fn
search
(
&
mut
self
,
forward
:
bool
)
->
io
::
Result
<
()
>
{
pub
fn
search
(
&
mut
self
,
forward
:
bool
)
{
if
!
self
.is_search
()
{
self
.freshen_history
();
self
.refresh_search
(
forward
);
...
...
@@ -322,8 +322,6 @@ impl<'a, W: io::Write> Editor<'a, W> {
None
};
}
self
.display
()
?
;
Ok
(())
}
pub
fn
flush
(
&
mut
self
)
->
io
::
Result
<
()
>
{
...
...
@@ -545,9 +543,9 @@ impl<'a, W: io::Write> Editor<'a, W> {
}
/// Move up (backwards) in history.
pub
fn
move_up
(
&
mut
self
)
->
io
::
Result
<
()
>
{
pub
fn
move_up
(
&
mut
self
)
{
if
self
.is_search
()
{
self
.search
(
false
)
self
.search
(
false
)
;
}
else
{
self
.hist_buf_valid
=
false
;
self
.freshen_history
();
...
...
@@ -580,14 +578,13 @@ impl<'a, W: io::Write> Editor<'a, W> {
}
self
.move_cursor_to_end_of_line
();
self
.no_newline
=
true
;
self
.display
()
}
}
/// Move down (forwards) in history, or to the new buffer if we reach the end of history.
pub
fn
move_down
(
&
mut
self
)
->
io
::
Result
<
()
>
{
pub
fn
move_down
(
&
mut
self
)
{
if
self
.is_search
()
{
self
.search
(
true
)
self
.search
(
true
)
;
}
else
{
self
.hist_buf_valid
=
false
;
if
self
.new_buf
.num_chars
()
>
0
{
...
...
@@ -612,12 +609,11 @@ impl<'a, W: io::Write> Editor<'a, W> {
}
self
.move_cursor_to_end_of_line
();
self
.no_newline
=
true
;
self
.display
()
}
}
/// Moves to the start of history (ie. the earliest history entry).
pub
fn
move_to_start_of_history
(
&
mut
self
)
->
io
::
Result
<
()
>
{
pub
fn
move_to_start_of_history
(
&
mut
self
)
{
self
.hist_buf_valid
=
false
;
if
self
.context.history
.len
()
>
0
{
self
.cur_history_loc
=
Some
(
0
);
...
...
@@ -625,19 +621,15 @@ impl<'a, W: io::Write> Editor<'a, W> {
}
else
{
self
.cur_history_loc
=
None
;
}
self
.no_newline
=
true
;
self
.display
()
}
/// Moves to the end of history (ie. the new buffer).
pub
fn
move_to_end_of_history
(
&
mut
self
)
->
io
::
Result
<
()
>
{
pub
fn
move_to_end_of_history
(
&
mut
self
)
{
self
.hist_buf_valid
=
false
;
if
self
.cur_history_loc
.is_some
()
{
self
.cur_history_loc
=
None
;
self
.move_cursor_to_end_of_line
();
}
self
.no_newline
=
true
;
self
.display
()
}
/// Inserts a string directly after the cursor, moving the cursor to the right.
...
...
src/keymap/emacs.rs
View file @
d23320eb
...
...
@@ -49,8 +49,14 @@ impl Emacs {
ed
.display
()
}
'd'
=>
ed
.delete_after_cursor
(),
'p'
=>
ed
.move_up
(),
'n'
=>
ed
.move_down
(),
'p'
=>
{
ed
.move_up
();
ed
.display
()
}
'n'
=>
{
ed
.move_down
();
ed
.display
()
}
'u'
=>
ed
.delete_all_before_cursor
(),
'k'
=>
ed
.delete_all_after_cursor
(),
'w'
=>
ed
.delete_word_before_cursor
(
true
),
...
...
@@ -64,8 +70,16 @@ impl Emacs {
fn
handle_alt_key
<
'a
,
W
:
Write
>
(
&
mut
self
,
c
:
char
,
ed
:
&
mut
Editor
<
'a
,
W
>
)
->
io
::
Result
<
()
>
{
match
c
{
'<'
=>
ed
.move_to_start_of_history
(),
'>'
=>
ed
.move_to_end_of_history
(),
'<'
=>
{
ed
.move_to_start_of_history
();
ed
.no_newline
=
true
;
ed
.display
()
}
'>'
=>
{
ed
.move_to_end_of_history
();
ed
.no_newline
=
true
;
ed
.display
()
}
'\x7F'
=>
ed
.delete_word_before_cursor
(
true
),
'f'
=>
{
emacs_move_word
(
ed
,
EmacsMoveDir
::
Right
);
...
...
@@ -151,8 +165,14 @@ impl KeyMap for Emacs {
ed
.no_newline
=
true
;
ed
.display
()
}
Key
::
Up
=>
ed
.move_up
(),
Key
::
Down
=>
ed
.move_down
(),
Key
::
Up
=>
{
ed
.move_up
();
ed
.display
()
}
Key
::
Down
=>
{
ed
.move_down
();
ed
.display
()
}
Key
::
Home
=>
{
ed
.move_cursor_to_start_of_line
();
...
...
src/keymap/mod.rs
View file @
d23320eb
...
...
@@ -48,10 +48,12 @@ pub trait KeyMap: Default {
editor
.accept_autosuggestion
()
?
;
}
Key
::
Ctrl
(
'r'
)
=>
{
editor
.search
(
false
)
?
;
editor
.search
(
false
);
editor
.display
()
?
;
}
Key
::
Ctrl
(
's'
)
=>
{
editor
.search
(
true
)
?
;
editor
.search
(
true
);
editor
.display
()
?
;
}
Key
::
Right
if
editor
.is_currently_showing_autosuggestion
()
...
...
src/keymap/vi.rs
View file @
d23320eb
...
...
@@ -510,8 +510,14 @@ impl Vi {
ed
.no_newline
=
true
;
ed
.display
()
}
Key
::
Up
=>
ed
.move_up
(),
Key
::
Down
=>
ed
.move_down
(),
Key
::
Up
=>
{
ed
.move_up
();
ed
.display
()
}
Key
::
Down
=>
{
ed
.move_down
();
ed
.display
()
}
Key
::
Home
=>
{
ed
.move_cursor_to_start_of_line
();
ed
.no_newline
=
true
;
...
...
@@ -590,7 +596,8 @@ impl Vi {
self
.count
=
0
;
self
.movement_reset
=
true
;
ed
.current_buffer_mut
()
.end_undo_group
();
ed
.move_up
()
?
;
ed
.move_up
();
ed
.display
()
?
;
ed
.current_buffer_mut
()
.start_undo_group
();
Ok
(())
}
...
...
@@ -598,7 +605,8 @@ impl Vi {
self
.count
=
0
;
self
.movement_reset
=
true
;
ed
.current_buffer_mut
()
.end_undo_group
();
ed
.move_down
()
?
;
ed
.move_down
();
ed
.display
()
?
;
ed
.current_buffer_mut
()
.start_undo_group
();
Ok
(())
}
...
...
@@ -727,11 +735,13 @@ impl Vi {
self
.pop_mode_after_movement
(
Exclusive
,
ed
)
}
Key
::
Char
(
'k'
)
|
Key
::
Up
=>
{
ed
.move_up
()
?
;
ed
.move_up
();
ed
.display
()
?
;
self
.pop_mode_after_movement
(
Exclusive
,
ed
)
}
Key
::
Char
(
'j'
)
|
Key
::
Down
=>
{
ed
.move_down
()
?
;
ed
.move_down
();
ed
.display
()
?
;
self
.pop_mode_after_movement
(
Exclusive
,
ed
)
}
Key
::
Char
(
't'
)
=>
{
...
...
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