deduce left/right from state where possible

[?]
Jul 13, 2022, 3:59 AM
MXA3RZYKUI4UF2ISY7JEF6VKX6NOPZMZH5SLLCZHRJKFIXXXDPSAC

Dependencies

  • [2] NDHQN23G done passing left/right margins everywhere
  • [3] MTJEVRJR add state arg to a few functions
  • [4] UHB4GARJ left/right margin -> left/right coordinates
  • [5] 2L5MEZV3 experiment: new edit namespace
  • [6] 5DOTWNVM right margin
  • [7] U7M4M2F7 bugfix: don't rely on Screen_bottom1 while scrolling
  • [8] CBPV5SSI stop handling nil screen_line_starting_pos everywhere
  • [9] KECEMMMR extract couple of functions
  • [10] HOSPP2AN crisp font rendering
  • [11] WLJCIXYM add state arg to a few functions
  • [12] PR4KIAZD first stab at equally hacky cursor down support
  • [13] DRFE3B3Z mouse buttons are integers, not strings
  • [14] CVSRHMJ2 experiment: slightly adaptive scrolling
  • [15] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [16] MYC7XR5Q bugfix: lines that aren't drawn from the start
  • [17] 2ZRC7FUL .
  • [18] AYE2VEGJ extract a couple of methods
  • [19] 2LC3BM2N support other whitespace chars in word movements
  • [20] ULKLJBN6 couple of renames
  • [21] HIKLULFQ extract a function
  • [22] MDXGMZU2 disable all debug prints
  • [23] ZZ2B5RPQ extract variables for drawing padding
  • [24] QCPXQ2E3 add state arg to a few functions
  • [25] 537TQ2QN some more logging
  • [26] U52E2XZN fix a crash
  • [27] CUIV2LE5 some typos
  • [28] A2NV3WVO scrolling with up arrow
  • [29] 2TQR4PSY add args to some functions
  • [30] GGJEDJOO add args to some functions
  • [31] GN3IF4WF bugfix: pasting newlines
  • [32] EMRPLZPW drop an arg from a function
  • [33] HYEAFRZ2 split mouse_pressed events between Text and Drawing
  • [34] AIRIP35Z cleaner
  • [35] V3EABA35 skip multiple consecutive whitespace
  • [36] FHSZYAZ2 more precise search highlighting
  • [37] JRGTJ2IW quite the frustrating bugfix
  • [38] F65ADDGL add state arg to a few functions
  • [39] 242L3OQX bugfix: ensure Cursor_line is always on a text line
  • [40] 3TFEAQSW start using some globals
  • [41] KOTI3MFG bugfix in previous commit
  • [42] KZ5GAYRP this fixes the immediate regression
  • [43] WOXIYUTL bugfix: manage screen_top and cursor when resizing
  • [44] LERERVPH keep one screen line of overlap on pagedown
  • [45] GK47BBCY start passing left/right margins everywhere
  • [46] TRNWIQN6 more precise height calculation when scrolling up as much as possible while keeping cursor on screen
  • [47] QCQTMUZ7 add args to some functions
  • [48] QLTJG7Q3 indent
  • [49] QYIFOHW3 first test!
  • [50] LXTTOB33 extract a couple of files
  • [51] CCYSVZA2 bugfix: BSOD in #4.
  • [52] 5L7K4GBD clicking to the right of a wrapped line
  • [53] BZRRUIFQ correct location of the line width slider
  • [54] OYXDYPGS get rid of debug variables
  • [55] HTWAM4NZ bugfix: scrolling in left/right movements
  • [56] LF7BWEG4 group all editor globals
  • [57] T57DTBX6 add args to some functions
  • [58] 4VKEE43Z bugfix
  • [59] LNUHQOGH start passing in Editor_state explicitly
  • [60] GCEF4N3V stop repeatedly checking for line wrapping
  • [61] OGUV4HSA remove some memory leaks from rendered fragments
  • [62] 4CXVIEBS add args to some functions
  • [63] OP643FFG move
  • [64] K4OBZSHE add args to some functions
  • [65] 4KC7I3E2 make colors easier to edit
  • [66] MP2TBKU6 bugfix: crash in Text.up() after return
  • [67] S2MISTTM add state arg to a few functions
  • [68] BTKAW76L rename
  • [69] CTJ3IZGS add args to some functions
  • [70] 2CH77LZC add args to some functions
  • [71] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [72] 5OALPNN3 add args to some functions
  • [73] 4J2L6JMR bugfix: deleting a selection spanning pages
  • [74] SVJZZDC3 snapshot - no, that's all wrong
  • [75] BOFNXP5G clicking now moves the cursor even on long, wrapped lines
  • [76] ESETRNLB bugfix: printing the first part of a line at the bottom made it seem non-wrapping
  • [77] IMEJA43L snapshot
  • [78] CVGE3SIG I feel confident now that page-down is working.
  • [79] WLHI7KD3 new globals: draw partial screen line up top
  • [80] 3OKKTUT4 up and down arrow now moving by screen line where possible
  • [81] ZPUQSPQP extract a few methods
  • [82] ZHLO7K3M add args to some functions
  • [83] 2LOQ5ALJ add args to some functions
  • [84] DHI6IJCN selecting text and deleting selections
  • [85] YJJ4X4JG bugfix: avoid scrolling on 'end'
  • [86] 2H67P75X switch arg for a function
  • [87] R22PA3XR fix a second BSOD in #4 :/
  • [88] BULPIBEG beginnings of a module for the text editor
  • [89] M6TH7VSZ rip out notion of Line_width
  • [90] UV4EWOLY add args to some functions
  • [91] 4CTZOJPC stop pretending globals are local
  • [92] X3F7ECSL add state arg to some functions
  • [93] Z5HLXU4P add state arg to a few functions
  • [94] KOYAJWE4 extract a couple more methods
  • [95] EGH7XDBK support non-text lines in Text.to2
  • [96] 5FW7YOFT highlight selection while dragging
  • [97] JY4VK7L2 rename
  • [98] LAW2O3NW extract variable Margin_left
  • [99] 62PZGSUC optimization: moving cursor to next word
  • [100] JJ7J4PUB some unnecessary mutations

