Add gradient colour to statusbar
This commit is contained in:
parent
52bec5865d
commit
33087ba392
|
@ -39,29 +39,43 @@ wezterm.on("update-right-status", function(window, pane)
|
||||||
-- The filled in variant of the ( symbol
|
-- The filled in variant of the ( symbol
|
||||||
local SOLID_LEFT_SEP = utf8.char(0xe0b6)
|
local SOLID_LEFT_SEP = utf8.char(0xe0b6)
|
||||||
|
|
||||||
-- Define various colours used from active colourscheme
|
-- Foreground color for the text across the fade
|
||||||
local tab_bar_bg = "#333333" -- Not defined in scheme for some reason...
|
local text_fg = scheme.foreground
|
||||||
local tab_bg = scheme.foreground
|
-- Fancy tab bar background colour to complete fade
|
||||||
local tab_fg = scheme.background
|
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
|
-- The elements to be formatted
|
||||||
local elements = {}
|
local elements = {}
|
||||||
|
-- How many cells have been formatted
|
||||||
|
local num_cells = 0
|
||||||
|
|
||||||
table.insert(elements, { Foreground = { Color = tab_bg } })
|
-- Translate a cell into elements
|
||||||
table.insert(elements, { Background = { Color = tab_bar_bg } })
|
local function push(text, is_last)
|
||||||
table.insert(elements, { Text = SOLID_LEFT_SEP })
|
local cell_no = num_cells + 1
|
||||||
while #cells > 1 do
|
table.insert(elements, { Foreground = { Color = text_fg } })
|
||||||
local text = table.remove(cells, 1)
|
table.insert(elements, { Background = { Color = colours[cell_no] } })
|
||||||
table.insert(elements, { Foreground = { Color = tab_fg } })
|
|
||||||
table.insert(elements, { Background = { Color = tab_bg } })
|
|
||||||
table.insert(elements, { Text = " " .. text .. " " })
|
table.insert(elements, { Text = " " .. text .. " " })
|
||||||
table.insert(elements, { Foreground = { Color = tab_fg } })
|
if not is_last then
|
||||||
table.insert(elements, { Text = LEFT_SEP })
|
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
|
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))
|
window:set_right_status(wezterm.format(elements))
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in a new issue