YCWU4GJYJAUYPFHMZNSGSG66EB4SRJV7MKEOY54CGBL4ELEPB5BAC KCDRLLAAANY5USQHWZ5QQDZDHJFJB6NS4WYZB3WE4AW4LPIV2RAAC B6DS4GZC46Q4QSD3TXP5Q7NDERTOBAQV66JBCT5O6FAKKTLEVJLAC R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC JOPVPUSAMMU6RFVDQR4NJC4GNNUFB7GPKVH7OS5FKCYS5QZ53VLQC RU4HIK436ZRQJEPZXFS4FQTYVRL7BK5NWKYFGHFHZQOEOBF7M5SQC FXI74QCLOZ4BS7UVZ3U2PE3LOL7MX3FWGHZCTGH3DYFXGTXVVIRAC ICUW7F3XQLURK4LSNPH5E3NDEFSRHKATEUHH2UPFJTMHYR3ZJF3QC 7Y7C7N6OVIL4YT33DYCBAPTH7COHOAWQGHGPUNBNLYQ2HW65PWFAC FNJFBXABRFX5WK6SSRDLZDCNCABN5X36HUPKRMJ7ECQTEK2XJJJQC ZLJYLPOTXIVBVWJ4NTRM2YCQPT2FCSN7446P56MJFEFY45QTB7IAC 3VHUIIATPOF7FXB7NTL5MESCV5BCQACII2D7QZ4UIUCBX3CWXMMAC function source.initialize_window_geometry()-- Initialize window width/height and make window resizable.---- I get tempted to have opinions about window dimensions here, but they're-- non-portable:-- - maximizing doesn't work on mobile and messes things up-- - maximizing keeps the title bar on screen in Linux, but off screen on-- Windows. And there's no way to get the height of the title bar.-- It seems more robust to just follow LÖVE's default window size until-- someone overrides it.App.screen.width, App.screen.height, App.screen.flags = App.screen.size()source.initialize_window_geometry()Editor_state = edit.initialize_state(Margin_top, Margin_left, App.screen.width-Margin_right)
run = {}Editor_state = {}-- called both in tests and real runfunction run.initialize_globals()-- tests currently mostly clear their own state-- blinking cursorCursor_time = 0end-- called only for real runfunction run.initialize(arg)log_new('run')if Settings thenrun.load_settings()elserun.initialize_default_settings()end
Editor_state.filename = arg[1]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}elseload_from_disk(Editor_state)Text.redraw_all(Editor_state)endedit.check_locs(Editor_state)-- keep a few blank lines around: https://merveilles.town/@akkartik/110084833821965708love.window.setTitle('text.love - '..Editor_state.filename)if #arg > 1 thenprint('ignoring commandline args after '..arg[1])endif rawget(_G, 'jit') thenjit.off()jit.flush()end
App.screen.flags.resizable = trueApp.screen.width, App.screen.height = Settings.width, Settings.heightApp.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
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.cursorend
function run.initialize_default_settings()local font_height = 20love.graphics.setFont(love.graphics.newFont(font_height))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)Settings = run.settings()end
App.screen.width, App.screen.height, App.screen.flags = App.screen.size()App.screen.flags.resizable = trueApp.screen.resize(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.file_drop(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)Editor_state.screen_top1 = {line=1, pos=1}Editor_state.cursor1 = {line=1, pos=1}-- keep a few blank lines around: https://merveilles.town/@akkartik/110084833821965708love.window.setTitle('text.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()
endfunction run.mouse_press(x,y, mouse_button)Cursor_time = 0 -- ensure cursor is visible immediately after it movesreturn edit.mouse_press(Editor_state, x,y, mouse_button)endfunction run.mouse_release(x,y, mouse_button)Cursor_time = 0 -- ensure cursor is visible immediately after it movesreturn edit.mouse_release(Editor_state, x,y, mouse_button)endfunction run.mouse_wheel_move(dx,dy)Cursor_time = 0 -- ensure cursor is visible immediately after it movesreturn edit.mouse_wheel_move(Editor_state, dx,dy)endfunction run.text_input(t)Cursor_time = 0 -- ensure cursor is visible immediately after it movesreturn edit.text_input(Editor_state, t)endfunction run.keychord_press(chord, key)Cursor_time = 0 -- ensure cursor is visible immediately after it movesreturn edit.keychord_press(Editor_state, chord, key)endfunction run.key_release(key, scancode)Cursor_time = 0 -- ensure cursor is visible immediately after it movesreturn edit.key_release(Editor_state, key, scancode)end