Change contents

  • replacement in text.lua at line 12
    [5.103][5.3:65]()
    function Text.draw(State, line, line_index, top, left, right)
    [5.103]
    [5.1129]
    function Text.draw(State, line, line_index, top)
  • replacement in text.lua at line 16
    [5.1768][5.59:76]()
    local x = left
    [5.1768]
    [5.76]
    local x = State.left
  • replacement in text.lua at line 21
    [5.1850][2.3:49]()
    Text.compute_fragments(line, left, right)
    [5.1850]
    [5.103]
    Text.compute_fragments(line, State.left, State.right)
  • replacement in text.lua at line 23
    [5.109][5.3:63]()
    Text.populate_screen_line_starting_pos(line, left, right)
    [5.109]
    [5.1]
    Text.populate_screen_line_starting_pos(line, State.left, State.right)
  • replacement in text.lua at line 32
    [5.334][5.337:417](),[5.54396][5.337:417](),[5.337][5.337:417]()
    if x + frag_width > right then
    assert(x > left) -- no overfull lines
    [5.334]
    [5.1]
    if x + frag_width > State.right then
    assert(x > State.left) -- no overfull lines
  • replacement in text.lua at line 44
    [5.129][5.418:433]()
    x = left
    [5.129]
    [5.2198]
    x = State.left
  • replacement in text.lua at line 50
    [5.665][5.3:97]()
    local lo, hi = Text.clip_selection(State, line_index, pos, pos+frag_len, left, right)
    [5.665]
    [5.97]
    local lo, hi = Text.clip_selection(State, line_index, pos, pos+frag_len)
  • replacement in text.lua at line 354
    [5.51][5.2564:2605]()
    function Text.pageup(State, left, right)
    [5.51]
    [5.3]
    function Text.pageup(State)
  • replacement in text.lua at line 357
    [5.115][5.686:749]()
    local top2 = Text.to2(State, State.screen_top1, left, right)
    [5.115]
    [5.152]
    local top2 = Text.to2(State, State.screen_top1)
  • replacement in text.lua at line 368
    [5.563][5.750:813]()
    top2 = Text.previous_screen_line(State, top2, left, right)
    [5.563]
    [5.77]
    top2 = Text.previous_screen_line(State, top2)
  • replacement in text.lua at line 373
    [5.3220][5.859:956]()
    Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary(State, left, right)
    [5.3220]
    [5.3221]
    Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary(State)
  • replacement in text.lua at line 378
    [5.88][5.3320:3363]()
    function Text.pagedown(State, left, right)
    [5.88]
    [5.117]
    function Text.pagedown(State)
  • replacement in text.lua at line 383
    [5.2991][5.957:1023]()
    local top2 = Text.to2(State, State.screen_bottom1, left, right)
    [5.2991]
    [5.3031]
    local top2 = Text.to2(State, State.screen_bottom1)
  • replacement in text.lua at line 397
    [5.3782][5.1066:1163]()
    Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary(State, left, right)
    [5.3782]
    [5.3783]
    Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary(State)
  • replacement in text.lua at line 403
    [5.1219][5.3831:3868]()
    function Text.up(State, left, right)
    [5.1219]
    [5.3868]
    function Text.up(State)
  • replacement in text.lua at line 406
    [5.4029][5.3:116]()
    local screen_line_index,screen_line_starting_pos = Text.pos_at_start_of_cursor_screen_line(State, left, right)
    [5.4029]
    [5.295]
    local screen_line_index,screen_line_starting_pos = Text.pos_at_start_of_cursor_screen_line(State)
  • replacement in text.lua at line 416
    [5.4182][5.4182:4275]()
    Text.populate_screen_line_starting_pos(State.lines[State.cursor1.line], left, right)
    [5.4182]
    [5.826]
    Text.populate_screen_line_starting_pos(State.lines[State.cursor1.line], State.left, State.right)
  • replacement in text.lua at line 430
    [5.4882][5.4882:4990]()
    State.cursor1.pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, State.cursor_x, left) - 1
    [5.4882]
    [5.1691]
    State.cursor1.pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, State.cursor_x, State.left) - 1
  • replacement in text.lua at line 449
    [5.5703][5.5703:5811]()
    State.cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, State.cursor_x, left) - 1
    [5.5703]
    [5.5811]
    State.cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, State.cursor_x, State.left) - 1
  • replacement in text.lua at line 454
    [5.2682][5.5877:5916]()
    function Text.down(State, left, right)
    [5.2682]
    [5.5916]
    function Text.down(State)
  • replacement in text.lua at line 457
    [5.6132][5.1258:1321]()
    if Text.cursor_at_final_screen_line(State, left, right) then
    [5.6132]
    [5.2916]
    if Text.cursor_at_final_screen_line(State) then
  • replacement in text.lua at line 465
    [5.6328][5.6328:6440]()
    State.cursor1.pos = Text.nearest_cursor_pos(State.lines[State.cursor1.line].data, State.cursor_x, left)
    [5.6328]
    [5.6440]
    State.cursor1.pos = Text.nearest_cursor_pos(State.lines[State.cursor1.line].data, State.cursor_x, State.left)
  • replacement in text.lua at line 473
    [5.3562][5.1322:1385]()
    Text.snap_cursor_to_bottom_of_screen(State, left, right)
    [5.3562]
    [5.6623]
    Text.snap_cursor_to_bottom_of_screen(State)
  • replacement in text.lua at line 483
    [5.3993][5.117:233]()
    local screen_line_index, screen_line_starting_pos = Text.pos_at_start_of_cursor_screen_line(State, left, right)
    [5.3993]
    [5.6767]
    local screen_line_index, screen_line_starting_pos = Text.pos_at_start_of_cursor_screen_line(State)
  • replacement in text.lua at line 488
    [5.7111][5.7111:7219]()
    State.cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, State.cursor_x, left) - 1
    [5.7111]
    [5.7219]
    State.cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, State.cursor_x, State.left) - 1
  • replacement in text.lua at line 492
    [5.4678][5.1386:1449]()
    Text.snap_cursor_to_bottom_of_screen(State, left, right)
    [5.4678]
    [5.7294]
    Text.snap_cursor_to_bottom_of_screen(State)
  • replacement in text.lua at line 506
    [5.6260][5.7732:7778]()
    function Text.end_of_line(State, left, right)
    [5.6260]
    [5.7778]
    function Text.end_of_line(State)
  • replacement in text.lua at line 508
    [5.7851][5.234:313]()
    local _,botpos = Text.pos_at_start_of_cursor_screen_line(State, left, right)
    [5.7851]
    [5.7852]
    local _,botpos = Text.pos_at_start_of_cursor_screen_line(State)
  • replacement in text.lua at line 511
    [5.362][5.1450:1511]()
    Text.snap_cursor_to_bottom_of_screen(State, left, right)
    [5.362]
    [5.6543]
    Text.snap_cursor_to_bottom_of_screen(State)
  • replacement in text.lua at line 515
    [5.4936][5.7910:7954]()
    function Text.word_left(State, left, right)
    [5.4936]
    [5.840]
    function Text.word_left(State)
  • replacement in text.lua at line 524
    [5.1006][5.3:37]()
    Text.left(State, left, right)
    [5.1006]
    [5.1007]
    Text.left(State)
  • replacement in text.lua at line 528
    [5.1059][5.38:72]()
    Text.left(State, left, right)
    [5.1059]
    [5.8080]
    Text.left(State)
  • replacement in text.lua at line 539
    [5.5252][5.8239:8284]()
    function Text.word_right(State, left, right)
    [5.5252]
    [5.1136]
    function Text.word_right(State)
  • replacement in text.lua at line 560
    [5.411][5.1512:1573]()
    Text.snap_cursor_to_bottom_of_screen(State, left, right)
    [5.411]
    [5.36]
    Text.snap_cursor_to_bottom_of_screen(State)
  • replacement in text.lua at line 573
    [5.47][5.149:188]()
    function Text.left(State, left, right)
    [5.47]
    [5.188]
    function Text.left(State)
  • replacement in text.lua at line 589
    [5.606][5.1574:1702]()
    local top2 = Text.to2(State, State.screen_top1, left, right)
    top2 = Text.previous_screen_line(State, top2, left, right)
    [5.606]
    [5.1702]
    local top2 = Text.to2(State, State.screen_top1)
    top2 = Text.previous_screen_line(State, top2)
  • replacement in text.lua at line 595
    [5.579][5.705:745]()
    function Text.right(State, left, right)
    [5.579]
    [5.745]
    function Text.right(State)
  • replacement in text.lua at line 598
    [5.460][5.1749:1810]()
    Text.snap_cursor_to_bottom_of_screen(State, left, right)
    [5.460]
    [5.245]
    Text.snap_cursor_to_bottom_of_screen(State)
  • replacement in text.lua at line 619
    [5.1332][5.461:617]()
    function Text.pos_at_start_of_cursor_screen_line(State, left, right)
    Text.populate_screen_line_starting_pos(State.lines[State.cursor1.line], left, right)
    [5.1332]
    [5.617]
    function Text.pos_at_start_of_cursor_screen_line(State)
    Text.populate_screen_line_starting_pos(State.lines[State.cursor1.line], State.left, State.right)
  • replacement in text.lua at line 630
    [5.6][5.1811:1960]()
    function Text.cursor_at_final_screen_line(State, left, right)
    Text.populate_screen_line_starting_pos(State.lines[State.cursor1.line], left, right)
    [5.6]
    [5.1960]
    function Text.cursor_at_final_screen_line(State)
    Text.populate_screen_line_starting_pos(State.lines[State.cursor1.line], State.left, State.right)
  • replacement in text.lua at line 637
    [5.1938][5.2159:2263]()
    function Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary(State, left, right)
    [5.1938]
    [4.16712]
    function Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary(State)
  • replacement in text.lua at line 655
    [5.1581][5.2862:2923]()
    Text.snap_cursor_to_bottom_of_screen(State, left, right)
    [5.1581]
    [5.529]
    Text.snap_cursor_to_bottom_of_screen(State)
  • replacement in text.lua at line 660
    [5.2961][5.2961:3086]()
    function Text.snap_cursor_to_bottom_of_screen(State, left, right)
    local top2 = Text.to2(State, State.cursor1, left, right)
    [5.2961]
    [5.533]
    function Text.snap_cursor_to_bottom_of_screen(State)
    local top2 = Text.to2(State, State.cursor1)
  • replacement in text.lua at line 687
    [5.883][5.3597:3660]()
    top2 = Text.previous_screen_line(State, top2, left, right)
    [5.883]
    [5.925]
    top2 = Text.previous_screen_line(State, top2)
  • replacement in text.lua at line 695
    [5.936][5.3875:3927]()
    function Text.in_line(State, line, x,y, left,right)
    [5.936]
    [5.1014]
    function Text.in_line(State, line, x,y)
  • replacement in text.lua at line 697
    [5.1085][5.49:85]()
    if x < left then return false end
    [5.1085]
    [5.1086]
    if x < State.left then return false end
  • replacement in text.lua at line 699
    [5.1129][5.518:578]()
    Text.populate_screen_line_starting_pos(line, left, right)
    [5.1129]
    [5.3928]
    Text.populate_screen_line_starting_pos(line, State.left, State.right)
  • replacement in text.lua at line 704
    [5.1150][5.4057:4120]()
    function Text.to_pos_on_line(State, line, mx, my, left, right)
    [5.1150]
    [5.3]
    function Text.to_pos_on_line(State, line, mx, my)
  • replacement in text.lua at line 706
    [5.35][2.622:668]()
    Text.compute_fragments(line, left, right)
    [5.35]
    [5.80]
    Text.compute_fragments(line, State.left, State.right)
  • replacement in text.lua at line 726
    [5.1751][5.383:607]()
    --? print('return', mx, Text.nearest_cursor_pos(s, mx, left), '=>', screen_line_starting_pos + Text.nearest_cursor_pos(s, mx, left) - 1)
    return screen_line_starting_pos + Text.nearest_cursor_pos(s, mx, left) - 1
    [5.1751]
    [5.1279]
    --? print('return', mx, Text.nearest_cursor_pos(s, mx, State.left), '=>', screen_line_starting_pos + Text.nearest_cursor_pos(s, mx, State.left) - 1)
    return screen_line_starting_pos + Text.nearest_cursor_pos(s, mx, State.left) - 1
  • replacement in text.lua at line 836
    [5.3295][5.4162:4206]()
    function Text.to2(State, pos1, left, right)
    [5.3295]
    [5.4206]
    function Text.to2(State, pos1)
  • replacement in text.lua at line 841
    [5.7808][5.4258:4336]()
    Text.populate_screen_line_starting_pos(State.lines[pos1.line], left, right)
    [5.7808]
    [5.4336]
    Text.populate_screen_line_starting_pos(State.lines[pos1.line], State.left, State.right)
  • replacement in text.lua at line 896
    [5.564][5.4608:4669]()
    function Text.previous_screen_line(State, pos2, left, right)
    [5.564]
    [5.1432]
    function Text.previous_screen_line(State, pos2)
  • replacement in text.lua at line 905
    [5.4767][5.4767:4849]()
    Text.populate_screen_line_starting_pos(State.lines[pos2.line-1], left, right)
    [5.4767]
    [5.4849]
    Text.populate_screen_line_starting_pos(State.lines[pos2.line-1], State.left, State.right)
  • replacement in text.lua at line 936
    [5.4975][5.4975:5037]()
    function Text.tweak_screen_top_and_cursor(State, left, right)
    [5.4975]
    [5.5037]
    function Text.tweak_screen_top_and_cursor(State)
  • replacement in text.lua at line 940
    [5.5176][5.866:926](),[5.77696][5.866:926](),[5.221][5.866:926]()
    Text.populate_screen_line_starting_pos(line, left, right)
    [5.5176]
    [5.221]
    Text.populate_screen_line_starting_pos(line, State.left, State.right)
  • replacement in text.lua at line 967
    [5.5776][5.5776:5878]()
    pos=Text.to_pos_on_line(State, line, App.screen.width-5, App.screen.height-5, left, right),
    [5.5776]
    [5.139]
    pos=Text.to_pos_on_line(State, line, App.screen.width-5, App.screen.height-5),
  • replacement in text.lua at line 979
    [5.419][5.979:1062]()
    --? local _,botpos = Text.pos_at_start_of_cursor_screen_line(State, left, right)
    [5.419]
    [5.1062]
    --? local _,botpos = Text.pos_at_start_of_cursor_screen_line(State)
  • replacement in select.lua at line 9
    [5.44455][5.524:597]()
    function Text.clip_selection(State, line_index, apos, bpos, left, right)
    [5.44455]
    [5.597]
    function Text.clip_selection(State, line_index, apos, bpos)
  • replacement in select.lua at line 15
    [5.1213][5.773:824]()
    maxl,maxp = Text.mouse_pos(State, left, right)
    [5.1213]
    [5.44737]
    maxl,maxp = Text.mouse_pos(State)
  • replacement in select.lua at line 79
    [5.45876][5.1017:1061]()
    function Text.mouse_pos(State, left, right)
    [5.45876]
    [5.45902]
    function Text.mouse_pos(State)
  • replacement in select.lua at line 85
    [5.1228][5.1228:1309]()
    local line,pos = Text.to_pos(State, App.mouse_x(), App.mouse_y(), left, right)
    [5.1228]
    [5.46148]
    local line,pos = Text.to_pos(State, App.mouse_x(), App.mouse_y())
  • replacement in select.lua at line 93
    [5.46275][5.1437:1483]()
    function Text.to_pos(State, x,y, left, right)
    [5.46275]
    [5.1483]
    function Text.to_pos(State, x,y)
  • replacement in select.lua at line 96
    [5.46375][5.5954:6090]()
    if Text.in_line(State, line, x,y, left, right) then
    return line_index, Text.to_pos_on_line(State, line, x,y, left, right)
    [5.46375]
    [5.46471]
    if Text.in_line(State, line, x,y) then
    return line_index, Text.to_pos_on_line(State, line, x,y)
  • replacement in select.lua at line 103
    [5.10][5.1532:1580]()
    function Text.cut_selection(State, left, right)
    [5.10]
    [5.1580]
    function Text.cut_selection(State)
  • replacement in select.lua at line 106
    [5.1669][5.1669:1713]()
    Text.delete_selection(State, left, right)
    [5.1669]
    [5.100]
    Text.delete_selection(State)
  • replacement in select.lua at line 110
    [5.46500][5.1714:1765]()
    function Text.delete_selection(State, left, right)
    [5.46500]
    [5.1765]
    function Text.delete_selection(State)
  • replacement in select.lua at line 114
    [3.1939][5.1886:1943](),[5.46629][5.1886:1943]()
    Text.delete_selection_without_undo(State, left, right)
    [3.1939]
    [3.1940]
    Text.delete_selection_without_undo(State)
  • replacement in select.lua at line 118
    [5.46740][5.2017:2081]()
    function Text.delete_selection_without_undo(State, left, right)
    [5.46740]
    [5.2081]
    function Text.delete_selection_without_undo(State)
  • replacement in select.lua at line 136
    [5.2509][5.1180:1270]()
    _,State.screen_top1.pos = Text.pos_at_start_of_cursor_screen_line(State, left, right)
    [5.2509]
    [5.1160]
    _,State.screen_top1.pos = Text.pos_at_start_of_cursor_screen_line(State)
  • replacement in edit.lua at line 167
    [5.5677][4.22496:22605]()
    y, State.screen_bottom1.pos = Text.draw(State, line, line_index, line.starty, State.left, State.right)
    [5.5677]
    [5.3957]
    y, State.screen_bottom1.pos = Text.draw(State, line, line_index, line.starty)