bugfix: lines that aren't drawn from the start

[?]
Jul 1, 2022, 1:00 AM
MYC7XR5QOT2AXHF6UNGSNFFD5VL6UHGUZQBP7PWWLZ5NNXE7UMTAC

Dependencies

  • [2] TNHZZYWP update some documentation
  • [3] LAW2O3NW extract variable Margin_left
  • [4] PLKNHYZ4 extract a function
  • [5] GJLOKCYK bugfix: clicking past end of screen line
  • [6] IWYLK45K clicking to the right of a line within line width
  • [7] 5FW7YOFT highlight selection while dragging
  • [8] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [9] YJGADSGK delete unused arg
  • [10] HYEAFRZ2 split mouse_pressed events between Text and Drawing
  • [11] R53OF3ON one bug I've repeatedly run into while testing with Moby Dick
  • [12] CPZGQT72 go through and fix similar issues
  • [13] U52E2XZN fix a crash
  • [14] OGUV4HSA remove some memory leaks from rendered fragments
  • [15] JCSLDGAH beginnings of support for multiple shapes
  • [16] HOSPP2AN crisp font rendering
  • [17] KZ5GAYRP this fixes the immediate regression
  • [18] 6E3HVYWF test and App helper for mouse clicks
  • [19] 4VKEE43Z bugfix
  • [20] UWNHC4AA redo y computations
  • [21] 3TFEAQSW start using some globals
  • [22] OYXDYPGS get rid of debug variables
  • [23] GCEF4N3V stop repeatedly checking for line wrapping
  • [24] ZZ2B5RPQ extract variables for drawing padding
  • [25] DLQMM265 scroll past first page
  • [26] YTSPVDZH first successful pagedown test, first bug found by test
  • [27] CVGE3SIG I feel confident now that page-down is working.
  • [28] 5L7K4GBD clicking to the right of a wrapped line
  • [29] BOFNXP5G clicking now moves the cursor even on long, wrapped lines
  • [30] VVXVV2D2 change data model; text can now have metadata
  • [31] 65XHTZEK regression: couldn't do many drawing operations because line.y was reset
  • [32] CCYSVZA2 bugfix: BSOD in #4.
  • [33] 242L3OQX bugfix: ensure Cursor_line is always on a text line
  • [34] B3IWYWSR delete another arg that can be deduced
  • [35] DXT4QTAH a few more integer coordinates
  • [36] DAENUOGV eliminate assumptions that line length == size in bytes
  • [37] YLKLDF4R .
  • [38] MP2TBKU6 bugfix: crash in Text.up() after return
  • [39] CBPV5SSI stop handling nil screen_line_starting_pos everywhere
  • [40] ESETRNLB bugfix: printing the first part of a line at the bottom made it seem non-wrapping
  • [*] LXTTOB33 extract a couple of files
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] OTIBCAUJ love2d scaffold

Change contents

  • edit in text_tests.lua at line 187
    [5.884]
    [5.884]
    function test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen()
    io.write('\ntest_click_on_wrapping_line_rendered_from_partway_at_top_of_screen')
    -- display a wrapping line from its second screen line
    App.screen.init{width=80, height=80}
    -- 12345678901234
    Lines = load_array{"madam I'm adam"}
    Line_width = 75
    Cursor1 = {line=1, pos=8}
    Screen_top1 = {line=1, pos=7}
    Screen_bottom1 = {}
    App.draw()
    local y = Margin_top
    App.screen.check(y, "I'm ada", 'F - test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen/baseline/screen:2')
    y = y + Line_height
    -- click past end of second screen line
    App.run_after_mouse_click(App.screen.width-2,y-2, 1)
    -- cursor moves to end of screen line
    check_eq(Cursor1.line, 1, 'F - test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen/cursor:line')
    check_eq(Cursor1.pos, 13, 'F - test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen/cursor:pos')
    end
  • replacement in text.lua at line 20
    [3.2202][7.1783:1802](),[7.1783][7.1783:1802]()
    local y = line.y
    [3.2202]
    [7.1802]
    local y = line.starty
  • replacement in text.lua at line 662
    [7.47][7.367:433](),[7.39][7.367:433]()
    if line.y == nil then return false end -- outside current page
    [7.47]
    [3.2342]
    if line.starty == nil then return false end -- outside current page
  • replacement in text.lua at line 664
    [7.697][7.214:252](),[3.2385][7.214:252](),[7.214][7.214:252]()
    if y < line.y then return false end
    [3.2385]
    [7.48]
    if y < line.starty then return false end
  • replacement in text.lua at line 666
    [7.101][7.3806:3873](),[7.224][7.3806:3873](),[7.3806][7.3806:3873]()
    return y < line.y + #line.screen_line_starting_pos * Line_height
    [7.101]
    [7.95]
    return y < line.starty + Line_height*(#line.screen_line_starting_pos - Text.screen_line_index(line, line.startpos) + 1)
  • replacement in text.lua at line 675
    [7.86][7.653:676](),[7.653][7.653:676]()
    assert(my >= line.y)
    [7.86]
    [7.863]
    assert(my >= line.starty)
  • replacement in text.lua at line 677
    [7.904][7.904:923](),[7.923][7.40:133](),[7.133][7.740:836]()
    local y = line.y
    for screen_line_index,screen_line_starting_pos in ipairs(line.screen_line_starting_pos) do
    local screen_line_starting_byte_offset = Text.offset(line.data, screen_line_starting_pos)
    [7.904]
    [7.910]
    local y = line.starty
    local start_screen_line_index = Text.screen_line_index(line, line.startpos)
    for screen_line_index = start_screen_line_index,#line.screen_line_starting_pos do
    local screen_line_starting_pos = line.screen_line_starting_pos[screen_line_index]
    local screen_line_starting_byte_offset = Text.offset(line.data, screen_line_starting_pos)
  • edit in text.lua at line 728
    [6.1644]
    [6.1644]
    end
    function Text.screen_line_index(line, pos)
    for i = #line.screen_line_starting_pos,1,-1 do
    if line.screen_line_starting_pos[i] <= pos then
    return i
    end
    end
  • replacement in text.lua at line 922
    [7.4058][7.3:20]()
    line.y = nil
    [7.4058]
    [4.317]
    line.starty = nil
    line.startpos = nil
  • replacement in main.lua at line 23
    [2.44][2.44:105]()
    -- a (y) coord in pixels (updated while painting screen),
    [2.44]
    [2.105]
    -- startpos, the index of data the line starts rendering from (if currently on screen), can only be >1 for topmost line on screen
    -- starty, the y coord in pixels
  • replacement in main.lua at line 279
    [7.153][7.194:213](),[7.2115][7.194:213](),[7.2400][7.194:213](),[7.1510][7.194:213]()
    line.y = y
    [7.153]
    [7.335]
    line.starty = y
    line.startpos = 1
    if line_index == Screen_top1.line then
    line.startpos = Screen_top1.pos
    end