Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sodium
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
28
Issues
28
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
redox-os
sodium
Commits
ca007766
Commit
ca007766
authored
May 23, 2016
by
Jake Goldsborough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds the W command to go to next WORD. adds a find next word forward function
parent
cacada51
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
movement.rs
src/caret/movement.rs
+20
-0
exec.rs
src/core/exec.rs
+8
-0
No files found.
src/caret/movement.rs
View file @
ca007766
...
@@ -175,4 +175,24 @@ impl Editor {
...
@@ -175,4 +175,24 @@ impl Editor {
None
None
}
}
/// Get next WORD forward
/// "A WORD consists of a sequence of non-blank characters, separated with
/// whitespace. An empty line is also considered to be a WORD."
pub
fn
_
next_word_forward
(
&
self
,
n
:
usize
)
->
Option
<
usize
>
{
let
mut
dn
=
0
;
let
mut
x
=
self
.x
();
for
(
i
,
ch
)
in
self
.buffers
.current_buffer
()[
self
.y
()]
.chars
()
.skip
(
x
)
.enumerate
()
{
if
ch
.is_whitespace
()
{
dn
+=
1
;
if
dn
==
n
{
x
+=
i
+
1
;
return
Some
(
x
);
}
}
}
None
}
}
}
src/core/exec.rs
View file @
ca007766
...
@@ -199,6 +199,14 @@ impl Editor {
...
@@ -199,6 +199,14 @@ impl Editor {
mov
=
true
;
mov
=
true
;
}
}
}
}
(
Command
(
Normal
),
Char
(
'W'
))
=>
{
let
pos
=
self
._next_word_forward
(
n
);
if
let
Some
(
p
)
=
pos
{
let
y
=
self
.y
();
self
.goto
((
p
,
y
));
mov
=
true
;
}
}
(
Command
(
Normal
),
Char
(
';'
))
=>
(
Command
(
Normal
),
Char
(
';'
))
=>
self
.cursor_mut
()
.mode
=
Mode
::
Primitive
(
PrimitiveMode
::
Prompt
),
self
.cursor_mut
()
.mode
=
Mode
::
Primitive
(
PrimitiveMode
::
Prompt
),
(
Command
(
Normal
),
Char
(
' '
))
=>
self
.next_cursor
(),
(
Command
(
Normal
),
Char
(
' '
))
=>
self
.next_cursor
(),
...
...
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