title case for etf sectors, force upper case on symbol search

This commit is contained in:
Emil Lerch 2026-03-06 15:11:04 -08:00
parent 3d679f9d75
commit 71a5c548d5
Signed by: lobo
GPG key ID: A7B62D657EF764F8
2 changed files with 8 additions and 4 deletions

View file

@ -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});
}
}
}

View file

@ -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());
}
}