mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-05 23:28:41 +00:00
terminal: redesign pin map for formatter
This commit is contained in:
@@ -6,9 +6,9 @@ const std = @import("std");
|
||||
const build_options = @import("terminal_options");
|
||||
const oni = @import("oniguruma");
|
||||
const point = @import("point.zig");
|
||||
const PinMap = @import("formatter.zig").PinMap;
|
||||
const Selection = @import("Selection.zig");
|
||||
const Screen = @import("Screen.zig");
|
||||
const Pin = @import("PageList.zig").Pin;
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
// Retry budget for StringMap regex searches.
|
||||
@@ -18,11 +18,15 @@ const Allocator = std.mem.Allocator;
|
||||
const oni_search_retry_limit = 100_000;
|
||||
|
||||
string: [:0]const u8,
|
||||
map: []Pin,
|
||||
|
||||
/// Mapping of string byte offsets to pins. See PinMap for the
|
||||
/// storage details.
|
||||
map: PinMap.Map,
|
||||
|
||||
pub fn deinit(self: StringMap, alloc: Allocator) void {
|
||||
alloc.free(self.string);
|
||||
alloc.free(self.map);
|
||||
var map = self.map;
|
||||
map.deinit(alloc);
|
||||
}
|
||||
|
||||
/// Returns an iterator that yields the next match of the given regex.
|
||||
@@ -106,8 +110,8 @@ pub const Match = struct {
|
||||
pub fn selection(self: Match) Selection {
|
||||
const start_idx: usize = @intCast(self.region.starts()[0]);
|
||||
const end_idx: usize = @intCast(self.region.ends()[0] - 1);
|
||||
const start_pt = self.map.map[self.offset + start_idx];
|
||||
const end_pt = self.map.map[self.offset + end_idx];
|
||||
const start_pt = self.map.map.get(self.offset + start_idx).?;
|
||||
const end_pt = self.map.map.get(self.offset + end_idx).?;
|
||||
return .init(start_pt, end_pt, false);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user