diff options
author | 2010-03-25 06:31:16 -0400 | |
---|---|---|
committer | 2010-03-25 06:31:16 -0400 | |
commit | 9583dadb72798bddcf14260d263a2b3b9ac451a3 (patch) | |
tree | 0b949e1939c4c6d5e7b5e9bd49a66bb53b91708c | |
parent | 67fdad16ebd8874420fd95e8329070dfe4f78e47 (diff) | |
download | textadept-9583dadb72798bddcf14260d263a2b3b9ac451a3.tar.gz textadept-9583dadb72798bddcf14260d263a2b3b9ac451a3.zip |
Added notification for session files not found.
-rw-r--r-- | core/locale.conf | 8 | ||||
-rw-r--r-- | modules/textadept/session.lua | 16 |
2 files changed, 23 insertions, 1 deletions
diff --git a/core/locale.conf b/core/locale.conf index 2a933b40..8d8bdb11 100644 --- a/core/locale.conf +++ b/core/locale.conf @@ -654,3 +654,11 @@ M_TEXTADEPT_RUN_FILE_DOES_NOT_EXIST "The file "%s" does not exist." % modules/textadept/snippets.lua % "Lexer %s\nStyle %s (%d)" M_TEXTADEPT_SNIPPETS_SHOW_STYLE "Lexer %s\nStyle %s (%d)" + +% modules/textadept/session.lua +% "Session Files Not Found" +M_SESSION_FILES_NOT_FOUND_TITLE "Session Files Not Found" + +% modules/textadept/session.lua +% "The following session files were not found" +M_SESSION_FILES_NOT_FOUND_TEXT "The following session files were not found" diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua index a867ddf5..ed1cbe8e 100644 --- a/modules/textadept/session.lua +++ b/modules/textadept/session.lua @@ -20,6 +20,8 @@ DEFAULT_SESSION = _USERHOME..'/session' SAVE_ON_QUIT = true -- end settings +local lfs = require 'lfs' + --- -- Loads a Textadept session file. -- Textadept restores split views, opened buffers, cursor information, and @@ -29,6 +31,7 @@ SAVE_ON_QUIT = true -- @return true if the session file was opened and read; false otherwise. -- @usage _m.textadept.session.load(filename) function load(filename) + local not_found = {} local f = io.open(filename or DEFAULT_SESSION, 'rb') if not f then if not textadept.io.close_all() then return false end @@ -40,7 +43,11 @@ function load(filename) local anchor, current_pos, first_visible_line, filename = line:match('^buffer: (%d+) (%d+) (%d+) (.+)$') if not filename:find('^%[.+%]$') then - textadept.io.open(filename or '') + if lfs.attributes(filename) then + textadept.io.open(filename) + else + not_found[#not_found + 1] = filename + end else textadept.new_buffer() buffer._type = filename @@ -79,6 +86,13 @@ function load(filename) f:close() textadept.views[current_view]:focus() textadept.session_file = filename or DEFAULT_SESSION + if #not_found > 0 then + textadept.dialog('msgbox', + '--title', locale.M_SESSION_FILES_NOT_FOUND_TITLE, + '--text', locale.M_SESSION_FILES_NOT_FOUND_TEXT, + '--informative-text', + string.format('%s', table.concat(not_found, '\n'))) + end return true end |