aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/file_io.lua14
-rw-r--r--modules/textadept/keys.lua18
2 files changed, 13 insertions, 19 deletions
diff --git a/core/file_io.lua b/core/file_io.lua
index c7ca424f..7079776f 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -51,6 +51,7 @@ events.FILE_SAVED_AS = 'file_saved_as'
---
-- List of recently opened files.
+-- The most recent are towards the top.
-- @class table
-- @name recent_files
recent_files = {}
@@ -101,7 +102,7 @@ try_encodings = {
-- Opens a file or goes to its already open buffer.
-- @param utf8_filename The absolute path to the file to open. Must be UTF-8
-- encoded.
-local function open_helper(utf8_filename)
+local function _open(utf8_filename)
if not utf8_filename then return end
utf8_filename = utf8_filename:gsub('^file://', '')
if WIN32 then utf8_filename = utf8_filename:gsub('/', '\\') end
@@ -166,7 +167,7 @@ local function open_helper(utf8_filename)
break
end
end
- recent_files[#recent_files + 1] = utf8_filename
+ table.insert(recent_files, 1, utf8_filename)
end
---
@@ -181,7 +182,7 @@ function open_file(utf8_filenames)
'--select-multiple',
'--with-directory',
(buffer.filename or ''):match('.+[/\\]') or '')
- for filename in utf8_filenames:gmatch('[^\n]+') do open_helper(filename) end
+ for filename in utf8_filenames:gmatch('[^\n]+') do _open(filename) end
end
-- LuaDoc is in core/.buffer.luadoc.
@@ -352,3 +353,10 @@ events.connect(events.FILE_OPENED, function(utf8_filename)
buffer:close()
end
end)
+
+---
+-- Prompts the user to open a recently opened file.
+function open_recent_file()
+ local i = gui.filteredlist(L('Open'), L('File'), recent_files, true)
+ if i then open_file(recent_files[i + 1]) end
+end
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index 634e61e8..8d7c38c6 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -34,20 +34,6 @@ local function toggle_setting(setting, i)
end
events.emit(events.UPDATE_UI) -- for updating statusbar
end
-local RECENT_FILES = _SCINTILLA.next_user_list_type()
-events.connect(events.USER_LIST_SELECTION,
- function(type, text) if type == RECENT_FILES then io.open_file(text) end end)
-local function show_recent_file_list()
- local buffer = buffer
- local files = {}
- for _, filename in ipairs(io.recent_files) do
- table.insert(files, 1, filename)
- end
- local sep = buffer.auto_c_separator
- buffer.auto_c_separator = ('|'):byte()
- buffer:user_list_show(RECENT_FILES, table.concat(files, '|'))
- buffer.auto_c_separator = sep
-end
local function show_style()
local buffer = buffer
local style = buffer.style_at[buffer.current_pos]
@@ -187,7 +173,7 @@ if not OSX then
keys.c0 = function() buffer.zoom = 0 end
-- Miscellaneous not in standard menu.
- keys.ao = show_recent_file_list
+ keys.ao = io.open_recent_file
keys.caI = show_style
else
@@ -314,7 +300,7 @@ else
keys.c0 = function() buffer.zoom = 0 end
-- Miscellaneous not in standard menu.
- keys.co = show_recent_file_list
+ keys.co = io.open_recent_file
keys.caI = show_style
-- Movement/selection commands