run script on startup; new button to switch to source editor

akkartik
Jan 1, 2024, 5:45 AM
3DRVHB7C3UGLINVPVTGQ2YNIWER4GVVZRY7KUAZRXVFDV4Z2SXRQC

Dependencies

  • [2] 7D7J5J4X append errors to output buffer
  • [3] RJPNFXVQ new fork: a personal dashboard for mobile devices
  • [4] LRG2TNA7 screens now run
  • [5] URM35DJS rip out the canvas
  • [6] 5MEJ7XNH lay out buttons based on device dimensions
  • [7] I52S4E5F running `print` now appends to output editor
  • [8] HVXZLNCC send errors from event handlers to output editor
  • [9] OGDDLU5B close all menus when tapping any button
  • [10] W4EQ6IW4 simplify state management for menus
  • [11] PN6VP3LV escape hatch when print is overridden
  • [12] GWLETNMW Mike's suggested button layout
  • [13] 5OCELN37 bugfix in output editor wrapping
  • [14] GVX7YSQY initial script after splitting up text-zoom
  • [15] W3RRTO4P extract a second helper for buttons
  • [16] GAKJROFZ ahh, got the background color sliders working
  • [*] R5QXEHUI somebody stop me
  • [*] ZM7NOBRM new fork: carousel shell
  • [*] SIASJPGR save the list of open files across restart

Change contents

  • replacement in screens/widgets at line 3
    [5.37][5.37:68]()
    -- button to invoke add_editor
    [5.37]
    [5.68]
    -- button to add a text box
  • replacement in screens/widgets at line 7
    [5.134][5.134:333]()
    rect('line', Safe_width-65, Menu_bottom+5, 30,30, 5)
    line(Safe_width-60, Menu_bottom+20, Safe_width-40, Menu_bottom+20)
    line(Safe_width-50, Menu_bottom+10, Safe_width-50, Menu_bottom+30)
    [5.134]
    [5.333]
    rect('line', Safe_width-115, 5, 30,30, 5)
    line(Safe_width-110, 20, Safe_width-90, 20)
    line(Safe_width-100, 10, Safe_width-100, 30)
  • replacement in screens/widgets at line 12
    [5.368][5.368:424]()
    return x2 >= Safe_width-65 and y2 <= Menu_bottom+35
    [5.368]
    [5.424]
    return x2 >= Safe_width-120 and x2 <= Safe_width-85 and y2 <= 40
  • edit in screens/widgets at line 16
    [5.456]
    -- button to stop the app and return to the source editor
    table.insert(widgets, {
    draw = function()
    color(0, 0.6,0.6)
    g.setFont(Font)
    local s = App.width('exit')
    rect('line', Safe_width-s-15, 75, s+10,30, 5)
    g.print('exit', Safe_width-s-10, 80)
    end,
    ispress = function(x2,y2)
    g.setFont(Font)
    local s = App.width('exit')
    return x2 >= Safe_width-s-15 and y2 >= 75 and y2 <= 105
    end,
    press = stop_app,
    })
  • edit in screens/main at line 9
    [5.6828]
    [5.6828]
    color(0, 0.6,0.6)
    line(Safe_width-120, 0, Safe_width-120, 40)
    g.setFont(Font)
    local s = App.width('exit')
    line(Safe_width-120, 40, Safe_width-s-20, 40)
    line(Safe_width-s-20, 40, Safe_width-s-20, 110)
    line(Safe_width-s-20, 110, Safe_width+100, 110)
  • file addition: 0161-stop_app (----------)
    [18.2]
    stop_app = function()
    clear_handlers()
    Show_code = true
    end
  • file addition: 0160-run_app (----------)
    [18.2]
    run_app = function()
    -- ## run: initialize
    clear_handlers()
    edit.clear(Current_pane.output_editor_state)
    print = print_to_output
    -- ## run
    local error = eval_all()
    -- ## run: save some stuff, clean up the rest
    if error == nil then
    Show_code = nil
    else
    print = Real_print
    clear_handlers()
    -- could be either output or error
    table.insert(Current_pane.output_editor_state.lines, {data=tostring(error)})
    end
    if #Current_pane.output_editor_state.lines == 0 then
    table.insert(Current_pane.output_editor_state.lines, {data=''})
    end
    Text.redraw_all(Current_pane.output_editor_state)
    end
  • replacement in 0102-send_errors_to_output at line 8
    [2.308][5.893:911](),[5.893][5.893:911](),[5.911][4.738:756]()
    clear_handlers()
    Show_code = true
    [2.308]
    [5.911]
    stop_app()
  • replacement in 0051-run_button at line 5
    [5.616][5.329:354](),[5.804][5.329:354](),[5.830][5.329:354](),[5.329][5.329:354](),[5.354][5.1072:1092](),[5.1092][5.354:463](),[5.354][5.354:463](),[5.43][5.1093:1141](),[5.795][5.795:835](),[5.835][4.765:793](),[4.793][5.876:925](),[5.1193][5.876:925](),[5.876][5.876:925](),[5.925][4.794:890](),[4.890][5.990:1029](),[5.990][5.990:1029](),[5.1029][4.891:972](),[4.972][5.1111:1302](),[5.1111][5.1111:1302]()
    -- ## run: initialize
    clear_handlers()
    local buf = table.concat(map(Current_pane.editor_state.lines, function(line) return line.data end), '\n')
    edit.clear(Current_pane.output_editor_state)
    print = print_to_output
    -- ## run
    local error = eval_all()
    -- ## run: save some stuff, clean up the rest
    if error == nil then
    Show_code = nil
    else
    print = Real_print
    clear_handlers()
    -- could be either output or error
    table.insert(Current_pane.output_editor_state.lines, {data=tostring(error)})
    end
    if #Current_pane.output_editor_state.lines == 0 then
    table.insert(Current_pane.output_editor_state.lines, {data=''})
    end
    Text.redraw_all(Current_pane.output_editor_state)
    [5.616]
    [5.805]
    run_app()
  • edit in 0011-on.initialize at line 22
    [20.1180]
    [3.173]
    run_app()