about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--main.lua4
-rw-r--r--select.lua20
-rw-r--r--text.lua6
3 files changed, 15 insertions, 15 deletions
diff --git a/main.lua b/main.lua
index 2c79b77..37d5d01 100644
--- a/main.lua
+++ b/main.lua
@@ -434,7 +434,7 @@ function App.keychord_pressed(chord, key)
       -- (we're not creating any ctrl-shift- or alt-shift- combinations using regular/printable keys)
       (not App.shift_down() or utf8.len(key) == 1) and
       chord ~= 'C-c' and chord ~= 'C-x' and chord ~= 'backspace' and backspace ~= 'delete' and not App.is_cursor_movement(chord) then
-    Text.delete_selection()
+    Text.delete_selection(Margin_left, App.screen.width-Margin_right)
   end
   if Search_term then
     if chord == 'escape' then
@@ -506,7 +506,7 @@ function App.keychord_pressed(chord, key)
     end
   elseif chord == 'C-x' then
     for _,line in ipairs(Lines) do line.y = nil end  -- just in case we scroll
-    local s = Text.cut_selection()
+    local s = Text.cut_selection(Margin_left, App.screen.width-Margin_right)
     if s then
       App.setClipboardText(s)
     end
diff --git a/select.lua b/select.lua
index 4f6b10c..1b57df2 100644
--- a/select.lua
+++ b/select.lua
@@ -8,13 +8,13 @@ local utf8 = require 'utf8'
 -- and {line=line_index, pos=bpos}.
 -- apos must be less than bpos. However Selection1 and Cursor1 can be in any order.
 -- Result: positions spos,epos between apos,bpos.
-function Text.clip_selection(line_index, apos, bpos)
+function Text.clip_selection(line_index, apos, bpos, left, right)
   if Selection1.line == nil then return nil,nil end
   -- min,max = sorted(Selection1,Cursor1)
   local minl,minp = Selection1.line,Selection1.pos
   local maxl,maxp
   if App.mouse_down(1) then
-    maxl,maxp = Text.mouse_pos()
+    maxl,maxp = Text.mouse_pos(left, right)
   else
     maxl,maxp = Cursor1.line,Cursor1.pos
   end
@@ -78,13 +78,13 @@ function Text.draw_highlight(line, x,y, pos, lo,hi)
 end
 
 -- inefficient for some reason, so don't do it on every frame
-function Text.mouse_pos()
+function Text.mouse_pos(left, right)
   local time = love.timer.getTime()
   if Recent_mouse.time and Recent_mouse.time > time-0.1 then
     return Recent_mouse.line, Recent_mouse.pos
   end
   Recent_mouse.time = time
-  local line,pos = Text.to_pos(App.mouse_x(), App.mouse_y())
+  local line,pos = Text.to_pos(App.mouse_x(), App.mouse_y(), left, right)
   if line then
     Recent_mouse.line = line
     Recent_mouse.pos = pos
@@ -92,7 +92,7 @@ function Text.mouse_pos()
   return Recent_mouse.line, Recent_mouse.pos
 end
 
-function Text.to_pos(x,y)
+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
@@ -102,22 +102,22 @@ function Text.to_pos(x,y)
   end
 end
 
-function Text.cut_selection()
+function Text.cut_selection(left, right)
   if Selection1.line == nil then return end
   local result = Text.selection()
-  Text.delete_selection()
+  Text.delete_selection(left, right)
   return result
 end
 
-function Text.delete_selection()
+function Text.delete_selection(left, right)
   if Selection1.line == nil then return end
   local minl,maxl = minmax(Selection1.line, Cursor1.line)
   local before = snapshot(minl, maxl)
-  Text.delete_selection_without_undo()
+  Text.delete_selection_without_undo(left, right)
   record_undo_event({before=before, after=snapshot(Cursor1.line)})
 end
 
-function Text.delete_selection_without_undo()
+function Text.delete_selection_without_undo(left, right)
   if Selection1.line == nil then return end
   -- min,max = sorted(Selection1,Cursor1)
   local minl,minp = Selection1.line,Selection1.pos
diff --git a/text.lua b/text.lua
index 873bf00..d66adde 100644
--- a/text.lua
+++ b/text.lua
@@ -49,7 +49,7 @@ function Text.draw(line, line_index, top, left, right)
     -- don't draw text above screen top
     if Text.le1(Screen_top1, {line=line_index, pos=pos}) then
       if Selection1.line then
-        local lo, hi = Text.clip_selection(line_index, pos, pos+frag_len)
+        local lo, hi = Text.clip_selection(line_index, pos, pos+frag_len, left, right)
         Text.draw_highlight(line, x,y, pos, lo,hi)
       end
 --?       print('drawing '..frag)
@@ -184,7 +184,7 @@ function Text.keychord_pressed(chord)
     record_undo_event({before=before, after=snapshot(Cursor1.line)})
   elseif chord == 'backspace' then
     if Selection1.line then
-      Text.delete_selection()
+      Text.delete_selection(Margin_left, App.screen.width-Margin_right)
       schedule_save()
       return
     end
@@ -225,7 +225,7 @@ function Text.keychord_pressed(chord)
     record_undo_event({before=before, after=snapshot(Cursor1.line)})
   elseif chord == 'delete' then
     if Selection1.line then
-      Text.delete_selection()
+      Text.delete_selection(Margin_left, App.screen.width-Margin_right)
       schedule_save()
       return
     end