about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--edit.lua4
-rw-r--r--select.lua2
-rw-r--r--text.lua6
3 files changed, 6 insertions, 6 deletions
diff --git a/edit.lua b/edit.lua
index 2de3cb2..17bbc9e 100644
--- a/edit.lua
+++ b/edit.lua
@@ -215,7 +215,7 @@ function edit.mouse_pressed(State, x,y, mouse_button)
         State.mousepress_shift = App.shift_down()
         State.selection1 = {
             line=line_index,
-            pos=Text.to_pos_on_line(State, line, x, y),
+            pos=Text.to_pos_on_line(State, line_index, x, y),
         }
 --?         print('selection', State.selection1.line, State.selection1.pos)
         break
@@ -249,7 +249,7 @@ function edit.mouse_released(State, x,y, mouse_button)
 --?           print('reset selection')
           State.cursor1 = {
               line=line_index,
-              pos=Text.to_pos_on_line(State, line, x, y),
+              pos=Text.to_pos_on_line(State, line_index, x, y),
           }
 --?           print('cursor', State.cursor1.line, State.cursor1.pos)
           if State.mousepress_shift then
diff --git a/select.lua b/select.lua
index 9e87081..a728f84 100644
--- a/select.lua
+++ b/select.lua
@@ -94,7 +94,7 @@ function Text.to_pos(State, x,y)
   for line_index,line in ipairs(State.lines) do
     if line.mode == 'text' then
       if Text.in_line(State, line_index, x,y) then
-        return line_index, Text.to_pos_on_line(State, line, x,y)
+        return line_index, Text.to_pos_on_line(State, line_index, x,y)
       end
     end
   end
diff --git a/text.lua b/text.lua
index 7f7c8f4..50c9c15 100644
--- a/text.lua
+++ b/text.lua
@@ -703,7 +703,8 @@ function Text.in_line(State, line_index, x,y)
 end
 
 -- convert mx,my in pixels to schema-1 coordinates
-function Text.to_pos_on_line(State, line, mx, my)
+function Text.to_pos_on_line(State, line_index, mx, my)
+  local line = State.lines[line_index]
   if line.fragments == nil then
     Text.compute_fragments(line, State.left, State.right)
   end
@@ -964,10 +965,9 @@ function Text.tweak_screen_top_and_cursor(State)
 --?     print('too low')
     if Text.cursor_past_screen_bottom(State) then
 --?       print('tweak')
-      local line = State.lines[State.screen_bottom1.line]
       State.cursor1 = {
           line=State.screen_bottom1.line,
-          pos=Text.to_pos_on_line(State, line, App.screen.width-5, App.screen.height-5),
+          pos=Text.to_pos_on_line(State, State.screen_bottom1.line, App.screen.width-5, App.screen.height-5),
       }
     end
   end