beginning of a new approach to scroll+wrap

[?]
May 21, 2022, 11:24 PM
2RXZ3PGOTTZ6M4R372JXIKPLBQKPVBMAXNPIEO2HZDN4EMYW4GNAC

Dependencies

  • [2] O6T3TPXD bugfix: position cursor up top when loading file
  • [3] 2ZYV7D3W handle tab characters
  • [4] GE56XURA bugfix: cursor past end of screen line
  • [5] 3TFEAQSW start using some globals
  • [6] PYGMASTV disable some debug prints
  • [7] 242L3OQX bugfix: ensure Cursor_line is always on a text line
  • [8] WLHI7KD3 new globals: draw partial screen line up top
  • [9] 7IKRRESB longer names for indices in long loops
  • [10] SVJZZDC3 snapshot - no, that's all wrong
  • [11] OTIBCAUJ love2d scaffold
  • [12] AVQ5MC5D finish uppercasing all globals
  • [13] BULPIBEG beginnings of a module for the text editor
  • [14] A2QPFRFJ move
  • [15] 3CSIZJ33 clearer comments
  • [16] 2POFQQLW keep cursor on screen when pressing 'down'
  • [17] DLQMM265 scroll past first page
  • [18] Y6FTGOHJ simpler
  • [19] 537TQ2QN some more logging
  • [20] 252M2QMD forgot to move this special case out
  • [21] UWNHC4AA redo y computations
  • [22] HYEAFRZ2 split mouse_pressed events between Text and Drawing
  • [23] B3IWYWSR delete another arg that can be deduced
  • [24] C42QQZSF another piece of support for line wrapping in cursor up
  • [25] FJ4L6N74 draw lines by default
  • [26] 5T2E3PDV couple of bugfixes to file-handling
  • [27] 5L7K4GBD clicking to the right of a wrapped line
  • [28] MGT5FTJ3 first stab at supporting wrapping in cursor up
  • [29] PR4KIAZD first stab at equally hacky cursor down support
  • [30] HIH47LNB drop unused arg
  • [31] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [32] W4UVZETR 2 regressions:
  • [33] DXT4QTAH a few more integer coordinates
  • [34] DAENUOGV eliminate assumptions that line length == size in bytes
  • [35] IZZVOCLB confirm that we have access to all of the love API
  • [36] HBZ2UCUF stop recomputing Cursor_x now that we're saving it
  • [37] TRNWIQN6 more precise height calculation when scrolling up as much as possible while keeping cursor on screen
  • [38] RCDVDFJQ comment
  • [39] JY4VK7L2 rename
  • [40] KJKKASHZ reduce ambitions a bit: page up/down need not start screen from the middle of a line
  • [41] WKTPVZKL ensure integer coordinates
  • [42] XVR2O5PI change text cursor shape
  • [43] PHQPLJUQ rename
  • [44] 5DOC2CBM extract a function
  • [45] XX7G2FFJ intermingle freehand line drawings with text
  • [46] BOFNXP5G clicking now moves the cursor even on long, wrapped lines
  • [47] 2C7CTIQY make space for multiple kinds of width
  • [48] EWMPYCDO bugfix
  • [49] JCSLDGAH beginnings of support for multiple shapes
  • [50] MGOQ5XAV start uppercasing globals
  • [51] OIB2QPRC start remembering where the cursor is drawn in px
  • [52] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing
  • [53] Y36LOGR5 bugfix: show cursor when past end of line
  • [54] XNFTJHC4 split keyboard handling between Text and Drawing
  • [55] VXORMHME delete experimental REPL
  • [56] IYW7X3WL left/right cursor movement, deleting characters
  • [57] VHQCNMAR several more modules
  • [58] BYG5CEMV support for naming points
  • [59] JVRL5TWL store device-independent coordinates inside drawings
  • [60] 5ED3YGHW planning out cursor up/down over wrapped lines

