about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
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
 
id='n142' href='#n142'>142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201