Merge lines.love
[?]
Sep 4, 2022, 12:15 AM
DCO5BQWVIAW3KDY3VUMKZPCPWAVZJSTZGNWU6CRY3I5FVLU76REQCDependencies
- [2]
2CTN2IEFMerge lines.love - [3]
VNJ2M364bugfix: window title - [4]
CQYKYJJUremember window positions across restart/ctrl+e - [5]
YT5P6TO6bugfix: save previous file when dropping a new one on - [6]
LXTTOB33extract a couple of files - [7]
VHQCNMARseveral more modules - [8]
OTIBCAUJlove2d scaffold - [9]
D2GCFTTTclean up repl functionality - [10]
TVCPXAAUrename - [11]
AVTNUQYRbasic test-enabled framework - [12]
MD3W5IRAnew fork: rip out drawing support - [13]
2L5MEZV3experiment: new edit namespace - [14]
GUOQRUL7Merge lines.love - [15]
JOPVPUSAediting source code from within the app - [16]
6LJZN727handle chords - [17]
FS2ITYYHrecord a known issue - [18]
73OCE2MCafter much struggle, a brute-force undo - [19]
TLOAPLBJadd a license - [20]
AJB4LFRBtry to maintain a reasonable line width - [21]
VXORMHMEdelete experimental REPL - [22]
RSZD5A7Gforgot to add json.lua - [23]
K2X6G75Zstart writing some tests for drawings - [24]
4YDBYBA4clean up memory leak experiments - [25]
3QNOKBFMbeginnings of a test harness - [26]
BJ5X5O4Alet's prevent the text cursor from ever getting on a drawing - [27]
BULPIBEGbeginnings of a module for the text editor - [28]
32V6ZHQBMerge lines.love - [29]
CE4LZV4Tdrop last couple of manual tests - [30]
KKMFQDR4editing source code from within the app - [31]
OGUV4HSAremove some memory leaks from rendered fragments - [32]
R5QXEHUIsomebody stop me - [33]
T4FRZSYLdelete an ancient, unused file - [34]
BLWAYPKVextract a module - [35]
XX7G2FFJintermingle freehand line drawings with text - [36]
66X36NZNa little more prose describing manual_tests
Change contents
- file deletion: run.lua run.lua
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}endfunction run.mouse_pressed(x,y, mouse_button)Cursor_time = 0 -- ensure cursor is visible immediately after it movesreturn edit.mouse_pressed(Editor_state, x,y, mouse_button)endfunction run.mouse_released(x,y, mouse_button)Cursor_time = 0 -- ensure cursor is visible immediately after it movesreturn edit.mouse_released(Editor_state, x,y, mouse_button)endfunction run.textinput(t)Cursor_time = 0 -- ensure cursor is visible immediately after it movesreturn edit.textinput(Editor_state, t)endfunction run.keychord_pressed(chord, key)Cursor_time = 0 -- ensure cursor is visible immediately after it movesreturn edit.keychord_pressed(Editor_state, chord, key)endfunction run.key_released(key, scancode)Cursor_time = 0 -- ensure cursor is visible immediately after it movesreturn edit.key_released(Editor_state, key, scancode)end-- use this sparinglyfunction to_text(s)if Text_cache[s] == nil thenText_cache[s] = App.newText(love.graphics.getFont(), s)endreturn Text_cache[s]endif Current_app == 'run' thenSettings.x, Settings.y, Settings.displayindex = love.window.getPosition()endlocal filename = Editor_state.filenameif filename:sub(1,1) ~= '/' thenfilename = love.filesystem.getWorkingDirectory()..'/'..filename -- '/' should work even on Windowsendreturn {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.filenameEditor_state.screen_top1 = Settings.screen_topEditor_state.cursor1 = Settings.cursorendfunction run.initialize_default_settings()local font_height = 20love.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_heightEditor_state.line_height = math.floor(font_height*1.3)Editor_state.em = emSettings = run.settings()endfunction run.initialize_window_geometry(em_width)-- maximize windowlove.window.setMode(0, 0) -- maximizeApp.screen.width, App.screen.height, App.screen.flags = love.window.getMode()-- shrink height slightly to account for window decorationApp.screen.height = App.screen.height-100App.screen.width = 40*em_widthApp.screen.flags.resizable = trueApp.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)endfunction run.resize(w, h)--? print(("Window resized to width: %d and height: %d."):format(w, h))App.screen.width, App.screen.height = w, hText.redraw_all(Editor_state)Editor_state.selection1 = {} -- no support for shift drag while we're resizingEditor_state.right = App.screen.width-Margin_rightEditor_state.width = Editor_state.right-Editor_state.leftText.tweak_screen_top_and_cursor(Editor_state, Editor_state.left, Editor_state.right)endfunction run.filedropped(file)-- first make sure to save edits on any existing fileif Editor_state.next_save thensave_to_disk(Editor_state)end-- clear the slate for the new fileApp.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)endfunction run.draw()edit.draw(Editor_state)endfunction run.update(dt)Cursor_time = Cursor_time + dtedit.update(Editor_state, dt)endfunction run.quit()edit.quit(Editor_state)endfunction run.settings() - edit in source_file.lua at line 57
endfunction file_exists(filename)local infile = App.open_for_reading(filename)if infile theninfile:close()return trueelsereturn falseend - edit in run.lua at line 56
love.window.setPosition(Settings.x, Settings.y, Settings.displayindex) - edit in run.lua at line 61
love.window.setPosition(Settings.x, Settings.y, Settings.displayindex) - replacement in run.lua at line 132
local x,y,displayindex = love.window.getPosition()if Current_app == 'run' thenSettings.x, Settings.y, Settings.displayindex = love.window.getPosition()end - replacement in run.lua at line 140
x=x, y=y, displayindex=displayindex,x=Settings.x, y=Settings.y, displayindex=Settings.displayindex, - edit in main.lua at line 101
love.window.setTitle('lines.love - '..Current_app) - replacement in main.lua at line 108
love.window.setTitle('text.love - '..Current_app)love.window.setTitle('lines.love - '..Current_app)