Merge lines.love

[?]
Sep 19, 2022, 7:55 AM
ATQO62TFDZ7J4RCOSB3K2QCCB5R6PNYQIIGNXTLZMEFG5UG5PUJQC

Dependencies

  • [2] VBU5YHLR Merge lines.love
  • [3] MKPXANB5 bugfix: mouse clicks on file navigator above log browser side
  • [4] L2FWWEQL source: remember cursor position of multiple files
  • [5] W6XUYQKP source: show files in MRU order
  • [6] YMNOUE2M ugh, missed deleting an arg
  • [7] A23MMLJH migrate old settings, attempt #3
  • [8] LXTTOB33 extract a couple of files
  • [9] 5ZA3BRNY add state arg to a few functions
  • [10] JOPVPUSA editing source code from within the app
  • [11] D2GCFTTT clean up repl functionality
  • [12] VHQCNMAR several more modules
  • [13] OTIBCAUJ love2d scaffold
  • [14] KMSL74GA support selections in the source editor
  • [15] ZJOSQFN6 bugfix: path munging on Windows
  • [16] CE4LZV4T drop last couple of manual tests
  • [17] ZTK4QTZT extract a couple of functions
  • [18] C3NYQP57 Merge lines.love
  • [19] 2CTN2IEF Merge lines.love
  • [20] BLWAYPKV extract a module
  • [21] D4B52CQ2 Merge lines.love
  • [22] QSKWIEU3 support special chars like '(' in search
  • [23] 6LJZN727 handle chords
  • [24] S3PNFXTB handle missing cursors in settings
  • [25] AKZWDWIA Merge lines.love
  • [26] QZ2SXLHF some debug prints
  • [27] GUOQRUL7 Merge lines.love
  • [28] 73OCE2MC after much struggle, a brute-force undo
  • [29] MDGHRTIF source: up/down in file navigator
  • [30] 32V6ZHQB Merge lines.love
  • [31] KKMFQDR4 editing source code from within the app
  • [32] XX7G2FFJ intermingle freehand line drawings with text
  • [33] TVCPXAAU rename
  • [34] MUJTM6RE bring back a level of wrapping
  • [35] LLAOOMUL bugfix: search upwards
  • [36] 7PZ4CQFV search: transparently handle drawings everywhere
  • [37] 3QWK3GSA support mouse clicks in file navigator
  • [38] B4JEWKWI hide editor cursor while in file navigator
  • [39] VXORMHME delete experimental REPL
  • [40] AOZX2G5F source: no commandline args
  • [41] P3K7UH5C Merge lines.love
  • [42] BULPIBEG beginnings of a module for the text editor
  • [43] RQUVBX62 filter candidates in file navigator
  • [44] C7OO4H3S source: support only relative paths within the app
  • [45] OI4FPFIN support drawings in the source editor
  • [46] 4YDBYBA4 clean up memory leak experiments
  • [47] T4FRZSYL delete an ancient, unused file
  • [48] R5QXEHUI somebody stop me
  • [49] BYKXF3YY bugfix: draw menu after everything else
  • [50] EETIR4GX bugfix: skip over drawings when searching
  • [51] SDO4DHNU source: load cursor position from settings
  • [52] 3QNOKBFM beginnings of a test harness
  • [53] RSZD5A7G forgot to add json.lua
  • [54] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing
  • [55] 66X36NZN a little more prose describing manual_tests
  • [56] VHUNJHXB Merge lines.love
  • [57] NFI42KGX more correct absolute path detection
  • [58] JMUD7T3O get rid of ugly side-effects in tests
  • [59] NYRESFK6 source: show all files in navigator
  • [60] X3CQLBTR set window title within each app
  • [61] OGUV4HSA remove some memory leaks from rendered fragments
  • [62] 3PSFWAIL Merge lines.love
  • [63] AVTNUQYR basic test-enabled framework
  • [64] FS2ITYYH record a known issue
  • [65] K2X6G75Z start writing some tests for drawings
  • [66] MSOQI3A5 bugfix: check before cursor on same line
  • [67] MD3W5IRA new fork: rip out drawing support
  • [68] AYX33NBC Merge lines.love
  • [69] D3FLL7SL start showing source menu file navigation state graphically
  • [70] 2L5MEZV3 experiment: new edit namespace
  • [71] TLOAPLBJ add a license
  • [72] AMOPICKV bugfix: check after cursor on same line when searching upwards

