test harness now supports copy/paste

[?]
Jun 3, 2022, 1:52 AM
JF5L2BBS7ESMKHNGKLXI2F32GZKET2ICJ4KT2L5BMH3P2L2Y5MRAC

Dependencies

  • [2] 6E3HVYWF test and App helper for mouse clicks
  • [3] KWOJ6XHE cut/copy selected text to clipboard
  • [4] VJ77YABH more efficient undo/redo
  • [5] GN3IF4WF bugfix: pasting newlines
  • [6] CG3264MM move
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] AD34IX2Z couple more tests
  • [*] 3QNOKBFM beginnings of a test harness
  • [*] AVTNUQYR basic test-enabled framework

Change contents

  • edit in text.lua at line 323
    [9.1487]
    [9.1487]
    end
    function test_insert_newline()
    io.write('\ntest_insert_newline')
    -- display a few lines with cursor on bottom line
    App.screen.init{width=25+30, height=60}
    Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
    Line_width = App.screen.width
    Cursor1 = {line=1, pos=2}
    Screen_top1 = {line=1, pos=1}
    Screen_bottom1 = {}
    Zoom = 1
    local screen_top_margin = 15 -- pixels
    local line_height = math.floor(15*Zoom) -- pixels
    App.draw()
    local y = screen_top_margin
    App.screen.check(y, 'abc', 'F - test_insert_newline/baseline/screen:1')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_insert_newline/baseline/screen:2')
    y = y + line_height
    App.screen.check(y, 'ghi', 'F - test_insert_newline/baseline/screen:3')
    -- after hitting the enter key the screen scrolls down
    App.run_after_keychord('return')
    check_eq(Screen_top1.line, 1, 'F - test_insert_newline/screen_top')
    check_eq(Cursor1.line, 2, 'F - test_insert_newline/cursor:line')
    check_eq(Cursor1.pos, 1, 'F - test_insert_newline/cursor:pos')
    y = screen_top_margin
    App.screen.check(y, 'a', 'F - test_insert_newline/screen:1')
    y = y + line_height
    App.screen.check(y, 'bc', 'F - test_insert_newline/screen:2')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_insert_newline/screen:3')
  • edit in text.lua at line 357
    [9.1492]
    [2.1]
    function test_insert_from_clipboard()
    io.write('\ntest_insert_from_clipboard')
    -- display a few lines with cursor on bottom line
    App.screen.init{width=25+30, height=60}
    Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
    Line_width = App.screen.width
    Cursor1 = {line=1, pos=2}
    Screen_top1 = {line=1, pos=1}
    Screen_bottom1 = {}
    Zoom = 1
    local screen_top_margin = 15 -- pixels
    local line_height = math.floor(15*Zoom) -- pixels
    App.draw()
    local y = screen_top_margin
    App.screen.check(y, 'abc', 'F - test_insert_from_clipboard/baseline/screen:1')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_insert_from_clipboard/baseline/screen:2')
    y = y + line_height
    App.screen.check(y, 'ghi', 'F - test_insert_from_clipboard/baseline/screen:3')
    -- after hitting the enter key the screen scrolls down
    App.clipboard = 'xy\nz'
    App.run_after_keychord('M-v')
    check_eq(Screen_top1.line, 1, 'F - test_insert_from_clipboard/screen_top')
    check_eq(Cursor1.line, 2, 'F - test_insert_from_clipboard/cursor:line')
    check_eq(Cursor1.pos, 2, 'F - test_insert_from_clipboard/cursor:pos')
    y = screen_top_margin
    App.screen.check(y, 'axy', 'F - test_insert_from_clipboard/screen:1')
    y = y + line_height
    App.screen.check(y, 'zbc', 'F - test_insert_from_clipboard/screen:2')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_insert_from_clipboard/screen:3')
    end
  • replacement in text.lua at line 1430
    [3.1037][3.1037:1075]()
    love.system.setClipboardText(s)
    [3.1037]
    [3.1075]
    App.setClipboardText(s)
  • replacement in text.lua at line 1435
    [3.1161][3.1161:1199]()
    love.system.setClipboardText(s)
    [3.1161]
    [3.1199]
    App.setClipboardText(s)
  • replacement in text.lua at line 1440
    [4.2275][5.76:121](),[5.76][5.76:121]()
    local s = love.system.getClipboardText()
    [4.2275]
    [5.121]
    local s = App.getClipboardText()
  • edit in app.lua at line 179
    [11.6979]
    [11.6979]
    end
    App.clipboard = ''
    function App.getClipboardText()
    return App.clipboard
  • edit in app.lua at line 185
    [11.6983]
    [11.6983]
    function App.setClipboardText(s)
    App.clipboard = s
    end
  • edit in app.lua at line 270
    [9.2791]
    [11.8162]
    App.getClipboardText = love.system.getClipboardText
    App.setClipboardText = love.system.setClipboardText