From 71a5c548d5169fb45cba08b354294b386d4eb1e6 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Fri, 6 Mar 2026 15:11:04 -0800 Subject: [PATCH] title case for etf sectors, force upper case on symbol search --- src/commands/etf.zig | 4 +++- src/tui.zig | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/commands/etf.zig b/src/commands/etf.zig index 8e3175a..170031f 100644 --- a/src/commands/etf.zig +++ b/src/commands/etf.zig @@ -73,10 +73,12 @@ pub fn printProfile(profile: zfin.EtfProfile, symbol: []const u8, color: bool, o try out.print("\n Sector Allocation:\n", .{}); try cli.reset(out, color); for (sectors) |sec| { + var title_buf: [64]u8 = undefined; + const name = fmt.toTitleCase(&title_buf, sec.name); try cli.setFg(out, color, cli.CLR_ACCENT); try out.print(" {d:>5.1}%", .{sec.weight * 100.0}); try cli.reset(out, color); - try out.print(" {s}\n", .{sec.name}); + try out.print(" {s}\n", .{name}); } } } diff --git a/src/tui.zig b/src/tui.zig index 39083bd..eeb4019 100644 --- a/src/tui.zig +++ b/src/tui.zig @@ -500,7 +500,8 @@ const App = struct { return ctx.consumeAndRedraw(); } if (key.codepoint >= 0x20 and key.codepoint < 0x7f and self.input_len < self.input_buf.len) { - self.input_buf[self.input_len] = @intCast(key.codepoint); + const c: u8 = @intCast(key.codepoint); + self.input_buf[self.input_len] = std.ascii.toUpper(c); self.input_len += 1; return ctx.consumeAndRedraw(); } @@ -2923,8 +2924,9 @@ const App = struct { try col3.add(arena, "Sectors", th.headerStyle()); const show = @min(sectors.len, 7); for (sectors[0..show]) |sec| { - // Truncate long sector names - const name = if (sec.name.len > 20) sec.name[0..20] else sec.name; + var title_buf: [64]u8 = undefined; + const title_name = fmt.toTitleCase(&title_buf, sec.name); + const name = if (title_name.len > 20) title_name[0..20] else title_name; try col3.add(arena, try std.fmt.allocPrint(arena, " {d:>5.1}% {s}", .{ sec.weight * 100.0, name }), th.contentStyle()); } }