switch copy/paste to ctrl- hotkeys

[?]
Jun 3, 2022, 6:52 AM
LS55YKGWKICTQTAHR5KLMNDOL6CDI4ATT3NT5Z2YL5IM3CRQOONQC

Dependencies

Change contents

  • replacement in text.lua at line 430
    [3.2158][3.2158:2190]()
    App.run_after_keychord('M-v')
    [3.2158]
    [3.2190]
    App.run_after_keychord('C-v')
  • edit in text.lua at line 1382
    [3.8121][3.36:47](),[3.3956][3.36:47](),[3.47][3.963:1037](),[3.1037][3.2703:2733](),[3.2733][3.1075:1161](),[3.1075][3.1075:1161](),[3.1161][3.2734:2764](),[3.2764][3.1199:1207](),[3.1199][3.1199:1207](),[3.1207][3.47:76](),[3.47][3.47:76](),[3.76][3.2:138](),[3.138][3.2197:2275](),[3.76][3.2197:2275](),[3.2275][3.2:52](),[3.52][3.139:177](),[3.177][3.52:100](),[3.52][3.52:100](),[3.100][3.28:113](),[3.156][3.28:113](),[3.113][3.178:216](),[3.216][3.113:181](),[3.113][3.113:181](),[3.181][3.217:430](),[3.181][3.201:209](),[3.430][3.201:209](),[3.201][3.201:209](),[3.209][3.3039:3130](),[3.3130][3.530:860](),[3.530][3.530:860](),[3.860][3.3131:3396](),[3.3396][3.1141:1259](),[3.1141][3.1141:1259](),[3.1259][3.2276:2358](),[3.209][3.2276:2358]()
    -- 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)})
  • edit in main.lua at line 296
    [2.638]
    [2.638]
    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()
  • edit in main.lua at line 343
    [2.646]
    [19.3819]
    record_undo_event({before=before, after=snapshot(before_line, Cursor1.line)})
    -- dispatch to drawing or text