repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
wezterm/bugabinga/presentation_mode.lua
Raw-- stolen from https://github.com/xarvex/presentation.wez/blob/main/plugin/init.lua
local state_by_window = {}
local function deep_copy( value )
if type( value ) ~= 'table' then return value end
local copy = {}
for key, item in pairs( value ) do
copy[key] = deep_copy( item )
end
return copy
end
local function ensure_font_override( config, overrides )
if not overrides.font then overrides.font = deep_copy( config.font or {} ) end
if not overrides.font.font then overrides.font.font = {} end
if not overrides.font.font[1] and config.font and config.font.font then
overrides.font.font[1] = deep_copy( config.font.font[1] )
end
return overrides.font.font[1]
end
local function enable( win )
local id = win:window_id()
local config = win:effective_config()
local overrides = win:get_config_overrides() or {}
local font = ensure_font_override( config, overrides )
state_by_window[id] = {
active = true,
font_size = config.font_size,
font_weight = font and font.weight or nil,
}
if font then font.weight = 'DemiBold' end
overrides.font_size = config.font_size * 2.0
win:toggle_fullscreen()
win:set_config_overrides( overrides )
end
local function disable( win )
local id = win:window_id()
local state = state_by_window[id]
if not state then return end
local config = win:effective_config()
local overrides = win:get_config_overrides() or {}
local font = ensure_font_override( config, overrides )
if font then font.weight = state.font_weight end
overrides.font_size = state.font_size
win:toggle_fullscreen()
win:set_config_overrides( overrides )
state_by_window[id] = nil
end
local function toggle( win )
local state = state_by_window[win:window_id()]
if state and state.active then
disable( win )
else
enable( win )
end
end
return {
toggle = toggle,
}