refactor(wezterm): comments/cleanup

This commit is contained in:
winston 2022-09-21 01:33:04 +02:00
parent 2e8bdd0036
commit 20216389da
Signed by: winston
GPG key ID: 3786770EDBC2B481

View file

@ -61,8 +61,10 @@ local function get_font(name)
end end
-- }}} -- }}}
local function superscript(number) -- superscript/subscript {{{
local numbers = { local function numberStyle(number, script)
local scripts = {
superscript = {
"", "",
"¹", "¹",
"²", "²",
@ -73,20 +75,35 @@ local function superscript(number)
"", "",
"", "",
"", "",
},
subscript = {
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
},
} }
local numbers = scripts[script]
local number_string = tostring(number) local number_string = tostring(number)
local result = "" local result = ""
for i = 1, #number_string do for i = 1, #number_string do
local char = number_string:sub(i, i) local char = number_string:sub(i, i)
local number = tonumber(char) local num = tonumber(char)
if number then if num then
result = result .. numbers[number + 1] result = result .. numbers[num + 1]
else else
result = result .. char result = result .. char
end end
end end
return result return result
end end
-- }}}
-- custom tab bar {{{ -- custom tab bar {{{
-- @diagnostic disable-next-line: unused-local -- @diagnostic disable-next-line: unused-local
@ -145,7 +162,7 @@ wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_wid
return { return {
{ Background = { Color = s_bg } }, { Background = { Color = s_bg } },
{ Foreground = { Color = s_fg } }, { Foreground = { Color = s_fg } },
{ Text = " " .. tab.tab_index + 1 .. ": " .. tab.active_pane.title .. superscript(count) .. " " }, { Text = " " .. tab.tab_index + 1 .. ": " .. tab.active_pane.title .. numberStyle(count, "superscript") .. " " },
{ Background = { Color = e_bg } }, { Background = { Color = e_bg } },
{ Foreground = { Color = e_fg } }, { Foreground = { Color = e_fg } },
{ Text = RIGHT_DIVIDER }, { Text = RIGHT_DIVIDER },
@ -153,7 +170,6 @@ wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_wid
end) end)
-- }}} -- }}}
local function get_os() local function get_os()
local target = wezterm.target_triple local target = wezterm.target_triple
if string.find(target, "linux") then if string.find(target, "linux") then
@ -163,6 +179,8 @@ local function get_os()
end end
end end
-- different padding on macOS and Linux
-- this is because the macOS window borders are "on the inside" of the window
local window_padding = { local window_padding = {
linux = { linux = {
left = 0, left = 0,
@ -179,11 +197,10 @@ local window_padding = {
} }
local function scheme_for_appearance(appearance) local function scheme_for_appearance(appearance)
-- default to dark mode, so I don't burn out my eyes if appearance:find("Dark") then
if not appearance:find("Dark") then
return "Catppuccin Latte"
else
return "Catppuccin Frappe" return "Catppuccin Frappe"
else
return "Catppuccin Latte"
end end
end end
@ -254,5 +271,5 @@ return {
-- nightly only -- nightly only
clean_exit_codes = { 130 }, clean_exit_codes = { 130 },
-- bell -- bell
audible_bell = "Disabled" audible_bell = "Disabled",
} }