aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--core/.ui.dialogs.luadoc415
-rw-r--r--core/file_io.lua128
-rw-r--r--core/ui.lua111
-rw-r--r--doc/14_Appendix.md7
-rw-r--r--modules/textadept/adeptsense.lua18
-rw-r--r--modules/textadept/bookmarks.lua7
-rw-r--r--modules/textadept/editing.lua13
-rw-r--r--modules/textadept/file_types.lua6
-rw-r--r--modules/textadept/find.lua26
-rw-r--r--modules/textadept/menu.lua18
-rw-r--r--modules/textadept/session.lua39
-rw-r--r--modules/textadept/snippets.lua11
12 files changed, 613 insertions, 186 deletions
diff --git a/core/.ui.dialogs.luadoc b/core/.ui.dialogs.luadoc
new file mode 100644
index 00000000..dc3e99e8
--- /dev/null
+++ b/core/.ui.dialogs.luadoc
@@ -0,0 +1,415 @@
+-- Copyright 2007-2013 Mitchell mitchell.att.foicica.com. See LICENSE.
+-- This is a DUMMY FILE used for making LuaDoc for built-in functions in the
+-- ui.dialogs table.
+
+--- Provides a set of interactive dialog prompts for user input.
+module('ui.dialogs')
+
+---
+-- Prompts the user with a generic message box dialog defined by dialog options
+-- table *options*, returning the index of the selected button or, if
+-- *options*.`string_output` is `true`, the selected button's label.
+-- If the dialog timed out, returns `0` or `"timeout"`. If the user canceled the
+-- dialog, returns `-1` or `"delete"`.
+-- @param options Table of key-value option pairs for the message box.
+--
+-- * `title`: The dialog's title text.
+-- * `text`: The dialog's main message text.
+-- * `informative_text`: The dialog's extra informative text.
+-- * `icon`: The dialog's GTK stock icon name. Examples are
+-- "gtk-dialog-error", "gtk-dialog-info", "gtk-dialog-question", and
+-- "gtk-dialog-warning". The dialog does not display an icon by default.
+-- * `icon_file`: The dialog's icon file path. This option has no effect when
+-- `icon` is set.
+-- * `button1`: The right-most button's label. The default value is
+-- `_L['_OK']`.
+-- * `button2`: The middle button's label.
+-- * `button3`: The left-most button's label. This option requires `button2`
+-- to be set.
+-- * `string_output`: Return the selected button's label or the dialog's exit
+-- status instead of the button's index or the exit code. The default value
+-- is `false`.
+-- * `width`: The pixel width of the dialog.
+-- * `height`: The pixel height of the dialog.
+-- * `float`: Show the dialog on top of all desktop windows. The default value
+-- is `false`.
+-- * `timeout`: The number of seconds the dialog waits for the user to select
+-- a button before timing out. Dialogs do not time out by default.
+-- @return selected button or exit code
+-- @usage ui.dialogs.msgbox{title = 'EOL Mode', text = 'Which EOL?',
+-- icon = 'gtk-dialog-question', button1 = 'CRLF', button2 = 'CR',
+-- button3 = 'LF'}
+function msgbox(options) end
+
+---
+-- Prompts the user with a generic message box dialog defined by dialog options
+-- table *options* and with localized "Ok" and "Cancel" buttons, returning the
+-- index of the selected button or, if *options*.`string_output` is `true`, the
+-- selected button's label.
+-- If the dialog timed out, returns `0` or `"timeout"`. If the user canceled the
+-- dialog, returns `-1` or `"delete"`.
+-- @param options Table of key-value option pairs for the message box.
+--
+-- * `title`: The dialog's title text.
+-- * `text`: The dialog's main message text.
+-- * `informative_text`: The dialog's extra informative text.
+-- * `icon`: The dialog's GTK stock icon name. Examples are
+-- "gtk-dialog-error", "gtk-dialog-info", "gtk-dialog-question", and
+-- "gtk-dialog-warning". The dialog does not display an icon by default.
+-- * `icon_file`: The dialog's icon file path. This option has no effect when
+-- `icon` is set.
+-- * `no_cancel`: Do not display the "Cancel" button. The default value is
+-- `false`.
+-- * `string_output`: Return the selected button's label or the dialog's exit
+-- status instead of the button's index or the exit code. The default value
+-- is `false`.
+-- * `width`: The pixel width of the dialog.
+-- * `height`: The pixel height of the dialog.
+-- * `float`: Show the dialog on top of all desktop windows. The default value
+-- is `false`.
+-- * `timeout`: The number of seconds the dialog waits for the user to select
+-- a button before timing out. Dialogs do not time out by default.
+-- @return selected button or exit code
+function ok_msgbox(options) end
+
+---
+-- Prompts the user with a generic message box dialog defined by dialog options
+-- table *options* and with localized "Yes", "No", and "Cancel" buttons,
+-- returning the index of the selected button or, if *options*.`string_output`
+-- is `true`, the selected button's label.
+-- If the dialog timed out, returns `0` or `"timeout"`. If the user canceled the
+-- dialog, returns `-1` or `"delete"`.
+-- @param options Table of key-value option pairs for the message box.
+--
+-- * `title`: The dialog's title text.
+-- * `text`: The dialog's main message text.
+-- * `informative_text`: The dialog's extra informative text.
+-- * `icon`: The dialog's GTK stock icon name. Examples are
+-- "gtk-dialog-error", "gtk-dialog-info", "gtk-dialog-question", and
+-- "gtk-dialog-warning". The dialog does not display an icon by default.
+-- * `icon_file`: The dialog's icon file path. This option has no effect when
+-- `icon` is set.
+-- * `no_cancel`: Do not display the "Cancel" button. The default value is
+-- `false`.
+-- * `string_output`: Return the selected button's label or the dialog's exit
+-- status instead of the button's index or the exit code. The default value
+-- is `false`.
+-- * `width`: The pixel width of the dialog.
+-- * `height`: The pixel height of the dialog.
+-- * `float`: Show the dialog on top of all desktop windows. The default value
+-- is `false`.
+-- * `timeout`: The number of seconds the dialog waits for the user to select
+-- a button before timing out. Dialogs do not time out by default.
+-- @return selected button or exit code
+function yesno_msgbox(options) end
+
+---
+-- Prompts the user with a one-line input box dialog defined by dialog options
+-- table *options*, returning the index of the selected button along with the
+-- input text or, if *options*.`string_output` is `true`, the selected button's
+-- label along with the input text.
+-- If the dialog timed out, returns `0` or `"timeout"`. If the user canceled the
+-- dialog, returns `-1` or `"delete"`.
+-- @param options Table of key-value option pairs for the input box.
+--
+-- * `title`: The dialog's title text.
+-- * `informative_text`: The dialog's main message text.
+-- * `text`: The dialog's initial input text.
+-- * `button1`: The right-most button's label. The default value is
+-- `_L['_OK']`.
+-- * `button2`: The middle button's label.
+-- * `button3`: The left-most button's label. This option requires `button2`
+-- to be set.
+-- * `string_output`: Return the selected button's label or the dialog's exit
+-- status instead of the button's index or the exit code. The default value
+-- is `false`.
+-- * `width`: The pixel width of the dialog.
+-- * `height`: The pixel height of the dialog.
+-- * `float`: Show the dialog on top of all desktop windows. The default value
+-- is `false`.
+-- * `timeout`: The number of seconds the dialog waits for the user to select
+-- a button before timing out. Dialogs do not time out by default.
+-- @return selected button or exit code, input text
+-- @usage ui.dialogs.inputbox{title = 'Goto Line', informative_text = 'Line:',
+-- text = '1'}
+function inputbox(options) end
+
+---
+-- Prompts the user with a one-line input box dialog defined by dialog options
+-- table *options* and with localized "Ok" and "Cancel" buttons, returning the
+-- index of the selected button along with the input text or, if
+-- *options*.`string_output` is `true`, the selected button's label along with
+-- the input text.
+-- If the dialog timed out, returns `0` or `"timeout"`. If the user canceled the
+-- dialog, returns `-1` or `"delete"`.
+-- @param options Table of key-value option pairs for the input box.
+--
+-- * `title`: The dialog's title text.
+-- * `informative_text`: The dialog's main message text.
+-- * `text`: The dialog's initial input text.
+-- * `no_cancel`: Do not display the "Cancel" button. The default value is
+-- `false`.
+-- * `string_output`: Return the selected button's label or the dialog's exit
+-- status instead of the button's index or the exit code. The default value
+-- is `false`.
+-- * `width`: The pixel width of the dialog.
+-- * `height`: The pixel height of the dialog.
+-- * `float`: Show the dialog on top of all desktop windows. The default value
+-- is `false`.
+-- * `timeout`: The number of seconds the dialog waits for the user to select
+-- a button before timing out. Dialogs do not time out by default.
+-- @return selected button or exit code, input text
+function standard_inputbux(options) end
+
+---
+-- Prompts the user with a one-line masked input box dialog defined by dialog
+-- options table *options*, returning the index of the selected button along
+-- with the input text or, if *options*.`string_output` is `true`, the selected
+-- button's label along with the input text.
+-- If the dialog timed out, returns `0` or `"timeout"`. If the user canceled the
+-- dialog, returns `-1` or `"delete"`.
+-- @param options Table of key-value option pairs for the input box.
+--
+-- * `title`: The dialog's title text.
+-- * `informative_text`: The dialog's main message text.
+-- * `text`: The dialog's initial input text.
+-- * `button1`: The right-most button's label. The default value is
+-- `_L['_OK']`.
+-- * `button2`: The middle button's label.
+-- * `button3`: The left-most button's label. This option requires `button2`
+-- to be set.
+-- * `string_output`: Return the selected button's label or the dialog's exit
+-- status instead of the button's index or the exit code. The default value
+-- is `false`.
+-- * `width`: The pixel width of the dialog.
+-- * `height`: The pixel height of the dialog.
+-- * `float`: Show the dialog on top of all desktop windows. The default value
+-- is `false`.
+-- * `timeout`: The number of seconds the dialog waits for the user to select
+-- a button before timing out. Dialogs do not time out by default.
+-- @return selected button or exit code, input text
+function secure_inputbox(options) end
+
+---
+-- Prompts the user with a one-line masked input box dialog defined by dialog
+-- options table *options* and with localized "Ok" and "Cancel" buttons,
+-- returning the index of the selected button along with the input text or, if
+-- *options*.`string_output` is `true`, the selected button's label along with
+-- the input text.
+-- If the dialog timed out, returns `0` or `"timeout"`. If the user canceled the
+-- dialog, returns `-1` or `"delete"`.
+-- @param options Table of key-value option pairs for the input box.
+--
+-- * `title`: The dialog's title text.
+-- * `informative_text`: The dialog's main message text.
+-- * `text`: The dialog's initial input text.
+-- * `no_cancel`: Do not display the "Cancel" button. The default value is
+-- `false`.
+-- * `string_output`: Return the selected button's label or the dialog's exit
+-- status instead of the button's index or the exit code. The default value
+-- is `false`.
+-- * `width`: The pixel width of the dialog.
+-- * `height`: The pixel height of the dialog.
+-- * `float`: Show the dialog on top of all desktop windows. The default value
+-- is `false`.
+-- * `timeout`: The number of seconds the dialog waits for the user to select
+-- a button before timing out. Dialogs do not time out by default.
+-- @return selected button or exit code, input text
+function secure_standard_inputbox(options) end
+
+---
+-- Prompts the user with a file selection dialog defined by dialog options
+-- table *options*, returning the string file selected or, if
+-- *options*.`select_multiple` is `true`, the list of files selected.
+-- If the user canceled the dialog, returns `nil`.
+-- @param options Table of key-value option pairs for the dialog.
+--
+-- * `title`: The dialog's title text.
+-- * `with_directory`: The initial filesystem directory to show.
+-- * `with_file`: The initially selected filename. This option requires
+-- `with_directory` to be set.
+-- * `with_extension`: The list of extensions selectable files must have.
+-- * `select_multiple`: Allow the user to select multiple files. The default
+-- value is `false`.
+-- * `select_only_directories`: Only allow the user to select directories. The
+-- default value is `false`.
+-- @return filename, list of filenames, or nil
+-- @usage ui.dialogs.fileselect{title = 'Open C File', with_directory = _HOME,
+-- with_extension = {'c', 'h'}, select_multiple = true}
+function fileselect(options) end
+
+---
+-- Prompts the user with a file save dialog defined by dialog options table
+-- *options*, returning the string file chosen.
+-- If the user canceled the dialog, returns `nil`.
+-- @param options Table of key-value option pairs for the dialog.
+--
+-- * `title`: The dialog's title text.
+-- * `with_directory`: The initial filesystem directory to show.
+-- * `with_file`: The initially chosen filename. This option requires
+-- `with_directory` to be set.
+-- * `with_extension`: The list of extensions selectable files must have.
+-- * `no_create_directories`: Prevent the user from creating new directories.
+-- The default value is `false`.
+-- @return filename or nil
+function filesave(options) end
+
+---
+-- Prompts the user with a multiple-line textbox dialog defined by dialog
+-- options table *options*, returning the index of the selected button along
+-- with the textbox text if *options*.`editable` is `true` or, if
+-- *options*.`string_output` is `true`, the selected button's label along with
+-- the textbox text if *options*.`editable` is also `true`.
+-- If the dialog timed out, returns `0` or `"timeout"`. If the user canceled the
+-- dialog, returns `-1` or `"delete"`.
+-- @param options Table of key-value option pairs for the dialog.
+--
+-- * `title`: The dialog's title text.
+-- * `informative_text`: The dialog's main message text.
+-- * `text`: The dialog's initial textbox text.
+-- * `text_from_file`: The filename whose contents are loaded into the
+-- textbox. This option has no effect when `text` is given.
+-- * `button1`: The right-most button's label. The default value is
+-- `_L['_OK']`.
+-- * `button2`: The middle button's label.
+-- * `button3`: The left-most button's label. This option requires `button2`
+-- to be set.
+-- * `editable`: Allows the user to edit the text in the textbox. The default
+-- value is `false`.
+-- * `focus_textbox`: Focus the textbox instead of the dialog buttons. The
+-- default value is `false`.
+-- * `scroll_to`: Where to scroll the textbox text when it is not all visible.
+-- The available values are `"top"` and `"bottom"`. The default value is
+-- `"top"`.
+-- * `selected`: Select all textbox text. The default value is `false`.
+-- * `monospaced_font`: Use a monospaced font in the textbox instead of a
+-- proportional one. The default value is `false`.
+-- * `string_output`: Return the selected button's label or the dialog's exit
+-- status instead of the button's index or the exit code. The default value
+-- is `false`.
+-- * `width`: The pixel width of the dialog.
+-- * `height`: The pixel height of the dialog.
+-- * `float`: Show the dialog on top of all desktop windows. The default value
+-- is `false`.
+-- * `timeout`: The number of seconds the dialog waits for the user to select
+-- a button before timing out. Dialogs do not time out by default.
+-- @return selected button or exit code, textbox text
+-- @usage ui.dialogs.textbox{title = 'License Agreement',
+-- informative_text = 'You agree to:', text_from_file = _HOME..'/LICENSE'}
+function textbox(options) end
+
+---
+-- Prompts the user with a drop down item selection dialog defined by dialog
+-- options table *options*, returning the index of the selected button along
+-- with the index of the selected item or, if *options*.`string_output` is
+-- `true`, the selected button's label along with the selected item's text.
+-- If *options*.`exit_onchange` closed the dialog, returns `4` along with either
+-- the index of the selected item or the selected item's text. If the dialog
+-- timed out, returns `0` or `"timeout"`. If the user canceled the dialog,
+-- returns `-1` or `"delete"`.
+-- @param options Table of key-value option pairs for the drop down dialog.
+--
+-- * `title`: The dialog's title text.
+-- * `text`: The dialog's main message text.
+-- * `items`: The list of string items to show in the drop down.
+-- * `button1`: The right-most button's label. The default value is
+-- `_L['_OK']`.
+-- * `button2`: The middle button's label.
+-- * `button3`: The left-most button's label. This option requires `button2`
+-- to be set.
+-- * `exit_onchange`: Close the dialog after selecting a new item. The default
+-- value is `false`.
+-- * `select`: The index of the initially selected list item. The default
+-- value is `1`.
+-- * `string_output`: Return the selected button's label or the dialog's exit
+-- status along with the selected item's text instead of the button's index
+-- or the exit code along with the item's index. The default value is
+-- `false`.
+-- * `width`: The pixel width of the dialog.
+-- * `height`: The pixel height of the dialog.
+-- * `float`: Show the dialog on top of all desktop windows. The default value
+-- is `false`.
+-- * `timeout`: The number of seconds the dialog waits for the user to select
+-- a button before timing out. Dialogs do not time out by default.
+-- @return selected button or exit code, selected item
+-- @usage ui.dialogs.dropdown{title = 'Select Encoding', width = 200,
+-- items = io.encodings, string_output = true}
+function dropdown(options) end
+
+---
+-- Prompts the user with a drop down item selection dialog defined by dialog
+-- options table *options* and with localized "Ok" and "Cancel" buttons,
+-- returning the index of the selected button along with the index of the
+-- selected item or, if *options*.`string_output` is `true`, the selected
+-- button's label along with the selected item's text.
+-- If *options*.`exit_onchange` closed the dialog, returns `4` along with either
+-- the index of the selected item or the selected item's text. If the dialog
+-- timed out, returns `0` or `"timeout"`. If the user canceled the dialog,
+-- returns `-1` or `"delete"`.
+-- @param options Table of key-value option pairs for the drop down dialog.
+--
+-- * `title`: The dialog's title text.
+-- * `text`: The dialog's main message text.
+-- * `items`: The list of string items to show in the drop down.
+-- * `no_cancel`: Do not display the "Cancel" button. The default value is
+-- `false`.
+-- * `exit_onchange`: Close the dialog after selecting a new item. The default
+-- value is `false`.
+-- * `select`: The index of the initially selected list item. The default
+-- value is `1`.
+-- * `string_output`: Return the selected button's label or the dialog's exit
+-- status along with the selected item's text instead of the button's index
+-- or the exit code along with the item's index. The default value is
+-- `false`.
+-- * `width`: The pixel width of the dialog.
+-- * `height`: The pixel height of the dialog.
+-- * `float`: Show the dialog on top of all desktop windows. The default value
+-- is `false`.
+-- * `timeout`: The number of seconds the dialog waits for the user to select
+-- a button before timing out. Dialogs do not time out by default.
+-- @return selected button or exit code, selected item
+function standard_dropdown(options) end
+
+---
+-- Prompts the user with a filtered list item selection dialog defined by dialog
+-- options table *options*, returning the index of the selected button along
+-- with the index(es) of the selected item(s) (depending on whether or not
+-- *options*.`select_multiple` is `true`) or, if *options*.`string_output` is
+-- `true`, the selected button's label along with the selected item's or items'
+-- text.
+-- If the dialog timed out, returns `0` or `"timeout"`. If the user canceled the
+-- dialog, returns `-1` or `"delete"`.
+-- Spaces in the filter text are treated as wildcards.
+-- @param options Table of key-value option pairs for the drop down dialog.
+--
+-- * `title`: The dialog's title text.
+-- * `text`: The dialog's main message text.
+-- * `columns`: The list of string column names for list rows.
+-- * `items`: The list of string items to show in the drop down.
+-- * `button1`: The right-most button's label. The default value is
+-- `_L['_OK']`.
+-- * `button2`: The middle button's label.
+-- * `button3`: The left-most button's label. This option requires `button2`
+-- to be set.
+-- * `select_multiple`: Allow the user to select multiple items. The default
+-- value is `false`.
+-- * `search_column`: The column number to filter the input text against. The
+-- default value is `1`. This option requires `columns` to be set and
+-- contain at least *n* column names.
+-- * `output_column`: The column number to use for `string_output`. The
+-- default value is `1`. This option requires `columns` to be set and
+-- contain at least *n* column names.
+-- * `string_output`: Return the selected button's label or the dialog's exit
+-- status along with the selected item's text instead of the button's index
+-- or the exit code along with the item's index. The default value is
+-- `false`.
+-- * `width`: The pixel width of the dialog.
+-- * `height`: The pixel height of the dialog.
+-- * `float`: Show the dialog on top of all desktop windows. The default value
+-- is `false`.
+-- * `timeout`: The number of seconds the dialog waits for the user to select
+-- a button before timing out. Dialogs do not time out by default.
+-- @return selected button or exit code, selected item or list of selected items
+-- @usage ui.dialogs.filteredlist{title = 'Title', columns = {'Foo', 'Bar'},
+-- items = {'a', 'b', 'c', 'd'}}
+function filteredlist(options) end
diff --git a/core/file_io.lua b/core/file_io.lua
index ce3bf8ec..09533196 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -91,22 +91,22 @@ io.boms = {
io.encodings = {'UTF-8', 'ASCII', 'ISO-8859-1', 'MacRoman'}
---
--- Opens *filenames*, a "\n" delimited string of filenames, or user-selected
--- files.
+-- Opens *filenames*, a string filename, table of filenames, or user-selected
+-- filenames.
-- Emits a `FILE_OPENED` event.
--- @param filenames Optional string list filenames to open. If `nil`, the user
--- is prompted with a fileselect dialog.
+-- @param filenames Optional string filename or table of filenames to open. If
+-- `nil`, the user is prompted with a fileselect dialog.
-- @see _G.events
-- @name open_file
function io.open_file(filenames)
- filenames = filenames or
- ui.dialog('fileselect',
- '--title', _L['Open'],
- '--select-multiple',
- '--with-directory',
- (buffer.filename or ''):match('^.+[/\\]') or '')
- for filename in filenames:gmatch('[^\n]+') do
- filename = filename:gsub('^file://', '')
+ if type(filenames) == 'string' then filenames = {filenames} end
+ filenames = filenames or ui.dialogs.fileselect{
+ title = _L['Open'], select_multiple = true,
+ with_directory = (buffer.filename or ''):match('^.+[/\\]')
+ }
+ if not filenames then return end
+ for i = 1, #filenames do
+ local filename = filenames[i]:gsub('^file://', '')
if WIN32 then filename = filename:gsub('/', '\\') end
for i, buffer in ipairs(_BUFFERS) do
if filename == buffer.filename then view:goto_buffer(i) return end
@@ -235,14 +235,12 @@ end
-- user is prompted for one.
-- @name save_file_as
function io.save_file_as(filename)
- local dir = (buffer.filename or ''):match('^.+[/\\]') or ''
- local name = (buffer.filename or ''):match('[^/\\]+$') or ''
- filename = filename or ui.dialog('filesave',
- '--title', _L['Save'],
- '--with-directory', dir,
- '--with-file', name:iconv('UTF-8', _CHARSET),
- '--no-newline')
- if filename == '' then return end
+ local dir, name = (buffer.filename or ''):match('^(.-[/\\]?)([^/\\]*)$')
+ filename = filename or ui.dialogs.filesave{
+ title = _L['Save'], with_directory = dir,
+ with_file = name:iconv('UTF-8', _CHARSET)
+ }
+ if not filename then return end
buffer.filename = filename
io.save_file()
events.emit(events.FILE_SAVED_AS, filename)
@@ -268,15 +266,13 @@ end
-- @name close_buffer
function io.close_buffer()
local filename = buffer.filename or buffer._type or _L['Untitled']
- if buffer.dirty and ui.dialog('msgbox',
- '--title', _L['Close without saving?'],
- '--text', _L['There are unsaved changes in'],
- '--informative-text',
- filename:iconv('UTF-8', _CHARSET),
- '--icon', 'gtk-dialog-question',
- '--button1', _L['_Cancel'],
- '--button2', _L['Close _without saving'],
- '--no-newline') ~= '2' then
+ if buffer.dirty and ui.dialogs.msgbox{
+ title = _L['Close without saving?'],
+ text = _L['There are unsaved changes in'],
+ informative_text = filename:iconv('UTF-8', _CHARSET),
+ icon = 'gtk-dialog-question', button1 = _L['_Cancel'],
+ button2 = _L['Close _without saving']
+ } ~= 2 then
return nil -- returning false can cause unwanted key command propagation
end
buffer:delete()
@@ -306,19 +302,15 @@ local function update_modified_file()
if not mod_time or not buffer.mod_time then return end
if buffer.mod_time < mod_time then
buffer.mod_time = mod_time
- if ui.dialog('yesno-msgbox',
- '--title', _L['Reload?'],
- '--text', _L['Reload modified file?'],
- '--informative-text',
- ('"%s"\n%s'):format(buffer.filename:iconv('UTF-8', _CHARSET),
- _L['has been modified. Reload it?']),
- '--icon', 'gtk-dialog-question',
- '--button1', _L['_Yes'],
- '--button2', _L['_No'],
- '--no-cancel',
- '--no-newline') == '1' then
- io.reload_file()
- end
+ local msg = string.format('"%s"\n%s',
+ buffer.filename:iconv('UTF-8', _CHARSET),
+ _L['has been modified. Reload it?'])
+ local button = ui.dialogs.msgbox{
+ title = _L['Reload?'], text = _L['Reload modified file?'],
+ informative_text = msg, icon = 'gtk-dialog-question',
+ button1 = _L['_Yes'], button2 = _L['_No']
+ }
+ if button == 1 then io.reload_file() end
end
end
events_connect(events.BUFFER_AFTER_SWITCH, update_modified_file)
@@ -342,14 +334,16 @@ function io.open_recent_file()
for _, filename in ipairs(io.recent_files) do
utf8_filenames[#utf8_filenames + 1] = filename:iconv('UTF-8', _CHARSET)
end
- local i = ui.filteredlist(_L['Open'], _L['File'], utf8_filenames, true,
- CURSES and {'--width', ui.size[1] - 2} or '')
- if i then io.open_file(io.recent_files[i + 1]) end
+ local button, i = ui.dialogs.filteredlist{
+ title = _L['Open'], columns = _L['File'], items = utf8_filenames,
+ width = CURSES and ui.size[1] - 2 or nil
+ }
+ if button == 1 and i then io.open_file(io.recent_files[i]) end
end
---
--- Quickly open files from *paths*, a "\n" delimited string of directory paths,
--- using a filtered list dialog.
+-- Quickly open files from *paths*, a string directory path or table of
+-- directory paths, using a filtered list dialog.
-- Files shown in the dialog do not match any pattern in string or table
-- *filter*, and, unless *exclude_FILTER* is `true`, `lfs.FILTER` as well. A
-- filter table contains Lua patterns that match filenames to exclude, with
@@ -358,13 +352,14 @@ end
-- pattern that follows. Use a table of raw file extensions assigned to an
-- `extensions` key for fast filtering by extension. The number of files in the
-- list is capped at `SNAPOPEN_MAX`.
--- @param paths String list of directory paths to search.
+-- @param paths String directory path or table of directory paths to search.
-- @param filter Optional filter for files and folders to exclude.
-- @param exclude_FILTER Optional flag indicating whether or not to exclude the
-- default filter `lfs.FILTER` in the search. If `false`, adds `lfs.FILTER` to
-- *filter*.
-- The default value is `false` to include the default filter.
--- @param ... Optional additional parameters to pass to `ui.dialog()`.
+-- @param opts Optional additional options to pass to
+-- `ui.dialogs.filteredlist()`.
-- @usage io.snapopen(buffer.filename:match('^.+/')) -- list all files in the
-- current file's directory, subject to the default filter
-- @usage io.snapopen('/project', '!%.lua$') -- list all Lua files in a project
@@ -374,27 +369,32 @@ end
-- @see lfs.FILTER
-- @see SNAPOPEN_MAX
-- @name snapopen
-function io.snapopen(paths, filter, exclude_FILTER, ...)
+function io.snapopen(paths, filter, exclude_FILTER, opts)
+ if type(paths) == 'string' then paths = {paths} end
local utf8_list = {}
- for path in paths:gmatch('[^\n]+') do
- lfs.dir_foreach(path, function(file)
+ for i = 1, #paths do
+ lfs.dir_foreach(paths[i], function(file)
if #utf8_list >= io.SNAPOPEN_MAX then return false end
file = file:gsub('^%.[/\\]', ''):iconv('UTF-8', _CHARSET)
utf8_list[#utf8_list + 1] = file
end, filter, exclude_FILTER)
end
if #utf8_list >= io.SNAPOPEN_MAX then
- ui.dialog('ok-msgbox',
- '--title', _L['File Limit Exceeded'],
- '--text',
- string.format('%d %s %d', io.SNAPOPEN_MAX,
- _L['files or more were found. Showing the first'],
- io.SNAPOPEN_MAX),
- '--icon', 'gtk-dialog-info',
- '--button1', _L['_OK'])
+ local msg = string.format('%d %s %d', io.SNAPOPEN_MAX,
+ _L['files or more were found. Showing the first'],
+ io.SNAPOPEN_MAX)
+ ui.dialogs.msgbox{
+ title = _L['File Limit Exceeded'], text = msg, icon = 'gtk-dialog-info'
+ }
end
- local width = CURSES and {'--width', ui.size[1] - 2} or ''
- local files = ui.filteredlist(_L['Open'], _L['File'], utf8_list, false,
- '--select-multiple', width, ...) or ''
- io.open_file(files:iconv(_CHARSET, 'UTF-8'))
+ local options = {
+ title = _L['Open'], columns = _L['File'], items = utf8_list,
+ button1 = _L['_OK'], button2 = _L['_Cancel'], select_multiple = true,
+ string_output = true, width = CURSES and ui.size[1] - 2 or nil
+ }
+ if opts then for k, v in pairs(opts) do options[k] = v end end
+ local button, files = ui.dialogs.filteredlist(options)
+ if button ~= _L['_OK'] or not files then return end
+ for i = 1, #files do files[i] = files[i]:iconv(_CHARSET, 'UTF-8') end
+ io.open_file(files)
end
diff --git a/core/ui.lua b/core/ui.lua
index 8149b9d7..f1ed2e30 100644
--- a/core/ui.lua
+++ b/core/ui.lua
@@ -70,43 +70,49 @@ function ui._print(buffer_type, ...) pcall(_print, buffer_type, ...) end
-- @name print
function ui.print(...) ui._print(_L['[Message Buffer]'], ...) end
----
--- Convenience function for `ui.dialog('filteredlist', ...)` with "Ok" and
--- "Cancel" buttons that returns the text or index of the selection depending on
--- the boolean value of *int_return*.
--- *title* is the title of the dialog, *columns* is a list of column names, and
--- *items* is a list of items to show.
--- @param title The title for the filtered list dialog.
--- @param columns A column name or list of column names.
--- @param items An item or list of items.
--- @param int_return Optional flag indicating whether to return the integer
--- index of the selected item in the filtered list or the string selected
--- item. A `true` value is not compatible with the `'--select-multiple'`
--- option. The default value is `false`.
--- @param ... Optional additional parameters to pass to `ui.dialog()`.
--- @return Either a string or integer on success; `nil` otherwise. In strings,
--- multiple items are separated by newlines.
--- @usage ui.filteredlist('Title', 'Foo', {'Bar', 'Baz'})
--- @usage ui.filteredlist('Title', {'Foo', 'Bar'}, {'a', 'b', 'c', 'd'}, false,
--- '--output-column', '2')
--- @see dialog
--- @name filteredlist
-function ui.filteredlist(title, columns, items, int_return, ...)
- local out = ui.dialog('filteredlist',
- '--title', title,
- '--button1', _L['_OK'],
- '--button2', _L['_Cancel'],
- '--no-newline',
- int_return and '' or '--string-output',
- '--columns', columns,
- '--items', items,
- ...)
- local patt = int_return and '^(%-?%d+)\n(%d+)$' or '^([^\n]+)\n(.+)$'
- local response, value = out:match(patt)
- if response == (int_return and '1' or _L['_OK']) then
- return not int_return and value or tonumber(value)
+-- Documentation is in core/.ui.dialogs.luadoc.
+ui.dialogs = setmetatable({}, {__index = function(t, k)
+ -- Wrapper for `ui.dialog(k)`, transforming the given table of arguments into
+ -- a set of command line arguments and transforming the resulting standard
+ -- output into Lua objects.
+ -- @param options Table of key-value command line options for gtdialog.
+ -- @return Lua objects depending on the dialog kind
+ return function(options)
+ if not options.button1 then options.button1 = _L['_OK'] end
+ if options.select then options.select = options.select - 1 end
+ -- Transform key-value pairs into command line arguments.
+ local args = {}
+ for option, value in pairs(options) do
+ if value then
+ args[#args + 1] = '--'..option:gsub('_', '-')
+ if value ~= true then args[#args + 1] = value end
+ end
+ end
+ -- Call gtdialog, stripping any trailing newline in the standard output.
+ local result = ui.dialog(k:gsub('_', '-'), table.unpack(args))
+ result = result:match('^(.-)\n?$')
+ -- Depending on the dialog type, transform the result into Lua objects.
+ if k == 'fileselect' or k == 'filesave' then
+ if result == '' then return nil end
+ if k == 'filesave' or not options.select_multiple then return result end
+ local files = {}
+ for file in result:gmatch('[^\n]+') do files[#files + 1] = file end
+ return files
+ elseif k == 'filteredlist' then
+ local button, value = result:match('^([^\n]+)\n?(.*)$')
+ if not options.string_output then button = tonumber(button) end
+ local items = {}
+ for item in value:gmatch('[^\n]+') do
+ items[#items + 1] = options.string_output and item or tonumber(item) + 1
+ end
+ return button, options.select_multiple and items or items[1]
+ elseif not options.string_output then
+ local i, value = result:match('^(%-?%d+)\n?(.*)$')
+ return tonumber(i), k ~= 'dropdown' and value or tonumber(value) + 1
+ end
+ return result:match('([^\n]+)\n(.*)$')
end
-end
+end})
---
-- Prompts the user to select a buffer to switch to.
@@ -120,9 +126,11 @@ function ui.switch_buffer()
items[#items + 1] = (buffer.dirty and '*' or '')..basename
items[#items + 1] = filename
end
- local i = ui.filteredlist(_L['Switch Buffers'], columns, items, true,
- CURSES and {'--width', ui.size[1] - 2} or '--')
- if i then view:goto_buffer(i + 1) end
+ local button, i = ui.dialogs.filteredlist{
+ title = _L['Switch Buffers'], columns = columns, items = items,
+ width = CURSES and ui.size[1] - 2 or nil
+ }
+ if button == 1 and i then view:goto_buffer(i) end
end
---
@@ -357,15 +365,12 @@ events_connect(events.QUIT, function()
list[#list + 1] = filename:iconv('UTF-8', _CHARSET)
end
end
- return #list < 1 or ui.dialog('msgbox',
- '--title', _L['Quit without saving?'],
- '--text',
- _L['The following buffers are unsaved:'],
- '--informative-text', table.concat(list, '\n'),
- '--icon', 'gtk-dialog-question',
- '--button1', _L['_Cancel'],
- '--button2', _L['Quit _without saving'],
- '--no-newline') == '2'
+ return #list < 1 or ui.dialogs.msgbox{
+ title = _L['Quit without saving?'],
+ text = _L['The following buffers are unsaved:'],
+ informative_text = table.concat(list, '\n'), icon = 'gtk-dialog-question',
+ button1 = _L['_Cancel'], button2 = _L['Quit _without saving']
+ } == 2
end)
events_connect(events.ERROR, ui.print)
@@ -388,14 +393,16 @@ local size
The functions below are Lua C functions.
---
--- Displays a [gtdialog][] of kind *kind* with the given string arguments to
--- pass to the dialog and returns a formatted string of the dialog's output.
+-- Low-level function for prompting the user with a [gtdialog][]s of kind *kind*
+-- with the given string and table arguments, returning a formatted string of
+-- the dialog's output.
+-- You probably want to use the higher-level functions in the [`ui.dialogs`][]
+-- module.
-- Table arguments containing strings are allowed and expanded in place. This is
-- useful for filtered list dialogs with many items.
--- For more information on gtdialog, see [http://foicica.com/gtdialog][].
--
-- [gtdialog]: http://foicica.com/gtdialog/02_Usage.html
--- [http://foicica.com/gtdialog]: http://foicica.com/gtdialog
+-- [`ui.dialogs`]: ui.dialogs.html
-- @param kind The kind of gtdialog.
-- @param ... Parameters to the gtdialog.
-- @return string gtdialog result.
diff --git a/doc/14_Appendix.md b/doc/14_Appendix.md
index d5a83c1d..06a1bd08 100644
--- a/doc/14_Appendix.md
+++ b/doc/14_Appendix.md
@@ -202,8 +202,12 @@ docstatusbar\_text |Renamed |[bufstatusbar\_text][]
N/A |New |[maximized][]
find.goto\_file\_in\_list() |Renamed |find.[goto\_file\_found()][]
select\_theme |Removed |N/A
+N/A |New |[dialogs][]
+filteredlist |Removed |N/A
**io** | |
try\_encodings |Renamed |[encodings][]
+open\_file(string) |Changed |[open\_file][](string or table)
+snapopen(string, ...) |Changed |[snapopen][](string or table, ...)
save\_all() |Renamed |[save\_all\_files()][]
close\_all() |Renamed |[close\_all\_buffers()][]
@@ -246,7 +250,10 @@ close\_all() |Renamed |[close\_all\_buffers()][]
[bufstatusbar\_text]: api/ui.html#bufstatusbar_text
[maximized]: api/ui.html#maximized
[goto\_file\_found()]: api/ui.find.html#goto_file_found
+[dialogs]: api/ui.dialogs.html
[encodings]: api/io.html#encodings
+[open\_file]: api/io.html#open_file
+[snapopen]: api/io.html#snapopen
[save\_all\_files()]: api/io.html#save_all_files
[close\_all\_buffers()]: api/io.html#close_all_buffers
[`buffer.marker_back`]: api/buffer.html#marker_back
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.