diff options
author | 2009-07-08 21:18:27 -0400 | |
---|---|---|
committer | 2009-07-08 21:18:27 -0400 | |
commit | 29808b6c6224d22a2f36b1d1a573b23001a0638c (patch) | |
tree | f4009d66af4754efbbd1c9a902fbc35701b6c7c4 /core/ext | |
parent | 3c3401d47c364140d8e1ebe95f6cb2b9e188f698 (diff) | |
download | textadept-29808b6c6224d22a2f36b1d1a573b23001a0638c.tar.gz textadept-29808b6c6224d22a2f36b1d1a573b23001a0638c.zip |
Better session management.
Can load and save from the menu now as well.
Diffstat (limited to 'core/ext')
-rw-r--r-- | core/ext/menu.lua | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/core/ext/menu.lua b/core/ext/menu.lua index 25e9950c..0fe2cfb5 100644 --- a/core/ext/menu.lua +++ b/core/ext/menu.lua @@ -358,8 +358,34 @@ local actions = { [ID.SAVEAS] = { 'save_as', b }, [ID.CLOSE] = { 'close', b }, [ID.CLOSE_ALL] = { t.io.close_all }, - [ID.LOAD_SESSION] = { t.io.load_session }, -- TODO: file open dialog prompt - [ID.SAVE_SESSION] = { t.io.save_session }, -- TODO: file save dialog prompt + [ID.LOAD_SESSION] = { + function() + local utf8_filename = + cocoa_dialog('fileselect', { + title = l.MENU_LOAD_SESSION_TITLE, + ['with-directory'] = (textadept.session_file or ''):match('.+[/\\]'), + ['with-file'] = (textadept.session_file or ''):match('[^/\\]+$'), + ['no-newline'] = true + }) + if #utf8_filename > 0 then + t.io.load_session(t.iconv(utf8_filename, _CHARSET, 'UTF-8')) + end + end + }, + [ID.SAVE_SESSION] = { + function() + local utf8_filename = + cocoa_dialog('filesave', { + title = l.MENU_SAVE_SESSION_TITLE, + ['with-directory'] = (textadept.session_file or ''):match('.+[/\\]'), + ['with-file'] = (textadept.session_file or ''):match('[^/\\]+$'), + ['no-newline'] = true + }) + if #utf8_filename > 0 then + t.io.save_session(t.iconv(utf8_filename, _CHARSET, 'UTF-8')) + end + end + }, [ID.QUIT] = { t.quit }, -- Edit [ID.UNDO] = { 'undo', b }, |