Merge lines.love

[?]
Sep 4, 2022, 12:15 AM
DCO5BQWVIAW3KDY3VUMKZPCPWAVZJSTZGNWU6CRY3I5FVLU76REQC

Dependencies

  • [2] 2CTN2IEF Merge lines.love
  • [3] VNJ2M364 bugfix: window title
  • [4] CQYKYJJU remember window positions across restart/ctrl+e
  • [5] YT5P6TO6 bugfix: save previous file when dropping a new one on
  • [6] LXTTOB33 extract a couple of files
  • [7] VHQCNMAR several more modules
  • [8] OTIBCAUJ love2d scaffold
  • [9] D2GCFTTT clean up repl functionality
  • [10] TVCPXAAU rename
  • [11] AVTNUQYR basic test-enabled framework
  • [12] MD3W5IRA new fork: rip out drawing support
  • [13] 2L5MEZV3 experiment: new edit namespace
  • [14] GUOQRUL7 Merge lines.love
  • [15] JOPVPUSA editing source code from within the app
  • [16] 6LJZN727 handle chords
  • [17] FS2ITYYH record a known issue
  • [18] 73OCE2MC after much struggle, a brute-force undo
  • [19] TLOAPLBJ add a license
  • [20] AJB4LFRB try to maintain a reasonable line width
  • [21] VXORMHME delete experimental REPL
  • [22] RSZD5A7G forgot to add json.lua
  • [23] K2X6G75Z start writing some tests for drawings
  • [24] 4YDBYBA4 clean up memory leak experiments
  • [25] 3QNOKBFM beginnings of a test harness
  • [26] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing
  • [27] BULPIBEG beginnings of a module for the text editor
  • [28] 32V6ZHQB Merge lines.love
  • [29] CE4LZV4T drop last couple of manual tests
  • [30] KKMFQDR4 editing source code from within the app
  • [31] OGUV4HSA remove some memory leaks from rendered fragments
  • [32] R5QXEHUI somebody stop me
  • [33] T4FRZSYL delete an ancient, unused file
  • [34] BLWAYPKV extract a module
  • [35] XX7G2FFJ intermingle freehand line drawings with text
  • [36] 66X36NZN a little more prose describing manual_tests

