aboutsummaryrefslogtreecommitdiff
path: root/core/ui.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2020-03-18 22:43:27 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2020-03-18 22:43:27 -0400
commit612c43f3b1c0351fe2601ed73024d39bacd4ed52 (patch)
treee8b422252d6ee8e9ed9790ab0b7732049f992c7b /core/ui.lua
parent9b02a146612e1a2e15b7bb8d2a5185f1d3925572 (diff)
downloadtextadept-612c43f3b1c0351fe2601ed73024d39bacd4ed52.tar.gz
textadept-612c43f3b1c0351fe2601ed73024d39bacd4ed52.zip
Added `ui.dialogs.progressbar()` and utilize it with Find in Files.
Diffstat (limited to 'core/ui.lua')
-rw-r--r--core/ui.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/ui.lua b/core/ui.lua
index 5adbc758..21217609 100644
--- a/core/ui.lua
+++ b/core/ui.lua
@@ -99,8 +99,9 @@ ui.dialogs = setmetatable({}, {__index = function(_, k)
-- 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.
+ -- @param f Work function for progressbar dialogs.
-- @return Lua objects depending on the dialog kind
- return function(options)
+ return function(options, f)
if not options.button1 then options.button1 = _L['OK'] end
if k == 'filteredlist' and not options.width then
options.width = ui.size[1] - 2 * (CURSES and 1 or 100)
@@ -129,6 +130,9 @@ ui.dialogs = setmetatable({}, {__index = function(_, k)
if type(value) ~= 'boolean' then args[#args + 1] = value end
end
end
+ if k == 'progressbar' then
+ args[#args + 1] = assert_type(f, 'function', 2)
+ end
-- Call gtdialog, stripping any trailing newline in the standard output.
local result = ui.dialog(
k:gsub('_', '-'), table.unpack(args)):match('^(.-)\n?$')
@@ -161,7 +165,7 @@ ui.dialogs = setmetatable({}, {__index = function(_, k)
local r, g, b = result:match('^#(%x%x)(%x%x)(%x%x)$')
local bgr = r and g and b and string.format('0x%s%s%s', b, g, r) or nil
return tonumber(bgr)
- elseif k == 'fontselect' then
+ elseif k == 'fontselect' or k == 'progressbar' then
return result ~= '' and result or nil
elseif not options.string_output then
local i, value = result:match('^(%-?%d+)\n?(.*)$')