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)
downloadlines.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
#n173'>173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248