summaryrefslogtreecommitdiff
path: root/src/client/cursor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/cursor.cpp')
-rw-r--r--src/client/cursor.cpp46
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);
+ }
+};
+