aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2023-01-08 05:32:10 -0400
committerjgmdev <jgmdev@gmail.com>2023-01-08 05:32:10 -0400
commit3dbe2e1b10a5911e858da9442bba099b794b817b (patch)
treed0bc778ab692dba937a3056f8ac7eb0e586fb41b /plugins
parent07d33a93090b5c8ae40141f1b80ae63b5110d1c7 (diff)
downloadlite-xl-plugins-3dbe2e1b10a5911e858da9442bba099b794b817b.tar.gz
lite-xl-plugins-3dbe2e1b10a5911e858da9442bba099b794b817b.zip
settings: added ability to filter keybinds
Diffstat (limited to 'plugins')
-rw-r--r--plugins/settings.lua27
1 files changed, 24 insertions, 3 deletions
diff --git a/plugins/settings.lua b/plugins/settings.lua
index ec722bc..d6c524e 100644
--- a/plugins/settings.lua
+++ b/plugins/settings.lua
@@ -1624,11 +1624,13 @@ function Settings:load_keymap_settings()
end
table.sort(ordered)
+ ---@type widget.textbox
+ local textbox = TextBox(self.keybinds, "", "filter bindings...")
+
---@type widget.listbox
local listbox = ListBox(self.keybinds)
listbox.border.width = 0
- listbox:enable_expand(true)
listbox:add_column("Command")
listbox:add_column("Bindings")
@@ -1653,8 +1655,15 @@ function Settings:load_keymap_settings()
}, name)
end
- function listbox:on_row_click(idx, data)
- if not keymap_dialog:is_visible() then
+ function textbox:on_change(value)
+ listbox:filter(value)
+ end
+
+ function listbox:on_mouse_pressed(button, x, y, clicks)
+ listbox.super.on_mouse_pressed(self, button, x, y, clicks)
+ local idx = listbox:get_selected()
+ local data = listbox:get_row_data(idx)
+ if clicks == 2 and not keymap_dialog:is_visible() then
local bindings = { keymap.get_binding(data) }
keymap_dialog:set_bindings(bindings)
keymap_dialog.row_id = idx
@@ -1663,6 +1672,14 @@ function Settings:load_keymap_settings()
keymap_dialog:show()
end
end
+
+ ---@param self widget
+ function self.keybinds:update_positions()
+ textbox:set_position(0, 0)
+ textbox:set_size(self:get_width() - self.border.width * 2)
+ listbox:set_position(0, textbox:get_bottom())
+ listbox:set_size(self:get_width() - self.border.width * 2, self:get_height() - textbox:get_height())
+ end
end
function Settings:setup_about()
@@ -1819,6 +1836,10 @@ function Settings:update()
end
end
+ if self.keybinds:is_visible() then
+ self.keybinds:update_positions()
+ end
+
if self.about:is_visible() then
self.about:update_positions()
end