start sketching out a scrollbar

akkartik
Nov 18, 2023, 12:23 PM
MZ3DMYPD4LSSQKEA3GNI5MK2QNTJ523DTNG6DUPWEWLH4FLUIQSAC

Dependencies

  • [2] 6K5PFF6X helper: trimming whitespace from strings
  • [3] DTBFNHJD manual tests for the protocol with the driver
  • [4] PRE6XPRN responsively increase/decrease font height
  • [5] OI4FPFIN support drawings in the source editor
  • [6] 36Z442IV back to commit 8123959e52f without code editing
  • [7] PLKNHYZ4 extract a function
  • [8] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [9] OGUV4HSA remove some memory leaks from rendered fragments
  • [10] LF7BWEG4 group all editor globals
  • [11] 4CTZOJPC stop pretending globals are local
  • [12] MU2HIRR6 Merge lines.love
  • [13] ZM7NOBRM new fork: carousel shell
  • [14] R53OF3ON one bug I've repeatedly run into while testing with Moby Dick
  • [15] PTDO2SOT add state arg to schedule_save
  • [16] SPSW74Y5 add state arg to Text.keychord_pressed
  • [17] S2MISTTM add state arg to a few functions
  • [18] XNFTJHC4 split keyboard handling between Text and Drawing
  • [19] QCPXQ2E3 add state arg to a few functions
  • [20] LSYLEVBD drop some redundant args when clearing the cache
  • [21] MUJTM6RE bring back a level of wrapping
  • [22] BULPIBEG beginnings of a module for the text editor
  • [23] HMODUNJE scroll on backspace
  • [24] LXTTOB33 extract a couple of files
  • [25] 7LVK4KRD fix a failing test
  • [26] PX7DDEMO autosave slightly less aggressively
  • [27] 4EGQRXDA bugfix: naming points
  • [28] I64IPGJX avoid saving fragments in lines
  • [29] ILOA5BYF separate data structure for each line's cache data
  • [30] TGHAJBES use line cache for drawings as well
  • [31] Z5HLXU4P add state arg to a few functions
  • [32] JCXL74WV bring back everything from commit a68647ae22
  • [33] AYE2VEGJ extract a couple of methods
  • [34] MD3W5IRA new fork: rip out drawing support
  • [*] SDEY7LFJ rename a variable
  • [*] 2L5MEZV3 experiment: new edit namespace
  • [*] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing
  • [*] R5QXEHUI somebody stop me
  • [*] 5RUFNRJO start of the visual skeleton

