about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-01-31 22:29:44 +0000
committerJames Booth <boothj5@gmail.com>2015-01-31 22:29:44 +0000
commita19c0a5989c45ced8460284fe6591bebe08d22ac (patch)
tree1d8b57fb87b8609def4af950474e46c8e47e31b4 /src
parent3b3ffcfb3770a781a38a93d930df38f9d4a37c28 (diff)
downloadprofani-tty-a19c0a5989c45ced8460284fe6591bebe08d22ac.tar.gz
Added scroll handler
Diffstat (limited to 'src')
-rw-r--r--src/ui/inputwin.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 083b6c4e..ee800e56 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -366,12 +366,34 @@ inp_block(void)
 }
 
 void
+inp_win_handle_scroll(void)
+{
+    int col = getcurx(inp_win);
+    int wcols = getmaxx(stdscr);
+
+    // if lost cursor off screen, move contents to show it
+    if (col >= pad_start + (wcols -2)) {
+        pad_start = col - (wcols / 2);
+        if (pad_start < 0) {
+            pad_start = 0;
+        }
+    } else if (col <= pad_start) {
+        pad_start = pad_start - (wcols / 2);
+        if (pad_start < 0) {
+            pad_start = 0;
+        }
+    }
+}
+
+void
 inp_write(char *line, int offset)
 {
     int col = offset_to_col(line, offset);
     werase(inp_win);
     waddstr(inp_win, line);
     wmove(inp_win, 0, col);
+    inp_win_handle_scroll();
+
     _inp_win_update_virtual();
 }