aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/file_io.lua3
-rw-r--r--core/ui.lua6
-rw-r--r--modules/textadept/menu.lua2
-rw-r--r--modules/textadept/snippets.lua2
-rw-r--r--test/test.lua2
5 files changed, 8 insertions, 7 deletions
diff --git a/core/file_io.lua b/core/file_io.lua
index d0c0fb8f..ad9649d0 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -337,8 +337,7 @@ function io.open_recent_file()
utf8_list[#utf8_list + 1] = io.recent_files[i]:iconv('UTF-8', _CHARSET)
end
local button, i = ui.dialogs.filteredlist{
- title = _L['Open File'], columns = _L['Filename'], items = utf8_list,
- width = CURSES and ui.size[1] - 2 or nil
+ title = _L['Open File'], columns = _L['Filename'], items = utf8_list
}
if button == 1 and i then io.open_file(io.recent_files[i]) end
end
diff --git a/core/ui.lua b/core/ui.lua
index aec0725f..5adbc758 100644
--- a/core/ui.lua
+++ b/core/ui.lua
@@ -102,6 +102,9 @@ ui.dialogs = setmetatable({}, {__index = function(_, k)
-- @return Lua objects depending on the dialog kind
return function(options)
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)
+ end
-- Transform key-value pairs into command line arguments.
local args = {}
for option, value in pairs(options) do
@@ -220,8 +223,7 @@ function ui.switch_buffer(zorder)
utf8_list[#utf8_list + 1] = filename
end
local button, i = ui.dialogs.filteredlist{
- title = _L['Switch Buffers'], columns = columns, items = utf8_list,
- width = CURSES and ui.size[1] - 2 or nil
+ title = _L['Switch Buffers'], columns = columns, items = utf8_list
}
if button == 1 and i then
view:goto_buffer(buffers[not zorder and i or i + 1])
diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua
index df800e02..02ae948b 100644
--- a/modules/textadept/menu.lua
+++ b/modules/textadept/menu.lua
@@ -565,7 +565,7 @@ function M.select_command()
build_command_tables(getmetatable(M.menubar).menu)
local button, i = ui.dialogs.filteredlist{
title = _L['Run Command'], columns = {_L['Command'], _L['Key Binding']},
- items = items, width = CURSES and ui.size[1] - 2 or nil
+ items = items
}
if button == 1 and i then events.emit(events.MENU_CLICKED, i) end
end
diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua
index 9e002348..9e1cc9dd 100644
--- a/modules/textadept/snippets.lua
+++ b/modules/textadept/snippets.lua
@@ -636,7 +636,7 @@ function M.select()
end
local button, i = ui.dialogs.filteredlist{
title = _L['Select Snippet'], columns = {_L['Trigger'], _L['Snippet Text']},
- items = items, width = CURSES and ui.size[1] - 2 or nil
+ items = items
}
if button == 1 and i then M.insert(items[i * 2]) end
end
diff --git a/test/test.lua b/test/test.lua
index fc0d9e27..ba7354bd 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -794,7 +794,7 @@ function test_ui_dialogs_filteredlist_interactive()
items = {'foo', 'foobar', 'bar', 'barbaz', 'baz', 'bazfoo'},
search_column = 2, text = 'baz', output_column = 2, string_output = true,
select_multiple = true, button1 = _L['OK'], button2 = _L['Cancel'],
- button3 = 'Other'
+ button3 = 'Other', width = ui.size[1] / 2
}
assert_equal(text, {'barbaz'})
end