mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
input: add link highlight always/hover w/ mods
This commit is contained in:
@ -2289,7 +2289,7 @@ fn linkAtPos(
|
|||||||
for (self.config.links) |link| {
|
for (self.config.links) |link| {
|
||||||
switch (link.highlight) {
|
switch (link.highlight) {
|
||||||
.always, .hover => {},
|
.always, .hover => {},
|
||||||
.mods => |v| if (!v.equal(self.mouse.mods)) continue,
|
.always_mods, .hover_mods => |v| if (!v.equal(self.mouse.mods)) continue,
|
||||||
}
|
}
|
||||||
|
|
||||||
var it = strmap.searchIterator(link.regex);
|
var it = strmap.searchIterator(link.regex);
|
||||||
|
@ -1437,7 +1437,7 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
|
|||||||
try result.link.links.append(alloc, .{
|
try result.link.links.append(alloc, .{
|
||||||
.regex = url.regex,
|
.regex = url.regex,
|
||||||
.action = .{ .open = {} },
|
.action = .{ .open = {} },
|
||||||
.highlight = .{ .mods = inputpkg.ctrlOrSuper(.{}) },
|
.highlight = .{ .hover_mods = inputpkg.ctrlOrSuper(.{}) },
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -32,9 +32,12 @@ pub const Highlight = union(enum) {
|
|||||||
/// Only highlight the link when the mouse is hovering over it.
|
/// Only highlight the link when the mouse is hovering over it.
|
||||||
hover: void,
|
hover: void,
|
||||||
|
|
||||||
/// Highlight anytime the given mods are pressed, regardless of
|
/// Highlight anytime the given mods are pressed, either when
|
||||||
/// hover state.
|
/// hovering or always. For always, all links will be highlighted
|
||||||
mods: Mods,
|
/// when the mods are pressed regardless of if the mouse is hovering
|
||||||
|
/// over them.
|
||||||
|
always_mods: Mods,
|
||||||
|
hover_mods: Mods,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Returns a new oni.Regex that can be used to match the link.
|
/// Returns a new oni.Regex that can be used to match the link.
|
||||||
|
@ -991,6 +991,7 @@ pub fn rebuildCells(
|
|||||||
arena_alloc,
|
arena_alloc,
|
||||||
screen,
|
screen,
|
||||||
mouse.point orelse .{},
|
mouse.point orelse .{},
|
||||||
|
mouse.mods,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -96,8 +96,13 @@ pub const Set = struct {
|
|||||||
// error if any other conditions are added.
|
// error if any other conditions are added.
|
||||||
switch (link.highlight) {
|
switch (link.highlight) {
|
||||||
.always => {},
|
.always => {},
|
||||||
.hover => if (!line.selection().contains(mouse_pt)) continue,
|
.always_mods => |v| if (!mouse_mods.equal(v)) continue,
|
||||||
.mods => |v| if (!mouse_mods.equal(v)) continue,
|
inline .hover, .hover_mods => |v, tag| {
|
||||||
|
if (!line.selection().contains(mouse_pt)) continue;
|
||||||
|
if (comptime tag == .hover_mods) {
|
||||||
|
if (!mouse_mods.equal(v)) continue;
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var it = strmap.searchIterator(link.regex);
|
var it = strmap.searchIterator(link.regex);
|
||||||
|
Reference in New Issue
Block a user