Change contents

  • replacement in text.lua at line 25
    [7.2151][7.1:82]()
    if line_index > Screen_top_line or pos > Top_screen_line_starting_pos then
    [7.2151]
    [7.83]
    if line_index > Screen_top1.line or pos > Screen_top1.pos then
  • replacement in text.lua at line 36
    [7.2206][7.128:222](),[7.199][7.130:210](),[7.222][7.130:210](),[7.2206][7.130:210]()
    if Debug_new_render then print('checking to draw', pos, Top_screen_line_starting_pos) end
    if line_index > Screen_top_line or pos >= Top_screen_line_starting_pos then
    [7.2206]
    [7.223]
    if Debug_new_render then print('checking to draw', pos, Screen_top1.pos) end
    if line_index > Screen_top1.line or pos >= Screen_top1.pos then
  • replacement in text.lua at line 43
    [7.2324][5.51:223]()
    if line_index == Cursor_line then
    if pos <= Cursor_pos and pos + frag_len > Cursor_pos then
    Text.draw_cursor(x+Text.cursor_x2(frag, Cursor_pos-pos+1), y)
    [7.2324]
    [7.2594]
    if line_index == Cursor1.line then
    if pos <= Cursor1.pos and pos + frag_len > Cursor1.pos then
    Text.draw_cursor(x+Text.cursor_x2(frag, Cursor1.pos-pos+1), y)
  • replacement in text.lua at line 51
    [7.37][5.224:282]()
    if line_index == Cursor_line and Cursor_pos == pos then
    [7.37]
    [7.72]
    if line_index == Cursor1.line and Cursor1.pos == pos then
  • replacement in text.lua at line 112
    [7.191][7.191:285]()
    if Cursor_pos > 1 then
    byte_offset = utf8.offset(Lines[Cursor_line].data, Cursor_pos-1)
    [7.191]
    [7.285]
    if Cursor1.pos > 1 then
    byte_offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos-1)
  • replacement in text.lua at line 117
    [7.318][7.318:453](),[7.453][7.2797:2834](),[7.2834][7.453:481](),[7.453][7.453:481]()
    Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_offset)..t..string.sub(Lines[Cursor_line].data, byte_offset+1)
    Lines[Cursor_line].fragments = nil
    Cursor_pos = Cursor_pos+1
    [7.318]
    [7.513]
    Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_offset)..t..string.sub(Lines[Cursor1.line].data, byte_offset+1)
    Lines[Cursor1.line].fragments = nil
    Cursor1.pos = Cursor1.pos+1
  • replacement in text.lua at line 126
    [7.655][7.655:921](),[7.921][7.2835:2874](),[7.2874][7.921:972](),[7.921][7.921:972]()
    local byte_offset = utf8.offset(Lines[Cursor_line].data, Cursor_pos)
    table.insert(Lines, Cursor_line+1, {mode='text', data=string.sub(Lines[Cursor_line].data, byte_offset)})
    Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_offset-1)
    Lines[Cursor_line].fragments = nil
    Cursor_line = Cursor_line+1
    Cursor_pos = 1
    [7.655]
    [3.100]
    local byte_offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos)
    table.insert(Lines, Cursor1.line+1, {mode='text', data=string.sub(Lines[Cursor1.line].data, byte_offset)})
    Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_offset-1)
    Lines[Cursor1.line].fragments = nil
    Cursor1.line = Cursor1.line+1
    Cursor1.pos = 1
  • replacement in text.lua at line 137
    [7.1036][7.1036:1141]()
    assert(Lines[Cursor_line].mode == 'text')
    if Cursor_pos > 1 then
    Cursor_pos = Cursor_pos-1
    [7.1036]
    [7.1141]
    assert(Lines[Cursor1.line].mode == 'text')
    if Cursor1.pos > 1 then
    Cursor1.pos = Cursor1.pos-1
  • replacement in text.lua at line 141
    [7.1150][7.1150:1192]()
    local new_cursor_line = Cursor_line
    [7.1150]
    [7.1192]
    local new_cursor_line = Cursor1.line
  • replacement in text.lua at line 145
    [7.1325][7.1325:1365](),[7.1365][7.114:175]()
    Cursor_line = new_cursor_line
    Cursor_pos = utf8.len(Lines[Cursor_line].data) + 1
    [7.1325]
    [7.1415]
    Cursor1.line = new_cursor_line
    Cursor1.pos = utf8.len(Lines[Cursor1.line].data) + 1
  • replacement in text.lua at line 150
    [7.11][7.11:93]()
    if Cursor_line < Screen_top_line then
    Screen_top_line = Cursor_line
    [7.11]
    [7.1443]
    if Cursor1.line < Screen_top1.line then
    Screen_top1.line = Cursor1.line
  • replacement in text.lua at line 155
    [7.1492][7.1492:1538](),[7.1538][7.176:236](),[7.236][7.1589:1621](),[7.1589][7.1589:1621]()
    assert(Lines[Cursor_line].mode == 'text')
    if Cursor_pos <= utf8.len(Lines[Cursor_line].data) then
    Cursor_pos = Cursor_pos+1
    [7.1492]
    [7.1621]
    assert(Lines[Cursor1.line].mode == 'text')
    if Cursor1.pos <= utf8.len(Lines[Cursor1.line].data) then
    Cursor1.pos = Cursor1.pos+1
  • replacement in text.lua at line 159
    [7.1630][7.1630:1672]()
    local new_cursor_line = Cursor_line
    [7.1630]
    [7.1672]
    local new_cursor_line = Cursor1.line
  • replacement in text.lua at line 163
    [7.1813][7.1813:1878]()
    Cursor_line = new_cursor_line
    Cursor_pos = 1
    [7.1813]
    [7.1878]
    Cursor1.line = new_cursor_line
    Cursor1.pos = 1
  • replacement in text.lua at line 168
    [7.1916][7.94:179]()
    if Cursor_line > Screen_bottom_line then
    Screen_top_line = Cursor_line
    [7.1916]
    [7.179]
    if Cursor1.line > Screen_bottom1.line then
    Screen_top1.line = Cursor1.line
  • replacement in text.lua at line 173
    [7.1954][7.1954:1973]()
    Cursor_pos = 1
    [7.1954]
    [7.1973]
    Cursor1.pos = 1
  • replacement in text.lua at line 175
    [7.2002][7.237:292]()
    Cursor_pos = utf8.len(Lines[Cursor_line].data) + 1
    [7.2002]
    [7.2046]
    Cursor1.pos = utf8.len(Lines[Cursor1.line].data) + 1
  • replacement in text.lua at line 177
    [7.2081][7.2081:2256]()
    if Cursor_pos > 1 then
    local byte_start = utf8.offset(Lines[Cursor_line].data, Cursor_pos-1)
    local byte_end = utf8.offset(Lines[Cursor_line].data, Cursor_pos)
    [7.2081]
    [7.2256]
    if Cursor1.pos > 1 then
    local byte_start = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos-1)
    local byte_end = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos)
  • replacement in text.lua at line 182
    [7.2306][7.2306:2442]()
    Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_start-1)..string.sub(Lines[Cursor_line].data, byte_end)
    [7.2306]
    [7.2442]
    Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_start-1)..string.sub(Lines[Cursor1.line].data, byte_end)
  • replacement in text.lua at line 184
    [7.2455][7.2455:2544]()
    Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_start-1)
    [7.2455]
    [7.2544]
    Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_start-1)
  • replacement in text.lua at line 186
    [7.2556][7.2875:2918](),[7.2918][7.2556:2590](),[7.2556][7.2556:2590]()
    Lines[Cursor_line].fragments = nil
    Cursor_pos = Cursor_pos-1
    [7.2556]
    [7.2590]
    Lines[Cursor1.line].fragments = nil
    Cursor1.pos = Cursor1.pos-1
  • replacement in text.lua at line 189
    [7.2600][7.2600:2728]()
    elseif Cursor_line > 1 then
    if Lines[Cursor_line-1].mode == 'drawing' then
    table.remove(Lines, Cursor_line-1)
    [7.2600]
    [7.2728]
    elseif Cursor1.line > 1 then
    if Lines[Cursor1.line-1].mode == 'drawing' then
    table.remove(Lines, Cursor1.line-1)
  • replacement in text.lua at line 194
    [7.2761][7.2761:2907](),[7.2907][7.2919:2964](),[7.2964][7.2907:2948](),[7.2907][7.2907:2948]()
    Cursor_pos = utf8.len(Lines[Cursor_line-1].data)+1
    Lines[Cursor_line-1].data = Lines[Cursor_line-1].data..Lines[Cursor_line].data
    Lines[Cursor_line-1].fragments = nil
    table.remove(Lines, Cursor_line)
    [7.2761]
    [7.2948]
    Cursor1.pos = utf8.len(Lines[Cursor1.line-1].data)+1
    Lines[Cursor1.line-1].data = Lines[Cursor1.line-1].data..Lines[Cursor1.line].data
    Lines[Cursor1.line-1].fragments = nil
    table.remove(Lines, Cursor1.line)
  • replacement in text.lua at line 199
    [7.2958][7.2958:2992]()
    Cursor_line = Cursor_line-1
    [7.2958]
    [7.2992]
    Cursor1.line = Cursor1.line-1
  • replacement in text.lua at line 203
    [7.3066][7.293:353](),[7.353][7.3117:3265](),[7.3117][7.3117:3265]()
    if Cursor_pos <= utf8.len(Lines[Cursor_line].data) then
    local byte_start = utf8.offset(Lines[Cursor_line].data, Cursor_pos)
    local byte_end = utf8.offset(Lines[Cursor_line].data, Cursor_pos+1)
    [7.3066]
    [7.3265]
    if Cursor1.pos <= utf8.len(Lines[Cursor1.line].data) then
    local byte_start = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos)
    local byte_end = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos+1)
  • replacement in text.lua at line 208
    [7.3315][7.3315:3451]()
    Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_start-1)..string.sub(Lines[Cursor_line].data, byte_end)
    [7.3315]
    [7.3451]
    Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_start-1)..string.sub(Lines[Cursor1.line].data, byte_end)
  • replacement in text.lua at line 210
    [7.3464][7.3464:3553]()
    Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_start-1)
    [7.3464]
    [7.3553]
    Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_start-1)
  • replacement in text.lua at line 212
    [7.3565][7.2965:3008](),[7.3008][7.3565:3600](),[7.3565][7.3565:3600]()
    Lines[Cursor_line].fragments = nil
    -- no change to Cursor_pos
    [7.3565]
    [7.3600]
    Lines[Cursor1.line].fragments = nil
    -- no change to Cursor1.pos
  • replacement in text.lua at line 215
    [7.3610][7.3610:3743]()
    elseif Cursor_line < #Lines then
    if Lines[Cursor_line+1].mode == 'drawing' then
    table.remove(Lines, Cursor_line+1)
    [7.3610]
    [7.3743]
    elseif Cursor1.line < #Lines then
    if Lines[Cursor1.line+1].mode == 'drawing' then
    table.remove(Lines, Cursor1.line+1)
  • replacement in text.lua at line 220
    [7.3776][7.3776:3861](),[7.3861][7.3009:3052](),[7.3052][7.3861:3904](),[7.3861][7.3861:3904]()
    Lines[Cursor_line].data = Lines[Cursor_line].data..Lines[Cursor_line+1].data
    Lines[Cursor_line].fragments = nil
    table.remove(Lines, Cursor_line+1)
    [7.3776]
    [7.3904]
    Lines[Cursor1.line].data = Lines[Cursor1.line].data..Lines[Cursor1.line+1].data
    Lines[Cursor1.line].fragments = nil
    table.remove(Lines, Cursor1.line+1)
  • replacement in text.lua at line 227
    [7.3984][7.3984:4030](),[7.4030][6.1:63]()
    assert(Lines[Cursor_line].mode == 'text')
    --? print('up', Cursor_pos, Top_screen_line_starting_pos)
    [7.3984]
    [7.1]
    assert(Lines[Cursor1.line].mode == 'text')
    --? print('up', Cursor1.pos, Screen_top1.pos)
  • replacement in text.lua at line 233
    [7.51][7.183:225](),[7.183][7.183:225]()
    local new_cursor_line = Cursor_line
    [7.51]
    [7.225]
    local new_cursor_line = Cursor1.line
  • replacement in text.lua at line 237
    [7.437][7.437:477](),[7.477][7.1:70](),[7.70][7.1:85]()
    Cursor_line = new_cursor_line
    if Lines[Cursor_line].screen_line_starting_pos == nil then
    Cursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, Cursor_x)
    [7.358]
    [7.151]
    Cursor1.line = new_cursor_line
    if Lines[Cursor1.line].screen_line_starting_pos == nil then
    Cursor1.pos = Text.nearest_cursor_pos(Lines[Cursor1.line].data, Cursor_x)
  • replacement in text.lua at line 243
    [7.118][7.183:270](),[7.183][7.183:270]()
    local screen_line_starting_pos = Lines[Cursor_line].screen_line_starting_pos
    [7.118]
    [7.270]
    local screen_line_starting_pos = Lines[Cursor1.line].screen_line_starting_pos
  • replacement in text.lua at line 246
    [6.238][7.302:480](),[7.463][7.302:480](),[7.302][7.302:480](),[7.480][6.239:355]()
    if Screen_top_line == Cursor_line and Top_screen_line_starting_pos == screen_line_starting_pos then
    Top_screen_line_starting_pos = screen_line_starting_pos
    --? print('pos of top of screen is also '..tostring(Top_screen_line_starting_pos)..' of the same line')
    [6.238]
    [7.480]
    if Screen_top1.line == Cursor1.line and Screen_top1.pos == screen_line_starting_pos then
    Screen_top1.pos = screen_line_starting_pos
    --? print('pos of top of screen is also '..tostring(Screen_top1.pos)..' of the same line')
  • replacement in text.lua at line 250
    [7.494][7.425:507](),[7.425][7.425:507](),[7.507][7.86:177]()
    local s = string.sub(Lines[Cursor_line].data, screen_line_starting_pos)
    Cursor_pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1
    [7.494]
    [7.556]
    local s = string.sub(Lines[Cursor1.line].data, screen_line_starting_pos)
    Cursor1.pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1
  • replacement in text.lua at line 255
    [7.594][7.594:676]()
    if Cursor_line < Screen_top_line then
    Screen_top_line = Cursor_line
    [7.594]
    [7.4415]
    if Cursor1.line < Screen_top1.line then
    Screen_top1.line = Cursor1.line
  • replacement in text.lua at line 262
    [7.896][7.558:660]()
    new_screen_line_starting_pos = Lines[Cursor_line].screen_line_starting_pos[screen_line_index-1]
    [7.896]
    [6.423]
    new_screen_line_starting_pos = Lines[Cursor1.line].screen_line_starting_pos[screen_line_index-1]
  • replacement in text.lua at line 264
    [6.571][7.804:978](),[7.804][7.804:978](),[7.978][6.572:671]()
    if Screen_top_line == Cursor_line and Top_screen_line_starting_pos == screen_line_starting_pos then
    Top_screen_line_starting_pos = new_screen_line_starting_pos
    --? print('also setting pos of top of screen to '..tostring(Top_screen_line_starting_pos))
    [6.571]
    [7.1073]
    if Screen_top1.line == Cursor1.line and Screen_top1.pos == screen_line_starting_pos then
    Screen_top1.pos = new_screen_line_starting_pos
    --? print('also setting pos of top of screen to '..tostring(Screen_top1.pos))
  • replacement in text.lua at line 268
    [7.1083][7.1083:1256](),[7.1256][6.672:732]()
    local s = string.sub(Lines[Cursor_line].data, new_screen_line_starting_pos)
    Cursor_pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1
    --? print('cursor pos is now '..tostring(Cursor_pos))
    [7.1083]
    [7.268]
    local s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_pos)
    Cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1
    --? print('cursor pos is now '..tostring(Cursor1.pos))
  • replacement in text.lua at line 273
    [7.4463][7.4463:4509]()
    assert(Lines[Cursor_line].mode == 'text')
    [7.4463]
    [7.267]
    assert(Lines[Cursor1.line].mode == 'text')
  • replacement in text.lua at line 277
    [6.798][7.421:463](),[7.421][7.421:463]()
    local new_cursor_line = Cursor_line
    [6.798]
    [7.463]
    local new_cursor_line = Cursor1.line
  • replacement in text.lua at line 281
    [7.601][7.601:723](),[7.723][6.799:831]()
    Cursor_line = new_cursor_line
    Cursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, Cursor_x)
    --? print(Cursor_pos)
    [7.601]
    [7.751]
    Cursor1.line = new_cursor_line
    Cursor1.pos = Text.nearest_cursor_pos(Lines[Cursor1.line].data, Cursor_x)
    --? print(Cursor1.pos)
  • replacement in text.lua at line 287
    [7.789][6.832:893](),[7.121][7.789:836](),[6.893][7.789:836](),[7.789][7.789:836](),[7.836][6.894:981](),[7.84][7.836:874](),[6.981][7.836:874](),[7.836][7.836:874]()
    --? print(Cursor_line, Cursor_pos, Screen_bottom_line)
    if Cursor_line > Screen_bottom_line then
    --? print('screen top before:', Screen_top_line, Top_screen_line_starting_pos)
    Screen_top_line = Cursor_line
    [7.789]
    [6.982]
    --? print(Cursor1.line, Cursor1.pos, Screen_bottom1.line)
    if Cursor1.line > Screen_bottom1.line then
    --? print('screen top before:', Screen_top1.line, Screen_top1.pos)
    Screen_top1.line = Cursor1.line
  • replacement in text.lua at line 293
    [7.922][6.1032:1118]()
    --? print('screen top after:', Screen_top_line, Top_screen_line_starting_pos)
    [7.922]
    [7.4899]
    --? print('screen top after:', Screen_top1.line, Screen_top1.pos)
  • replacement in text.lua at line 295
    [7.4909][6.1119:1186]()
    --? print('=>', Cursor_line, Cursor_pos, Screen_bottom_line)
    [7.4909]
    [7.923]
    --? print('=>', Cursor1.line, Cursor1.pos, Screen_bottom1.line)
  • replacement in text.lua at line 300
    [7.1145][7.1145:1247]()
    new_screen_line_starting_pos = Lines[Cursor_line].screen_line_starting_pos[screen_line_index+1]
    [7.1145]
    [6.1254]
    new_screen_line_starting_pos = Lines[Cursor1.line].screen_line_starting_pos[screen_line_index+1]
  • replacement in text.lua at line 302
    [6.1402][7.1391:1564](),[7.1391][7.1391:1564](),[7.1564][6.1403:1463](),[6.1463][7.122:158](),[7.1620][7.122:158]()
    local s = string.sub(Lines[Cursor_line].data, new_screen_line_starting_pos)
    Cursor_pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1
    --? print('cursor pos is now '..tostring(Cursor_pos))
    Screen_top_line = Cursor_line
    [6.1402]
    [6.1464]
    local s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_pos)
    Cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1
    --? print('cursor pos is now '..tostring(Cursor1.pos))
    Screen_top1.line = Cursor1.line
  • replacement in text.lua at line 308
    [7.1666][6.1512:1596]()
    --? print('screen top after:', Screen_top_line, Top_screen_line_starting_pos)
    [7.1666]
    [7.1313]
    --? print('screen top after:', Screen_top1.line, Screen_top1.pos)
  • replacement in text.lua at line 314
    [7.1383][7.1383:1444]()
    if Lines[Cursor_line].screen_line_starting_pos == nil then
    [7.1383]
    [7.1444]
    if Lines[Cursor1.line].screen_line_starting_pos == nil then
  • replacement in text.lua at line 317
    [7.1465][7.1465:1621]()
    for i=#Lines[Cursor_line].screen_line_starting_pos,1,-1 do
    local spos = Lines[Cursor_line].screen_line_starting_pos[i]
    if spos <= Cursor_pos then
    [7.1465]
    [7.1621]
    for i=#Lines[Cursor1.line].screen_line_starting_pos,1,-1 do
    local spos = Lines[Cursor1.line].screen_line_starting_pos[i]
    if spos <= Cursor1.pos then
  • replacement in text.lua at line 327
    [7.1711][7.1711:1772]()
    if Lines[Cursor_line].screen_line_starting_pos == nil then
    [7.1711]
    [7.1772]
    if Lines[Cursor1.line].screen_line_starting_pos == nil then
  • replacement in text.lua at line 330
    [7.1794][7.1794:1933]()
    i=#Lines[Cursor_line].screen_line_starting_pos
    local spos = Lines[Cursor_line].screen_line_starting_pos[i]
    return spos <= Cursor_pos
    [7.1794]
    [7.1933]
    i=#Lines[Cursor1.line].screen_line_starting_pos
    local spos = Lines[Cursor1.line].screen_line_starting_pos[i]
    return spos <= Cursor1.pos
  • replacement in text.lua at line 336
    [7.87][7.87:166]()
    while Cursor_line <= #Lines do
    if Lines[Cursor_line].mode == 'text' then
    [7.87]
    [7.166]
    while Cursor1.line <= #Lines do
    if Lines[Cursor1.line].mode == 'text' then
  • replacement in text.lua at line 340
    [7.186][7.186:220]()
    Cursor_line = Cursor_line + 1
    [7.186]
    [7.220]
    Cursor1.line = Cursor1.line + 1
  • replacement in text.lua at line 343
    [7.287][7.287:354]()
    if Cursor_line > #Lines then
    assert(Cursor_line == #Lines+1)
    [7.287]
    [7.354]
    if Cursor1.line > #Lines then
    assert(Cursor1.line == #Lines+1)
  • replacement in text.lua at line 347
    [7.408][7.408:485]()
    if Cursor_line > Screen_bottom_line then
    Screen_top_line = Cursor_line
    [7.408]
    [7.485]
    if Cursor1.line > Screen_bottom1.line then
    Screen_top1.line = Cursor1.line
  • replacement in text.lua at line 355
    [7.266][6.1597:1718]()
    --? print('cursor pos '..tostring(Cursor_pos)..' is on the #'..tostring(cursor_pos_screen_lines)..' screen line down')
    [7.266]
    [7.383]
    --? print('cursor pos '..tostring(Cursor1.pos)..' is on the #'..tostring(cursor_pos_screen_lines)..' screen line down')
  • replacement in text.lua at line 359
    [7.660][7.660:703]()
    if Screen_top_line == 1 then break end
    [7.660]
    [6.1719]
    if Screen_top1.line == 1 then break end
  • replacement in text.lua at line 362
    [7.531][7.531:717]()
    if Lines[Screen_top_line-1].mode == 'drawing' then
    h = 20 + Drawing.pixels(Lines[Screen_top_line-1].h)
    elseif Lines[Screen_top_line-1].screen_line_starting_pos == nil then
    [7.531]
    [7.717]
    if Lines[Screen_top1.line-1].mode == 'drawing' then
    h = 20 + Drawing.pixels(Lines[Screen_top1.line-1].h)
    elseif Lines[Screen_top1.line-1].screen_line_starting_pos == nil then
  • replacement in text.lua at line 367
    [7.776][7.776:843]()
    local n = #Lines[Screen_top_line-1].screen_line_starting_pos
    [7.776]
    [7.843]
    local n = #Lines[Screen_top1.line-1].screen_line_starting_pos
  • replacement in text.lua at line 378
    [7.883][7.883:925]()
    Screen_top_line = Screen_top_line - 1
    [7.883]
    [7.925]
    Screen_top1.line = Screen_top1.line - 1
  • replacement in text.lua at line 391
    [7.48][7.153:180](),[7.49][7.153:180](),[7.471][7.153:180](),[7.153][7.153:180]()
    Cursor_line = line_index
    [7.471]
    [7.472]
    Cursor1.line = line_index
  • replacement in text.lua at line 393
    [7.555][7.555:611]()
    Cursor_pos = Text.nearest_cursor_pos(line.data, mx)
    [7.519]
    [7.611]
    Cursor1.pos = Text.nearest_cursor_pos(line.data, mx)
  • replacement in text.lua at line 407
    [7.437][4.1:73]()
    Cursor_pos = line.screen_line_starting_pos[screen_line_index+1]
    [7.437]
    [7.513]
    Cursor1.pos = line.screen_line_starting_pos[screen_line_index+1]
  • replacement in text.lua at line 411
    [7.1185][7.1185:1266]()
    Cursor_pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, mx) - 1
    [7.1185]
    [7.1266]
    Cursor1.pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, mx) - 1
  • replacement in text.lua at line 426
    [7.1502][7.1502:1533]()
    -- Cursor_pos = 4 + 2 - 1 = 5
    [7.1502]
    [7.1533]
    -- Cursor1.pos = 4 + 2 - 1 = 5
  • replacement in text.lua at line 431
    [7.1643][7.1643:1674]()
    -- Cursor_pos = 7 + 2 - 1 = 8
    [7.1643]
    [7.468]
    -- Cursor1.pos = 7 + 2 - 1 = 8
  • edit in text.lua at line 476
    [7.3295]
    [7.1438]
    function Text.to2(pos1)
    local result = {line=pos1.line, screen_line=1}
    if Line[pos1.line].screen_line_starting_pos == nil then
    result.screen_pos = pos1.pos
    else
    for i=#Lines[pos1.line].screen_line_starting_pos,1,-1 do
    local spos = Lines[pos1.line].screen_line_starting_pos[i]
    if spos <= Cursor1.pos then
    result.screen_line = i
    result.screen_pos = spos
    break
    end
    end
    end
    assert(result.screen_pos)
    return result
    end
    function Text.to1(pos2)
    local result = {line=pos2.line, pos=pos2.screen_pos}
    if pos2.screen_line > 1 then
    result.pos = Lines[pos2.line].screen_line_starting_pos[pos2.screen_line] + pos2.screen_pos
    end
    return result
    end
  • replacement in main.lua at line 40
    [7.479][7.2:18](),[7.35][7.2:18](),[7.18][7.216:287]()
    Cursor_line = 1
    Cursor_pos = 1 -- in Unicode codepoints, from 1 to utf8.len(line) + 1
    [7.35]
    [7.1238]
    -- Lines can be too long to fit on screen, in which case they _wrap_ into
    -- multiple _screen lines_.
    --
    -- Therefore, any potential location for the cursor can be described in two ways:
    -- * schema 1: As a combination of line index and position within a line (in utf8 codepoint units)
    -- * schema 2: As a combination of line index, screen line index within the line, and a position within the screen line.
    --
    -- Most of the time we'll only persist positions in schema 1, translating to
    -- schema 2 when that's convenient.
    Cursor1 = {line=1, pos=1} -- position of cursor
    Screen_top1 = {line=1, pos=1} -- position of start of screen line at top of screen
    Screen_bottom1 = {line=1, pos=1} -- position of start of screen line at bottom of screen
  • edit in main.lua at line 58
    [7.4][7.4:68](),[7.68][7.288:377](),[7.68][7.1240:1241](),[7.95][7.1240:1241](),[7.114][7.1240:1241](),[7.377][7.1240:1241](),[7.455][7.1240:1241](),[7.45][7.1240:1241]()
    -- scrolling support
    Screen_top_line = 1
    Screen_bottom_line = 1
    Top_screen_line_starting_pos = 1 -- when top of screen starts in between a wrapped line
  • replacement in main.lua at line 89
    [7.430][7.668:690]()
    Cursor_line = i
    [7.430]
    [2.3]
    Cursor1.line = i
  • replacement in main.lua at line 103
    [7.532][7.780:802]()
    Cursor_line = i
    [7.532]
    [2.16]
    Cursor1.line = i
  • replacement in main.lua at line 121
    [7.43][7.546:588](),[7.223][7.546:588](),[7.44][7.546:588](),[7.650][7.650:688]()
    if line_index >= Screen_top_line then
    Screen_bottom_line = line_index
    [7.223]
    [7.705]
    if line_index >= Screen_top1.line then
    Screen_bottom1.line = line_index
  • replacement in main.lua at line 129
    [7.1011][7.1011:1121]()
    if Cursor_line >= line_index then
    Cursor_line = Cursor_line+1
    [7.1011]
    [7.1121]
    if Cursor1.line >= line_index then
    Cursor1.line = Cursor1.line+1
  • replacement in main.lua at line 133
    [7.1175][7.1175:1219]()
    if line_index == Cursor_line then
    [7.1175]
    [7.263]
    if line_index == Cursor1.line then
  • replacement in main.lua at line 218
    [7.1627][7.1627:1702](),[7.1702][7.762:845]()
    Screen_top_line = Screen_bottom_line
    Cursor_line = Screen_top_line
    Top_screen_line_starting_pos = 1
    Cursor_pos = Top_screen_line_starting_pos
    [7.1627]
    [7.939]
    Screen_top1.line = Screen_bottom1.line
    Screen_top1.pos = 1
    Cursor1.line = Screen_top1.line
    Cursor1.pos = Screen_top1.pos
  • replacement in main.lua at line 227
    [7.1844][7.1844:1889]()
    if Screen_top_line == 1 then break end
    [7.1844]
    [7.274]
    if Screen_top1.line == 1 then break end
  • replacement in main.lua at line 229
    [7.308][7.1043:1098](),[7.1043][7.1043:1098](),[7.1098][7.1976:2033](),[7.1976][7.1976:2033]()
    if Lines[Screen_top_line].mode == 'drawing' then
    y = y - Drawing.pixels(Lines[Screen_top_line].h)
    [7.308]
    [7.2033]
    if Lines[Screen_top1.line].mode == 'drawing' then
    y = y - Drawing.pixels(Lines[Screen_top1.line].h)
  • replacement in main.lua at line 232
    [7.2043][7.2043:2087]()
    Screen_top_line = Screen_top_line - 1
    [7.2043]
    [7.2087]
    Screen_top1.line = Screen_top1.line - 1
  • replacement in main.lua at line 234
    [7.2095][7.2095:2159]()
    if Cursor_line ~= Screen_top_line then
    Cursor_pos = 1
    [7.2095]
    [7.155]
    if Cursor1.line ~= Screen_top1.line then
    Cursor1.pos = 1
  • replacement in main.lua at line 237
    [7.163][7.2160:2194]()
    Cursor_line = Screen_top_line
    [7.163]
    [7.1099]
    Cursor1.line = Screen_top1.line