diff options
Diffstat (limited to 'src/body_layer.zig')
| -rw-r--r-- | src/body_layer.zig | 64 |
1 files changed, 14 insertions, 50 deletions
diff --git a/src/body_layer.zig b/src/body_layer.zig index 2aa8e5f8..0ddda41d 100644 --- a/src/body_layer.zig +++ b/src/body_layer.zig @@ -6,7 +6,6 @@ const pardes = @import("pardes.zig"); const normal = @import("normal.zig"); const edit = @import("edit.zig"); const config = @import("config.zig"); -const limits = @import("memory.zig").limits; const layout = @import("layout.zig"); const modal = @import("modal.zig"); const tracy = @import("tracy.zig"); @@ -23,19 +22,7 @@ const TAG_TEXT_INSET = pardes.TAG_TEXT_INSET; const Rect = layout.Rect; const Pardes = pardes.Pardes; const tagline = @import("tagline.zig"); -const Messages = @import("Messages.zig"); const Text = panes.Text; -const MAX_PANES = pardes.MAX_PANES; -const TagKind = @import("Layer.zig").Kind; -const MAX_TAG_ROWS = pardes.MAX_TAG_ROWS; -const NOTICE_LAYER_BASE = pardes.NOTICE_LAYER_BASE; -const TAG_LINE_LAYER_BASE = pardes.TAG_LINE_LAYER_BASE; -const HEADER_LINE_LAYER_BASE = pardes.HEADER_LINE_LAYER_BASE; -const MAX_COLS = pardes.MAX_COLS; -const TOPBAR_H = pardes.TOPBAR_H; -const COLBAR_H = pardes.COLBAR_H; -const TAG_GAP = pardes.TAG_GAP; -const wordBoundsAtCol = pardes.wordBoundsAtCol; const Layer = @import("Layer.zig"); @@ -71,14 +58,9 @@ fn paintTerminalSelection(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, rows: [ lo = modal.graphemeStart(line, @min(lo, line.len)); hi = @min(hi, line.len); if (lo >= hi) continue; - var col = panes.File.rawDisplayCol(line, lo); - const end = if (row.to_edge and hi == line.len) width else panes.File.rawDisplayCol(line, hi); - while (col < end and col < width) : (col += 1) { - const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(visible))); - cell.default = false; - cell.style.bg = .{ .rgb = bg }; - if (fg) |ink| cell.style.fg = .{ .rgb = ink }; - } + const col = panes.File.rawDisplayCol(line, lo); + const end = @min(width, if (row.to_edge and hi == line.len) width else panes.File.rawDisplayCol(line, hi)); + if (col < end) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(visible)), @intCast(end - col), bg, fg); } } } @@ -113,14 +95,9 @@ fn paintSourceSelection(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, rows: []c const lo = @max(start, row.lo); const hi = @min(end, row.hi); if (lo >= hi) continue; - var col = prefix + source.pad + @as(i32, @intCast(panes.File.rawDisplayCol(line[start..], lo - start))); - const last = if (row.to_edge and hi == end) @as(i32, width) else prefix + source.pad + @as(i32, @intCast(panes.File.rawDisplayCol(line[start..], hi - start))); - while (col < last and col < width) : (col += 1) { - const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(visible))); - cell.default = false; - cell.style.bg = .{ .rgb = bg }; - if (fg) |ink| cell.style.fg = .{ .rgb = ink }; - } + const col = prefix + source.pad + @as(i32, @intCast(panes.File.rawDisplayCol(line[start..], lo - start))); + const last = @min(width, if (row.to_edge and hi == end) @as(i32, width) else prefix + source.pad + @as(i32, @intCast(panes.File.rawDisplayCol(line[start..], hi - start)))); + if (col < last) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(visible)), @intCast(last - col), bg, fg); } } } @@ -151,15 +128,11 @@ pub fn paintPointerSelection( // File line numbers occupy a gutter only in the body. The tag is // row zero in Sel space and starts at its real first text cell. const scroll: i32 = if (row < pane.tag_rows) pane.tag_scroll else 0; - var col: i32 = if (pane.file != null and row >= pane.tag_rows) @max(c0, @as(i32, panes.File.gutterWidth(pane))) else @max(0, c0 - scroll); + const col: i32 = if (pane.file != null and row >= pane.tag_rows) @max(c0, @as(i32, panes.File.gutterWidth(pane))) else @max(0, c0 - scroll); const row_x = if (row < pane.tag_rows) r.x + @min(TAG_TEXT_INSET, r.w) else tx; const row_width = if (row < pane.tag_rows) r.w -| TAG_TEXT_INSET else tw; - while (col <= c1 - scroll and col < row_width) : (col += 1) { - const cell = s.at(row_x + @as(u16, @intCast(col)), sy); - cell.default = false; - cell.style.bg = .{ .rgb = bg }; - if (fg) |ink| cell.style.fg = .{ .rgb = ink }; - } + const end = @min(c1 - scroll + 1, row_width); + if (col < end) s.tint(row_x + @as(u16, @intCast(col)), sy, @intCast(end - col), bg, fg); } } @@ -345,13 +318,8 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane while (row < body_bottom) : (row += 1) { const ar = pane.wrapAt(@as(i32, row) - @as(i32, pane.tag_rows)).line; if (ar < lo or ar > hi) continue; - var col: u16 = if (pane.file != null) panes.File.gutterWidth(pane) else 0; - while (col < tw) : (col += 1) { - const cell = s.at(tx + col, body_y + row - pane.tag_rows); - cell.default = false; - cell.style.bg = .{ .rgb = modal_bg }; - if (!hover_only) cell.style.fg = .{ .rgb = th.sel_fg }; - } + const col: u16 = if (pane.file != null) panes.File.gutterWidth(pane) else 0; + if (col < tw) s.tint(tx + col, body_y + row - pane.tag_rows, tw - col, modal_bg, if (hover_only) null else th.sel_fg); } } const preview = normal.selRegexArmed(pane) != null; @@ -409,13 +377,9 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane panes.File.lineDisplayEndOffset(visible_line, @intCast(@max(0, w.at)), @intCast(@max(0, bnd.hi_col)))) + vpfx + w.pad else @as(i32, tw) - 1; - var col: i32 = @max(cstart, vpfx); - while (col <= cend and col < tw) : (col += 1) { - const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr))); - cell.default = false; - cell.style.bg = .{ .rgb = bg }; - if (!hover_only) cell.style.fg = .{ .rgb = th.sel_fg }; - } + const col: i32 = @max(cstart, vpfx); + const end = @min(cend + 1, tw); + if (col < end) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr)), @intCast(end - col), bg, if (hover_only) null else th.sel_fg); } if (primary and !preview and !hover_only) continue; // the hardware cursor IS the primary's if (hover_only) continue; // quiet preview preserves the source ink |
