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KVH7OS5FKCYS5QZ53VLQC
AYX33NBCPCBFWEZI5KZXHP3Y2Q62GYVT4WHYJUYRIPYV67KPSYZAC
3PSFWAILGRA4OYXWS2DX7VF332AIBPYBXHEA4GIQY2XEJVD65UMAC
MSOQI3A5BC5PY2MZXZQAQ4EQDT4KICQJPN3YUZVDYTWXSPZWBLIAC
MUJTM6REGQAK3LZTIFWGJRXE2UPCM4HSLXQYSF5ITLXLS6JCVPMQC
LXTTOB33N2HCUZFIUDRQGGBVHK2HODRG4NBLH6RXRQZDCHF27BSAC
5ZA3BRNYWKSGEBJ4JLA4UBC3LJPT5JBWYCU7PQYRSGX6MJMEWDIQC
AMOPICKVRHMQERJLFPMAAEBV7TL5QACGGSBJWRCMV5R5O3KDVETAC
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_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
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
})
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
function empty(h)
for _,_ in pairs(h) do
return false
end
return true
end
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)
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
Editor_state.screen_top1 = settings.screen_top
Editor_state.cursor1 = settings.cursor
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
Editor_state.screen_top1 = {line=1, pos=1}
Editor_state.cursor1 = {line=1, pos=1}
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
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
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
navigate_to_file(File_navigation.candidates[File_navigation.index])