add lots of buttons to the toolbar

akkartik
Nov 21, 2023, 6:23 AM
RK2ASPN7A55RCEG2YRFZLFXNPSME2VKBE2ZXO257DYZPS5TPXC5QC

Dependencies

  • [2] 2Q437U4F starting to experiment with animated pane transitions
  • [3] UPQJIFDP hide file numbers in output editor
  • [4] FPSPT5TM show current pane number
  • [5] I52S4E5F running `print` now appends to output editor
  • [6] VUF2SX7B implement carousel buttons for inserting/switching current pane
  • [7] PRE6XPRN responsively increase/decrease font height
  • [8] 5RUFNRJO start of the visual skeleton
  • [9] WR2WMEPE implement 'Run' button
  • [10] 4QFVRJ5U get rid of pane transition animations
  • [11] OV6FE23R Merge text0
  • [12] MZ3DMYPD start sketching out a scrollbar
  • [13] R2ASHK5C fix a bad merge
  • [14] 4GX6NAY4 some very basic animations for switching panes
  • [15] Z5M23NTK implement second, 'output' editor
  • [16] 6RYGW5H3 bugfix: output border color
  • [17] ZM7NOBRM new fork: carousel shell
  • [18] VAVXKWZV aggregate global state inside a 'pane' object
  • [*] 2L5MEZV3 experiment: new edit namespace
  • [*] R5QXEHUI somebody stop me

