about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-07-08 15:37:09 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-07-08 15:37:09 -0700
commit00c64ed6e49fd679bb2d08dd076f585842bbf423 (patch)
tree0d8b4c55491236636886cc134fa735b4d230faf8
parenta27dd15c1f0e69d2259bcc9a7c246edcd7200f67 (diff)
downloadlines.love-00c64ed6e49fd679bb2d08dd076f585842bbf423.tar.gz
add args to some functions
  - Text.in_line
-rw-r--r--main.lua4
-rw-r--r--select.lua2
-rw-r--r--text.lua4
3 files changed, 5 insertions, 5 deletions
diff --git a/main.lua b/main.lua
index 37d5d01..08cad48 100644
--- a/main.lua
+++ b/main.lua
@@ -338,7 +338,7 @@ function App.mousepressed(x,y, mouse_button)
 
   for line_index,line in ipairs(Lines) do
     if line.mode == 'text' then
-      if Text.in_line(line, x,y) then
+      if Text.in_line(line, x,y, Margin_left, App.screen.width-Margin_right) then
         -- delicate dance between cursor, selection and old cursor/selection
         -- scenarios:
         --  regular press+release: sets cursor, clears selection
@@ -382,7 +382,7 @@ function App.mousereleased(x,y, button)
   else
     for line_index,line in ipairs(Lines) do
       if line.mode == 'text' then
-        if Text.in_line(line, x,y) then
+        if Text.in_line(line, x,y, Margin_left, App.screen.width-Margin_right) then
 --?           print('reset selection')
           Cursor1 = {line=line_index, pos=Text.to_pos_on_line(line, x, y)}
 --?           print('cursor', Cursor1.line, Cursor1.pos)
diff --git a/select.lua b/select.lua
index 1b57df2..ed79261 100644
--- a/select.lua
+++ b/select.lua
@@ -95,7 +95,7 @@ end
 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) then
+      if Text.in_line(line, x,y, left, right) then
         return line_index, Text.to_pos_on_line(line, x,y)
       end
     end
diff --git a/text.lua b/text.lua
index d66adde..416b703 100644
--- a/text.lua
+++ b/text.lua
@@ -663,9 +663,9 @@ function Text.snap_cursor_to_bottom_of_screen()
   Text.redraw_all()  -- if we're scrolling, reclaim all fragments to avoid memory leaks
 end
 
-function Text.in_line(line, x,y)
+function Text.in_line(line, x,y, left,right)
   if line.starty == nil then return false end  -- outside current page
-  if x < Margin_left then return false end
+  if x < left then return false end
   if y < line.starty then return false end
   Text.populate_screen_line_starting_pos(line)
   return y < line.starty + Line_height*(#line.screen_line_starting_pos - Text.screen_line_index(line, line.startpos) + 1)