diff options
Diffstat (limited to 'modules/textadept')
-rw-r--r-- | modules/textadept/adeptsense.lua | 18 | ||||
-rw-r--r-- | modules/textadept/bookmarks.lua | 7 | ||||
-rw-r--r-- | modules/textadept/editing.lua | 13 | ||||
-rw-r--r-- | modules/textadept/file_types.lua | 6 | ||||
-rw-r--r-- | modules/textadept/find.lua | 26 | ||||
-rw-r--r-- | modules/textadept/menu.lua | 18 | ||||
-rw-r--r-- | modules/textadept/session.lua | 39 | ||||
-rw-r--r-- | modules/textadept/snippets.lua | 11 |
8 files changed, 68 insertions, 70 deletions
diff --git a/modules/textadept/adeptsense.lua b/modules/textadept/adeptsense.lua index 4987f0cf..fc1431c9 100644 --- a/modules/textadept/adeptsense.lua +++ b/modules/textadept/adeptsense.lua @@ -807,22 +807,24 @@ end function M.goto_ctag(sense, kind, title) if not sense.locations[kind] then return end -- no Ctags loaded local items = {} - local kind = sense.ctags_kinds[kind] + local adeptsense_kind = sense.ctags_kinds[kind] for kind, v in pairs(sense.locations[kind]) do items[#items + 1] = kind:match('[^#]+$') -- symbol name - if kind == M.FUNCTION or kind == M.FIELD then - items[#items + 1] = kind:match('^[^#]+') -- class name + if adeptsense_kind == M.FUNCTION or adeptsense_kind == M.FIELD then + items[#items + 1] = kind:match('^[^#]*') -- class name end items[#items + 1] = v[1]:iconv('UTF-8', _CHARSET)..':'..v[2] end local columns = {'Name', 'Location'} - if kind == M.FUNCTION or kind == M.FIELD then + if adeptsense_kind == M.FUNCTION or adeptsense_kind == M.FIELD then table.insert(columns, 2, 'Class') end - local location = ui.filteredlist(title, columns, items, false, - '--output-column', '3') - if not location then return end - local path, line = location:match('^(%a?:?[^:]+):(.+)$') + local button, i = ui.dialogs.filteredlist{ + title = title, columns = columns, items = items, + width = CURSES and ui.size[1] - 2 or nil + } + if button ~= 1 or not i then return end + local path, line = items[i * #columns]:match('^(%a?:?[^:]+):(.+)$') io.open_file(path:iconv(_CHARSET, 'UTF-8')) if not tonumber(line) then -- /^ ... $/ diff --git a/modules/textadept/bookmarks.lua b/modules/textadept/bookmarks.lua index 6c9f7a03..cd752ca7 100644 --- a/modules/textadept/bookmarks.lua +++ b/modules/textadept/bookmarks.lua @@ -53,8 +53,11 @@ function M.goto_mark(next) marks[#marks + 1] = tostring(line + 1)..': '..text line = buffer:marker_next(line + 1, 2^M.MARK_BOOKMARK) until line < 0 - local line = ui.filteredlist(_L['Select Bookmark'], _L['Bookmark'], marks) - if line then textadept.editing.goto_line(line:match('^%d+')) end + local button, i = ui.dialogs.filteredlist{ + title = _L['Select Bookmark'], columns = _L['Bookmark'], items = marks + } + if button ~= 1 or not i then return end + textadept.editing.goto_line(marks[i]:match('^%d+')) else local f = next and buffer.marker_next or buffer.marker_previous local current_line = buffer:line_from_position(buffer.current_pos) diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 1fd74e07..ac703fe2 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -307,13 +307,12 @@ end -- @name goto_line function M.goto_line(line) if not line then - line = tonumber(ui.dialog('inputbox', - '--title', _L['Go To'], - '--text', _L['Line Number:'], - '--button1', _L['_OK'], - '--button2', _L['_Cancel'], - '--no-newline'):match('%-?%d+$')) - if not line or line < 0 then return end + local button, value = ui.dialogs.inputbox{ + title = _L['Go To'], informative_text = _L['Line Number:'], + button1 = _L['_OK'], button2 = _L['_Cancel'] + } + line = tonumber(value) + if button ~= 1 or not line then return end end buffer:ensure_visible_enforce_policy(line - 1) buffer:goto_line(line - 1) diff --git a/modules/textadept/file_types.lua b/modules/textadept/file_types.lua index 1d77c178..2e48b959 100644 --- a/modules/textadept/file_types.lua +++ b/modules/textadept/file_types.lua @@ -126,8 +126,10 @@ events.connect(events.RESET_AFTER, restore_lexer) -- @see buffer.set_lexer -- @name select_lexer function M.select_lexer() - local lexer = ui.filteredlist(_L['Select Lexer'], _L['Name'], M.lexers) - if lexer then buffer:set_lexer(lexer) end + local button, i = ui.dialogs.filteredlist{ + title = _L['Select Lexer'], columns = _L['Name'], items = M.lexers + } + if button == 1 and i then buffer:set_lexer(M.lexers[i]) end end -- Generate lexer list. diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index 82b5f4c4..177e85e8 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -217,13 +217,11 @@ end -- @see FILTER -- @name find_in_files function M.find_in_files(dir) - dir = dir or ui.dialog('fileselect', - '--title', _L['Find in Files'], - '--select-only-directories', - '--with-directory', - (buffer.filename or ''):match('^.+[/\\]') or '', - '--no-newline') - if dir == '' then return end + dir = dir or ui.dialogs.fileselect{ + title = _L['Find in Files'], select_only_directories = true, + with_directory = (buffer.filename or ''):match('^.+[/\\]'), + } + if not dir then return end local text = M.find_entry_text if not M.lua then text = text:gsub('([().*+?^$%%[%]-])', '%%%1') end @@ -275,15 +273,11 @@ local function replace(rtext) buffer:replace_target(rtext:gsub('\\[abfnrtv\\]', escapes)) buffer:goto_pos(buffer.target_end) -- 'find' text after this replacement else - ui.dialog('ok-msgbox', - '--title', _L['Error'], - '--text', _L['An error occured:'], - '--informative-text', - rtext:match(':1:(.+)$') or rtext:match(':%d+:(.+)$'), - '--icon', 'gtk-dialog-error', - '--button1', _L['_OK'], - '--button2', _L['_Cancel'], - '--no-cancel') + ui.dialogs.msgbox{ + title = _L['Error'], text = _L['An error occured:'], + informative_text = rtext:match(':1:(.+)$') or rtext:match(':%d+:(.+)$'), + icon = 'gtk-dialog-error' + } -- Since find is called after replace returns, have it 'find' the current -- text again, rather than the next occurance so the user can fix the error. buffer:goto_pos(buffer.current_pos) diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua index 2f984d8a..4099cc28 100644 --- a/modules/textadept/menu.lua +++ b/modules/textadept/menu.lua @@ -192,10 +192,10 @@ local menubar = { {_L['Show _LuaDoc'], {utils.open_webpage, _HOME..'/doc/api/index.html'}}, SEPARATOR, {_L['_About'], - {ui.dialog, 'ok-msgbox', '--title', 'Textadept', '--text', _RELEASE, - '--informative-text', 'Copyright © 2007-2013 Mitchell. See LICENSE\n'.. - 'http://foicica.com/textadept', '--button1', _L['_OK'], '--no-cancel', - '--icon-file', _HOME..'/core/images/ta_64x64.png'}}, + {ui.dialogs.msgbox, {title = 'Textadept', text = _RELEASE, + informative_text = 'Copyright © 2007-2013 Mitchell. See LICENSE\n'.. + 'http://foicica.com/textadept', + icon_file = _HOME..'/core/images/ta_64x64.png'}}}, }, } @@ -341,10 +341,12 @@ if not CURSES then M.set_contextmenu(context_menu) end -- Prompts the user to select a menu command to run. -- @name select_command function M.select_command() - local i = ui.filteredlist(_L['Run Command'], - {_L['Command'], _L['Key Command']}, items, true, - CURSES and {'--width', ui.size[1] - 2} or '') - if i then keys.run_command(commands[i + 1], type(commands[i + 1])) end + local button, i = ui.dialogs.filteredlist{ + title = _L['Run Command'], columns = {_L['Command'], _L['Key Command']}, + items = items, width = CURSES and ui.size[1] - 2 or nil + } + if button ~= 1 or not i then return end + keys.run_command(commands[i], type(commands[i])) end -- Performs the appropriate action when clicking a menu item. 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 diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua index 6a664792..da6193df 100644 --- a/modules/textadept/snippets.lua +++ b/modules/textadept/snippets.lua @@ -189,11 +189,12 @@ function M._select() for i = 1, #list do t[#t + 1], t[#t + 2], t[#t + 3] = list[i]:match('^(%Z+)%z(%Z+)%z(%Z+)$') end - local i = ui.filteredlist(_L['Select Snippet'], - {_L['Trigger'], _L['Scope'], _L['Snippet Text']}, - t, true, '--output-column', '2', - CURSES and {'--width', ui.size[1] - 2} or '') - if i then M._insert(t[(i + 1) * 3]) end + local button, i = ui.dialogs.filteredlist{ + title = _L['Select Snippet'], + columns = {_L['Trigger'], _L['Scope'], _L['Snippet Text']}, items = t, + width = CURSES and ui.size[1] - 2 or nil + } + if button == 1 and i then M._insert(t[i * 3]) end end -- Table of escape sequences. |