about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-12-23 12:33:41 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-12-23 12:33:41 -0800
commita5533d79406d2dc8c18fa7253edc54d037462159 (patch)
treea35fc88b97b6c9fa314319fdeb1a07ea07ef915b
parent916857dae08c499a9016082185a83b6139f2e4b6 (diff)
downloadteliva-a5533d79406d2dc8c18fa7253edc54d037462159.tar.gz
toot-toot: plug width into cursor movement
-rw-r--r--toot-toot.tlv7
1 files changed, 4 insertions, 3 deletions
diff --git a/toot-toot.tlv b/toot-toot.tlv
index 0f9de69..5ea090d 100644
--- a/toot-toot.tlv
+++ b/toot-toot.tlv
@@ -289,6 +289,7 @@
   update:
     >function update(window)
     >  local key = curses.getch()
+    >  local h, w = window:getmaxyx()
     >  if key == curses.KEY_LEFT then
     >    if cursor > 1 then
     >      cursor = cursor-1
@@ -298,9 +299,9 @@
     >      cursor = cursor+1
     >    end
     >  elseif key == curses.KEY_DOWN then
-    >    cursor = cursor_down(prose, cursor)
+    >    cursor = cursor_down(prose, cursor, w)
     >  elseif key == curses.KEY_UP then
-    >    cursor = cursor_up(prose, cursor)
+    >    cursor = cursor_up(prose, cursor, w)
     >  elseif key == curses.KEY_BACKSPACE then
     >    if cursor > 1 then
     >      cursor = cursor-1
@@ -320,7 +321,7 @@
     >end
 - __teliva_timestamp: original
   cursor_down:
-    >function cursor_down(s, old_idx)
+    >function cursor_down(s, old_idx, width)
     >  local max = string.len(s)
     >  local i = 1
     >  -- compute oldcol, the screen column of old_idx