add state arg to a few functions

[?]
Jul 12, 2022, 11:39 PM
Z5HLXU4PJWWJJDBCK52NBD6PIRIA3TAN2BKZB5HBYFGIDBX4F5HAC

Dependencies

  • [2] SPSW74Y5 add state arg to Text.keychord_pressed
  • [3] 3MAZEQK5 add state arg to Text.textinput
  • [4] GCEF4N3V stop repeatedly checking for line wrapping
  • [5] 2ZYV7D3W handle tab characters
  • [6] UV4EWOLY add args to some functions
  • [7] DLQMM265 scroll past first page
  • [8] PHFWIFYK scroll on enter
  • [9] GN3IF4WF bugfix: pasting newlines
  • [10] SVJZZDC3 snapshot - no, that's all wrong
  • [11] UFIUYYYV additional logging for an active bug
  • [12] 2TQR4PSY add args to some functions
  • [13] YJJ4X4JG bugfix: avoid scrolling on 'end'
  • [14] 73OCE2MC after much struggle, a brute-force undo
  • [15] 4QQBMWLL regression: typing uppercase letters in text
  • [16] IRCKL6VN extract scrolling logic out of insert_at_cursor
  • [17] GGJEDJOO add args to some functions
  • [18] XNFTJHC4 split keyboard handling between Text and Drawing
  • [19] YPHKZVWM extract a new variable
  • [20] ESETRNLB bugfix: printing the first part of a line at the bottom made it seem non-wrapping
  • [21] HTWAM4NZ bugfix: scrolling in left/right movements
  • [22] PR4KIAZD first stab at equally hacky cursor down support
  • [23] AVLAYODP much simpler
  • [24] V3EABA35 skip multiple consecutive whitespace
  • [25] 2LOQ5ALJ add args to some functions
  • [26] G6OYAYHU paste in text with M-v
  • [27] 3TDOZESE extract scrolling logic out of insert_return
  • [28] EBBFOW4X bugfix: clear selection in a couple more places
  • [29] KECEMMMR extract couple of functions
  • [30] VJ77YABH more efficient undo/redo
  • [31] TRNWIQN6 more precise height calculation when scrolling up as much as possible while keeping cursor on screen
  • [32] ZPUQSPQP extract a few methods
  • [33] DHI6IJCN selecting text and deleting selections
  • [34] PFT5Y2ZY move
  • [35] ED2FYWDK turns out super- chords to get to textinput
  • [36] ZHLO7K3M add args to some functions
  • [37] 2CH77LZC add args to some functions
  • [38] OGUV4HSA remove some memory leaks from rendered fragments
  • [39] DRFE3B3Z mouse buttons are integers, not strings
  • [40] AYE2VEGJ extract a couple of methods
  • [41] V5MJRFOZ bugfix: down arrow doesn't scroll up unnecessarily
  • [42] AOIRVVJA revert selection logic to before commit 3ffc2ed8f
  • [43] 5UG5PQ6K undo commit 861c57b533
  • [44] 2L5MEZV3 experiment: new edit namespace
  • [45] LNUHQOGH start passing in Editor_state explicitly
  • [46] CVSRHMJ2 experiment: slightly adaptive scrolling
  • [47] HOSPP2AN crisp font rendering
  • [48] X75QPYVW move Selection1 clearing past business logic
  • [49] BYG5CEMV support for naming points
  • [50] MP2TBKU6 bugfix: crash in Text.up() after return
  • [51] 62PZGSUC optimization: moving cursor to next word
  • [52] CPZGQT72 go through and fix similar issues
  • [53] 5OALPNN3 add args to some functions
  • [54] KOYAJWE4 extract a couple more methods
  • [55] CG3264MM move
  • [56] CUIV2LE5 some typos
  • [57] VA2ZYFFF better fix for commit 3ffc2ed8f
  • [58] PX7DDEMO autosave slightly less aggressively
  • [59] 2H67P75X switch arg for a function
  • [60] SLLR6KKI bugfix for non-ASCII
  • [61] 2LC3BM2N support other whitespace chars in word movements
  • [62] PYGMASTV disable some debug prints
  • [63] AMSESRTH move some code
  • [64] EMHRPJ3R no, that's not right
  • [65] 4KOI3E6R remove some redundant checks
  • [66] SQLVYKVJ rename
  • [67] QCQTMUZ7 add args to some functions
  • [68] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [69] LF7BWEG4 group all editor globals
  • [70] KZ5GAYRP this fixes the immediate regression
  • [71] MDXGMZU2 disable all debug prints
  • [*] BULPIBEG beginnings of a module for the text editor

