repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

ui: tune wezterm pi pulse

bd30d4cea365d55260f0f0ae7cfab943c2c607d2

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (1)

wezterm/bugabinga/status.lua

Modified
5 5 local palette = require 'bugabinga.nugu.palette_dark'.palette
6 6 local icon_names = require 'bugabinga.icons'
8 +local animation_tick = 0
8 10 local zoomed = function ( pane )
9 11 local tab = pane:tab()
10 12 local any_is_zoomed = false
81 83 return ''
84 -local busy_frame = function ()
85 - local frames = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' }
86 - return frames[(os.time() % #frames) + 1]
86 +local hex_to_rgb = function ( color )
87 + return tonumber( color:sub( 2, 3 ), 16 ),
88 + tonumber( color:sub( 4, 5 ), 16 ),
89 + tonumber( color:sub( 6, 7 ), 16 )
90 +end
92 +local mix_color = function ( a, b, t )
93 + local ar, ag, ab = hex_to_rgb( a )
94 + local br, bg, bb = hex_to_rgb( b )
95 + local blend = function ( x, y )
96 + return math.floor( x + (y - x) * t + 0.5 )
97 + end
98 + return string.format( '#%02x%02x%02x', blend( ar, br ), blend( ag, bg ), blend( ab, bb ) )
99 +end
101 +local pulse_color = function ()
102 + local phase = (animation_tick % 24) / 24
103 + local eased = (1 - math.cos( phase * math.pi * 2 )) / 2
104 + return mix_color( palette.ui.minor, palette.ui.important_global, eased )
105 +end
107 +local busy_badge = function ()
108 + -- Braille spinner glyphs sit low in JetBrains Mono/Nerd Font.
109 + -- Circle glyphs are visually centered in the tab/status row.
110 + local frames = { '○', '◌', '◎', '◉', '●', '◉', '◎', '◌' }
111 + local index = (math.floor( animation_tick / 2 ) % #frames) + 1
112 + return frames[index], pulse_color()
113 +end
115 +local colored_badge = function ( elements, badge, color, fallback )
116 + if not badge then return end
117 + table.insert( elements, { Text = ' ' } )
118 + table.insert( elements, { Foreground = { Color = color or fallback } } )
119 + table.insert( elements, { Text = badge } )
120 + table.insert( elements, { Foreground = { Color = fallback } } )
89 123 local progress_badge = function ( progress )
90 124 if not progress or progress == 'None' then return nil end
91 - if progress == 'Indeterminate' then return busy_frame(), palette.info end
125 + if progress == 'Indeterminate' then return busy_badge() end
92 126 if type( progress ) == 'table' and progress.Error ~= nil then return '✗', palette.error end
93 - if type( progress ) == 'table' and progress.Percentage ~= nil then return busy_frame(), palette.info end
94 - return busy_frame(), palette.info
127 + if type( progress ) == 'table' and progress.Percentage ~= nil then return busy_badge() end
128 + return busy_badge()
97 131 local pi_state_badge = function ( state )
98 - if state == 'busy' or state == 'running' or state == 'thinking' then return busy_frame(), palette.info end
132 + if state == 'busy' or state == 'running' or state == 'thinking' then return busy_badge() end
99 133 if state == 'done' or state == 'success' then return '✓', palette.ui.important_local end
100 134 if state == 'error' or state == 'failed' then return '✗', palette.error end
101 135 if state == 'aborted' then return '×', palette.warning end
167 201 return summaries
170 -local workspace_badge = function ( summary, active )
171 - local parts = { short_workspace( summary.name ) }
173 - if summary.badge then
174 - table.insert( parts, summary.badge )
175 - end
177 - if active and summary.tabs > 1 then
178 - table.insert( parts, tostring( summary.tabs ) .. 't' )
179 - end
181 - return table.concat( parts, ' ' )
182 -end
184 204 local workspace_hud = function ( active_workspace )
185 205 local summaries = workspace_summaries()
186 206 local names = {}
200 220 if shown > 5 then break end
202 222 local active = name == active_workspace
203 - table.insert( elements, { Foreground = { Color = summaries[name].badge_color or (active and palette.ui.important_local or palette.ui.minor) } } )
223 + local fg = active and palette.ui.important_local or palette.ui.minor
224 + local summary = summaries[name]
225 + table.insert( elements, { Foreground = { Color = fg } } )
204 226 if active then table.insert( elements, { Attribute = { Intensity = 'Bold' } } ) end
205 - table.insert( elements, { Text = (active and ' ● ' or ' ○ ') .. workspace_badge( summaries[name], active ) .. ' ' } )
227 + table.insert( elements, { Text = (active and ' ● ' or ' ○ ') .. short_workspace( summary.name ) } )
228 + colored_badge( elements, summary.badge, summary.badge_color, fg )
229 + if active and summary.tabs > 1 then
230 + table.insert( elements, { Text = ' ' .. tostring( summary.tabs ) .. 't' } )
231 + end
232 + table.insert( elements, { Text = ' ' } )
206 233 table.insert( elements, { Attribute = { Intensity = 'Normal' } } )
285 312 local bg = tab.active and palette.ui.focus or palette.ui.backdrop
286 313 local fg = tab.active and palette.ui.backdrop or palette.ui.minor
288 - if tab.state_badge_color and not tab.active then
289 - bg = tab.state_badge_color
290 - fg = palette.content.backdrop
291 - elseif tab.has_unseen_output and not tab.active then
315 + if tab.has_unseen_output and not tab.active then
292 316 bg = palette.warning
293 317 fg = palette.content.backdrop
296 - local suffix = tab.state_badge and (' ' .. tab.state_badge) or (tab.has_unseen_output and ' !' or '')
320 + local suffix = tab.has_unseen_output and ' !' or ''
297 321 local text
298 322 if compact and not tab.active then
299 - text = string.format( ' %d %s%s ', tab.index + 1, tab.icon, suffix )
323 + text = string.format( ' %d %s%s', tab.index + 1, tab.icon, suffix )
301 - text = string.format( ' %d %s %s%s ', tab.index + 1, tab.icon, tab.label, suffix )
325 + text = string.format( ' %d %s %s%s', tab.index + 1, tab.icon, tab.label, suffix )
304 328 table.insert( elements, { Background = { Color = bg } } )
305 329 table.insert( elements, { Foreground = { Color = fg } } )
306 330 if tab.active then table.insert( elements, { Attribute = { Intensity = 'Bold' } } ) end
307 331 table.insert( elements, { Text = text } )
332 + colored_badge( elements, tab.state_badge, tab.state_badge_color, fg )
333 + table.insert( elements, { Text = ' ' } )
308 334 table.insert( elements, { Attribute = { Intensity = 'Normal' } } )
309 335 table.insert( elements, { Background = { Color = palette.content.backdrop } } )
310 336 table.insert( elements, { Text = ' ' } )
312 - return text_width( text ) + 1
338 + return text_width( text ) + (tab.state_badge and (text_width( tab.state_badge ) + 1) or 0) + 2
315 341 local fake_tabs = function ( window, max_width )
424 450 if tab.is_active then
425 451 bg = palette.ui.focus
426 452 fg = palette.ui.backdrop
427 - elseif state_badge_color then
428 - bg = state_badge_color
429 - fg = palette.content.backdrop
430 453 elseif has_unseen_output then
431 454 bg = palette.warning
432 455 fg = palette.content.backdrop
439 462 fg = palette.ui.minor
442 - local suffix = state_badge and (' ' .. state_badge) or (has_unseen_output and ' !' or '')
443 - local text = string.format( ' %d %s %s%s ', tab.tab_index + 1, icon, title, suffix )
465 + local suffix = has_unseen_output and ' !' or ''
466 + local text = string.format( ' %d %s %s%s', tab.tab_index + 1, icon, title, suffix )
444 467 text = wez.truncate_right( text, math.max( 1, max_width ) )
446 - return {
469 + local elements = {
447 470 { Background = { Color = bg } },
448 471 { Foreground = { Color = fg } },
449 472 { Text = text },
474 + colored_badge( elements, state_badge, state_badge_color, fg )
475 + table.insert( elements, { Text = ' ' } )
476 + return elements
453 479 wez.on( 'format-window-title', function ( tab, pane, tabs, panes, config )
460 486 -- Show which key table is active in the status area
461 487 wez.on( 'update-status', function ( window, pane )
488 + animation_tick = animation_tick + 1
462 489 local key_table = window:active_key_table()
463 490 local current_workspace = window:active_workspace()
464 491 local zoomed_state_ok, zoomed_state = pcall( zoomed, pane )
541 568 cfg.show_tabs_in_tab_bar = false
542 569 cfg.show_new_tab_button_in_tab_bar = false
543 570 cfg.tab_bar_at_bottom = true
544 - cfg.status_update_interval = 1000
571 + cfg.status_update_interval = 100