Change contents

  • file deletion: run.lua (----------)run.lua (----------)
    [5.2][5.184046:184077](),[5.2][5.184046:184077](),[5.184077][5.178044:178044]()
    x=Settings.x, y=Settings.y, displayindex=Settings.displayindex,
    width=App.screen.width, height=App.screen.height,
    font_height=Editor_state.font_height,
    filename=filename,
    screen_top=Editor_state.screen_top1, cursor=Editor_state.cursor1
    }
    end
    function run.mouse_pressed(x,y, mouse_button)
    Cursor_time = 0 -- ensure cursor is visible immediately after it moves
    return edit.mouse_pressed(Editor_state, x,y, mouse_button)
    end
    function run.mouse_released(x,y, mouse_button)
    Cursor_time = 0 -- ensure cursor is visible immediately after it moves
    return edit.mouse_released(Editor_state, x,y, mouse_button)
    end
    function run.textinput(t)
    Cursor_time = 0 -- ensure cursor is visible immediately after it moves
    return edit.textinput(Editor_state, t)
    end
    function run.keychord_pressed(chord, key)
    Cursor_time = 0 -- ensure cursor is visible immediately after it moves
    return edit.keychord_pressed(Editor_state, chord, key)
    end
    function run.key_released(key, scancode)
    Cursor_time = 0 -- ensure cursor is visible immediately after it moves
    return edit.key_released(Editor_state, key, scancode)
    end
    -- use this sparingly
    function to_text(s)
    if Text_cache[s] == nil then
    Text_cache[s] = App.newText(love.graphics.getFont(), s)
    end
    return Text_cache[s]
    end
    if Current_app == 'run' then
    Settings.x, Settings.y, Settings.displayindex = love.window.getPosition()
    end
    local filename = Editor_state.filename
    if filename:sub(1,1) ~= '/' then
    filename = love.filesystem.getWorkingDirectory()..'/'..filename -- '/' should work even on Windows
    end
    return {
    love.window.setPosition(Settings.x, Settings.y, Settings.displayindex)
    Editor_state = edit.initialize_state(Margin_top, Margin_left, App.screen.width-Margin_right, Settings.font_height, math.floor(Settings.font_height*1.3))
    Editor_state.filename = Settings.filename
    Editor_state.screen_top1 = Settings.screen_top
    Editor_state.cursor1 = Settings.cursor
    end
    function run.initialize_default_settings()
    local font_height = 20
    love.graphics.setFont(love.graphics.newFont(font_height))
    local em = App.newText(love.graphics.getFont(), 'm')
    run.initialize_window_geometry(App.width(em))
    Editor_state = edit.initialize_state(Margin_top, Margin_left, App.screen.width-Margin_right)
    Editor_state.font_height = font_height
    Editor_state.line_height = math.floor(font_height*1.3)
    Editor_state.em = em
    Settings = run.settings()
    end
    function run.initialize_window_geometry(em_width)
    -- maximize window
    love.window.setMode(0, 0) -- maximize
    App.screen.width, App.screen.height, App.screen.flags = love.window.getMode()
    -- shrink height slightly to account for window decoration
    App.screen.height = App.screen.height-100
    App.screen.width = 40*em_width
    App.screen.flags.resizable = true
    App.screen.flags.minwidth = math.min(App.screen.width, 200)
    App.screen.flags.minheight = math.min(App.screen.width, 200)
    love.window.setMode(App.screen.width, App.screen.height, App.screen.flags)
    end
    function run.resize(w, h)
    --? print(("Window resized to width: %d and height: %d."):format(w, h))
    App.screen.width, App.screen.height = w, h
    Text.redraw_all(Editor_state)
    Editor_state.selection1 = {} -- no support for shift drag while we're resizing
    Editor_state.right = App.screen.width-Margin_right
    Editor_state.width = Editor_state.right-Editor_state.left
    Text.tweak_screen_top_and_cursor(Editor_state, Editor_state.left, Editor_state.right)
    end
    function run.filedropped(file)
    -- 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
    App.initialize_globals()
    Editor_state.filename = file:getFilename()
    file:open('r')
    Editor_state.lines = load_from_file(file)
    file:close()
    Text.redraw_all(Editor_state)
    edit.fixup_cursor(Editor_state)
    love.window.setTitle('lines.love - '..Editor_state.filename)
    end
    function run.draw()
    edit.draw(Editor_state)
    end
    function run.update(dt)
    Cursor_time = Cursor_time + dt
    edit.update(Editor_state, dt)
    end
    function run.quit()
    edit.quit(Editor_state)
    end
    function run.settings()
  • edit in source_file.lua at line 57
    [5.151770][5.151770:151936]()
    end
    function file_exists(filename)
    local infile = App.open_for_reading(filename)
    if infile then
    infile:close()
    return true
    else
    return false
    end
  • edit in run.lua at line 56
    [5.179481][5.179481:179554]()
    love.window.setPosition(Settings.x, Settings.y, Settings.displayindex)
  • edit in run.lua at line 61
    [5.179864]
    [5.179864]
    love.window.setPosition(Settings.x, Settings.y, Settings.displayindex)
  • replacement in run.lua at line 132
    [5.182338][5.182338:182391]()
    local x,y,displayindex = love.window.getPosition()
    [5.182338]
    [5.182391]
    if Current_app == 'run' then
    Settings.x, Settings.y, Settings.displayindex = love.window.getPosition()
    end
  • replacement in run.lua at line 140
    [5.182588][5.182588:182629]()
    x=x, y=y, displayindex=displayindex,
    [5.182588]
    [5.182629]
    x=Settings.x, y=Settings.y, displayindex=Settings.displayindex,
  • edit in main.lua at line 101
    [5.187950][3.70:123](),[5.187950][3.70:123]()
    love.window.setTitle('lines.love - '..Current_app)
  • replacement in main.lua at line 108
    [5.187407][5.187407:187459]()
    love.window.setTitle('text.love - '..Current_app)
    [5.187407]
    [5.187459]
    love.window.setTitle('lines.love - '..Current_app)