Change contents

  • replacement in text.lua at line 142
    [4.78][4.1:28](),[4.118][4.1:28](),[3.235][4.1:28](),[4.1274][4.1:28](),[4.55973][4.1:28](),[4.171][4.1:28]()
    Text.insert_at_cursor(t)
    [3.235]
    [3.236]
    Text.insert_at_cursor(State, t)
  • replacement in text.lua at line 151
    [4.65][4.65:99](),[4.99][4.56608:57058]()
    function Text.insert_at_cursor(t)
    local byte_offset = Text.offset(Editor_state.lines[Editor_state.cursor1.line].data, Editor_state.cursor1.pos)
    Editor_state.lines[Editor_state.cursor1.line].data = string.sub(Editor_state.lines[Editor_state.cursor1.line].data, 1, byte_offset-1)..t..string.sub(Editor_state.lines[Editor_state.cursor1.line].data, byte_offset)
    Text.clear_cache(Editor_state.lines[Editor_state.cursor1.line])
    Editor_state.cursor1.pos = Editor_state.cursor1.pos+1
    [4.65]
    [4.513]
    function Text.insert_at_cursor(State, t)
    local byte_offset = Text.offset(State.lines[State.cursor1.line].data, State.cursor1.pos)
    State.lines[State.cursor1.line].data = string.sub(State.lines[State.cursor1.line].data, 1, byte_offset-1)..t..string.sub(State.lines[State.cursor1.line].data, byte_offset)
    Text.clear_cache(State.lines[State.cursor1.line])
    State.cursor1.pos = State.cursor1.pos+1
  • replacement in text.lua at line 165
    [4.1421][4.2:27]()
    Text.insert_return()
    [4.1421]
    [2.166]
    Text.insert_return(State)
  • replacement in text.lua at line 175
    [4.227][4.163:195](),[4.520][4.163:195](),[2.651][4.163:195](),[4.1547][4.163:195](),[4.6602][4.163:195](),[4.57774][4.163:195](),[4.163][4.163:195]()
    Text.insert_at_cursor('\t')
    [2.651]
    [2.652]
    Text.insert_at_cursor(State, '\t')
  • replacement in text.lua at line 261
    [4.277][2.4342:4412]()
    Text.left(State.margin_left, App.screen.width-State.margin_right)
    [4.277]
    [2.4412]
    Text.left(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 264
    [4.324][2.4439:4510]()
    Text.right(State.margin_left, App.screen.width-State.margin_right)
    [4.324]
    [2.4510]
    Text.right(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 270
    [4.8804][2.4653:4723]()
    Text.left(State.margin_left, App.screen.width-State.margin_right)
    [4.8804]
    [4.8820]
    Text.left(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 275
    [4.8952][2.4840:4911]()
    Text.right(State.margin_left, App.screen.width-State.margin_right)
    [4.8952]
    [4.369]
    Text.right(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 278
    [4.456][2.4912:4987]()
    Text.word_left(State.margin_left, App.screen.width-State.margin_right)
    [4.456]
    [2.4987]
    Text.word_left(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 281
    [4.794][2.5014:5090]()
    Text.word_right(State.margin_left, App.screen.width-State.margin_right)
    [4.794]
    [2.5090]
    Text.word_right(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 287
    [4.9221][2.5233:5308]()
    Text.word_left(State.margin_left, App.screen.width-State.margin_right)
    [4.9221]
    [4.9242]
    Text.word_left(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 292
    [4.9376][2.5425:5501]()
    Text.word_right(State.margin_left, App.screen.width-State.margin_right)
    [4.9376]
    [4.1073]
    Text.word_right(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 294
    [4.1103][4.5991:6016]()
    Text.start_of_line()
    [4.1103]
    [2.5502]
    Text.start_of_line(State)
  • replacement in text.lua at line 297
    [4.115][2.5529:5606]()
    Text.end_of_line(State.margin_left, App.screen.width-State.margin_right)
    [4.115]
    [2.5606]
    Text.end_of_line(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 303
    [4.9648][4.6041:6066]()
    Text.start_of_line()
    [4.9648]
    [4.9668]
    Text.start_of_line(State)
  • replacement in text.lua at line 308
    [4.9798][2.5865:5942]()
    Text.end_of_line(State.margin_left, App.screen.width-State.margin_right)
    [4.9798]
    [4.3956]
    Text.end_of_line(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 310
    [4.3984][2.5943:6011]()
    Text.up(State.margin_left, App.screen.width-State.margin_right)
    [4.3984]
    [2.6011]
    Text.up(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 313
    [4.4463][2.6038:6108]()
    Text.down(State.margin_left, App.screen.width-State.margin_right)
    [4.4463]
    [2.6108]
    Text.down(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 319
    [4.10118][2.6251:6319]()
    Text.up(State.margin_left, App.screen.width-State.margin_right)
    [4.10118]
    [4.10132]
    Text.up(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 324
    [4.10263][2.6436:6506]()
    Text.down(State.margin_left, App.screen.width-State.margin_right)
    [4.10263]
    [4.1]
    Text.down(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 326
    [4.33][2.6507:6579]()
    Text.pageup(State.margin_left, App.screen.width-State.margin_right)
    [4.33]
    [2.6579]
    Text.pageup(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 329
    [4.893][2.6606:6680]()
    Text.pagedown(State.margin_left, App.screen.width-State.margin_right)
    [4.893]
    [2.6680]
    Text.pagedown(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 335
    [4.10534][2.6823:6895]()
    Text.pageup(State.margin_left, App.screen.width-State.margin_right)
    [4.10534]
    [4.10552]
    Text.pageup(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 340
    [4.10687][2.7012:7086]()
    Text.pagedown(State.margin_left, App.screen.width-State.margin_right)
    [4.10687]
    [4.182]
    Text.pagedown(State, State.margin_left, App.screen.width-State.margin_right)
  • replacement in text.lua at line 344
    [4.193][4.193:223](),[4.223][4.65631:66263]()
    function Text.insert_return()
    local byte_offset = Text.offset(Editor_state.lines[Editor_state.cursor1.line].data, Editor_state.cursor1.pos)
    table.insert(Editor_state.lines, Editor_state.cursor1.line+1, {mode='text', data=string.sub(Editor_state.lines[Editor_state.cursor1.line].data, byte_offset)})
    Editor_state.lines[Editor_state.cursor1.line].data = string.sub(Editor_state.lines[Editor_state.cursor1.line].data, 1, byte_offset-1)
    Text.clear_cache(Editor_state.lines[Editor_state.cursor1.line])
    Text.clear_cache(Editor_state.lines[Editor_state.cursor1.line+1])
    Editor_state.cursor1.line = Editor_state.cursor1.line+1
    Editor_state.cursor1.pos = 1
    [4.193]
    [4.46]
    function Text.insert_return(State)
    local byte_offset = Text.offset(State.lines[State.cursor1.line].data, State.cursor1.pos)
    table.insert(State.lines, State.cursor1.line+1, {mode='text', data=string.sub(State.lines[State.cursor1.line].data, byte_offset)})
    State.lines[State.cursor1.line].data = string.sub(State.lines[State.cursor1.line].data, 1, byte_offset-1)
    Text.clear_cache(State.lines[State.cursor1.line])
    Text.clear_cache(State.lines[State.cursor1.line+1])
    State.cursor1.line = State.cursor1.line+1
    State.cursor1.pos = 1
  • replacement in text.lua at line 354
    [4.51][4.1111:1145]()
    function Text.pageup(left, right)
    [4.51]
    [4.3]
    function Text.pageup(State, left, right)
  • replacement in text.lua at line 357
    [4.115][4.66264:66327]()
    local top2 = Text.to2(Editor_state.screen_top1, left, right)
    [4.115]
    [4.152]
    local top2 = Text.to2(State.screen_top1, left, right)
  • replacement in text.lua at line 359
    [4.183][4.66328:66425]()
    local y = App.screen.height - Editor_state.line_height
    while y >= Editor_state.margin_top do
    [4.183]
    [4.26]
    local y = App.screen.height - State.line_height
    while y >= State.margin_top do
  • replacement in text.lua at line 362
    [4.89][4.66426:66841]()
    if Editor_state.screen_top1.line == 1 and Editor_state.screen_top1.pos == 1 then break end
    if Editor_state.lines[Editor_state.screen_top1.line].mode == 'text' then
    y = y - Editor_state.line_height
    elseif Editor_state.lines[Editor_state.screen_top1.line].mode == 'drawing' then
    y = y - Editor_state.drawing_padding_height - Drawing.pixels(Editor_state.lines[Editor_state.screen_top1.line].h)
    [4.89]
    [4.555]
    if State.screen_top1.line == 1 and State.screen_top1.pos == 1 then break end
    if State.lines[State.screen_top1.line].mode == 'text' then
    y = y - State.line_height
    elseif State.lines[State.screen_top1.line].mode == 'drawing' then
    y = y - State.drawing_padding_height - Drawing.pixels(State.lines[State.screen_top1.line].h)
  • replacement in text.lua at line 370
    [4.83][4.66842:67004]()
    Editor_state.screen_top1 = Text.to1(top2)
    Editor_state.cursor1.line = Editor_state.screen_top1.line
    Editor_state.cursor1.pos = Editor_state.screen_top1.pos
    [4.83]
    [4.3]
    State.screen_top1 = Text.to1(top2)
    State.cursor1.line = State.screen_top1.line
    State.cursor1.pos = State.screen_top1.pos
  • replacement in text.lua at line 374
    [4.93][4.67005:67131]()
    --? print(Editor_state.cursor1.line, Editor_state.cursor1.pos, Editor_state.screen_top1.line, Editor_state.screen_top1.pos)
    [4.93]
    [4.90]
    --? print(State.cursor1.line, State.cursor1.pos, State.screen_top1.line, State.screen_top1.pos)
  • replacement in text.lua at line 378
    [4.88][4.1146:1182]()
    function Text.pagedown(left, right)
    [4.88]
    [4.117]
    function Text.pagedown(State, left, right)
  • replacement in text.lua at line 383
    [4.2991][4.67132:67198]()
    local top2 = Text.to2(Editor_state.screen_bottom1, left, right)
    [4.2991]
    [4.3031]
    local top2 = Text.to2(State.screen_bottom1, left, right)
  • replacement in text.lua at line 388
    [4.3158][4.67199:67294]()
    if Text.lt1(Editor_state.screen_top1, new_top1) then
    Editor_state.screen_top1 = new_top1
    [4.3158]
    [4.3227]
    if Text.lt1(State.screen_top1, new_top1) then
    State.screen_top1 = new_top1
  • replacement in text.lua at line 391
    [4.3234][4.67295:67431]()
    Editor_state.screen_top1.line = Editor_state.screen_bottom1.line
    Editor_state.screen_top1.pos = Editor_state.screen_bottom1.pos
    [4.3234]
    [4.3318]
    State.screen_top1.line = State.screen_bottom1.line
    State.screen_top1.pos = State.screen_bottom1.pos
  • replacement in text.lua at line 394
    [4.3324][4.67432:67641]()
    --? print('setting top to', Editor_state.screen_top1.line, Editor_state.screen_top1.pos)
    Editor_state.cursor1.line = Editor_state.screen_top1.line
    Editor_state.cursor1.pos = Editor_state.screen_top1.pos
    [4.3324]
    [4.94]
    --? print('setting top to', State.screen_top1.line, State.screen_top1.pos)
    State.cursor1.line = State.screen_top1.line
    State.cursor1.pos = State.screen_top1.pos
  • replacement in text.lua at line 398
    [4.184][4.67642:67696]()
    --? print('top now', Editor_state.screen_top1.line)
    [4.184]
    [4.96]
    --? print('top now', State.screen_top1.line)
  • replacement in text.lua at line 403
    [4.1219][4.1183:1213](),[4.1213][4.67697:67900]()
    function Text.up(left, right)
    assert(Editor_state.lines[Editor_state.cursor1.line].mode == 'text')
    --? print('up', Editor_state.cursor1.line, Editor_state.cursor1.pos, Editor_state.screen_top1.line, Editor_state.screen_top1.pos)
    [4.1219]
    [4.3]
    function Text.up(State, left, right)
    assert(State.lines[State.cursor1.line].mode == 'text')
    --? print('up', State.cursor1.line, State.cursor1.pos, State.screen_top1.line, State.screen_top1.pos)
  • replacement in text.lua at line 410
    [4.443][4.67901:67955]()
    local new_cursor_line = Editor_state.cursor1.line
    [4.443]
    [4.484]
    local new_cursor_line = State.cursor1.line
  • replacement in text.lua at line 413
    [4.559][4.67956:68021]()
    if Editor_state.lines[new_cursor_line].mode == 'text' then
    [4.559]
    [4.611]
    if State.lines[new_cursor_line].mode == 'text' then
  • replacement in text.lua at line 415
    [4.657][4.68022:68181]()
    Editor_state.cursor1.line = new_cursor_line
    Text.populate_screen_line_starting_pos(Editor_state.lines[Editor_state.cursor1.line], left, right)
    [4.657]
    [4.826]
    State.cursor1.line = new_cursor_line
    Text.populate_screen_line_starting_pos(State.lines[State.cursor1.line], left, right)
  • replacement in text.lua at line 419
    [4.937][4.68182:68294]()
    local screen_line_starting_pos = Editor_state.lines[Editor_state.cursor1.line].screen_line_starting_pos
    [4.937]
    [4.1023]
    local screen_line_starting_pos = State.lines[State.cursor1.line].screen_line_starting_pos
  • replacement in text.lua at line 423
    [4.1264][4.68295:68617]()
    if Editor_state.screen_top1.line > Editor_state.cursor1.line then
    Editor_state.screen_top1.line = Editor_state.cursor1.line
    Editor_state.screen_top1.pos = screen_line_starting_pos
    --? print('pos of top of screen is also '..tostring(Editor_state.screen_top1.pos)..' of the same line')
    [4.1264]
    [4.1508]
    if State.screen_top1.line > State.cursor1.line then
    State.screen_top1.line = State.cursor1.line
    State.screen_top1.pos = screen_line_starting_pos
    --? print('pos of top of screen is also '..tostring(State.screen_top1.pos)..' of the same line')
  • replacement in text.lua at line 428
    [4.1520][4.68618:68994]()
    local screen_line_starting_byte_offset = Text.offset(Editor_state.lines[Editor_state.cursor1.line].data, screen_line_starting_pos)
    local s = string.sub(Editor_state.lines[Editor_state.cursor1.line].data, screen_line_starting_byte_offset)
    Editor_state.cursor1.pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, Editor_state.cursor_x, left) - 1
    [4.1520]
    [4.1691]
    local screen_line_starting_byte_offset = Text.offset(State.lines[State.cursor1.line].data, screen_line_starting_pos)
    local s = string.sub(State.lines[State.cursor1.line].data, screen_line_starting_byte_offset)
    State.cursor1.pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, State.cursor_x, left) - 1
  • replacement in text.lua at line 434
    [4.1714][4.68995:69129]()
    if Editor_state.cursor1.line < Editor_state.screen_top1.line then
    Editor_state.screen_top1.line = Editor_state.cursor1.line
    [4.1714]
    [4.1796]
    if State.cursor1.line < State.screen_top1.line then
    State.screen_top1.line = State.cursor1.line
  • replacement in text.lua at line 441
    [4.1956][4.69130:69257]()
    new_screen_line_starting_pos = Editor_state.lines[Editor_state.cursor1.line].screen_line_starting_pos[screen_line_index-1]
    [4.1956]
    [4.2057]
    new_screen_line_starting_pos = State.lines[State.cursor1.line].screen_line_starting_pos[screen_line_index-1]
  • replacement in text.lua at line 443
    [4.2203][4.69258:69553]()
    if Editor_state.screen_top1.line == Editor_state.cursor1.line and Editor_state.screen_top1.pos == screen_line_starting_pos then
    Editor_state.screen_top1.pos = new_screen_line_starting_pos
    --? print('also setting pos of top of screen to '..tostring(Editor_state.screen_top1.pos))
    [4.2203]
    [4.2433]
    if State.screen_top1.line == State.cursor1.line and State.screen_top1.pos == screen_line_starting_pos then
    State.screen_top1.pos = new_screen_line_starting_pos
    --? print('also setting pos of top of screen to '..tostring(State.screen_top1.pos))
  • replacement in text.lua at line 447
    [4.2441][4.69554:70006]()
    local new_screen_line_starting_byte_offset = Text.offset(Editor_state.lines[Editor_state.cursor1.line].data, new_screen_line_starting_pos)
    local s = string.sub(Editor_state.lines[Editor_state.cursor1.line].data, new_screen_line_starting_byte_offset)
    Editor_state.cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Editor_state.cursor_x, left) - 1
    --? print('cursor pos is now '..tostring(Editor_state.cursor1.pos))
    [4.2441]
    [4.2671]
    local new_screen_line_starting_byte_offset = Text.offset(State.lines[State.cursor1.line].data, new_screen_line_starting_pos)
    local s = string.sub(State.lines[State.cursor1.line].data, new_screen_line_starting_byte_offset)
    State.cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, State.cursor_x, left) - 1
    --? print('cursor pos is now '..tostring(State.cursor1.pos))
  • replacement in text.lua at line 454
    [4.2682][4.1214:1246](),[4.1246][4.70007:70279]()
    function Text.down(left, right)
    assert(Editor_state.lines[Editor_state.cursor1.line].mode == 'text')
    --? print('down', Editor_state.cursor1.line, Editor_state.cursor1.pos, Editor_state.screen_top1.line, Editor_state.screen_top1.pos, Editor_state.screen_bottom1.line, Editor_state.screen_bottom1.pos)
    [4.2682]
    [4.3]
    function Text.down(State, left, right)
    assert(State.lines[State.cursor1.line].mode == 'text')
    --? print('down', State.cursor1.line, State.cursor1.pos, State.screen_top1.line, State.screen_top1.pos, State.screen_bottom1.line, State.screen_bottom1.pos)
  • replacement in text.lua at line 460
    [4.3017][4.70280:70385]()
    local new_cursor_line = Editor_state.cursor1.line
    while new_cursor_line < #Editor_state.lines do
    [4.3017]
    [4.3096]
    local new_cursor_line = State.cursor1.line
    while new_cursor_line < #State.lines do
  • replacement in text.lua at line 463
    [4.3138][4.70386:70687]()
    if Editor_state.lines[new_cursor_line].mode == 'text' then
    Editor_state.cursor1.line = new_cursor_line
    Editor_state.cursor1.pos = Text.nearest_cursor_pos(Editor_state.lines[Editor_state.cursor1.line].data, Editor_state.cursor_x, left)
    --? print(Editor_state.cursor1.pos)
    [4.3138]
    [4.3342]
    if State.lines[new_cursor_line].mode == 'text' then
    State.cursor1.line = new_cursor_line
    State.cursor1.pos = Text.nearest_cursor_pos(State.lines[State.cursor1.line].data, State.cursor_x, left)
    --? print(State.cursor1.pos)
  • replacement in text.lua at line 470
    [4.1321][4.70688:70860]()
    if Editor_state.cursor1.line > Editor_state.screen_bottom1.line then
    --? print('screen top before:', Editor_state.screen_top1.line, Editor_state.screen_top1.pos)
    [4.1321]
    [4.3515]
    if State.cursor1.line > State.screen_bottom1.line then
    --? print('screen top before:', State.screen_top1.line, State.screen_top1.pos)
  • replacement in text.lua at line 474
    [4.321][4.70861:70959]()
    --? print('screen top after:', Editor_state.screen_top1.line, Editor_state.screen_top1.pos)
    [4.321]
    [4.3680]
    --? print('screen top after:', State.screen_top1.line, State.screen_top1.pos)
  • replacement in text.lua at line 479
    [4.103][4.70960:71032]()
    if Text.le1(Editor_state.screen_bottom1, Editor_state.cursor1) then
    [4.103]
    [4.104]
    if Text.le1(State.screen_bottom1, State.cursor1) then
  • replacement in text.lua at line 484
    [4.219][4.71033:71160]()
    new_screen_line_starting_pos = Editor_state.lines[Editor_state.cursor1.line].screen_line_starting_pos[screen_line_index+1]
    [4.219]
    [4.4192]
    new_screen_line_starting_pos = State.lines[State.cursor1.line].screen_line_starting_pos[screen_line_index+1]
  • replacement in text.lua at line 486
    [4.4338][4.71161:71629]()
    local new_screen_line_starting_byte_offset = Text.offset(Editor_state.lines[Editor_state.cursor1.line].data, new_screen_line_starting_pos)
    local s = string.sub(Editor_state.lines[Editor_state.cursor1.line].data, new_screen_line_starting_byte_offset)
    Editor_state.cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Editor_state.cursor_x, left) - 1
    --? print('cursor pos is now', Editor_state.cursor1.line, Editor_state.cursor1.pos)
    [4.4338]
    [4.130]
    local new_screen_line_starting_byte_offset = Text.offset(State.lines[State.cursor1.line].data, new_screen_line_starting_pos)
    local s = string.sub(State.lines[State.cursor1.line].data, new_screen_line_starting_byte_offset)
    State.cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, State.cursor_x, left) - 1
    --? print('cursor pos is now', State.cursor1.line, State.cursor1.pos)
  • replacement in text.lua at line 493
    [4.378][4.71630:71728]()
    --? print('screen top after:', Editor_state.screen_top1.line, Editor_state.screen_top1.pos)
    [4.378]
    [4.4796]
    --? print('screen top after:', State.screen_top1.line, State.screen_top1.pos)
  • replacement in text.lua at line 496
    [4.4810][4.71729:71928]()
    --? print('=>', Editor_state.cursor1.line, Editor_state.cursor1.pos, Editor_state.screen_top1.line, Editor_state.screen_top1.pos, Editor_state.screen_bottom1.line, Editor_state.screen_bottom1.pos)
    [4.4810]
    [4.6091]
    --? print('=>', State.cursor1.line, State.cursor1.pos, State.screen_top1.line, State.screen_top1.pos, State.screen_bottom1.line, State.screen_bottom1.pos)
  • replacement in text.lua at line 499
    [4.6096][4.6096:6126](),[4.6126][4.71929:72130]()
    function Text.start_of_line()
    Editor_state.cursor1.pos = 1
    if Text.lt1(Editor_state.cursor1, Editor_state.screen_top1) then
    Editor_state.screen_top1 = {line=Editor_state.cursor1.line, pos=Editor_state.cursor1.pos} -- copy
    [4.6096]
    [4.6249]
    function Text.start_of_line(State)
    State.cursor1.pos = 1
    if Text.lt1(State.cursor1, State.screen_top1) then
    State.screen_top1 = {line=State.cursor1.line, pos=State.cursor1.pos} -- copy
  • replacement in text.lua at line 506
    [4.6260][4.1247:1286](),[4.1286][4.72131:72225]()
    function Text.end_of_line(left, right)
    Editor_state.cursor1.pos = utf8.len(Editor_state.lines[Editor_state.cursor1.line].data) + 1
    [4.6260]
    [4.220]
    function Text.end_of_line(State, left, right)
    State.cursor1.pos = utf8.len(State.lines[State.cursor1.line].data) + 1
  • replacement in text.lua at line 509
    [4.292][4.72226:72290]()
    local botline1 = {line=Editor_state.cursor1.line, pos=botpos}
    [4.292]
    [4.3]
    local botline1 = {line=State.cursor1.line, pos=botpos}
  • replacement in text.lua at line 515
    [4.4936][4.1287:1324]()
    function Text.word_left(left, right)
    [4.4936]
    [4.840]
    function Text.word_left(State, left, right)
  • replacement in text.lua at line 518
    [4.4978][4.72291:72333]()
    if Editor_state.cursor1.pos == 1 then
    [4.4978]
    [4.896]
    if State.cursor1.pos == 1 then
  • replacement in text.lua at line 521
    [4.916][4.72334:72443]()
    if Text.match(Editor_state.lines[Editor_state.cursor1.line].data, Editor_state.cursor1.pos-1, '%S') then
    [4.916]
    [4.986]
    if Text.match(State.lines[State.cursor1.line].data, State.cursor1.pos-1, '%S') then
  • replacement in text.lua at line 529
    [4.1086][4.72444:72486]()
    if Editor_state.cursor1.pos == 1 then
    [4.1086]
    [4.1115]
    if State.cursor1.pos == 1 then
  • replacement in text.lua at line 532
    [4.1135][4.72487:72637]()
    assert(Editor_state.cursor1.pos > 1)
    if Text.match(Editor_state.lines[Editor_state.cursor1.line].data, Editor_state.cursor1.pos-1, '%s') then
    [4.1135]
    [4.5221]
    assert(State.cursor1.pos > 1)
    if Text.match(State.lines[State.cursor1.line].data, State.cursor1.pos-1, '%s') then
  • replacement in text.lua at line 539
    [4.5252][4.1353:1391]()
    function Text.word_right(left, right)
    [4.5252]
    [4.1136]
    function Text.word_right(State, left, right)
  • replacement in text.lua at line 542
    [4.1178][4.72638:72738]()
    if Editor_state.cursor1.pos > utf8.len(Editor_state.lines[Editor_state.cursor1.line].data) then
    [4.1178]
    [4.1239]
    if State.cursor1.pos > utf8.len(State.lines[State.cursor1.line].data) then
  • replacement in text.lua at line 545
    [4.1259][4.72739:72846]()
    if Text.match(Editor_state.lines[Editor_state.cursor1.line].data, Editor_state.cursor1.pos, '%S') then
    [4.1259]
    [4.1327]
    if Text.match(State.lines[State.cursor1.line].data, State.cursor1.pos, '%S') then
  • replacement in text.lua at line 552
    [4.35][4.72847:72947]()
    if Editor_state.cursor1.pos > utf8.len(Editor_state.lines[Editor_state.cursor1.line].data) then
    [4.35]
    [4.1447]
    if State.cursor1.pos > utf8.len(State.lines[State.cursor1.line].data) then
  • replacement in text.lua at line 555
    [4.1467][4.72948:73055]()
    if Text.match(Editor_state.lines[Editor_state.cursor1.line].data, Editor_state.cursor1.pos, '%s') then
    [4.1467]
    [4.5516]
    if Text.match(State.lines[State.cursor1.line].data, State.cursor1.pos, '%s') then
  • replacement in edit.lua at line 389
    [4.14136][4.14136:14165]()
    Text.insert_return()
    [4.14136]
    [4.14165]
    Text.insert_return(State)
  • replacement in edit.lua at line 391
    [4.14176][4.14176:14209]()
    Text.insert_at_cursor(c)
    [4.14176]
    [4.14209]
    Text.insert_at_cursor(State, c)