about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--main.lua4
-rw-r--r--select.lua2
-rw-r--r--text.lua5
3 files changed, 5 insertions, 6 deletions
diff --git a/main.lua b/main.lua
index 483f560..7d5b073 100644
--- a/main.lua
+++ b/main.lua
@@ -353,7 +353,7 @@ function App.mousepressed(x,y, mouse_button)
         Mousepress_shift = App.shift_down()
         Selection1 = {
             line=line_index,
-            pos=Text.to_pos_on_line(line, x, y),
+            pos=Text.to_pos_on_line(line, x, y, Margin_left, App.screen.width-Margin_right),
         }
 --?         print('selection', Selection1.line, Selection1.pos)
         break
@@ -389,7 +389,7 @@ function App.mousereleased(x,y, button)
 --?           print('reset selection')
           Cursor1 = {
               line=line_index,
-              pos=Text.to_pos_on_line(line, x, y),
+              pos=Text.to_pos_on_line(line, x, y, Margin_left, App.screen.width-Margin_right),
           }
 --?           print('cursor', Cursor1.line, Cursor1.pos)
           if Mousepress_shift then
diff --git a/select.lua b/select.lua
index ed79261..05d4cd9 100644
--- a/select.lua
+++ b/select.lua
@@ -96,7 +96,7 @@ function Text.to_pos(x,y, left, right)
   for line_index,line in ipairs(Lines) do
     if line.mode == 'text' then
       if Text.in_line(line, x,y, left, right) then
-        return line_index, Text.to_pos_on_line(line, x,y)
+        return line_index, Text.to_pos_on_line(line, x,y, left, right)
       end
     end
   end
diff --git a/text.lua b/text.lua
index dbf1604..2ac62ec 100644
--- a/text.lua
+++ b/text.lua
@@ -672,8 +672,7 @@ function Text.in_line(line, x,y, left,right)
 end
 
 -- convert mx,my in pixels to schema-1 coordinates
-function Text.to_pos_on_line(line, mx, my)
---?   print('Text.to_pos_on_line', mx, my, 'width', App.screen.width-Margin_right)
+function Text.to_pos_on_line(line, mx, my, left, right)
   if line.fragments == nil then
     Text.compute_fragments(line)
   end
@@ -948,7 +947,7 @@ function Text.tweak_screen_top_and_cursor(left, right)
       local line = Lines[Screen_bottom1.line]
       Cursor1 = {
           line=Screen_bottom1.line,
-          pos=Text.to_pos_on_line(line, App.screen.width-5, App.screen.height-5),
+          pos=Text.to_pos_on_line(line, App.screen.width-5, App.screen.height-5, left, right),
       }
     end
   end