source: show files in MRU order
I'm not going to save this MRU order across sessions for now. It's good enough to save cursor positions for individual files, I think.
This commit is contained in:
parent
fd7d36fefd
commit
690a1c334c
12
commands.lua
12
commands.lua
|
@ -64,10 +64,6 @@ function source.draw_file_navigator()
|
||||||
love.graphics.rectangle('fill', 0,Menu_status_bar_height, App.screen.width, File_navigation.num_lines * Editor_state.line_height + --[[highlight padding]] 2)
|
love.graphics.rectangle('fill', 0,Menu_status_bar_height, App.screen.width, File_navigation.num_lines * Editor_state.line_height + --[[highlight padding]] 2)
|
||||||
local x,y = 5, Menu_status_bar_height
|
local x,y = 5, Menu_status_bar_height
|
||||||
for i,filename in ipairs(File_navigation.candidates) do
|
for i,filename in ipairs(File_navigation.candidates) do
|
||||||
if filename == 'source' then
|
|
||||||
App.color(Menu_border_color)
|
|
||||||
love.graphics.line(Menu_cursor-10,2, Menu_cursor-10,Menu_status_bar_height-2)
|
|
||||||
end
|
|
||||||
x,y = add_file_to_menu(x,y, filename, i == File_navigation.index)
|
x,y = add_file_to_menu(x,y, filename, i == File_navigation.index)
|
||||||
if Menu_cursor >= App.screen.width - 5 then
|
if Menu_cursor >= App.screen.width - 5 then
|
||||||
break
|
break
|
||||||
|
@ -134,11 +130,19 @@ function add_file_to_menu(x,y, s, cursor_highlight)
|
||||||
end
|
end
|
||||||
|
|
||||||
function navigate_to_file(s)
|
function navigate_to_file(s)
|
||||||
|
move_candidate_to_front(s)
|
||||||
local candidate = guess_source(s..'.lua')
|
local candidate = guess_source(s..'.lua')
|
||||||
source.switch_to_file(candidate)
|
source.switch_to_file(candidate)
|
||||||
reset_file_navigator()
|
reset_file_navigator()
|
||||||
end
|
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()
|
function reset_file_navigator()
|
||||||
Show_file_navigator = false
|
Show_file_navigator = false
|
||||||
File_navigation.index = 1
|
File_navigation.index = 1
|
||||||
|
|
Loading…
Reference in New Issue