Skip to content

Commit 18d43b2

Browse files
committed
feat(winbar): Added Enable & Disable functions
1 parent 8065320 commit 18d43b2

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

lua/bars/winbar.lua

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,8 @@ winbar.clean = function ()
826826
---|fE
827827
end
828828

829+
----------------------------------------------------------------------
830+
829831
--- Toggles state of given window.
830832
---@param window integer
831833
winbar.toggle = function (window)
@@ -851,6 +853,52 @@ winbar.Toggle = function ()
851853
winbar.state.enable = not winbar.state.enable;
852854
end
853855

856+
----------------------------------------------------------------------
857+
858+
--- Enables winbar for `window`.
859+
---@param window integer
860+
winbar.enable = function (window)
861+
if type(window) ~= "number" or winbar.state.attached_windows[window] == nil then
862+
return;
863+
end
864+
865+
winbar.attach(window);
866+
end
867+
868+
--- Enables *all* attached windows.
869+
winbar.Enable = function ()
870+
winbar.state.enable = true;
871+
872+
for window, state in pairs(winbar.state.attached_windows) do
873+
if state ~= true then
874+
winbar.attach(window);
875+
end
876+
end
877+
end
878+
879+
--- Disables winbar for `window`.
880+
---@param window integer
881+
winbar.disable = function (window)
882+
if type(window) ~= "number" or winbar.state.attached_windows[window] == nil then
883+
return;
884+
end
885+
886+
winbar.detach(window);
887+
end
888+
889+
--- Disables *all* attached windows.
890+
winbar.Disable = function ()
891+
for window, state in pairs(winbar.state.attached_windows) do
892+
if state ~= false then
893+
winbar.detach(window);
894+
end
895+
end
896+
897+
winbar.state.enable = false;
898+
end
899+
900+
----------------------------------------------------------------------
901+
854902
--- Sets up the winbar module.
855903
---@param config winbar.config | nil
856904
winbar.setup = function (config)

0 commit comments

Comments
 (0)