2023-11-22 20:38:16 +00:00
|
|
|
copy_button = function(x, y, r)
|
2023-11-21 06:23:09 +00:00
|
|
|
local w = App.width('copy')+10
|
2023-11-22 20:38:16 +00:00
|
|
|
local x2, y2 = maybe_draw_overflow_button(x, y, w, r)
|
|
|
|
if Overflow_button then
|
|
|
|
-- overflow
|
|
|
|
if not Show_overflow then
|
|
|
|
return x, y
|
2023-11-23 03:37:30 +00:00
|
|
|
else
|
|
|
|
y = y2
|
2023-11-22 20:38:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
button(Global_state, 'copy', {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
|
2023-11-21 06:23:09 +00:00
|
|
|
icon = function(p)
|
|
|
|
App.color(Normal_color)
|
|
|
|
love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
|
|
|
|
love.graphics.print('copy', p.x+5,p.y+2)
|
|
|
|
end,
|
|
|
|
onpress1 = function()
|
2023-11-24 00:20:37 +00:00
|
|
|
local e = Current_pane.editor_state
|
|
|
|
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)
|
2023-11-21 06:23:09 +00:00
|
|
|
end,
|
|
|
|
})
|
2023-11-22 20:38:16 +00:00
|
|
|
if Overflow_button then
|
|
|
|
return x, y+Line_height
|
|
|
|
else
|
|
|
|
return x+w+10, y
|
|
|
|
end
|
2023-11-21 06:23:09 +00:00
|
|
|
end
|