Change contents

  • replacement in edit.lua at line 372
    [5.9720][5.9720:9927]()
    for _,code in utf8.codes(clipboard_data) do
    local c = utf8.char(code)
    if c == '\n' then
    Text.insert_return(State)
    else
    Text.insert_at_cursor(State, c)
    end
    end
    [5.9720]
    [5.9927]
    Text.insert_text(State, clipboard_data)
  • edit in edit.lua at line 382
    [5.610]
    [5.10356]
    end
    end
    function Text.insert_text(State, d)
    for _,code in utf8.codes(d) do
    local c = utf8.char(code)
    if c == '\n' then
    Text.insert_return(State)
    else
    Text.insert_at_cursor(State, c)
    end
  • file addition: 0076-delete_pane_button (----------)
    [21.2]
    delete_pane_button = function(x)
    local w = App.width('delete')+10
    button(Global_state, 'delete', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
    icon = function(p)
    App.color(Normal_color)
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
    love.graphics.print('delete', p.x+5,p.y+2)
    end,
    onpress1 = function()
    table.remove(Panes, Current_pane_index)
    if #Panes == 0 then
    table.insert(Panes, new_pane())
    end
    if Current_pane_index > #Panes then
    Current_pane_index = Current_pane_index-1
    end
    Current_pane = Panes[Current_pane_index]
    end,
    })
    return x+w+10
    end
  • file addition: 0075-clear_pane (----------)
    [21.2]
    clear_pane = function()
    Current_pane.editor_state.lines = {{data=''}}
    Current_pane.editor_state.screen_top1 = {line=1, pos=1}
    Current_pane.editor_state.cursor1 = {line=1, pos=1}
    Text.redraw_all(Current_pane.editor_state)
    end
  • file addition: 0074-clear_pane_button (----------)
    [21.2]
    clear_pane_button = function(x)
    local w = App.width('clear')+10
    button(Global_state, 'clear', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
    icon = function(p)
    App.color(Normal_color)
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
    love.graphics.print('clear', p.x+5,p.y+2)
    end,
    onpress1 = clear_pane,
    })
    return x+w+10
    end
  • file addition: 0072-settings_button (----------)
    [21.2]
    settings_button = function(x, w)
    button(Global_state, 'settings', {x=x, y=Menu_top+5, w=w+10, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
    icon = function(p)
    App.color(Normal_color)
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
    love.graphics.print('settings', p.x+5,p.y+2)
    end,
    onpress1 = function()
    print('settings')
    end,
    })
    return x+w+10
    end
  • file addition: 0071-duplicate_pane_button (----------)
    [21.2]
    duplicate_pane_button = function(x)
    local w = App.width('dup')+10
    button(Global_state, 'duplicate', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
    icon = function(p)
    App.color(Normal_color)
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
    love.graphics.print('dup', p.x+5,p.y+2)
    end,
    onpress1 = function()
    local new_pane = {
    editor_state = copy_editor(Current_pane.editor_state)
    }
    new_pane.output_editor_state = output_editor_state(new_pane.editor_state)
    Current_pane_index = Current_pane_index+1
    table.insert(Panes, Current_pane_index, new_pane)
    Current_pane = Panes[Current_pane_index]
    end,
    })
    return x+w+10
    end
  • file addition: 0070-code_editor_state (----------)
    [21.2]
    code_editor_state = function()
    local result = edit.initialize_state(
    Menu_bottom + 20, -- top
    Safe_height/2-Line_height, -- bottom
    Menu_left + 50 + Line_number_padding, -- left
    math.min(100+30*App.width('m'), Safe_width*2/3), -- right
    love.graphics.getFont():getHeight(), Line_height)
    Text.redraw_all(result)
    return result
    end
  • file addition: 0069-output_editor_state (----------)
    [21.2]
    output_editor_state = function(editor_state)
    local result = edit.initialize_state(
    editor_state.bottom+5+10+5, -- top
    nil, -- buttom
    editor_state.left, editor_state.right,
    love.graphics.getFont():getHeight(), Line_height)
    Text.redraw_all(result)
    return result
    end
  • file addition: 0068-copy_editor (----------)
    [21.2]
    copy_editor = function(state)
    local new_state = edit.initialize_state(
    Menu_bottom + 20, -- top
    Safe_height/2-Line_height, -- bottom
    Menu_left + 50 + Line_number_padding, -- left
    math.min(100+30*App.width('m'), Safe_width*2/3), -- right
    love.graphics.getFont():getHeight(), Line_height)
    new_state.lines = map(state.lines,
    function(line)
    return {data=line.data}
    end)
    Text.redraw_all(new_state)
    return new_state
    end
  • file addition: 0067-paste_button (----------)
    [21.2]
    paste_button = function(x)
    local w = App.width('paste')+10
    button(Global_state, 'paste', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
    icon = function(p)
    App.color(Normal_color)
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
    love.graphics.print('paste', p.x+5,p.y+2)
    end,
    onpress1 = function()
    local s = App.get_clipboard()
    Text.insert_text(Current_pane.editor_state, s)
    end,
    })
    return x+w+10
    end
  • file addition: 0066-copy_button (----------)
    [21.2]
    copy_button = function(x)
    local w = App.width('copy')+10
    button(Global_state, 'copy', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
    icon = function(p)
    App.color(Normal_color)
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
    love.graphics.print('copy', p.x+5,p.y+2)
    end,
    onpress1 = function()
    local s = Text.selection(Current_pane.editor_state)
    if s then App.set_clipboard(s) end
    end,
    })
    return x+w+10
    end
  • file addition: 0065-hide_code_button (----------)
    [21.2]
    hide_code_button = function(x)
    local w = App.width('hide')+10
    button(Global_state, 'hide', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
    icon = function(p)
    App.color(Normal_color)
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
    love.graphics.print('hide', p.x+5,p.y+2)
    end,
    onpress1 = function()
    Show_code = false
    end,
    })
    return x+w+10
    end
  • file addition: 0064-show_code_button (----------)
    [21.2]
    show_code_button = function(x)
    local w = App.width('show')+10
    button(Global_state, 'show', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
    icon = function(p)
    App.color(Normal_color)
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
    love.graphics.print('show', p.x+5,p.y+2)
    end,
    onpress1 = function()
    Show_code = true
    end,
    })
    return x+w+10
    end
  • file addition: 0063-Show_code (----------)
    [21.2]
    Show_code = true
  • file addition: 0061-new_pane_button (----------)
    [21.2]
    new_pane_button = function(x)
    local w = App.width('new')+10
    button(Global_state, 'new', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
    icon = function(p)
    App.color(Normal_color)
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
    love.graphics.print('new', p.x+5,p.y+2)
    end,
    onpress1 = function()
    Current_pane_index = Current_pane_index+1
    table.insert(Panes, Current_pane_index, new_pane())
    Current_pane = Panes[Current_pane_index]
    end,
    })
    return x+w+10
    end
  • file addition: 0060-next_pane_button (----------)
    [21.2]
    next_pane_button = function(r)
    button(Global_state, 'right', {x=r-30, y=Menu_bottom, w=100, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
    icon = function(p)
    App.color{r=0.4,g=0.4,b=0.4}
    love.graphics.polygon('fill', r-25, App.screen.height/2-10, r-25, App.screen.height/2+10, r-5, App.screen.height/2)
    end,
    onpress1 = function()
    Current_pane_index = Current_pane_index+1
    Current_pane = Panes[Current_pane_index]
    end,
    })
    end
  • file addition: 0059-previous_pane_button (----------)
    [21.2]
    previous_pane_button = function()
    button(Global_state, 'previous_pane', {x=0, y=Menu_bottom, w=Menu_left+30, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
    icon = function(p)
    App.color{r=0.4,g=0.4,b=0.4}
    love.graphics.polygon('fill', Menu_left+5, App.screen.height/2, Menu_left+25, App.screen.height/2-10, Menu_left+25, App.screen.height/2+10)
    end,
    onpress1 = function()
    Current_pane_index = Current_pane_index-1
    Current_pane = Panes[Current_pane_index]
    end,
    })
    end
  • replacement in 0051-run_button at line 38
    [5.1365][4.183:195]()
    return x+w
    [5.1365]
    [5.1365]
    return x+w+10
  • replacement in 0049-new_pane at line 3
    [5.43][5.43:634]()
    result.editor_state = edit.initialize_state(
    Menu_bottom + 20, -- top
    Safe_height/2-Line_height, -- bottom
    Menu_left + 50 + Line_number_padding, -- left
    math.min(100+30*App.width('m'), Safe_width*2/3), -- right
    love.graphics.getFont():getHeight(), Line_height)
    Text.redraw_all(result.editor_state)
    result.output_editor_state = edit.initialize_state(
    result.editor_state.bottom+5+10+5, -- top
    nil, -- buttom
    result.editor_state.left, result.editor_state.right,
    love.graphics.getFont():getHeight(), Line_height)
    Text.redraw_all(result.output_editor_state)
    [5.43]
    [5.634]
    result.editor_state = code_editor_state()
    result.output_editor_state = output_editor_state(result.editor_state)
  • replacement in 0021-draw_menu at line 6
    [4.269][4.269:378]()
    love.graphics.print(Current_pane_index, x, Menu_top+5)
    x = x + App.width(tostring(Current_pane_index)) + 5
    [4.269]
    [5.746]
    love.graphics.print(Current_pane_index, x+5, Menu_top+5+2)
    x = x+5 + App.width(tostring(Current_pane_index)) + 10
  • edit in 0021-draw_menu at line 10
    [4.398]
    [5.957]
    if Show_code then
    x = hide_code_button(x)
    else
    x = show_code_button(x)
    end
    x = copy_button(x)
    x = paste_button(x)
    x = new_pane_button(x)
    x = duplicate_pane_button(x)
    x = clear_pane_button(x)
    x = delete_pane_button(x)
  • replacement in 0021-draw_menu at line 23
    [5.1019][5.1863:1982](),[5.1982][5.1138:1159](),[5.1138][5.1138:1159](),[5.1159][5.166:193](),[5.193][5.1185:1343](),[5.1185][5.1185:1343](),[5.1343][5.1085:1096](),[5.1085][5.1085:1096]()
    button(Global_state, 'settings', {x=Safe_width-w-10-5, y=Menu_top+5, w=w+10, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
    icon = function(p)
    App.color(Normal_color)
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
    love.graphics.print('settings', p.x+5,p.y+2)
    end,
    onpress1 = function()
    print('settings')
    end,
    })
    [5.1019]
    [5.1344]
    settings_button(Safe_width-w-10-5, w)
  • replacement in 0021-draw_menu at line 26
    [5.891][5.891:1336](),[2.2066][5.1336:1349](),[5.1336][5.1336:1349]()
    button(Global_state, 'left', {x=0, y=Menu_bottom, w=Menu_left+30, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
    icon = function(p)
    App.color{r=0.4,g=0.4,b=0.4}
    love.graphics.polygon('fill', Menu_left+5, App.screen.height/2, Menu_left+25, App.screen.height/2-10, Menu_left+25, App.screen.height/2+10)
    end,
    onpress1 = function()
    Current_pane_index = Current_pane_index-1
    Current_pane = Panes[Current_pane_index]
    end,
    })
    [5.891]
    [5.1349]
    previous_pane_button()
  • replacement in 0021-draw_menu at line 28
    [5.1354][5.1700:1734](),[5.1700][5.1700:1734](),[5.1734][5.1355:1784](),[2.2123][5.1784:2220](),[5.1784][5.1784:2220](),[2.2180][5.2220:2233](),[5.2220][5.2220:2233]()
    local r = Menu_left + Safe_width
    if Current_pane_index == #Panes then
    button(Global_state, 'right', {x=r-30, y=Menu_bottom, w=100, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
    icon = function(p)
    App.color{r=0.4,g=0.4,b=0.4}
    love.graphics.print('+', r-25, App.screen.height/2-10)
    end,
    onpress1 = function()
    table.insert(Panes, new_pane())
    Current_pane_index = Current_pane_index+1
    Current_pane = Panes[Current_pane_index]
    end,
    })
    else
    button(Global_state, 'right', {x=r-30, y=Menu_bottom, w=100, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
    icon = function(p)
    App.color{r=0.4,g=0.4,b=0.4}
    love.graphics.polygon('fill', r-25, App.screen.height/2-10, r-25, App.screen.height/2+10, r-5, App.screen.height/2)
    end,
    onpress1 = function()
    Current_pane_index = Current_pane_index+1
    Current_pane = Panes[Current_pane_index]
    end,
    })
    [5.1354]
    [5.2233]
    if Current_pane_index < #Panes then
    next_pane_button(Menu_left + Safe_width)
  • replacement in 0012-on.draw at line 4
    [5.905][5.905:934](),[5.934][5.1793:1924](),[5.1793][5.1793:1924](),[5.1924][3.961:1066](),[3.1066][5.4152:4195](),[5.4152][5.4152:4195](),[5.3146][5.1925:1947](),[5.4195][5.1925:1947](),[5.3033][5.1925:1947](),[5.1947][5.4196:4329]()
    --if Canvas then return end
    draw_editor_border()
    -- love.graphics.rectangle('line', 100-5-Line_number_padding,100-5, 300+Line_number_padding+10, 200+10, 5,5)
    edit.draw(Current_pane.editor_state, --[[fg]] nil, --[[hide_cursor]] nil, --[[show_line_numbers]] true)
    draw_scrollbar(Current_pane.editor_state)
    draw_output_border()
    edit.draw(Current_pane.output_editor_state, Normal_color, --[[hide cursor]] true)
    draw_scrollbar(Current_pane.output_editor_state)
    [5.905]
    [5.1947]
    if Show_code then
    draw_editor_border()
    edit.draw(Current_pane.editor_state, --[[fg]] nil, --[[hide_cursor]] nil, --[[show_line_numbers]] true)
    draw_scrollbar(Current_pane.editor_state)
    draw_output_border()
    edit.draw(Current_pane.output_editor_state, Normal_color, --[[hide cursor]] true)
    draw_scrollbar(Current_pane.output_editor_state)
    end