LS55YKGWKICTQTAHR5KLMNDOL6CDI4ATT3NT5Z2YL5IM3CRQOONQC
NQWWTGXRLSBASOSP75FPOSVYP664VYRFQH7MY5LALLIP2VEBQMCQC
JF5L2BBS7ESMKHNGKLXI2F32GZKET2ICJ4KT2L5BMH3P2L2Y5MRAC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
73OCE2MCBJJZZMN2KYPJTBOUCKBZAOQ2QIAMTGCNOOJ2AJAXFT2AC
CG3264MMJTTSCJWUA2EMTBOPTDB2NZIJ7XICKHWUTZ4UWLFP7POAC
XNFTJHC4QSHNSIWNN7K6QZEZ37GTQYKHS4EPNSVPQCUSWREROGIQC
KWOJ6XHEE7ERLFJ6FBXCL73DE6OFJQ7LXNXAN44G5P5EXFDH5HIAC
22S4LHNKMHVHEBGGRWJR6WLAD5TNHYUWQU6HRZVPCDLOD4ZIWGUAC
VJ77YABHVJZWJKLHAGIPC562GYM73AUGRLCP4JLKP5JPWPT2RIHAC
RTPXEETLAQXBVSUDBLXB6QMJQDOPCGKACAXN3CC2HIDM5EZAELVAC
GN3IF4WF352YK5K4YHVMAIMPL7PNTCEMDWW22PTKDOXKV2FZJ7NQC
HOSPP2ANSW654DYRTC6CQUQA2GUKV6T2FI7QBKXD2DZS3R32IMGAC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
Z4XRNDTRTGSZHNB65WNHOVUBFW4QWQABLVSK4RM3QJHGK33DMRJAC
-- paste
elseif chord == 'M-c' then
local s = Text.selection()
if s then
App.setClipboardText(s)
end
elseif chord == 'M-x' then
local s = Text.cut_selection()
if s then
App.setClipboardText(s)
end
elseif chord == 'M-v' then
-- We don't have a good sense of when to scroll, so we'll be conservative
-- and sometimes scroll when we didn't quite need to.
local before_line = Cursor1.line
local before = snapshot(before_line)
local clipboard_data = App.getClipboardText()
local num_newlines = 0 -- hack 1
for _,code in utf8.codes(clipboard_data) do
local c = utf8.char(code)
if c == '\n' then
Text.insert_return()
num_newlines = num_newlines+1
else
Text.insert_at_cursor(utf8.char(code))
end
end
-- hack 1: if we have too many newlines we definitely need to scroll
for i=before_line,Cursor1.line do
Lines[i].screen_line_starting_pos = nil
Text.populate_screen_line_starting_pos(i)
end
if Cursor1.line-Screen_top1.line+1 + num_newlines > App.screen.height/Line_height then
Screen_top1.line = Cursor1.line
Screen_top1.pos = 1
Text.scroll_up_while_cursor_on_screen()
end
-- hack 2: if we have too much text wrapping we definitely need to scroll
local clipboard_text = App.newText(love.graphics.getFont(), clipboard_data)
local clipboard_width = App.width(clipboard_text)
--? print(Cursor_y, Cursor_y*Line_width, Cursor_y*Line_width+Cursor_x, Cursor_y*Line_width+Cursor_x+clipboard_width, Line_width*App.screen.height/Line_height)
if Cursor_y*Line_width+Cursor_x + clipboard_width > Line_width*App.screen.height/Line_height then
Screen_top1.line = Cursor1.line
Screen_top1.pos = 1
Text.scroll_up_while_cursor_on_screen()
end
record_undo_event({before=before, after=snapshot(before_line, Cursor1.line)})
end
-- clipboard
elseif chord == 'C-c' then
local s = Text.selection()
if s then
App.setClipboardText(s)
end
elseif chord == 'C-x' then
local s = Text.cut_selection()
if s then
App.setClipboardText(s)
end
elseif chord == 'C-v' then
-- We don't have a good sense of when to scroll, so we'll be conservative
-- and sometimes scroll when we didn't quite need to.
local before_line = Cursor1.line
local before = snapshot(before_line)
local clipboard_data = App.getClipboardText()
local num_newlines = 0 -- hack 1
for _,code in utf8.codes(clipboard_data) do
local c = utf8.char(code)
if c == '\n' then
Text.insert_return()
num_newlines = num_newlines+1
else
Text.insert_at_cursor(utf8.char(code))
end
end
-- hack 1: if we have too many newlines we definitely need to scroll
for i=before_line,Cursor1.line do
Lines[i].screen_line_starting_pos = nil
Text.populate_screen_line_starting_pos(i)
end
if Cursor1.line-Screen_top1.line+1 + num_newlines > App.screen.height/Line_height then
Screen_top1.line = Cursor1.line
Screen_top1.pos = 1
Text.scroll_up_while_cursor_on_screen()
end
-- hack 2: if we have too much text wrapping we definitely need to scroll
local clipboard_text = App.newText(love.graphics.getFont(), clipboard_data)
local clipboard_width = App.width(clipboard_text)
--? print(Cursor_y, Cursor_y*Line_width, Cursor_y*Line_width+Cursor_x, Cursor_y*Line_width+Cursor_x+clipboard_width, Line_width*App.screen.height/Line_height)
if Cursor_y*Line_width+Cursor_x + clipboard_width > Line_width*App.screen.height/Line_height then
Screen_top1.line = Cursor1.line
Screen_top1.pos = 1
Text.scroll_up_while_cursor_on_screen()