add state arg to a few functions

[?]
Jul 12, 2022, 11:55 PM
MTJEVRJR5GLWUSK7HMIM4UXM6GS6O6YCRWJT3DUSU2RYMHCQNOEQC

Dependencies

  • [2] DLQAEAC7 add state arg to Drawing.mouse_pressed
  • [3] 23MA4T3G add state arg to Drawing.keychord_pressed
  • [4] Z5HLXU4P add state arg to a few functions
  • [5] S2MISTTM add state arg to a few functions
  • [6] DRFE3B3Z mouse buttons are integers, not strings
  • [7] PTDO2SOT add state arg to schedule_save
  • [8] LXTTOB33 extract a couple of files
  • [9] SPSW74Y5 add state arg to Text.keychord_pressed
  • [10] PHFWIFYK scroll on enter
  • [11] SQLVYKVJ rename
  • [12] 3MAZEQK5 add state arg to Text.textinput
  • [13] IRCKL6VN extract scrolling logic out of insert_at_cursor
  • [14] DHI6IJCN selecting text and deleting selections
  • [15] CG3264MM move
  • [16] LNUHQOGH start passing in Editor_state explicitly
  • [17] XNFTJHC4 split keyboard handling between Text and Drawing
  • [18] 4CXVIEBS add args to some functions
  • [19] QXVD2RIF add state arg to Drawing.mouse_released
  • [20] 73OCE2MC after much struggle, a brute-force undo
  • [21] 2ZYV7D3W handle tab characters
  • [22] 7LVK4KRD fix a failing test
  • [23] NQKFQSZE undo creating new drawings
  • [24] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [25] 5UG5PQ6K undo commit 861c57b533
  • [26] AYE2VEGJ extract a couple of methods
  • [27] 3TDOZESE extract scrolling logic out of insert_return
  • [28] GN3IF4WF bugfix: pasting newlines
  • [29] LF7BWEG4 group all editor globals
  • [30] YW5324Q3 bugfix: cut (C-x) without first selecting anything
  • [31] 3GFQP6IR stop saving the entire file when modifying drawings
  • [32] PX7DDEMO autosave slightly less aggressively
  • [33] 2L5MEZV3 experiment: new edit namespace
  • [34] VJ77YABH more efficient undo/redo
  • [35] EMHRPJ3R no, that's not right
  • [*] BULPIBEG beginnings of a module for the text editor