Change contents

  • file deletion: source_file.lua (----------)source_file.lua (----------)
    [8.2][8.152399:152438](),[8.2][8.152399:152438](),[8.152438][8.150241:150241]()
    function empty(h)
    for _,_ in pairs(h) do
    return false
    end
    return true
    end
    end
    function dirname(path)
    local os_path_separator = package.config:sub(1,1)
    if os_path_separator == '/' then
    -- POSIX systems permit backslashes in filenames
    return path:match('.*/') or './'
    elseif os_path_separator == '\\' then
    return path:match('.*[/\\]') or './'
    else
    error('What OS is this? LÖVE reports that the path separator is "'..os_path_separator..'"')
    end
    end
    function test_dirname()
    check_eq(dirname('a/b'), 'a/', 'F - test_dirname')
    check_eq(dirname('x'), './', 'F - test_dirname/current')
    end
    function basename(path)
    local os_path_separator = package.config:sub(1,1)
    if os_path_separator == '/' then
    -- POSIX systems permit backslashes in filenames
    return string.gsub(path, ".*/(.*)", "%1")
    elseif os_path_separator == '\\' then
    return string.gsub(path, ".*[/\\](.*)", "%1")
    else
    error('What OS is this? LÖVE reports that the path separator is "'..os_path_separator..'"')
    end
    end
  • file deletion: source.lua (----------)source.lua (----------)
    [8.2][8.177652:177686](),[8.2][8.177652:177686](),[8.177686][8.165766:165766]()
    File_navigation.cursors[Editor_state.filename] = {cursor1=Editor_state.cursor1, screen_top1=Editor_state.screen_top1}
    return {
    x=Settings.source.x, y=Settings.source.y, displayindex=Settings.source.displayindex,
    width=App.screen.width, height=App.screen.height,
    font_height=Editor_state.font_height,
    if File_navigation.cursors[filename] then
    Editor_state.screen_top1 = File_navigation.cursors[filename].screen_top1
    Editor_state.cursor1 = File_navigation.cursors[filename].cursor1
    else
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.cursor1 = {line=1, pos=1}
    end
    end
    function source.draw()
    Editor_state.filename = 'run.lua'
    Editor_state.font_height = font_height
    Editor_state.line_height = math.floor(font_height*1.3)
    Editor_state.em = em
    end
    function source.initialize_window_geometry(em_width)
    -- maximize window
    -- save cursor position
    File_navigation.cursors[Editor_state.filename] = {cursor1=Editor_state.cursor1, screen_top1=Editor_state.screen_top1}
    -- clear the slate for the new file
    Editor_state.filename = filename
    load_from_disk(Editor_state)
    Text.redraw_all(Editor_state)
    filename=Editor_state.filename,
    cursors=File_navigation.cursors,
    show_log_browser_side=Show_log_browser_side,
    focus=Focus,
    }
    end
    function source.mouse_pressed(x,y, mouse_button)
    Cursor_time = 0 -- ensure cursor is visible immediately after it moves
    --? print('mouse click', x, y)
    --? print(Editor_state.left, Editor_state.right)
    --? print(Log_browser_state.left, Log_browser_state.right)
    function source.initialize_edit_side()
    load_from_disk(Editor_state)
    Text.redraw_all(Editor_state)
    if settings.cursors then
    File_navigation.cursors = settings.cursors
    Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
    Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1
    else
    -- migrate old settings
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.cursor1 = {line=1, pos=1}
    end
    end
    function source.set_window_position_from_settings(settings)
    -- setPosition doesn't quite seem to do what is asked of it on Linux.
    love.window.setPosition(settings.x, settings.y-37, settings.displayindex)
    end
    function source.initialize_default_settings()
    local font_height = 20
    love.graphics.setFont(love.graphics.newFont(font_height))
    local em = App.newText(love.graphics.getFont(), 'm')
    source.initialize_window_geometry(App.width(em))
    Editor_state = edit.initialize_state(Margin_top, Margin_left, App.screen.width-Margin_right)
    if File_navigation.cursors[Editor_state.filename] then
    Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
    Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1
    else
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.cursor1 = {line=1, pos=1}
    end
    Editor_state.filename = basename(Editor_state.filename) -- migrate settings that used full paths; we now support only relative paths within the app
    if Show_file_navigator and y < Menu_status_bar_height + File_navigation.num_lines * Editor_state.line_height then
    -- send click to buttons
    edit.mouse_pressed(Editor_state, x,y, mouse_button)
    return
    end
    if x < Editor_state.right + Margin_right then
    source.initialize_edit_side()
    source.initialize_log_browser_side()
    Menu_status_bar_height = 5 + Editor_state.line_height + 5
    Editor_state.top = Editor_state.top + Menu_status_bar_height
    Log_browser_state.top = Log_browser_state.top + Menu_status_bar_height
  • file deletion: commands.lua (----------)commands.lua (----------)
    [8.2][8.207726:207762](),[8.2][8.207726:207762](),[8.207762][8.204370:204370]()
    navigate_to_file(File_navigation.candidates[File_navigation.index])
    elseif chord == 'backspace' then
    local len = utf8.len(File_navigation.filter)
    local byte_offset = Text.offset(File_navigation.filter, len)
    File_navigation.filter = string.sub(File_navigation.filter, 1, byte_offset-1)
    File_navigation.index = 1
    File_navigation.candidates = source.file_navigator_candidates()
    reset_file_navigator()
    elseif chord == 'return' then
    function navigate_to_file(s)
    local candidate = guess_source(s..'.lua')
    source.switch_to_file(candidate)
    reset_file_navigator()
    end
    function reset_file_navigator()
    Show_file_navigator = false
    File_navigation.index = 1
    File_navigation.filter = ''
    File_navigation.candidates = File_navigation.all_candidates
    end
    function keychord_pressed_on_file_navigator(chord, key)
    end
    function move_candidate_to_front(s)
    local index = array.find(File_navigation.all_candidates, s)
    assert(index)
    table.remove(File_navigation.all_candidates, index)
    table.insert(File_navigation.all_candidates, 1, s)
    move_candidate_to_front(s)
    navigate_to_file(s)
    end
    })
  • edit in source_file.lua at line 218
    [8.499]
    [8.499]
    end
    function dirname(path)
    local os_path_separator = package.config:sub(1,1)
    if os_path_separator == '/' then
    -- POSIX systems permit backslashes in filenames
    return path:match('.*/') or './'
    elseif os_path_separator == '\\' then
    return path:match('.*[/\\]') or './'
    else
    error('What OS is this? LÖVE reports that the path separator is "'..os_path_separator..'"')
    end
    end
    function test_dirname()
    check_eq(dirname('a/b'), 'a/', 'F - test_dirname')
    check_eq(dirname('x'), './', 'F - test_dirname/current')
    end
    function basename(path)
    local os_path_separator = package.config:sub(1,1)
    if os_path_separator == '/' then
    -- POSIX systems permit backslashes in filenames
    return string.gsub(path, ".*/(.*)", "%1")
    elseif os_path_separator == '\\' then
    return string.gsub(path, ".*[/\\](.*)", "%1")
    else
    error('What OS is this? LÖVE reports that the path separator is "'..os_path_separator..'"')
    end
  • edit in source_file.lua at line 248
    [8.503]
    function empty(h)
    for _,_ in pairs(h) do
    return false
    end
    return true
    end
  • edit in source.lua at line 48
    [2.428]
    [8.166577]
    cursors = {}, -- filename to cursor1, screen_top1
  • replacement in source.lua at line 75
    [8.167102][8.167102:167143]()
    source.initialize_edit_side{'run.lua'}
    [8.167102]
    [8.167143]
    source.initialize_edit_side()
  • replacement in source.lua at line 86
    [8.167543][8.167543:167706]()
    function source.initialize_edit_side(arg)
    if #arg > 0 then
    Editor_state.filename = arg[1]
    load_from_disk(Editor_state)
    Text.redraw_all(Editor_state)
    [8.167543]
    [8.167706]
    function source.initialize_edit_side()
    load_from_disk(Editor_state)
    Text.redraw_all(Editor_state)
    if File_navigation.cursors[Editor_state.filename] then
    Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
    Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1
    else
  • edit in source.lua at line 95
    [8.167796][8.167796:167950]()
    else
    load_from_disk(Editor_state)
    Text.redraw_all(Editor_state)
    end
    if #arg > 1 then
    print('ignoring commandline args after '..arg[1])
  • replacement in source.lua at line 137
    [8.169706][8.169706:169796]()
    Editor_state.screen_top1 = settings.screen_top
    Editor_state.cursor1 = settings.cursor
    [8.169706]
    [8.169796]
    Editor_state.filename = basename(Editor_state.filename) -- migrate settings that used full paths; we now support only relative paths within the app
    if settings.cursors then
    File_navigation.cursors = settings.cursors
    Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
    Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1
    else
    -- migrate old settings
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.cursor1 = {line=1, pos=1}
    end
  • edit in source.lua at line 160
    [8.170346]
    [8.170346]
    Editor_state.filename = 'run.lua'
  • edit in source.lua at line 222
    [8.172660]
    [8.172660]
    -- save cursor position
    File_navigation.cursors[Editor_state.filename] = {cursor1=Editor_state.cursor1, screen_top1=Editor_state.screen_top1}
  • replacement in source.lua at line 228
    [8.172796][8.172796:172882]()
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.cursor1 = {line=1, pos=1}
    [8.172796]
    [8.172882]
    if File_navigation.cursors[filename] then
    Editor_state.screen_top1 = File_navigation.cursors[filename].screen_top1
    Editor_state.cursor1 = File_navigation.cursors[filename].cursor1
    else
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.cursor1 = {line=1, pos=1}
    end
  • edit in source.lua at line 274
    [8.4880][8.173971:174018](),[8.173971][8.173971:174018](),[8.174018][8.506:647]()
    end
    local filename = Editor_state.filename
    if is_relative_path(filename) then
    filename = love.filesystem.getWorkingDirectory()..'/'..filename -- '/' should work even on Windows
  • edit in source.lua at line 276
    [8.174269]
    [8.174269]
    File_navigation.cursors[Editor_state.filename] = {cursor1=Editor_state.cursor1, screen_top1=Editor_state.screen_top1}
  • replacement in source.lua at line 281
    [8.174465][8.174465:174558]()
    filename=filename,
    screen_top=Editor_state.screen_top1, cursor=Editor_state.cursor1,
    [8.174465]
    [8.174558]
    filename=Editor_state.filename,
    cursors=File_navigation.cursors,
  • edit in source.lua at line 293
    [8.174901]
    [8.23378]
    if Show_file_navigator and y < Menu_status_bar_height + File_navigation.num_lines * Editor_state.line_height then
    -- send click to buttons
    edit.mouse_pressed(Editor_state, x,y, mouse_button)
    return
    end
  • edit in search.lua at line 24
    [8.758][8.7067:7162]()
    local pos = find(State.lines[State.cursor1.line].data, State.search_term, State.cursor1.pos)
  • edit in search.lua at line 31
    [8.211][8.7163:7220]()
    pos = find(State.lines[i].data, State.search_term)
  • edit in search.lua at line 41
    [8.368][8.7221:7278]()
    pos = find(State.lines[i].data, State.search_term)
  • edit in search.lua at line 50
    [8.833][8.7279:7351]()
    pos = find(State.lines[State.cursor1.line].data, State.search_term)
  • edit in search.lua at line 70
    [8.800][8.7352:7450]()
    local pos = rfind(State.lines[State.cursor1.line].data, State.search_term, State.cursor1.pos-1)
  • edit in search.lua at line 77
    [8.1238][8.7451:7509]()
    pos = rfind(State.lines[i].data, State.search_term)
  • edit in search.lua at line 87
    [8.1411][8.7510:7568]()
    pos = rfind(State.lines[i].data, State.search_term)
  • edit in search.lua at line 96
    [8.910][8.7569:7642]()
    pos = rfind(State.lines[State.cursor1.line].data, State.search_term)
  • edit in commands.lua at line 67
    [2.1772][2.1772:1805](),[2.1805][8.205816:205943](),[8.205816][8.205816:205943]()
    if filename == 'source' then
    App.color(Menu_border_color)
    love.graphics.line(Menu_cursor-10,2, Menu_cursor-10,Menu_status_bar_height-2)
    end
  • replacement in commands.lua at line 123
    [2.3240][2.3240:3361]()
    local candidate = guess_source(s..'.lua')
    source.switch_to_file(candidate)
    Show_file_navigator = false
    [2.3240]
    [2.3361]
    navigate_to_file(s)
  • edit in commands.lua at line 132
    [8.206573]
    [8.206573]
    function navigate_to_file(s)
    move_candidate_to_front(s)
    local candidate = guess_source(s..'.lua')
    source.switch_to_file(candidate)
    reset_file_navigator()
    end
    function move_candidate_to_front(s)
    local index = array.find(File_navigation.all_candidates, s)
    assert(index)
    table.remove(File_navigation.all_candidates, index)
    table.insert(File_navigation.all_candidates, 1, s)
    end
    function reset_file_navigator()
    Show_file_navigator = false
    File_navigation.index = 1
    File_navigation.filter = ''
    File_navigation.candidates = File_navigation.all_candidates
    end
  • replacement in commands.lua at line 157
    [8.206657][8.206657:206689](),[8.206689][2.3581:3707]()
    Show_file_navigator = false
    File_navigation.index = 1
    File_navigation.filter = ''
    File_navigation.candidates = File_navigation.all_candidates
    [8.206657]
    [8.206689]
    reset_file_navigator()
  • replacement in commands.lua at line 159
    [8.206721][8.206721:206884](),[8.206884][2.3708:3834]()
    local candidate = guess_source(File_navigation.candidates[File_navigation.index]..'.lua')
    source.switch_to_file(candidate)
    Show_file_navigator = false
    File_navigation.index = 1
    File_navigation.filter = ''
    File_navigation.candidates = File_navigation.all_candidates
    [8.206721]
    [2.3834]
    navigate_to_file(File_navigation.candidates[File_navigation.index])