Change contents

  • edit in text.lua at line 31
    [5.363]
    [36.3]
    --? print(i)
  • replacement in text.lua at line 170
    [5.2204][5.4:4](),[5.4][5.3:61](),[5.2113][5.3:61](),[5.2204][5.3:61](),[5.344][5.3:61]()
    Text.clear_screen_line_cache(State, State.cursor1.line)
    [5.2204]
    [5.396]
    Text.refresh_screen_line_cache(State, State.cursor1.line)
  • replacement in text.lua at line 239
    [5.3000][5.62:122]()
    Text.clear_screen_line_cache(State, State.cursor1.line)
    [5.3000]
    [5.2810]
    Text.refresh_screen_line_cache(State, State.cursor1.line)
  • replacement in text.lua at line 272
    [5.3922][5.123:183]()
    Text.clear_screen_line_cache(State, State.cursor1.line)
    [5.3922]
    [5.137]
    Text.refresh_screen_line_cache(State, State.cursor1.line)
  • replacement in text.lua at line 367
    [5.3889][5.184:242](),[5.3973][5.184:242](),[5.2389][5.184:242]()
    Text.clear_screen_line_cache(State, State.cursor1.line)
    [5.3973]
    [5.121]
    Text.refresh_screen_line_cache(State, State.cursor1.line)
  • edit in text.lua at line 933
    [5.1637]
    [5.7399]
    local curr_screen_line_index = 1
  • edit in text.lua at line 936
    [5.1667]
    [5.2910]
    State.line_cache[i].start_screen_line_index = curr_screen_line_index
    Text.populate_screen_line_starting_pos(State, i)
    curr_screen_line_index = curr_screen_line_index + #State.line_cache[i].screen_line_starting_pos
  • edit in text.lua at line 940
    [5.2916]
    [5.2916]
    State.screen_line_count = curr_screen_line_index-1
  • replacement in text.lua at line 943
    [5.2921][5.405:462]()
    function Text.clear_screen_line_cache(State, line_index)
    [5.2921]
    [5.1715]
    function Text.refresh_scrollbar_data(State)
    --? print('clearing fragments')
    local curr_screen_line_index = 1
    local npopulated = 0
    for i=1,#State.lines do
    if State.line_cache[i] == nil then
    State.line_cache[i] = {}
    end
    if State.line_cache[i].screen_line_starting_pos == nil then
    --? print(('refresh_scrollbar_data: populating line %d'):format(i))
    Text.populate_screen_line_starting_pos(State, i)
    npopulated = npopulated+1
    end
    State.line_cache[i].start_screen_line_index = curr_screen_line_index
    curr_screen_line_index = curr_screen_line_index + #State.line_cache[i].screen_line_starting_pos
    end
    if npopulated > 1 then
    print(('refresh_scrollbar_data: had to populate %d lines'):format(npopulated))
    end
    State.screen_line_count = curr_screen_line_index-1
    end
    function Text.refresh_screen_line_cache(State, line_index)
  • edit in text.lua at line 967
    [5.1777]
    [2.3]
    Text.populate_screen_line_starting_pos(State, line_index)
    Text.refresh_scrollbar_data(State)
  • edit in select.lua at line 120
    [5.47298][5.564:608]()
    Text.clear_screen_line_cache(State, minl)
  • edit in select.lua at line 125
    [5.6567]
    [5.47635]
    Text.refresh_screen_line_cache(State, minl)
  • edit in select.lua at line 135
    [5.6698]
    [5.47844]
    Text.refresh_screen_line_cache(State, minl)
  • edit in edit.lua at line 32
    [5.8245]
    [5.1829]
    -- start_screen_line_index: a count of the number of screen lines above this line
  • edit in Manual_tests.md at line 16
    [3.26]
    [3.26]
    * Type out a wrapping line, select all using ctrl+a and delete. Editor does
    not crash.
  • file addition: 0035-compute_scrollbar (----------)
    [39.2]
    -- returns:
    -- * a float between 0 and 1 regarding the relative position of the top line on screen
    -- * a float between 0 and 1 regarding the relative position of the bottom line on screen
    compute_scrollbar = function(state)
    local top = state.line_cache[state.screen_top1.line].start_screen_line_index
    local bot = state.line_cache[state.screen_bottom1.line].start_screen_line_index
    return (top-1)/state.screen_line_count, bot/state.screen_line_count
    end
  • file addition: 0034-draw_scrollbar (----------)
    [39.2]
    draw_scrollbar = function(Editor_state)
    App.color(Normal_color)
    love.graphics.line(Editor_state.right+30, Editor_state.top, Editor_state.right+30, Editor_state.bottom)
    love.graphics.line(Editor_state.right+25, Editor_state.top, Editor_state.right+35, Editor_state.top)
    love.graphics.line(Editor_state.right+25, Editor_state.bottom, Editor_state.right+35, Editor_state.bottom)
    local sbtop, sbbot = compute_scrollbar(Editor_state)
    local topy = Editor_state.top + sbtop*(Editor_state.bottom - Editor_state.top)
    local boty = Editor_state.top +sbbot*(Editor_state.bottom - Editor_state.top)
    App.color{r=0.6, g=0.6, b=0.8, a=0.5}
    love.graphics.rectangle('fill', Editor_state.right+20, topy, 20, boty-topy)
    end
  • replacement in 0013-on.keychord_press at line 11
    [4.2303][5.2847:2850](),[5.2847][5.2847:2850]()
    end
    [4.2303]
    end
  • edit in 0012-on.draw at line 6
    [5.3033]
    [40.1925]
    draw_scrollbar(Editor_state)