rearrange tui types
This commit is contained in:
parent
ea7da4ad5d
commit
c5c7f13400
2 changed files with 28 additions and 23 deletions
39
src/tui.zig
39
src/tui.zig
|
|
@ -62,10 +62,6 @@ pub fn colLabel(buf: []u8, name: []const u8, comptime col_width: usize, left: bo
|
|||
return buf[0..total_bytes];
|
||||
}
|
||||
|
||||
// Portfolio column layout: gain/loss column start position (display columns).
|
||||
// prefix(4) + sym(sym_col_width+1) + shares(9) + avgcost(11) + price(11) + mv(17) = 4 + sym_col_width + 49
|
||||
pub const gl_col_start: usize = 4 + fmt.sym_col_width + 49;
|
||||
|
||||
pub fn glyph(ch: u8) []const u8 {
|
||||
if (ch < 128) return ascii_g[ch];
|
||||
return " ";
|
||||
|
|
@ -99,6 +95,26 @@ pub const InputMode = enum {
|
|||
help,
|
||||
};
|
||||
|
||||
pub const StyledLine = struct {
|
||||
text: []const u8,
|
||||
style: vaxis.Style,
|
||||
// Optional per-character style override ranges (for mixed-color lines)
|
||||
alt_text: ?[]const u8 = null, // text for the gain/loss column
|
||||
alt_style: ?vaxis.Style = null,
|
||||
alt_start: usize = 0,
|
||||
alt_end: usize = 0,
|
||||
// Optional pre-encoded grapheme array for multi-byte Unicode (e.g. braille charts).
|
||||
// When set, each element is a grapheme string for one column position.
|
||||
graphemes: ?[]const []const u8 = null,
|
||||
// Optional per-cell style array (same length as graphemes). Enables color gradients.
|
||||
cell_styles: ?[]const vaxis.Style = null,
|
||||
};
|
||||
|
||||
// ── Tab-specific types ───────────────────────────────────────────
|
||||
// These logically belong to individual tab files, but live here because
|
||||
// App's struct fields reference them and Zig requires field types to be
|
||||
// resolved in the same struct definition.
|
||||
|
||||
pub const PortfolioSortField = enum {
|
||||
symbol,
|
||||
shares,
|
||||
|
|
@ -168,21 +184,6 @@ pub const PortfolioRow = struct {
|
|||
const Kind = enum { position, lot, watchlist, section_header, option_row, cd_row, cash_row, cash_total, illiquid_row, illiquid_total, drip_summary };
|
||||
};
|
||||
|
||||
pub const StyledLine = struct {
|
||||
text: []const u8,
|
||||
style: vaxis.Style,
|
||||
// Optional per-character style override ranges (for mixed-color lines)
|
||||
alt_text: ?[]const u8 = null, // text for the gain/loss column
|
||||
alt_style: ?vaxis.Style = null,
|
||||
alt_start: usize = 0,
|
||||
alt_end: usize = 0,
|
||||
// Optional pre-encoded grapheme array for multi-byte Unicode (e.g. braille charts).
|
||||
// When set, each element is a grapheme string for one column position.
|
||||
graphemes: ?[]const []const u8 = null,
|
||||
// Optional per-cell style array (same length as graphemes). Enables color gradients.
|
||||
cell_styles: ?[]const vaxis.Style = null,
|
||||
};
|
||||
|
||||
pub const OptionsRowKind = enum { expiration, calls_header, puts_header, call, put };
|
||||
|
||||
pub const OptionsRow = struct {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ const PortfolioSortField = tui.PortfolioSortField;
|
|||
const colLabel = tui.colLabel;
|
||||
const glyph = tui.glyph;
|
||||
|
||||
// Portfolio column layout: gain/loss column start position (display columns).
|
||||
// prefix(4) + sym(sym_col_width+1) + shares(9) + avgcost(11) + price(11) + mv(17) = 4 + sym_col_width + 49
|
||||
const gl_col_start: usize = 4 + fmt.sym_col_width + 49;
|
||||
|
||||
// ── Data loading ──────────────────────────────────────────────
|
||||
|
||||
pub fn loadPortfolioData(self: *App) void {
|
||||
|
|
@ -675,8 +679,8 @@ pub fn drawContent(self: *App, arena: std.mem.Allocator, buf: []vaxis.Cell, widt
|
|||
.text = text,
|
||||
.style = base_style,
|
||||
.alt_style = gl_style,
|
||||
.alt_start = tui.gl_col_start,
|
||||
.alt_end = tui.gl_col_start + 14,
|
||||
.alt_start = gl_col_start,
|
||||
.alt_end = gl_col_start + 14,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -721,8 +725,8 @@ pub fn drawContent(self: *App, arena: std.mem.Allocator, buf: []vaxis.Cell, widt
|
|||
.text = text,
|
||||
.style = base_style,
|
||||
.alt_style = gl_col_style,
|
||||
.alt_start = tui.gl_col_start,
|
||||
.alt_end = tui.gl_col_start + 14,
|
||||
.alt_start = gl_col_start,
|
||||
.alt_end = gl_col_start + 14,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue