refactor(wezterm): smart-padding function
This commit is contained in:
parent
ec0bee34c8
commit
e1abe82454
4 changed files with 31 additions and 26 deletions
|
@ -1,7 +1,7 @@
|
|||
"$schema" = "https://starship.rs/config-schema.json"
|
||||
|
||||
format = """
|
||||
[ ](bg:red)\
|
||||
[](fg:red)\
|
||||
$directory\
|
||||
$username\
|
||||
$hostname\
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
local wezterm = require("wezterm")
|
||||
local utils = require("utils")
|
||||
|
||||
local nonpadded_apps = { "nvim", "btop", "btm" }
|
||||
|
||||
wezterm.on("smartpadding", function(window, pane)
|
||||
local fgp = pane:get_foreground_process_info()
|
||||
if fgp == nil then
|
||||
return
|
||||
elseif utils.tableContains(nonpadded_apps, fgp.name) then
|
||||
window:set_config_overrides({
|
||||
window_padding = { left = 0, right = 0, top = 0, bottom = 0 },
|
||||
})
|
||||
else
|
||||
window:set_config_overrides({
|
||||
window_padding = wezterm.GLOBAL.smart_padding,
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
wezterm.on("update-status", function(window, pane)
|
||||
if wezterm.GLOBAL.smart_padding ~= nil then
|
||||
wezterm.emit("smartpadding", window, pane)
|
||||
end
|
||||
end)
|
23
home/apps/wezterm/smartpadding.lua
Normal file
23
home/apps/wezterm/smartpadding.lua
Normal file
|
@ -0,0 +1,23 @@
|
|||
local wezterm = require("wezterm")
|
||||
|
||||
local M = {}
|
||||
M.apply_to_config = function(c)
|
||||
local default_padding = c.window_padding
|
||||
|
||||
wezterm.on("smart-padding", function(window, pane)
|
||||
if pane:is_alt_screen_active() then
|
||||
window:set_config_overrides({
|
||||
window_padding = { left = 0, right = 0, top = 0, bottom = 0 },
|
||||
})
|
||||
else
|
||||
window:set_config_overrides({
|
||||
window_padding = default_padding,
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
wezterm.on("update-status", function(window, pane)
|
||||
wezterm.emit("smart-padding", window, pane)
|
||||
end)
|
||||
end
|
||||
return M
|
|
@ -8,6 +8,13 @@ end
|
|||
|
||||
require("fonts").apply(c)
|
||||
require("keys").apply(c)
|
||||
c.window_padding = {
|
||||
left = 10,
|
||||
right = 10,
|
||||
top = 10,
|
||||
bottom = 10,
|
||||
}
|
||||
require("smartpadding").apply_to_config(c)
|
||||
|
||||
-- set up terminfo on nix
|
||||
c.set_environment_variables = {
|
||||
|
|
Loading…
Reference in a new issue