about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2024-06-11 11:10:34 -0700
committerKartik K. Agaram <vc@akkartik.com>2024-06-11 11:10:34 -0700
commit55f5c2d696ffba6c5d220d8e317c15ed2335ac7b (patch)
tree40087d23284f702825522964560409f8d0a00acb
parent7aa43d1d2dd57792c447ba40cdf05791e3301123 (diff)
downloadlines.love-55f5c2d696ffba6c5d220d8e317c15ed2335ac7b.tar.gz
crap, fix some final changes in the source editor
-rw-r--r--app.lua2
-rw-r--r--source_select.lua2
-rw-r--r--source_text.lua12
3 files changed, 7 insertions, 9 deletions
diff --git a/app.lua b/app.lua
index 274f38d..263518c 100644
--- a/app.lua
+++ b/app.lua
@@ -131,7 +131,7 @@ function App.run_tests()
   end
   table.sort(sorted_names)
 --?   App.initialize_for_test() -- debug: run a single test at a time like these 2 lines
---?   test_click_moves_cursor()
+--?   test_click_below_all_lines()
   for _,name in ipairs(sorted_names) do
     App.initialize_for_test()
 --?     print('=== '..name)
diff --git a/source_select.lua b/source_select.lua
index 78d18db..b67dd16 100644
--- a/source_select.lua
+++ b/source_select.lua
@@ -69,7 +69,7 @@ end
 
 function Text.mouse_pos(State)
   local x,y = App.mouse_x(), App.mouse_y()
-  if y < State.line_cache[State.screen_top1.line].starty then
+  if y < State.top then
     return State.screen_top1.line, State.screen_top1.pos
   end
   for line_index,line in ipairs(State.lines) do
diff --git a/source_text.lua b/source_text.lua
index d2c68c2..6e0c4f9 100644
--- a/source_text.lua
+++ b/source_text.lua
@@ -439,11 +439,14 @@ function Text.starty(State, line_index)
   local loc2 = Text.to2(State, State.screen_top1)
   local y = State.top
   while true do
+    if State.lines[loc2.line].mode == 'drawing' then
+      y = y + Drawing_padding_top
+    end
     if loc2.line == line_index then return y end
     if State.lines[loc2.line].mode == 'text' then
       y = y + State.line_height
     elseif State.lines[loc2.line].mode == 'drawing' then
-      y = y + Drawing_padding_height + Drawing.pixels(State.lines[loc2.line].h, State.width)
+      y = y + Drawing.pixels(State.lines[loc2.line].h, State.width) + Drawing_padding_bottom
     end
     if y + State.line_height > App.screen.height then break end
     local next_loc2 = Text.next_screen_line(State, loc2)
@@ -1102,13 +1105,8 @@ function Text.tweak_screen_top_and_cursor(State)
   if Text.lt1(State.cursor1, State.screen_top1) then
     State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
   elseif State.cursor1.line >= screen_bottom1.line then
---?     print('too low')
     if Text.cursor_out_of_screen(State) then
---?       print('tweak')
-      State.cursor1 = {
-          line=screen_bottom1.line,
-          pos=Text.to_pos_on_line(State, screen_bottom1.line, State.right-5, App.screen.height-5),
-      }
+      State.cursor1 = Text.final_text_loc_on_screen(State)
     end
   end
 end