renderer: re-enable URL underlining

This commit is contained in:
Mitchell Hashimoto
2024-03-15 21:07:16 -07:00
parent 7419794a7b
commit fd9280429e
2 changed files with 28 additions and 44 deletions

View File

@ -1553,17 +1553,14 @@ fn rebuildCells(
var arena = ArenaAllocator.init(self.alloc); var arena = ArenaAllocator.init(self.alloc);
defer arena.deinit(); defer arena.deinit();
const arena_alloc = arena.allocator(); const arena_alloc = arena.allocator();
_ = arena_alloc;
_ = mouse;
// Create our match set for the links. // Create our match set for the links.
// TODO(paged-terminal) var link_match_set: link.MatchSet = if (mouse.point) |mouse_pt| try self.config.links.matchSet(
// var link_match_set: link.MatchSet = if (mouse.point) |mouse_pt| try self.config.links.matchSet( arena_alloc,
// arena_alloc, screen,
// screen, mouse_pt,
// mouse_pt, mouse.mods,
// mouse.mods, ) else .{};
// ) else .{};
// Determine our x/y range for preedit. We don't want to render anything // Determine our x/y range for preedit. We don't want to render anything
// here because we will render the preedit separately. // here because we will render the preedit separately.
@ -1672,21 +1669,15 @@ fn rebuildCells(
var copy = row; var copy = row;
copy.x = shaper_cell.x; copy.x = shaper_cell.x;
break :cell copy; break :cell copy;
// TODO(paged-terminal)
// // If our links contain this cell then we want to
// // underline it.
// if (link_match_set.orderedContains(.{
// .x = shaper_cell.x,
// .y = y,
// })) {
// cell.attrs.underline = .single;
// }
}; };
if (self.updateCell( if (self.updateCell(
screen, screen,
cell, cell,
if (link_match_set.orderedContains(screen, cell))
.single
else
null,
color_palette, color_palette,
shaper_cell, shaper_cell,
run, run,
@ -1754,6 +1745,7 @@ fn updateCell(
self: *Metal, self: *Metal,
screen: *const terminal.Screen, screen: *const terminal.Screen,
cell_pin: terminal.Pin, cell_pin: terminal.Pin,
cell_underline: ?terminal.Attribute.Underline,
palette: *const terminal.color.Palette, palette: *const terminal.color.Palette,
shaper_cell: font.shape.Cell, shaper_cell: font.shape.Cell,
shaper_run: font.shape.TextRun, shaper_run: font.shape.TextRun,
@ -1781,6 +1773,7 @@ fn updateCell(
const rac = cell_pin.rowAndCell(); const rac = cell_pin.rowAndCell();
const cell = rac.cell; const cell = rac.cell;
const style = cell_pin.style(cell); const style = cell_pin.style(cell);
const underline = cell_underline orelse style.flags.underline;
// The colors for the cell. // The colors for the cell.
const colors: BgFg = colors: { const colors: BgFg = colors: {
@ -1910,8 +1903,8 @@ fn updateCell(
}); });
} }
if (style.flags.underline != .none) { if (underline != .none) {
const sprite: font.Sprite = switch (style.flags.underline) { const sprite: font.Sprite = switch (underline) {
.none => unreachable, .none => unreachable,
.single => .underline, .single => .underline,
.double => .underline_double, .double => .underline_double,

View File

@ -974,20 +974,17 @@ pub fn rebuildCells(
var arena = ArenaAllocator.init(self.alloc); var arena = ArenaAllocator.init(self.alloc);
defer arena.deinit(); defer arena.deinit();
const arena_alloc = arena.allocator(); const arena_alloc = arena.allocator();
_ = arena_alloc;
_ = mouse;
// We've written no data to the GPU, refresh it all // We've written no data to the GPU, refresh it all
self.gl_cells_written = 0; self.gl_cells_written = 0;
// Create our match set for the links. // Create our match set for the links.
// TODO(paged-terminal) var link_match_set: link.MatchSet = if (mouse.point) |mouse_pt| try self.config.links.matchSet(
// var link_match_set: link.MatchSet = if (mouse.point) |mouse_pt| try self.config.links.matchSet( arena_alloc,
// arena_alloc, screen,
// screen, mouse_pt,
// mouse_pt, mouse.mods,
// mouse.mods, ) else .{};
// ) else .{};
// Determine our x/y range for preedit. We don't want to render anything // Determine our x/y range for preedit. We don't want to render anything
// here because we will render the preedit separately. // here because we will render the preedit separately.
@ -1085,23 +1082,15 @@ pub fn rebuildCells(
var copy = row; var copy = row;
copy.x = shaper_cell.x; copy.x = shaper_cell.x;
break :cell copy; break :cell copy;
// TODO(paged-terminal)
// // If our links contain this cell then we want to
// // underline it.
// if (link_match_set.orderedContains(.{
// .x = shaper_cell.x,
// .y = y,
// })) {
// cell.attrs.underline = .single;
// }
//
// break :cell cell;
}; };
if (self.updateCell( if (self.updateCell(
screen, screen,
cell, cell,
if (link_match_set.orderedContains(screen, cell))
.single
else
null,
color_palette, color_palette,
shaper_cell, shaper_cell,
run, run,
@ -1330,6 +1319,7 @@ fn updateCell(
self: *OpenGL, self: *OpenGL,
screen: *terminal.Screen, screen: *terminal.Screen,
cell_pin: terminal.Pin, cell_pin: terminal.Pin,
cell_underline: ?terminal.Attribute.Underline,
palette: *const terminal.color.Palette, palette: *const terminal.color.Palette,
shaper_cell: font.shape.Cell, shaper_cell: font.shape.Cell,
shaper_run: font.shape.TextRun, shaper_run: font.shape.TextRun,
@ -1357,6 +1347,7 @@ fn updateCell(
const rac = cell_pin.rowAndCell(); const rac = cell_pin.rowAndCell();
const cell = rac.cell; const cell = rac.cell;
const style = cell_pin.style(cell); const style = cell_pin.style(cell);
const underline = cell_underline orelse style.flags.underline;
// The colors for the cell. // The colors for the cell.
const colors: BgFg = colors: { const colors: BgFg = colors: {
@ -1507,8 +1498,8 @@ fn updateCell(
}); });
} }
if (style.flags.underline != .none) { if (underline != .none) {
const sprite: font.Sprite = switch (style.flags.underline) { const sprite: font.Sprite = switch (underline) {
.none => unreachable, .none => unreachable,
.single => .underline, .single => .underline,
.double => .underline_double, .double => .underline_double,