Add gradient colour to statusbar

This commit is contained in:
Evie Litherland-Smith 2023-02-15 10:20:56 +00:00
parent 52bec5865d
commit 33087ba392

View file

@ -39,29 +39,43 @@ wezterm.on("update-right-status", function(window, pane)
-- The filled in variant of the ( symbol
local SOLID_LEFT_SEP = utf8.char(0xe0b6)
-- Define various colours used from active colourscheme
local tab_bar_bg = "#333333" -- Not defined in scheme for some reason...
local tab_bg = scheme.foreground
local tab_fg = scheme.background
-- Foreground color for the text across the fade
local text_fg = scheme.foreground
-- Fancy tab bar background colour to complete fade
local fancy_tab_bar_bg = "#333333"
-- Color palette for the backgrounds of each cell
local colours = wezterm.color.gradient({
colors = {
scheme.tab_bar.background,
scheme.ansi[1],
},
}, #cells)
-- The elements to be formatted
local elements = {}
-- How many cells have been formatted
local num_cells = 0
table.insert(elements, { Foreground = { Color = tab_bg } })
table.insert(elements, { Background = { Color = tab_bar_bg } })
table.insert(elements, { Text = SOLID_LEFT_SEP })
while #cells > 1 do
local text = table.remove(cells, 1)
table.insert(elements, { Foreground = { Color = tab_fg } })
table.insert(elements, { Background = { Color = tab_bg } })
-- Translate a cell into elements
local function push(text, is_last)
local cell_no = num_cells + 1
table.insert(elements, { Foreground = { Color = text_fg } })
table.insert(elements, { Background = { Color = colours[cell_no] } })
table.insert(elements, { Text = " " .. text .. " " })
table.insert(elements, { Foreground = { Color = tab_fg } })
table.insert(elements, { Text = LEFT_SEP })
if not is_last then
table.insert(elements, { Foreground = { Color = colours[cell_no + 1] } })
table.insert(elements, { Text = SOLID_LEFT_SEP })
end
num_cells = num_cells + 1
end
table.insert(elements, { Foreground = { Color = colours[num_cells + 1] } })
table.insert(elements, { Background = { Color = fancy_tab_bar_bg } })
table.insert(elements, { Text = SOLID_LEFT_SEP })
while #cells > 0 do
local cell = table.remove(cells, 1)
push(cell, #cells == 0)
end
local text = table.remove(cells, 1)
table.insert(elements, { Foreground = { Color = tab_fg } })
table.insert(elements, { Background = { Color = tab_bg } })
table.insert(elements, { Text = " " .. text .. " " })
window:set_right_status(wezterm.format(elements))
end)