Change contents

  • replacement in undo.lua at line 9
    [6.427][6.427:460](),[6.460][6.1:209]()
    function record_undo_event(data)
    Editor_state.history[Editor_state.next_history] = data
    Editor_state.next_history = Editor_state.next_history+1
    for i=Editor_state.next_history,#Editor_state.history do
    Editor_state.history[i] = nil
    [6.427]
    [6.577]
    function record_undo_event(State, data)
    State.history[State.next_history] = data
    State.next_history = State.next_history+1
    for i=State.next_history,#State.history do
    State.history[i] = nil
  • replacement in undo.lua at line 17
    [6.588][6.588:610](),[6.610][6.210:441]()
    function undo_event()
    if Editor_state.next_history > 1 then
    --? print('moving to history', Editor_state.next_history-1)
    Editor_state.next_history = Editor_state.next_history-1
    local result = Editor_state.history[Editor_state.next_history]
    [6.588]
    [6.763]
    function undo_event(State)
    if State.next_history > 1 then
    --? print('moving to history', State.next_history-1)
    State.next_history = State.next_history-1
    local result = State.history[State.next_history]
  • replacement in undo.lua at line 26
    [6.792][6.792:814](),[6.814][6.442:694]()
    function redo_event()
    if Editor_state.next_history <= #Editor_state.history then
    --? print('restoring history', Editor_state.next_history+1)
    local result = Editor_state.history[Editor_state.next_history]
    Editor_state.next_history = Editor_state.next_history+1
    [6.792]
    [6.975]
    function redo_event(State)
    if State.next_history <= #State.history then
    --? print('restoring history', State.next_history+1)
    local result = State.history[State.next_history]
    State.next_history = State.next_history+1
  • replacement in undo.lua at line 37
    [6.1116][6.37:60]()
    function snapshot(s,e)
    [6.1116]
    [6.60]
    function snapshot(State, s,e)
  • replacement in undo.lua at line 43
    [6.218][6.695:729]()
    assert(#Editor_state.lines > 0)
    [6.218]
    [6.22]
    assert(#State.lines > 0)
  • replacement in undo.lua at line 45
    [6.48][6.730:792]()
    if s > #Editor_state.lines then s = #Editor_state.lines end
    [6.48]
    [6.84]
    if s > #State.lines then s = #State.lines end
  • replacement in undo.lua at line 47
    [6.110][6.793:855]()
    if e > #Editor_state.lines then e = #Editor_state.lines end
    [6.110]
    [6.1147]
    if e > #State.lines then e = #State.lines end
  • replacement in undo.lua at line 50
    [6.1206][6.856:999]()
    screen_top=deepcopy(Editor_state.screen_top1),
    selection=deepcopy(Editor_state.selection1),
    cursor=deepcopy(Editor_state.cursor1),
    [6.1206]
    [6.1310]
    screen_top=deepcopy(State.screen_top1),
    selection=deepcopy(State.selection1),
    cursor=deepcopy(State.cursor1),
  • replacement in undo.lua at line 54
    [6.1349][6.1000:1062]()
    previous_drawing_mode=Editor_state.previous_drawing_mode,
    [6.1349]
    [6.1413]
    previous_drawing_mode=State.previous_drawing_mode,
  • replacement in undo.lua at line 62
    [6.269][6.1063:1102]()
    local line = Editor_state.lines[i]
    [6.269]
    [6.1592]
    local line = State.lines[i]
  • replacement in text.lua at line 140
    [6.76][6.38:84]()
    local before = snapshot(State.cursor1.line)
    [6.76]
    [6.84]
    local before = snapshot(State, State.cursor1.line)
  • replacement in text.lua at line 148
    [6.402][6.691:764]()
    record_undo_event({before=before, after=snapshot(State.cursor1.line)})
    [6.402]
    [6.60]
    record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
  • replacement in text.lua at line 164
    [6.165][6.1380:1421](),[6.57197][6.1380:1421](),[6.1380][6.1380:1421]()
    local before = snapshot(before_line)
    [6.165]
    [4.439]
    local before = snapshot(State, before_line)
  • replacement in text.lua at line 171
    [6.28][6.361:449](),[6.23][6.361:449]()
    record_undo_event({before=before, after=snapshot(before_line, State.cursor1.line)})
    [6.28]
    [6.134]
    record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)})
  • replacement in text.lua at line 173
    [6.163][6.450:498]()
    local before = snapshot(State.cursor1.line)
    [6.163]
    [6.498]
    local before = snapshot(State, State.cursor1.line)
  • replacement in text.lua at line 182
    [6.54][6.1115:1190](),[6.44][6.1115:1190]()
    record_undo_event({before=before, after=snapshot(State.cursor1.line)})
    [6.54]
    [6.2046]
    record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
  • replacement in text.lua at line 191
    [6.1344][6.1344:1388]()
    before = snapshot(State.cursor1.line)
    [6.1344]
    [6.1388]
    before = snapshot(State, State.cursor1.line)
  • replacement in text.lua at line 203
    [6.1957][6.1957:2023]()
    before = snapshot(State.cursor1.line-1, State.cursor1.line)
    [6.1957]
    [6.2023]
    before = snapshot(State, State.cursor1.line-1, State.cursor1.line)
  • replacement in text.lua at line 223
    [6.108][6.2866:2941](),[6.88][6.2866:2941]()
    record_undo_event({before=before, after=snapshot(State.cursor1.line)})
    [6.108]
    [6.3034]
    record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
  • replacement in text.lua at line 232
    [6.3141][6.3141:3185]()
    before = snapshot(State.cursor1.line)
    [6.3141]
    [6.1969]
    before = snapshot(State, State.cursor1.line)
  • replacement in text.lua at line 234
    [6.1978][6.3186:3252]()
    before = snapshot(State.cursor1.line, State.cursor1.line+1)
    [6.1978]
    [6.8546]
    before = snapshot(State, State.cursor1.line, State.cursor1.line+1)
  • replacement in text.lua at line 258
    [6.162][6.4266:4341](),[6.132][6.4266:4341]()
    record_undo_event({before=before, after=snapshot(State.cursor1.line)})
    [6.162]
    [6.209]
    record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
  • replacement in select.lua at line 113
    [5.1885][6.46591:46629](),[6.79810][6.46591:46629](),[6.46591][6.46591:46629]()
    local before = snapshot(minl, maxl)
    [5.1885]
    [5.1886]
    local before = snapshot(State, minl, maxl)
  • replacement in select.lua at line 115
    [5.1943][5.1943:2016]()
    record_undo_event({before=before, after=snapshot(State.cursor1.line)})
    [5.1943]
    [6.46735]
    record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
  • replacement in edit.lua at line 136
    [6.4595][6.4595:4668]()
    Drawing.before = snapshot(line_index-1, line_index)
    [6.4595]
    [6.3139]
    Drawing.before = snapshot(State, line_index-1, line_index)
  • replacement in edit.lua at line 142
    [6.248][6.4958:5066](),[6.4958][6.4958:5066]()
    record_undo_event({before=Drawing.before, after=snapshot(line_index-1, line_index+1)})
    [6.248]
    [6.5066]
    record_undo_event(State, {before=Drawing.before, after=snapshot(State, line_index-1, line_index+1)})
  • replacement in edit.lua at line 230
    [6.5243][6.8220:8266](),[6.101069][6.8220:8266](),[6.8220][6.8220:8266]()
    Drawing.before = snapshot(line_index)
    [6.5243]
    [2.15]
    Drawing.before = snapshot(State, line_index)
  • replacement in edit.lua at line 245
    [6.8668][6.5378:5478]()
    record_undo_event({before=Drawing.before, after=snapshot(State.lines.current_drawing_index)})
    [6.8668]
    [6.8762]
    record_undo_event(State, {before=Drawing.before, after=snapshot(State, State.lines.current_drawing_index)})
  • replacement in edit.lua at line 284
    [6.6547][6.6547:6610]()
    local before = snapshot(State.lines.current_drawing_index)
    [6.6547]
    [6.6610]
    local before = snapshot(State, State.lines.current_drawing_index)
  • replacement in edit.lua at line 288
    [6.10201][6.6659:6749]()
    record_undo_event({before=before, after=snapshot(State.lines.current_drawing_index)})
    [6.10201]
    [6.10285]
    record_undo_event(State, {before=before, after=snapshot(State, State.lines.current_drawing_index)})
  • replacement in edit.lua at line 343
    [6.7943][6.12344:12375](),[6.104092][6.12344:12375](),[6.12344][6.12344:12375]()
    local event = undo_event()
    [6.7943]
    [6.12375]
    local event = undo_event(State)
  • replacement in edit.lua at line 355
    [6.8225][6.12825:12856](),[6.104409][6.12825:12856](),[6.12825][6.12825:12856]()
    local event = redo_event()
    [6.8225]
    [6.12856]
    local event = redo_event(State)
  • replacement in edit.lua at line 384
    [6.8812][6.13941:13982](),[6.105066][6.13941:13982](),[6.13941][6.13941:13982]()
    local before = snapshot(before_line)
    [6.8812]
    [6.13982]
    local before = snapshot(State, before_line)
  • replacement in edit.lua at line 398
    [6.577][6.8914:9002](),[6.14388][6.8914:9002]()
    record_undo_event({before=before, after=snapshot(before_line, State.cursor1.line)})
    [6.577]
    [6.14470]
    record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)})
  • replacement in edit.lua at line 404
    [6.14679][6.14679:14724]()
    local before = snapshot(drawing_index)
    [6.14679]
    [3.15]
    local before = snapshot(State, drawing_index)
  • replacement in edit.lua at line 406
    [3.60][6.14762:14834](),[6.14762][6.14762:14834]()
    record_undo_event({before=before, after=snapshot(drawing_index)})
    [3.60]
    [6.578]
    record_undo_event(State, {before=before, after=snapshot(State, drawing_index)})
  • replacement in edit.lua at line 420
    [6.15212][6.9201:9266]()
    local before = snapshot(State.lines.current_drawing_index)
    [6.15212]
    [6.9266]
    local before = snapshot(State, State.lines.current_drawing_index)
  • replacement in edit.lua at line 425
    [6.15429][6.9317:9411]()
    record_undo_event({before=before, after=snapshot(State.lines.current_drawing_index)})
    [6.15429]
    [6.15517]
    record_undo_event(State, {before=before, after=snapshot(State, State.lines.current_drawing_index)})
  • replacement in edit.lua at line 431
    [6.15745][6.9412:9506]()
    record_undo_event({before=before, after=snapshot(State.lines.current_drawing_index)})
    [6.15745]
    [6.15833]
    record_undo_event(State, {before=before, after=snapshot(State, State.lines.current_drawing_index)})