diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-08-05 20:09:25 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-08-05 20:09:25 -0300 |
commit | bebe98b46283bf21954f5f0a4923d3add45e4d5b (patch) | |
tree | c82bcc39efd29b3e0ccac8bcfcf34f242796d0d7 /src | |
parent | 4bbbfb8e8139e690ea084b72ccc2de71fdca1e08 (diff) | |
download | jet-bebe98b46283bf21954f5f0a4923d3add45e4d5b.tar.gz jet-bebe98b46283bf21954f5f0a4923d3add45e4d5b.zip |
Add vertical movement
Diffstat (limited to 'src')
-rw-r--r-- | src/client/cursor.cpp | 12 | ||||
-rw-r--r-- | src/client/jetc.cpp | 14 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/client/cursor.cpp b/src/client/cursor.cpp index 65e32bf..82548b1 100644 --- a/src/client/cursor.cpp +++ b/src/client/cursor.cpp @@ -32,9 +32,21 @@ struct Cursor { } void move_up() { + if (y != 0) { + y--; + if (x > w.line_ends[y]) { + x = w.line_ends[y]; + } + } } void move_down() { + if (element()) { + y++; + if (x > w.line_ends[y]) { + x = w.line_ends[y]; + } + } } void update() { diff --git a/src/client/jetc.cpp b/src/client/jetc.cpp index cfe3db7..94d59ac 100644 --- a/src/client/jetc.cpp +++ b/src/client/jetc.cpp @@ -40,6 +40,14 @@ void move_right() { cursor.move_right(); } +void move_down() { + cursor.move_down(); +} + +void move_up() { + cursor.move_up(); +} + void delete_element() { msg.encode1(OP_DELETE); io.send(msg); @@ -73,6 +81,12 @@ int main(int argc, char *argv[]) { case 'h': move_left(); break; + case 'j': + move_down(); + break; + case 'k': + move_up(); + break; case 'l': move_right(); break; |