summaryrefslogtreecommitdiff
path: root/src/body_layer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/body_layer.zig')
-rw-r--r--src/body_layer.zig25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/body_layer.zig b/src/body_layer.zig
index 76aec179..a8d09c66 100644
--- a/src/body_layer.zig
+++ b/src/body_layer.zig
@@ -37,7 +37,7 @@ fn paintTerminalSelection(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, rows: [
var visible: i32 = 0;
while (lines.next()) |line| : (visible += 1) {
if (visible >= r.h -| pane.tag_rows) break;
- const source_row = if (raw) panes.terminal.gridOffset(pane) + visible else pane.wrapAt(visible).line;
+ const source_row = if (raw) @as(i32, @intCast(panes.Term.grid(pane.terminal).offset)) + visible else pane.wrapAt(visible).line;
for (rows) |row| {
const target = if (row.raw_terminal)
(if (raw) row.row else pane.surfRow(row.row))
@@ -230,8 +230,7 @@ pub fn joinBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
fn drawGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw: u16, body_h: u16, active: bool) void {
const prefix_width = panes.File.gutterWidth(pane);
const goff = pane.scroll();
- const gcur = panes.terminal.gridCursor(pane);
- const gcrow = if (pane.body.cur_pinned) pane.body.cur_row else @as(i32, gcur.y) + goff;
+ const gcrow = if (pane.body.cur_pinned) pane.body.cur_row else @as(i32, panes.Term.grid(pane.terminal).cursor_y) + goff;
const typing_body = pane.focus == .body and (pane.prompt == .none or pane.prompt == .del_side or pane.prompt == .repl_choice);
const cur_line: i32 = if (active and typing_body) gcrow else std.math.minInt(i32);
// the body's first row, the way renderPane derives it
@@ -491,10 +490,9 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
// (the tag's or a prompt's cursor wins while that is being typed into)
if (active and pane.focus == .body and (pane.prompt == .none or pane.prompt == .del_side or pane.prompt == .repl_choice)) {
if (pane.body.mode != .tty) {
- const cur = panes.terminal.gridCursor(pane);
- const goff = panes.terminal.gridOffset(pane);
- const crow = if (pane.body.cur_pinned) pane.body.cur_row else pane.surfRow(@as(i32, @intCast(cur.y)) + goff);
- const ccol = if (pane.body.cur_pinned) pane.body.cur_col else @as(i32, @intCast(cur.x));
+ const grid = panes.Term.grid(pane.terminal);
+ const crow = if (pane.body.cur_pinned) pane.body.cur_row else pane.surfRow(@as(i32, grid.cursor_y) + @as(i32, @intCast(grid.offset)));
+ const ccol = if (pane.body.cur_pinned) pane.body.cur_col else @as(i32, grid.cursor_x);
const cwp = pane.wrapRow(crow, ccol);
const prow = cwp.row + @as(i32, pane.tag_rows);
// Off the view, the cursor is not measured (its column may be
@@ -515,9 +513,16 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
if (prow >= pane.tag_rows and cx >= 0 and prow < body_bottom and cx < tw)
s.cursor = .{ .x = tx + @as(u16, @intCast(cx)), .y = body_y + @as(u16, @intCast(prow - pane.tag_rows)), .bar = pane.body.mode == .insert };
}
- } else if (panes.terminal.visibleCursor(pane)) |cur| {
- if (cur.y + pane.tag_rows < body_bottom and cur.x < tw)
- s.cursor = .{ .x = tx + cur.x, .y = body_y + cur.y };
+ } else if (pane.terminal != null) visible: {
+ // Where the program shows its cursor, if it does and in the rows
+ // the view shows (past the rows a short view pans over).
+ const grid = panes.Term.grid(pane.terminal);
+ if (!grid.cursor_visible) break :visible;
+ const row = grid.total - grid.len + grid.cursor_y;
+ if (row < grid.offset + pane.pan or row - grid.offset >= grid.len) break :visible;
+ const y: u16 = @intCast(row - grid.offset - pane.pan);
+ if (y + pane.tag_rows < body_bottom and grid.cursor_x < tw)
+ s.cursor = .{ .x = tx + grid.cursor_x, .y = body_y + y };
}
}