experiment: simple hyperlinks just to local files

[?]
Aug 23, 2022, 10:13 PM
VG34LDWYWKMKO76MEKWLUV4RGZCY26LZNSGRA5U2EMAYNGB6LGXQC

Dependencies

  • [2] HALS7E5U more clearly skip prints before screen top
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] WLHI7KD3 new globals: draw partial screen line up top
  • [*] OTIBCAUJ love2d scaffold
  • [*] AVTNUQYR basic test-enabled framework
  • [*] VHQCNMAR several more modules
  • [*] 2L5MEZV3 experiment: new edit namespace
  • [*] 4KC7I3E2 make colors easier to edit

Change contents

  • edit in text.lua at line 40
    [2.258]
    [5.119]
    end
    -- If fragment is a filename relative to the current directory, register
    -- a button for clicks on it.
    local filename = rtrim(frag) -- compute_fragments puts whitespace at the end
    if file_exists(filename) then
    local filename_text = App.newText(love.graphics.getFont(), filename)
    button(State, 'link', {x=x,y=y, w=App.width(filename_text), h=State.line_height, color={1,1,1},
    icon = icon.hyperlink_decoration,
    onpress1 = function()
    switch_to_file(filename)
    end,
    })
  • edit in main.lua at line 135
    [6.188]
    [7.1353]
    -- a copy of App.filedropped when given a filename
    function switch_to_file(filename)
    -- first make sure to save edits on any existing file
    if Editor_state.next_save then
    save_to_disk(Editor_state)
    end
    -- clear the slate for the new file
    --? print('switching to', filename)
    Editor_state.filename = filename
    load_from_disk(Editor_state)
    Text.redraw_all(Editor_state)
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.cursor1 = {line=1, pos=1}
    end
  • edit in icons.lua at line 9
    [8.5526]
    [8.5560]
    end
    function icon.hyperlink_decoration(button_params)
    local x,y = button_params.x, button_params.y
    App.color(Hyperlink_decoration_color)
    love.graphics.line(x,y+Editor_state.line_height, x+button_params.w,y+Editor_state.line_height)
  • edit in edit.lua at line 4
    [10.519]
    [10.519]
    Hyperlink_decoration_color = {r=0.4, g=0.4, b=1}