diff --git a/src/tui/quote_tab.zig b/src/tui/quote_tab.zig index 89b7957..b755a14 100644 --- a/src/tui/quote_tab.zig +++ b/src/tui/quote_tab.zig @@ -875,8 +875,10 @@ fn buildStyledLines(app: *App, arena: std.mem.Allocator) ![]const StyledLine { try lines.append(arena, .{ .text = " Recent History:", .style = th.headerStyle() }); try lines.append(arena, .{ .text = try std.fmt.allocPrint(arena, " {s:>12} {s:>10} {s:>10} {s:>10} {s:>10} {s:>12}", .{ "Date", "Open", "High", "Low", "Close", "Volume" }), .style = th.mutedStyle() }); - const start_idx = if (c.len > 20) c.len - 20 else 0; - for (c[start_idx..]) |candle| { + const end_idx = if (c.len > 20) c.len - 20 else 0; + var curr = c.len - 1; + while (curr >= end_idx) : (curr -= 1) { + const candle = c[curr]; var row_buf: [128]u8 = undefined; const day_change = if (candle.close >= candle.open) th.positiveStyle() else th.negativeStyle(); try lines.append(arena, .{ .text = try arena.dupe(u8, fmt.fmtCandleRow(&row_buf, candle)), .style = day_change });