|
| 1 | +---@meta |
| 2 | +---@diagnostic disable:unused-local |
| 3 | + |
| 4 | +---@alias Ribbon.Attribute string|string[] |
| 5 | +---@alias Ribbon.FormatItem string|table |
| 6 | + |
| 7 | +---@class Ribbon.LogConfig |
| 8 | +---@field enabled boolean |
| 9 | +---@field threshold "DEBUG"|"INFO"|"WARN"|"ERROR"|integer |
| 10 | +---@field sinks? table Accepted for compatibility with older layout options. |
| 11 | + |
| 12 | +---@class Ribbon.Defaults |
| 13 | +---@field foreground? string Default foreground color. |
| 14 | +---@field background? string Default background color. |
| 15 | +---@field attributes table<string, table|string> Named text attributes. |
| 16 | +---@field colors table<string, boolean> ANSI color-name lookup table. |
| 17 | + |
| 18 | +---@class Ribbon.TextConfig |
| 19 | +---@field strip boolean Trim text before inserting it. |
| 20 | +---@field max_length? integer Maximum text length before truncation. |
| 21 | +---@field transform? fun(text: string): string Text transform callback. |
| 22 | + |
| 23 | +---@class Ribbon.Config |
| 24 | +---@field log Ribbon.LogConfig |
| 25 | +---@field defaults Ribbon.Defaults |
| 26 | +---@field attribute_aliases table<string, string|string[]> Attribute aliases. |
| 27 | +---@field validate_attributes boolean Warn or error on unknown attributes. |
| 28 | +---@field strict_mode boolean Error on unknown attributes when validation is enabled. |
| 29 | +---@field text Ribbon.TextConfig |
| 30 | +---@field atomic boolean Reset attributes after every text segment. |
| 31 | + |
| 32 | +---@class Ribbon.ConfigModule |
| 33 | +local Config = {} |
| 34 | + |
| 35 | +---Configure Ribbon. |
| 36 | +---@param opts? table Partial Ribbon configuration. |
| 37 | +---@return Ribbon.Config config |
| 38 | +function Config.setup(opts) end |
| 39 | + |
| 40 | +---Return the active Ribbon configuration. |
| 41 | +---@return Ribbon.Config config |
| 42 | +function Config.get() end |
| 43 | + |
| 44 | +---Return a copy of Ribbon defaults. |
| 45 | +---@return Ribbon.Config defaults |
| 46 | +function Config.defaults() end |
| 47 | + |
| 48 | +---@class Ribbon |
| 49 | +---@field atomic? boolean Whether attributes reset after each segment. |
| 50 | +---@field log table Logger instance. |
| 51 | +local R = {} |
| 52 | + |
| 53 | +---Add an element to the ribbon. |
| 54 | +---@param action "append"|"prepend" |
| 55 | +---@param background? string Background color name or value. |
| 56 | +---@param foreground? string Foreground color name or value. |
| 57 | +---@param text? string Text to insert. |
| 58 | +---@param attributes? Ribbon.Attribute Text attributes or aliases. |
| 59 | +---@return Ribbon|nil self |
| 60 | +function R:add(action, background, foreground, text, attributes) end |
| 61 | + |
| 62 | +---Append a formatted text segment. |
| 63 | +---@param background? string Background color name or value. |
| 64 | +---@param foreground? string Foreground color name or value. |
| 65 | +---@param text? string Text to insert. |
| 66 | +---@param attributes? Ribbon.Attribute Text attributes or aliases. |
| 67 | +---@return Ribbon|nil self |
| 68 | +function R:append(background, foreground, text, attributes) end |
| 69 | + |
| 70 | +---Prepend a formatted text segment. |
| 71 | +---@param background? string Background color name or value. |
| 72 | +---@param foreground? string Foreground color name or value. |
| 73 | +---@param text? string Text to insert. |
| 74 | +---@param attributes? Ribbon.Attribute Text attributes or aliases. |
| 75 | +---@return Ribbon|nil self |
| 76 | +function R:prepend(background, foreground, text, attributes) end |
| 77 | + |
| 78 | +---Append raw `wezterm.format` items. |
| 79 | +---@param items Ribbon.FormatItem|Ribbon.FormatItem[]|nil Format item or list of items. |
| 80 | +---@return Ribbon self |
| 81 | +function R:append_items(items) end |
| 82 | + |
| 83 | +---Prepend raw `wezterm.format` items. |
| 84 | +---@param items Ribbon.FormatItem|Ribbon.FormatItem[]|nil Format item or list of items. |
| 85 | +---@return Ribbon self |
| 86 | +function R:prepend_items(items) end |
| 87 | + |
| 88 | +---Clear all ribbon items. |
| 89 | +---@return Ribbon self |
| 90 | +function R:clear() end |
| 91 | + |
| 92 | +---Append a reset-attributes marker. |
| 93 | +function R:reset_attributes() end |
| 94 | + |
| 95 | +---Render with `wezterm.format`. |
| 96 | +---@return string formatted |
| 97 | +function R:format() end |
| 98 | + |
| 99 | +---Log the ribbon contents. |
| 100 | +---@param formatted boolean Log rendered text when true, raw items when false. |
| 101 | +function R:debug(formatted) end |
| 102 | + |
| 103 | +---Return the raw format items. |
| 104 | +---@return Ribbon.FormatItem[] items |
| 105 | +function R:items() end |
| 106 | + |
| 107 | +---@class Ribbon.Api |
| 108 | +---@field config Ribbon.ConfigModule Configuration helpers. |
| 109 | +local M = {} |
| 110 | + |
| 111 | +---Create a Ribbon instance. |
| 112 | +---@param self_or_name? Ribbon.Api|string Ribbon API table when called with `:`, or a name when called with `.`. |
| 113 | +---@param name_or_atomic? string|boolean Ribbon name when called with `:`, or atomic flag when called with `.`. |
| 114 | +---@param atomic? boolean Atomic flag when called with `:`. |
| 115 | +---@return Ribbon ribbon |
| 116 | +function M.new(self_or_name, name_or_atomic, atomic) end |
| 117 | + |
| 118 | +---Configure Ribbon. |
| 119 | +---@param opts? table Partial Ribbon configuration. |
| 120 | +---@return Ribbon.Config config |
| 121 | +function M.setup(opts) end |
| 122 | + |
| 123 | +-- vim: set ts=2 sts=2 sw=2 et ai si sta: |
0 commit comments