about summary refs log tree commit diff stats
path: root/main.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-04 14:14:26 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-04 14:54:40 -0700
commit1326914d7bda65a5791c2121dae6d3987a907994 (patch)
treeb8f47fd975f18540c62097e39cfb89fa3c5f4ddd /main.lua
parent98f50f0b404b48bc38d95126939aefa6c3bea139 (diff)
downloadtext.love-1326914d7bda65a5791c2121dae6d3987a907994.tar.gz
select text with shift + mouseclick
It's still a bit simple-minded. Most software will keep the first bound
fixed and move the second. Lines currently has the bounds in a queue of
sorts. But I have a test to indicate the behavior that is definitely
desired. We'll see if we need it to get more complex.
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/main.lua b/main.lua
index 3e60d19..3801a3f 100644
--- a/main.lua
+++ b/main.lua
@@ -196,9 +196,14 @@ 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 App.shift_down() then
+          Selection1 = {line=Cursor1.line, pos=Cursor1.pos}
+        end
         Cursor1.line = line_index
         Cursor1.pos = Text.to_pos_on_line(line, x, y)
-        Selection1 = {line=Cursor1.line, pos=Cursor1.pos}
+        if not App.shift_down() then
+          Selection1 = {line=Cursor1.line, pos=Cursor1.pos}
+        end
       end
     elseif line.mode == 'drawing' then
       if Drawing.in_drawing(line, x, y) then
@@ -218,12 +223,13 @@ function App.mousereleased(x,y, button)
         if Text.in_line(line, x,y) then
           Cursor1.line = line_index
           Cursor1.pos = Text.to_pos_on_line(line, x, y)
-          if Text.eq1(Cursor1, Selection1) then
+          if Text.eq1(Cursor1, Selection1) and not App.shift_down() then
             Selection1 = {}
           end
         end
       end
     end
+--?     print('select:', Selection1.line, Selection1.pos)
   end
 end