how to quick switch between window a[pre] b[current] #182
aabbcceedddd
started this conversation in
General
Replies: 1 comment 1 reply
|
You can use this script by @visixx like this in your config: Store the script in local args, state = ...
local scroll = require("scroll")
local function value_idx(tab, val)
for index, value in ipairs(tab) do
if value == val then
return index
end
end
return -1
end
local function on_focus(view, _)
local focus_list = scroll.state_get_value(state, "focus_list")
if focus_list == nil then
focus_list = {}
end
local focus_idx = value_idx(focus_list, view)
if focus_idx > 0 then
table.remove(focus_list, focus_idx)
end
table.insert(focus_list, 1, view)
scroll.state_set_value(state, "focus_list", focus_list)
end
local function on_destroy(view, _)
local focus_list = scroll.state_get_value(state, "focus_list")
if focus_list == nil then
return
end
local focus_idx = value_idx(focus_list, view)
if focus_idx == -1 then
return
end
table.remove(focus_list, focus_idx)
scroll.state_set_value(state, "focus_list", focus_list)
end
local function switch_to_prev()
local focus_list = scroll.state_get_value(state, "focus_list")
if #focus_list < 2 then
return
end
local prev = focus_list[2]
local container = scroll.view_get_container(prev)
scroll.container_set_focus(container)
end
if args[1] == "init" then
scroll.add_callback("view_focus", on_focus, nil)
scroll.add_callback("view_unmap", on_destroy, nil)
elseif args[1] == "prev" then
switch_to_prev()
endEdit your config to initialize the script when starting scroll and assign |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
dear developer
I want to switch between the two most recent windows, A and B, using Alt+Tab, but I failed. Could you please give me some guidance? Thank you.
All reactions