about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-12-23 11:01:52 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-12-23 11:08:56 -0800
commita2cb3da0c957cdc236d25a5cc1d8996ce9a32dbc (patch)
treef92e9e505ab33e29396ee7633aee81aa3d2f3e2e
parentc1bcd566e99121435b96403d5c5dafd8dcad03fa (diff)
downloadteliva-a2cb3da0c957cdc236d25a5cc1d8996ce9a32dbc.tar.gz
toot-toot: cursor_up now handles wrapping lines
-rw-r--r--toot-toot.tlv18
1 files changed, 12 insertions, 6 deletions
diff --git a/toot-toot.tlv b/toot-toot.tlv
index 1380f39..fc6fe92 100644
--- a/toot-toot.tlv
+++ b/toot-toot.tlv
@@ -659,7 +659,7 @@
     >  -- compute oldcol, the screen column of old_idx
     >  local oldcol = 0
     >  local col = 0
-    >  local previous_newline = 0
+    >  local newline_before_current_line = 0
     >  curses.addstr('^')
     >  while true do
     >    curses.addstr('|'..i)
@@ -669,7 +669,7 @@
     >    end
     >    if s[i] == '\n' then
     >      col = 0
-    >      previous_newline = i
+    >      newline_before_current_line = i
     >    else
     >      col = col+1
     >      if col == width then
@@ -680,12 +680,12 @@
     >  end
     >  -- find previous newline
     >  i = i-col-1
-    >--?   curses.addstr('w'..old_idx..'-'..previous_newline)
-    >  if old_idx - previous_newline > width then
+    >--?   curses.addstr('w'..old_idx..'-'..newline_before_current_line)
+    >  if old_idx - newline_before_current_line > width then
     >    -- we're in a wrapped line
     >    return old_idx - width
     >  end
-    >  -- scan back to previous line
+    >  -- scan back to start of previous line
     >  if s[i] == '\n' then
     >    i = i-1
     >  end
@@ -701,10 +701,16 @@
     >    end
     >    i = i-1
     >  end
-    >  -- compute index at same column on next line
     >  -- i is at a newline
     >  curses.addstr('/'..i)
     >  i = i+1
+    >  -- skip whole screen lines within previous line
+    >  curses.addstr('x'..old_idx..'-'..i)
+    >  while newline_before_current_line - i > width do
+    >    i = i + width
+    >    curses.addstr('p'..i)
+    >  end
+    >  -- compute index at same column on previous screen line
     >  col = 0
     >  while true do
     >    curses.addstr('>>'..i)