move

[?]
May 29, 2022, 5:27 AM
CG3264MMJTTSCJWUA2EMTBOPTDB2NZIJ7XICKHWUTZ4UWLFP7POAC

Dependencies

  • [2] G6OYAYHU paste in text with M-v
  • [3] DAENUOGV eliminate assumptions that line length == size in bytes
  • [4] 2ZYV7D3W handle tab characters
  • [5] XNFTJHC4 split keyboard handling between Text and Drawing
  • [6] 2HW3HUCG M-left/M-right for word-based motions
  • [7] DLQMM265 scroll past first page
  • [8] KECEMMMR extract couple of functions
  • [9] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [*] BULPIBEG beginnings of a module for the text editor

Change contents

  • edit in text.lua at line 899
    [3.627]
    [3.627]
    --== shortcuts that mutate text
  • edit in text.lua at line 915
    [3.1006][3.1006:1036](),[3.1036][3.1:17](),[3.17][3.1461:1492](),[3.1461][3.1461:1492](),[3.1492][3.18:35](),[3.35][3.1:725](),[3.725][2.79:252](),[2.252][3.725:733](),[3.725][3.725:733](),[3.35][3.1924:1954](),[3.733][3.1924:1954](),[3.1924][3.1924:1954](),[3.1954][3.1823:1843](),[3.1843][3.1973:2002](),[3.1973][3.1973:2002](),[3.2002][3.1844:1901]()
    elseif chord == 'left' then
    Text.left()
    elseif chord == 'right' then
    Text.right()
    -- left/right by one word
    -- C- hotkeys reserved for drawings, so we'll use M-
    elseif chord == 'M-left' then
    while true do
    Text.left()
    if Cursor1.pos == 1 then break end
    assert(Cursor1.pos > 1)
    local offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos)
    assert(offset > 1)
    if Lines[Cursor1.line].data:sub(offset-1,offset-1) == ' ' then
    break
    end
    end
    elseif chord == 'M-right' then
    while true do
    Text.right()
    if Cursor1.pos > utf8.len(Lines[Cursor1.line].data) then break end
    local offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos)
    if Lines[Cursor1.line].data:sub(offset,offset) == ' ' then
    break
    end
    end
    -- paste
    elseif chord == 'M-v' then
    local s = love.system.getClipboardText()
    for _,code in utf8.codes(s) do
    Text.insert_at_cursor(utf8.char(code))
    end
    elseif chord == 'home' then
    Cursor1.pos = 1
    elseif chord == 'end' then
    Cursor1.pos = utf8.len(Lines[Cursor1.line].data) + 1
  • edit in text.lua at line 971
    [3.3956]
    [3.3956]
    -- paste
    elseif chord == 'M-v' then
    local s = love.system.getClipboardText()
    for _,code in utf8.codes(s) do
    Text.insert_at_cursor(utf8.char(code))
    end
    --== shortcuts that move the cursor
    elseif chord == 'left' then
    Text.left()
    elseif chord == 'right' then
    Text.right()
    -- left/right by one word
    -- C- hotkeys reserved for drawings, so we'll use M-
    elseif chord == 'M-left' then
    while true do
    Text.left()
    if Cursor1.pos == 1 then break end
    assert(Cursor1.pos > 1)
    local offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos)
    assert(offset > 1)
    if Lines[Cursor1.line].data:sub(offset-1,offset-1) == ' ' then
    break
    end
    end
    elseif chord == 'M-right' then
    while true do
    Text.right()
    if Cursor1.pos > utf8.len(Lines[Cursor1.line].data) then break end
    local offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos)
    if Lines[Cursor1.line].data:sub(offset,offset) == ' ' then
    break
    end
    end
    elseif chord == 'home' then
    Cursor1.pos = 1
    elseif chord == 'end' then
    Cursor1.pos = utf8.len(Lines[Cursor1.line].data) + 1