send errors from event handlers to output editor

akkartik
Nov 22, 2023, 5:11 AM
HVXZLNCCLSMOKMA6TU7H7LKCRH5TAOP3X3EY6MEWFWZRWMVHEFWQC

Dependencies

  • [2] TOKSRJMD show how to load lines in editor
  • [3] GAKJROFZ ahh, got the background color sliders working
  • [4] 6DJMOJKE support event handlers
  • [5] I52S4E5F running `print` now appends to output editor
  • [6] JV27LDDK sliders for font size and color settings
  • [7] WR2WMEPE implement 'Run' button
  • [8] IP4LD33D mouse events for scrollbar
  • [9] PRE6XPRN responsively increase/decrease font height
  • [10] Z5M23NTK implement second, 'output' editor
  • [11] RK2ASPN7 add lots of buttons to the toolbar
  • [12] ZM7NOBRM new fork: carousel shell
  • [13] 4GX6NAY4 some very basic animations for switching panes
  • [14] VAVXKWZV aggregate global state inside a 'pane' object
  • [15] ZOLCTAGU get rid of an assertion
  • [*] N2NUGNN4 include a brief reference enabling many useful apps
  • [*] JNAQUQKB Merge lines.love
  • [*] 2L5MEZV3 experiment: new edit namespace
  • [*] R2ASHK5C fix a bad merge
  • [*] R5QXEHUI somebody stop me
  • [*] UEG224LH debug animations

Change contents

  • edit in reference.md at line 198
    [18.216]
    [2.7]
    * `edit.clear_state(state)` -- empties the editor of any text it may contain.
  • edit in edit.lua at line 397
    [20.10367]
    [20.10367]
    function edit.clear(State)
    State.lines = {{data=''}}
    Text.redraw_all(State)
    State.cursor1 = {line=1, pos=1}
    State.screen_top1 = {line=1, pos=1}
    end
  • file addition: 0105-clear_handlers (----------)
    [21.2]
    clear_handlers = function()
    for k in pairs(car) do
    car[k] = nil
    end
    end
  • file addition: 0104-call_protected (----------)
    [21.2]
    call_protected = function(f, ...)
    local args = {...}
    xpcall(
    function()
    f(unpack(args))
    end,
    send_errors_to_output)
    end
  • file addition: 0102-send_errors_to_output (----------)
    [21.2]
    send_errors_to_output = function(err)
    local callstack = debug.traceback('', 3)
    local error_with_callstack = cleaned_up_frame(tostring(err))..'\n'..cleaned_up_callstack(callstack)
    Text.insert_text(Current_pane.output_editor_state, error_with_callstack)
    Text.redraw_all(Current_pane.output_editor_state)
    clear_handlers()
    end
  • replacement in 0101-on.mouse_wheel_move at line 6
    [4.150][4.150:264]()
    if car.mouse_wheel_move then car.mouse_wheel_move(dx,dy) end
    if car.wheelmoved then car.wheelmoved(dx,dy) end
    [4.150]
    [4.264]
    if car.mouse_wheel_move then
    call_protected(car.mouse_wheel_move, dx,dy)
    end
    if car.wheelmoved then
    call_protected(car.wheelmoved, dx,dy)
    end
  • edit in 0051-run_button at line 11
    [5.354]
    [5.354]
    clear_handlers()
  • replacement in 0051-run_button at line 17
    [3.43][5.667:767](),[5.5673][5.667:767](),[5.667][5.667:767]()
    Current_pane.output_editor_state.lines = {}
    Text.redraw_all(Current_pane.output_editor_state)
    [3.43]
    [5.767]
    edit.clear(Current_pane.output_editor_state)
  • replacement in 0051-run_button at line 21
    [5.835][5.835:876]()
    local status, result = live.eval(buf)
    [5.835]
    [5.876]
    local status, result = live.eval(buf, 'editor')
  • replacement in 0017-on.mouse_release at line 19
    [4.1191][4.1191:1329]()
    if car.mouse_release then car.mouse_release(x,y, mouse_button) end
    if car.mousereleased then car.mousereleased(x,y, mouse_button) end
    [4.1191]
    [5.1416]
    if car.mouse_release then
    call_protected(car.mouse_release, x,y, mouse_button)
    end
    if car.mousereleased then
    call_protected(car.mousereleased, x,y, mouse_button)
    end
  • replacement in 0015-on.key_release at line 8
    [4.2308][4.2308:2430]()
    if car.key_release then car.key_release(key, scancode) end
    if car.keyreleased then car.keyreleased(key, scancode) end
    [4.2308]
    [5.105]
    if car.key_release then
    call_protected(car.key_release, key, scancode)
    end
    if car.keyreleased then
    call_protected(car.keyreleased, key, scancode)
    end
  • replacement in 0014-on.text_input at line 8
    [4.2576][4.2576:2668]()
    if car.text_input then car.text_input(t) end
    if car.textinput then car.textinput(t) end
    [4.2576]
    [5.203]
    if car.text_input then
    call_protected(car.text_input, t)
    end
    if car.textinput then
    call_protected(car.textinput, t)
    end
  • replacement in 0013-on.keychord_press at line 15
    [4.2878][4.2878:2991]()
    if car.keychord_press then car.keychord_press(chord, key) end
    if car.keypressed then car.keypressed(key) end
    [4.2878]
    [5.2298]
    if car.keychord_press then
    call_protected(car.keychord_press, chord, key)
    end
    if car.keypressed then
    call_protected(car.keypressed, key)
    end
  • replacement in 0012-on.draw at line 6
    [4.3021][4.3021:3069]()
    if car.draw then car.draw() end -- off canvas
    [4.3021]
    [5.8224]
    if car.draw then call_protected(car.draw) end -- off canvas
  • replacement in 0004-on.update at line 11
    [5.1677][4.3096:3135]()
    if car.update then car.update(dt) end
    [5.1677]
    [5.1677]
    if car.update then call_protected(car.update, dt) end