summaryrefslogtreecommitdiff
path: root/core/draw.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/draw.zig')
-rw-r--r--core/draw.zig38
1 files changed, 34 insertions, 4 deletions
diff --git a/core/draw.zig b/core/draw.zig
index ff76aa75..de08ef4f 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -16,6 +16,7 @@ const edit = @import("edit.zig");
const tagline = @import("tagline.zig");
const body_layer = @import("body_layer.zig");
const Messages = @import("Messages.zig");
+const TagState = @import("TagState.zig");
const builtins = @import("builtins.zig");
const Color = @import("surface.zig").Color;
const FontRole = @import("surface.zig").FontRole;
@@ -227,7 +228,7 @@ fn joinNotice(p: *Pardes, s: *Surface, arena: std.mem.Allocator, region: Region)
const kind = pane.notices.kinds[i];
const r = v.rects[id];
const chip = region.rect.w;
- var leader_buf: [16]u8 = undefined;
+ var leader_buf: [Messages.leader_room]u8 = undefined;
const text = Messages.noticeText(p, pane, i, &leader_buf);
const bg = chrome.tag_bg;
// Where an exec was sent to a REPL reads in the tag's name tint, set
@@ -812,7 +813,9 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
.font_role = .tagline,
});
const whole = try tagline.tagText(p, arena, pane);
- const tail = tagline.curTail(pane);
+ // Out of rest, the head in place of the tag's own text (TagState).
+ const head = try TagState.head(p, arena, pane);
+ const tail = if (head) |h| h.text else tagline.curTail(pane);
const prefix_len = whole.len - tail.len;
// A row per line shown, from `tag_top`: the tag's first line carries
// the prefix, the rest are the tag's own text alone.
@@ -835,7 +838,7 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
const at = modal.positionAt(shown.text, shown.fromReal(@intCast(@max(0, pane.input.cur_col))));
if (at.row < top or at.row >= top + rows) break :caret null;
break :caret .{ .row = at.row - top, .at = @min(lines[at.row - top].len, at.col) };
- } else if (pane.focus == .tag and pane.prompt == .none) caret: {
+ } else if (pane.focus == .tag and pane.prompt == .none and head == null) caret: {
const real = modal.offsetAt(whole, .{ .row = @intCast(@max(0, pane.tag.cur_row)), .col = @intCast(@max(0, pane.tag.cur_col)) });
const at = modal.positionAt(shown.text, shown.fromReal(real));
if (at.row < top or at.row >= top + rows) break :caret null;
@@ -868,9 +871,36 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
s.at(tx + @as(u16, @intCast(col)), y).style.fg = .{ .rgb = name_fg };
}
};
+ // The head's keys in the key ink, its dimmed, underlined and struck
+ // words (TagState.Span), over whichever rows they wrapped onto.
+ if (head) |h| for (h.spans) |span| {
+ const a = modal.positionAt(shown.text, shown.fromReal(prefix_len + span.lo));
+ const b = modal.positionAt(shown.text, shown.fromReal(prefix_len + span.hi));
+ var row = @max(a.row, top);
+ while (row <= b.row and row < top + rows) : (row += 1) {
+ const line = lines[row - top];
+ const from = if (row == a.row) a.col else 0;
+ const to = if (row == b.row) b.col else line.len;
+ var col = panes.File.rawDisplayCol(p.settings.tab, line, @min(from, line.len));
+ const end = panes.File.rawDisplayCol(p.settings.tab, line, @min(to, line.len));
+ const y = tag_y + @as(u16, @intCast(row - top));
+ while (col < end and col < tw) : (col += 1) {
+ const style = &s.at(tx + @as(u16, @intCast(col)), y).style;
+ switch (span.style) {
+ .key => {
+ style.fg = .{ .rgb = chrome.box };
+ style.bold = true;
+ },
+ .dim => style.dim = true,
+ .under => style.ul = .single,
+ .strike => style.strikethrough = true,
+ }
+ }
+ }
+ };
// The tag's own selections, while it has the keyboard, a line at a
// time. A range of one grapheme is the block cursor, not a selection.
- if (pane.focus == .tag) {
+ if (pane.focus == .tag and head == null) {
var ranges: [Text.max_selections]modal.Selection = undefined;
const got = pane.tag.ranges(whole, 0, &ranges);
for (ranges[0..got.n]) |range| {