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WMFU7MDLW4JFW4HVWGGGDEGLJKL4PIQC
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
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)
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()
-- 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)
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
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
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)
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 = {line=1, pos=1}
Editor_state.cursor1 = {line=1, pos=1}
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
cursors = {}, -- filename to cursor1, screen_top1
}
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)
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
function keychord_pressed_on_file_navigator(chord, key)
navigate_to_file(s)
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
end
local filename = Editor_state.filename
if is_relative_path(filename) then
filename = love.filesystem.getWorkingDirectory()..'/'..filename -- '/' should work even on Windows
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])