first successful pagedown test, first bug found by test

[?]
May 23, 2022, 3:13 PM
YTSPVDZHEN5LLNMGIBUBLPWFWSFM3SOHBRGWYSDEVFKRTH24ARRQC

Dependencies

  • [2] 3OKKTUT4 up and down arrow now moving by screen line where possible
  • [3] IRV65LZP fold variables for screen dimensions into the app framework
  • [4] QYIFOHW3 first test!
  • [5] VHQCNMAR several more modules
  • [6] DAENUOGV eliminate assumptions that line length == size in bytes
  • [7] LUNH47XX make text and drawings the same width
  • [8] 6LJZN727 handle chords
  • [9] JY4VK7L2 rename
  • [10] MGT5FTJ3 first stab at supporting wrapping in cursor up
  • [11] PGZJ6NAT ensure Filename is writable when opened outside a terminal
  • [12] 242L3OQX bugfix: ensure Cursor_line is always on a text line
  • [13] TRNWIQN6 more precise height calculation when scrolling up as much as possible while keeping cursor on screen
  • [14] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [15] BOFNXP5G clicking now moves the cursor even on long, wrapped lines
  • [16] UWNHC4AA redo y computations
  • [17] 3CS5KKCI up/down cursor movement
  • [18] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [19] 537TQ2QN some more logging
  • [20] AVTNUQYR basic test-enabled framework
  • [21] 4C375P53 this is a bit clearer
  • [22] OTIBCAUJ love2d scaffold
  • [23] CVGE3SIG I feel confident now that page-down is working.
  • [24] ESETRNLB bugfix: printing the first part of a line at the bottom made it seem non-wrapping
  • [25] CA5T33FG one more implication
  • [26] 2POFQQLW keep cursor on screen when pressing 'down'
  • [27] JCSLDGAH beginnings of support for multiple shapes
  • [28] AVQ5MC5D finish uppercasing all globals
  • [29] WLHI7KD3 new globals: draw partial screen line up top
  • [30] 7IKRRESB longer names for indices in long loops
  • [31] XX7G2FFJ intermingle freehand line drawings with text
  • [32] Y6FTGOHJ simpler
  • [33] DLQMM265 scroll past first page
  • [34] B3IWYWSR delete another arg that can be deduced
  • [35] 3TFEAQSW start using some globals
  • [36] 3QNOKBFM beginnings of a test harness
  • [37] YJGADSGK delete unused arg
  • [38] QU7NHFOV show cursor
  • [39] XNFTJHC4 split keyboard handling between Text and Drawing
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] PFT5Y2ZY move

