diff options
| author | ailurux <ailuruxx@gmail.com> | 2025-01-31 12:25:05 +1100 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2025-01-31 12:25:05 +1100 |
| commit | 5e3cfc8f3db18fac8e8962259f6521550add4139 (patch) | |
| tree | 774003df582f6986f4354e86223fcdaa52cf966e /lua | |
| parent | 001fc52ec87bf04b5fb5a262d310738e5dd3682a (diff) | |
| parent | abf13d4ec112fc430b9fadea69455aa45d4e3cd6 (diff) | |
| download | tangara-fw-5e3cfc8f3db18fac8e8962259f6521550add4139.tar.gz | |
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/browser.lua | 1 | ||||
| -rw-r--r-- | lua/file_browser.lua | 1 | ||||
| -rw-r--r-- | lua/widgets.lua | 8 |
3 files changed, 8 insertions, 2 deletions
diff --git a/lua/browser.lua b/lua/browser.lua index 2a024fc5..264db0c5 100644 --- a/lua/browser.lua +++ b/lua/browser.lua @@ -118,6 +118,7 @@ return screen:new { end widgets.InfiniteList(self.root, self.iterator, { + focus_first_item = true, get_icon = get_icon_func, callback = function(item) return function() diff --git a/lua/file_browser.lua b/lua/file_browser.lua index a85c2ba2..98261d55 100644 --- a/lua/file_browser.lua +++ b/lua/file_browser.lua @@ -59,6 +59,7 @@ return screen:new { end widgets.InfiniteList(self.root, self.iterator, { + focus_first_item = true, callback = function(item) return function() local is_dir = item:is_directory() diff --git a/lua/widgets.lua b/lua/widgets.lua index 5e18809b..0aac7705 100644 --- a/lua/widgets.lua +++ b/lua/widgets.lua @@ -306,10 +306,11 @@ function widgets.InfiniteList(parent, iterator, opts) fwd_iterator:prev() end - local function add_item(item, index) + local function add_item(item, index, item_opts) if not item then return end + item_opts = item_opts or {} local this_item = index local add_to_top = false if this_item < first_index then @@ -325,6 +326,9 @@ function widgets.InfiniteList(parent, iterator, opts) if add_to_top then btn:move_to_index(0) end + if item_opts.focus then + btn:focus() + end -- opts.callback should take an item and return a function matching the arg of onClicked if opts.callback then btn:onClicked(opts.callback(item)) @@ -361,7 +365,7 @@ function widgets.InfiniteList(parent, iterator, opts) if not val then break end - add_item(val, idx) + add_item(val, idx, { focus = (opts.focus_first_item and idx == 0) }) end return infinite_list |
