From 18d7be2d1eaaef73c56dc850a3172529726d7a34 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sun, 29 Sep 2013 21:09:56 -0400 Subject: Added new `ui.dialogs` module for more user-friendly dialog support. As a result, removed `ui.filteredlist()` and changed `io.open_file()` and `io.snapopen()` APIs to accept tables of files and paths instead of "\n" delimited strings. --- modules/textadept/session.lua | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'modules/textadept/session.lua') diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua index c7984481..2419a822 100644 --- a/modules/textadept/session.lua +++ b/modules/textadept/session.lua @@ -40,14 +40,11 @@ M.MAX_RECENT_FILES = 10 -- @see DEFAULT_SESSION -- @name load function M.load(filename) - local dir = M.DEFAULT_SESSION:match('^.+[/\\]') or '' - local name = M.DEFAULT_SESSION:match('[^/\\]+$') or '' - filename = filename or ui.dialog('fileselect', - '--title', _L['Load Session'], - '--with-directory', dir, - '--with-file', name, - '--no-newline') - if filename == '' then return end + local dir, name = M.DEFAULT_SESSION:match('^(.-[/\\]?)([^/\\]+)$') + filename = filename or ui.dialogs.fileselect{ + title = _L['Load Session'], with_directory = dir, with_file = name + } + if not filename then return end local not_found = {} local f = io.open(filename, 'rb') if not f then io.close_all_buffers() return false end @@ -104,12 +101,12 @@ function M.load(filename) f:close() ui.goto_view(current_view) if #not_found > 0 then - ui.dialog('msgbox', - '--title', _L['Session Files Not Found'], - '--text', _L['The following session files were not found'], - '--informative-text', table.concat(not_found, '\n'), - '--icon', 'gtk-dialog-warning', - '--button1', _L['_OK']) + ui.dialogs.msgbox{ + title = _L['Session Files Not Found'], + text = _L['The following session files were not found'], + informative_text = table.concat(not_found, '\n'), + icon = 'gtk-dialog-warning' + } end return true end @@ -127,14 +124,12 @@ end) -- @see DEFAULT_SESSION -- @name save function M.save(filename) - local dir = M.DEFAULT_SESSION:match('^.+[/\\]') or '' - local name = M.DEFAULT_SESSION:match('[^/\\]+$') or '' - filename = filename or ui.dialog('filesave', - '--title', _L['Save Session'], - '--with-directory', dir, - '--with-file', name:iconv('UTF-8', _CHARSET), - '--no-newline') - if filename == '' then return end + local dir, name = M.DEFAULT_SESSION:match('^(.-[/\\]?)([^/\\]+)$') + filename = filename or ui.dialogs.filesave{ + title = _L['Save Session'], with_directory = dir, + with_file = name:iconv('UTF-8', _CHARSET) + } + if not filename then return end local session = {} local buffer_line = "buffer: %d %d %d %s" -- anchor, cursor, line, filename local split_line = "%ssplit%d: %s %d" -- level, number, type, size -- cgit v1.2.3