copy entire buffer when there's no selection

This commit is contained in:
Kartik K. Agaram 2023-11-23 16:20:37 -08:00
parent 045aeec77a
commit 047b26d15a
1 changed files with 10 additions and 2 deletions

View File

@ -16,8 +16,16 @@ copy_button = function(x, y, r)
love.graphics.print('copy', p.x+5,p.y+2) love.graphics.print('copy', p.x+5,p.y+2)
end, end,
onpress1 = function() onpress1 = function()
local s = Text.selection(Current_pane.editor_state) local e = Current_pane.editor_state
if s then App.set_clipboard(s) end local s = Text.selection(e)
if s == nil then
-- nothing selected? copy entire editor
-- workaround while we have no way to save to file
e.selection1 = {line=1, pos=1}
e.cursor1 = {line=#e.lines, pos=utf8.len(e.lines[#e.lines].data)+1}
s = Text.selection(e)
end
App.set_clipboard(s)
end, end,
}) })
if Overflow_button then if Overflow_button then