type out a filename to load/save

akkartik
Nov 26, 2023, 4:53 PM
SJXIMERSV47SKYWCC5TA7TFGRWNN27S5FJE2PS5D46T5HOUN3V2AC

Dependencies

  • [2] 6DJMOJKE support event handlers
  • [3] FIUQJVL2 first draft of load/save buttons
  • [4] ZOLCTAGU get rid of an assertion
  • [5] VAVXKWZV aggregate global state inside a 'pane' object
  • [6] HVXZLNCC send errors from event handlers to output editor
  • [7] ZM7NOBRM new fork: carousel shell
  • [8] PRE6XPRN responsively increase/decrease font height
  • [*] R5QXEHUI somebody stop me

Change contents

  • file addition: 0141-File_dialog_input_draw_suffix (----------)
    [10.2]
    -- Cursor in the file dialog is always at end of input text.
    -- Cache where we start rendering the input from
    -- (for narrow devices)
    File_dialog_input_draw_suffix = ''
  • file addition: 0140-refresh_file_dialog_input_start (----------)
    [10.2]
    refresh_file_dialog_input_start = function()
    local len = utf8.len(File_dialog_input_text)
    for start=0,len do
    local s = File_dialog_input_text:sub(start)
    if App.width(s) < Safe_width-Menu_left-15-15 then
    File_dialog_input_draw_suffix = s
    return
    end
    end
    assert(false, "refresh_file_dialog_input_start isn't working right")
    end
  • file addition: 0139-refresh_file_dialog_start (----------)
    [10.2]
    refresh_file_dialog_start = function()
    end
  • file addition: 0138-File_dialog_input_start_suffix (----------)
    [10.2]
    -- Cursor in the file dialog is always at end of input text.
    -- Cache where we start rendering the input from
    -- (for narrow devices)
    File_dialog_input_start_suffix = ''
  • file addition: 0134-reset_file_dialog_state (----------)
    [10.2]
    reset_file_dialog_state = function()
    Show_file_dialog = false
    File_dialog_callback = nil
    File_dialog_input_text = ''
    end
  • file addition: 0133-File_dialog_input_text (----------)
    [10.2]
    File_dialog_input_text = ''
  • file addition: 0132-text_input_on_file_dialog (----------)
    [10.2]
    text_input_on_file_dialog = function(t)
    -- the file dialog input only supports appending
    File_dialog_input_text = File_dialog_input_text..t
    refresh_file_dialog_input_start()
    end
  • file addition: 0131-keychord_press_on_file_dialog (----------)
    [10.2]
    keychord_press_on_file_dialog = function(chord, key)
    if chord == 'escape' then
    reset_file_dialog_state()
    elseif chord == 'return' then
    File_dialog_callback(File_dialog_input_text)
    reset_file_dialog_state()
    elseif chord == 'backspace' then
    local len = utf8.len(File_dialog_input_text)
    local byte_offset = Text.offset(File_dialog_input_text, len)
    File_dialog_input_text = string.sub(File_dialog_input_text, 1, byte_offset-1)
    refresh_file_dialog_input_start()
    end
    end
  • file addition: 0129-draw_cursor (----------)
    [10.2]
    draw_cursor = function(x, y, line_height)
    -- blink every 0.5s
    if math.floor(Cursor_time*2)%2 == 0 then
    App.color(Cursor_color)
    love.graphics.rectangle('fill', x,y, 3,line_height)
    end
    end
  • file addition: 0128-draw_file_dialog_input (----------)
    [10.2]
    draw_file_dialog_input = function()
    -- draw a suffix to ensure the cursor is visible
    App.color(Normal_color)
    love.graphics.print(File_dialog_input_draw_suffix, Menu_left+15, Menu_top+5)
    local w = App.width(File_dialog_input_draw_suffix)
    draw_cursor(Menu_left+15+w, Menu_top+5, Current_pane.editor_state.line_height)
    end
  • edit in 0119-draw_file_dialog at line 2
    [3.1637]
    [3.1637]
    draw_file_dialog_input()
  • replacement in 0119-draw_file_dialog at line 19
    [3.2174][3.2174:2234]()
    Show_file_dialog = false
    File_dialog_callback = nil
    [3.2174]
    [3.2234]
    reset_file_dialog_state()
  • edit in 0117-load_button at line 7
    [3.2642]
    [3.2642]
    if filename == '' then
    -- clear filename
    Current_pane.filename = nil
    return
    end
  • replacement in 0014-on.text_input at line 2
    [4.2676][2.2431:2450]()
    if Show_code then
    [4.2676]
    [2.2450]
    if Show_file_dialog then
    text_input_on_file_dialog(t)
    elseif Show_code then
  • replacement in 0013-on.keychord_press at line 3
    [3.4042][3.4042:4069]()
    Show_file_dialog = false
    [3.4042]
    [3.4069]
    keychord_press_on_file_dialog(chord, key)