diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-05-29 08:12:47 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-05-29 08:12:47 -0700 |
commit | 23e9be3e10cf1159390268974bb84551df485bd5 (patch) | |
tree | f79705d9854a96efdfb7a7fb4b3636d5cfff4b41 /main.lua | |
parent | 524157fb8afa3d246e97008080dca8fae0e3049b (diff) | |
download | text.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.lua | 11 |
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 |