diff options
Diffstat (limited to 'core/draw.zig')
| -rw-r--r-- | core/draw.zig | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/core/draw.zig b/core/draw.zig index 37fdee1e..772cbece 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -488,13 +488,18 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: }); // In window mode the box holds the pane's letter instead of its mode. const label: ?u8 = if (p.view().window_pick != null) layout.windowLabel(p, id) else null; - s.set(r.x, tag_y, if (label) |*letter| @as(*const [1]u8, letter) else switch (pane.body.mode) { + // A tag in a typing state is typed in: its box says so (walk UI SPEC + // ยง3.2), whatever the body's mode. + const typing = p.view().tag_state.kind != .rest and TagState.hostOf(p) == id; + s.set(r.x, tag_y, if (label) |*letter| @as(*const [1]u8, letter) else if (typing) config.tag_insert else switch (pane.body.mode) { .normal => config.tag_normal, .insert => config.tag_insert, .tty => config.tag_tty, }, box_style); try joinPaneTag(p, s, arena, pane, r, id, active); + // The keyboard is in the head's field: its caret, not the body's. + const head_caret = if (typing) s.cursor else null; if (pane.band_rows > 0) try joinBand(p, s, arena, pane, r, id, active); // Folded panes retain their body state, but neither body pixels nor @@ -530,6 +535,10 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: } try body_layer.joinBody(p, s, arena, pane, r, id, active, rail.*); + if (typing) { + s.body_layers[id].cursor = null; + s.cursor = head_caret; + } if (pane.layers.heat > 0) @import("jj.zig").railHeat(p, s, pane, id, rail.rect); // A terminal panned to its cursor in a view shorter than it: an arrow // in the gutter's first body row says rows are above (views.zig). @@ -1003,6 +1012,15 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, } } } + // A head typed in: its caret a bar at the field's. + if (head) |h| if (h.caret) |c| if (active) { + const at = modal.positionAt(shown.text, shown.fromReal(prefix_len + c)); + if (at.row >= top and at.row < top + rows) { + const line = lines[at.row - top]; + const col = panes.File.rawDisplayCol(p.settings.tab, line, @min(at.col, line.len)); + if (col < tw) s.cursor = .{ .x = tx + @as(u16, @intCast(col)), .y = tag_y + @as(u16, @intCast(at.row - top)), .bar = true }; + } + }; // the caret: bar while typing, block in normal mode (same rule as a body) if (caret) |at| { const col = panes.File.rawDisplayCol(p.settings.tab, lines[at.row], at.at) -| pane.tag_scroll; |
