about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-18 17:22:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-18 17:42:08 -0700
commitf91e5201241451fe5f9712a97c288f1534e74b11 (patch)
treee5d6618d03e6a49bfbd120a536b4aba6dc7361cc /text.lua
parente27165cb9f0f0635f0290cb345442292faeba7fd (diff)
downloadtext.love-f91e5201241451fe5f9712a97c288f1534e74b11.tar.gz
scroll past first page
Still some limitations. The text cursor has to be visible on screen, so
if you have a long series of drawings without intervening lines of text
you won't be able to scroll through them all.
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/text.lua b/text.lua
index 6888fda..f7ffb63 100644
--- a/text.lua
+++ b/text.lua
@@ -50,6 +50,9 @@ function Text.keychord_pressed(chord)
           break
         end
       end
+      if Cursor_line < Screen_top_line then
+        Screen_top_line = Cursor_line
+      end
     end
   elseif chord == 'right' then
     assert(Lines[Cursor_line].mode == 'text')
@@ -65,6 +68,9 @@ function Text.keychord_pressed(chord)
           break
         end
       end
+      if Cursor_line > Screen_bottom_line then
+        Screen_top_line = Cursor_line
+      end
     end
   elseif chord == 'home' then
     Cursor_pos = 1
@@ -128,6 +134,9 @@ function Text.keychord_pressed(chord)
         break
       end
     end
+    if Cursor_line < Screen_top_line then
+      Screen_top_line = Cursor_line
+    end
   elseif chord == 'down' then
     assert(Lines[Cursor_line].mode == 'text')
     local new_cursor_line = Cursor_line
@@ -140,10 +149,14 @@ function Text.keychord_pressed(chord)
         break
       end
     end
+    if Cursor_line > Screen_bottom_line then
+      Screen_top_line = Cursor_line
+    end
   end
 end
 
 function Text.in_line(line, x,y)
+  if line.y == nil then return false end  -- outside current page
   return x >= 16 and y >= line.y and y < line.y+15*Zoom
 end