summaryrefslogtreecommitdiff
path: root/src/panes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/panes.zig')
-rw-r--r--src/panes.zig13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/panes.zig b/src/panes.zig
index ede1d661..f07e63c3 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -171,6 +171,9 @@ pub const Pane = struct {
/// A row map also exists for sticky headers when soft wrapping is off.
body_wrapped: bool = false,
context_rows: u16 = 0,
+ body_rows: u16 = 0,
+ body_visible_rows: u16 = 0,
+ context_row_limit: ?u16 = null,
sel: [3]Sel = @splat(.{}),
pointer_selections: [3]?PointerSelection = @splat(null),
next_pointer_selection: u64 = 0,
@@ -372,8 +375,9 @@ pub const Pane = struct {
// Scrolloff is measured in the ordinary body, excluding sticky rows.
var margin: i32 = @min(config.scroll_off, @divTrunc(@as(i32, pane.rows) - 1, 2));
var last = off + @as(i32, pane.rows) - 1;
- if (pane.context_rows < pane.wrap_n) {
- const lines_shown = pane.wrap_line[pane.wrap_n - 1] - pane.wrap_line[pane.context_rows];
+ const visible_rows = if (pane.body_visible_rows > 0) @min(pane.wrap_n, pane.body_visible_rows) else pane.wrap_n;
+ if (pane.context_rows < visible_rows) {
+ const lines_shown = pane.wrap_line[visible_rows - 1] - pane.wrap_line[pane.context_rows];
last = off + lines_shown;
margin = @min(margin, @divTrunc(@max(0, lines_shown), 2));
}
@@ -1829,7 +1833,7 @@ pub const File = struct {
fn prepareContextRows(pane: *Pane, file: *State) void {
pane.context_rows = 0;
if (!file.tree_context or !supportsContext(pane) or pane.rows > pane.wrap_line.len) return;
- const capacity = pane.rows -| 1; // retain at least one ordinary body row
+ const capacity = @min(pane.rows -| 1, pane.context_row_limit orelse std.math.maxInt(u16)); // retain an ordinary body row
for (file.context_declarations) |declaration| {
if (declaration.start_line >= file.scroll) break;
if (declaration.end_line < file.scroll) continue;
@@ -1882,7 +1886,7 @@ pub const File = struct {
var body_line: usize = f.scroll;
var body_at: usize = 0;
var written: usize = 0;
- for (0..pane.rows) |i| {
+ for (0..if (pane.body_rows > 0) pane.body_rows else pane.rows) |i| {
if (i > 0) {
if (dst) |out| out[written] = '\n';
written += 1;
@@ -1950,6 +1954,7 @@ pub const File = struct {
const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(context_row)));
cell.default = false;
cell.style.bg = .{ .rgb = context_bg };
+ if (p.settings.tree_context_tag_style) cell.style.font_role = .tagline;
}
}
var vr: u16 = 0;