about summary refs log tree commit diff stats
path: root/main.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-29 08:12:47 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-29 08:12:47 -0700
commit23e9be3e10cf1159390268974bb84551df485bd5 (patch)
treef79705d9854a96efdfb7a7fb4b3636d5cfff4b41 /main.lua
parent524157fb8afa3d246e97008080dca8fae0e3049b (diff)
downloadtext.love-23e9be3e10cf1159390268974bb84551df485bd5.tar.gz
selecting text and deleting selections
I've written a few tests for delete_selection, but the way different
operations initialize the selection seems fairly standard and not worth
testing so far.
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/main.lua b/main.lua
index df4828e..c53fb4e 100644
--- a/main.lua
+++ b/main.lua
@@ -60,6 +60,8 @@ Screen_top1 = {line=1, pos=1}  -- position of start of screen line at top of scr
 Cursor1 = {line=1, pos=1}  -- position of cursor
 Screen_bottom1 = {line=1, pos=1}  -- position of start of screen line at bottom of screen
 
+Selection1 = {}
+
 Cursor_x, Cursor_y = 0, 0  -- in pixels
 
 Current_drawing_mode = 'line'
@@ -178,6 +180,15 @@ 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 love.keyboard.isDown('lshift') or love.keyboard.isDown('rshift') then
+          if Selection1.line == nil then
+            Selection1 = {line=Cursor1.line, pos=Cursor1.pos}
+          end
+        else
+          if Selection1.line then
+            Selection1 = {}
+          end
+        end
         Text.move_cursor(line_index, line, x, y)
       end
     elseif line.mode == 'drawing' then