diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-07-22 22:52:51 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-07-22 22:52:51 -0300 |
commit | dacf6e0625d10ff47d2aad0ca8d705f90f030119 (patch) | |
tree | bfb7f55d024c96b2390bd5f999455b2285542828 /src/client/cursor.cpp | |
parent | ba2c428dca0080cd79ea3e6c7d0f48764076fd2c (diff) | |
download | jet-dacf6e0625d10ff47d2aad0ca8d705f90f030119.tar.gz jet-dacf6e0625d10ff47d2aad0ca8d705f90f030119.zip |
Update architecture
Diffstat (limited to 'src/client/cursor.cpp')
-rw-r--r-- | src/client/cursor.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/client/cursor.cpp b/src/client/cursor.cpp new file mode 100644 index 0000000..226b8a5 --- /dev/null +++ b/src/client/cursor.cpp @@ -0,0 +1,46 @@ +class Cursor { + int x; + int y; + Window &w; + + public: + + Cursor(Window &w) : x(0), y(0), w(w) {} + + char element() { + return w.view[x + y * w.width]; + } + + void move_left() { + if (x == 0) { + if (y != 0) { + y--; + x = w.line_ends[y]; + } + } else { + x--; + } + } + + void move_right() { + if (element()) { + if (element() == '\n') { + x = 0; + y++; + } else { + x++; + } + } + } + + void move_up() { + } + + void move_down() { + } + + void update() { + w.set_cursor(x, y); + } +}; + |