Change contents

  • replacement in text.lua at line 31
    [5.119][5.1:104]()
    if New_foo then print('text: new screen line', y, Screen_height, screen_line_starting_pos) end
    [5.119]
    [5.255]
    if New_foo then print('text: new screen line', y, App.screen.height, screen_line_starting_pos) end
  • replacement in text.lua at line 42
    [5.184][5.184:241]()
    if y + math.floor(15*Zoom) >= Screen_height then
    [5.184]
    [5.241]
    if y + math.floor(15*Zoom) >= App.screen.height then
  • edit in text.lua at line 82
    [4.137]
    [4.137]
    print('test_draw_text')
  • edit in text.lua at line 101
    [4.681]
    [42.1]
    function test_pagedown()
    print('test_pagedown')
    App.screen.init{width=120, height=45}
    Lines = load_array{'abc', 'def', 'ghi'}
    Line_width = 120
    Cursor1 = {line=1, pos=1}
    Screen_top1 = {line=1, pos=1}
    Screen_bottom1 = {}
    Zoom = 1
    local screen_top_margin = 15 -- pixels
    local line_height = math.floor(15*Zoom) -- pixels
    -- initially the first two lines are displayed
    App.draw()
    local y = screen_top_margin
    App.screen.check(y, 'abc', 'F - test_pagedown/baseline/screen:1')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_pagedown/baseline/screen:2')
    -- after pagedown the bottom line becomes the top
    App.run_after_keychord('pagedown')
    y = screen_top_margin
    App.screen.check(y, 'def', 'F - test_pagedown/screen:1')
    y = y + line_height
    App.screen.check(y, 'ghi', 'F - test_pagedown/screen:2')
    end
    function test_pagedown_skip_drawings()
    print('test_pagedown_skip_drawings')
    -- some lines of text with a drawing intermixed
    App.screen.init{width=50, height=45}
    Lines = load_array{'abc',
    '```lines', '```',
    'def',
    'ghi'}
    check_eq(Lines[2].mode, 'drawing', 'F - test_pagedown_skip_drawings/baseline/lines')
    Line_width = App.screen.width
    Cursor1 = {line=1, pos=1}
    Screen_top1 = {line=1, pos=1}
    Screen_bottom1 = {}
    Zoom = 1
    local screen_top_margin = 15 -- pixels
    local drawing_height = App.screen.width / 2 -- default
    -- initially the screen displays the first line and part of the drawing
    App.draw()
    local y = screen_top_margin
    App.screen.check(y, 'abc', 'F - test_pagedown_skip_drawings/baseline/screen:1')
    -- after pagedown the screen draws the screen up top
    App.run_after_keychord('pagedown')
    y = screen_top_margin + drawing_height
    App.screen.check(y, 'def', 'F - test_pagedown_skip_drawings/screen:1')
    y = y + line_height
    App.screen.check(y, 'ghi', 'F - test_pagedown_skip_drawings/screen:2')
    end
  • edit in text.lua at line 433
    [5.6916]
    [5.6916]
    print('scroll up')
  • replacement in text.lua at line 442
    [2.210][2.210:258]()
    local y = Screen_height - math.floor(15*Zoom)
    [2.210]
    [5.455]
    local y = App.screen.height - math.floor(15*Zoom)
  • replacement in main.lua at line 84
    [5.1592][5.1592:1607]()
    New_foo = true
    [5.1592]
    [5.47]
    Debug_main = false
  • replacement in main.lua at line 123
    [5.18][5.1978:2017]()
    if New_foo then print('== draw') end
    [5.18]
    [5.2]
    if Debug_main then print('== draw') end
  • replacement in main.lua at line 125
    [5.44][5.2018:2072]()
    if New_foo then print('draw:', line_index, y) end
    [5.44]
    [3.338]
    if Debug_main then print('draw:', line_index, y) end
  • replacement in main.lua at line 149
    [5.1510][5.2073:2115]()
    if New_foo then print('text') end
    [5.1510]
    [5.194]
    if Debug_main then print('text') end
  • replacement in main.lua at line 153
    [5.108][5.2116:2159]()
    if New_foo then print('aa', y) end
    [5.108]
    [5.1574]
    if Debug_main then print('aa', y) end
  • replacement in main.lua at line 157
    [5.416][5.2160:2178]()
    New_foo = false
    [5.416]
    [5.408]
    Debug_main = false
  • replacement in main.lua at line 198
    [5.1550][5.2179:2196](),[5.123][5.2179:2196]()
    New_foo = true
    [5.1550]
    [5.4920]
    --? Debug_main = true
  • edit in main.lua at line 229
    [5.1627]
    [5.9490]
    print('setting top to', Screen_bottom1.line)
  • replacement in file.lua at line 110
    [4.1467][4.1467:1490]()
    local i,line = 0, ''
    [4.1467]
    [4.1490]
    local i,line,drawing = 0, ''
  • edit in file.lua at line 114
    [4.1566]
    [4.1566]
    --? print(line)
  • replacement in file.lua at line 116
    [4.1671][4.1671:1740]()
    table.insert(result, load_drawing_from_array(next_line, a, i))
    [4.1671]
    [4.1740]
    --? print('inserting drawing')
    i, drawing = load_drawing_from_array(next_line, a, i)
    --? print('i now', i)
    table.insert(result, drawing)
  • edit in file.lua at line 121
    [4.1749]
    [4.1749]
    --? print('inserting text')
  • edit in file.lua at line 137
    [4.2106]
    [4.2106]
    --? print(i)
  • replacement in file.lua at line 165
    [4.3255][4.3255:3272]()
    return drawing
    [4.3255]
    [5.18207]
    return i, drawing
  • replacement in app.lua at line 96
    [5.4434][5.4434:4475]()
    -- App.run_with_keypress('pagedown')
    [5.4434]
    [5.4475]
    -- App.run_after_keypress('pagedown')
  • edit in app.lua at line 141
    [5.6151]
    [5.6151]
    print('drawing "'..msg..'" at y '..tostring(y))
  • edit in app.lua at line 175
    [5.7039]
    [5.7039]
    App.screen.contents = {}
    App.draw()
    end
    function App.run_after_keychord(key)
    App.keychord_pressed(key)
  • edit in app.lua at line 192
    [5.7257]
    [5.7257]
    if App.screen.contents[screen_row] == nil then
    error('no text at y '..tostring(y))
    end