mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-16 23:06:20 +00:00
move runIterator options to dedicated struct
This commit is contained in:
@@ -2,6 +2,9 @@ const builtin = @import("builtin");
|
|||||||
const options = @import("main.zig").options;
|
const options = @import("main.zig").options;
|
||||||
const run = @import("shaper/run.zig");
|
const run = @import("shaper/run.zig");
|
||||||
const feature = @import("shaper/feature.zig");
|
const feature = @import("shaper/feature.zig");
|
||||||
|
const configpkg = @import("../config.zig");
|
||||||
|
const terminal = @import("../terminal/main.zig");
|
||||||
|
const SharedGrid = @import("main.zig").SharedGrid;
|
||||||
pub const noop = @import("shaper/noop.zig");
|
pub const noop = @import("shaper/noop.zig");
|
||||||
pub const harfbuzz = @import("shaper/harfbuzz.zig");
|
pub const harfbuzz = @import("shaper/harfbuzz.zig");
|
||||||
pub const coretext = @import("shaper/coretext.zig");
|
pub const coretext = @import("shaper/coretext.zig");
|
||||||
@@ -61,6 +64,38 @@ pub const Options = struct {
|
|||||||
features: []const []const u8 = &.{},
|
features: []const []const u8 = &.{},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Options for runIterator.
|
||||||
|
pub const RunOptions = struct {
|
||||||
|
/// The font state for the terminal screen. This is mutable because
|
||||||
|
/// cached values may be updated during shaping.
|
||||||
|
grid: *SharedGrid,
|
||||||
|
|
||||||
|
/// The terminal screen to shape.
|
||||||
|
screen: *const terminal.Screen,
|
||||||
|
|
||||||
|
/// The row within the screen to shape. This row must exist within
|
||||||
|
/// screen; it is not validated.
|
||||||
|
row: terminal.Pin,
|
||||||
|
|
||||||
|
/// The selection boundaries. This is used to break shaping on
|
||||||
|
/// selection boundaries. This can be disabled by setting this to
|
||||||
|
/// null.
|
||||||
|
selection: ?terminal.Selection = null,
|
||||||
|
|
||||||
|
/// The cursor position within this row. This is used to break shaping
|
||||||
|
/// on cursor boundaries. This can be disabled by setting this to
|
||||||
|
/// null.
|
||||||
|
cursor_x: ?usize = null,
|
||||||
|
|
||||||
|
/// Apply the font break configuration to the run.
|
||||||
|
pub fn applyBreakConfig(
|
||||||
|
self: *RunOptions,
|
||||||
|
config: configpkg.FontShapingBreak,
|
||||||
|
) void {
|
||||||
|
if (!config.cursor) self.cursor_x = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
test {
|
test {
|
||||||
_ = Cache;
|
_ = Cache;
|
||||||
_ = Shaper;
|
_ = Shaper;
|
||||||
|
@@ -289,21 +289,11 @@ pub const Shaper = struct {
|
|||||||
|
|
||||||
pub fn runIterator(
|
pub fn runIterator(
|
||||||
self: *Shaper,
|
self: *Shaper,
|
||||||
grid: *SharedGrid,
|
opts: font.shape.RunOptions,
|
||||||
screen: *const terminal.Screen,
|
|
||||||
row: terminal.Pin,
|
|
||||||
selection: ?terminal.Selection,
|
|
||||||
cursor_x: ?usize,
|
|
||||||
break_config: config.FontShapingBreak,
|
|
||||||
) font.shape.RunIterator {
|
) font.shape.RunIterator {
|
||||||
return .{
|
return .{
|
||||||
.hooks = .{ .shaper = self },
|
.hooks = .{ .shaper = self },
|
||||||
.grid = grid,
|
.opts = opts,
|
||||||
.screen = screen,
|
|
||||||
.row = row,
|
|
||||||
.selection = selection,
|
|
||||||
.cursor_x = cursor_x,
|
|
||||||
.break_config = break_config,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,14 +587,11 @@ test "run iterator" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |_| count += 1;
|
while (try it.next(alloc)) |_| count += 1;
|
||||||
try testing.expectEqual(@as(usize, 1), count);
|
try testing.expectEqual(@as(usize, 1), count);
|
||||||
@@ -617,14 +604,11 @@ test "run iterator" {
|
|||||||
try screen.testWriteString("ABCD EFG");
|
try screen.testWriteString("ABCD EFG");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |_| count += 1;
|
while (try it.next(alloc)) |_| count += 1;
|
||||||
try testing.expectEqual(@as(usize, 1), count);
|
try testing.expectEqual(@as(usize, 1), count);
|
||||||
@@ -638,14 +622,11 @@ test "run iterator" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |_| count += 1;
|
while (try it.next(alloc)) |_| count += 1;
|
||||||
try testing.expectEqual(@as(usize, 3), count);
|
try testing.expectEqual(@as(usize, 3), count);
|
||||||
@@ -660,14 +641,11 @@ test "run iterator" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |_| count += 1;
|
while (try it.next(alloc)) |_| count += 1;
|
||||||
try testing.expectEqual(@as(usize, 2), count);
|
try testing.expectEqual(@as(usize, 2), count);
|
||||||
@@ -708,14 +686,11 @@ test "run iterator: empty cells with background set" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
{
|
{
|
||||||
const run = (try it.next(alloc)).?;
|
const run = (try it.next(alloc)).?;
|
||||||
const cells = try shaper.shape(run);
|
const cells = try shaper.shape(run);
|
||||||
@@ -745,14 +720,11 @@ test "shape" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -781,14 +753,11 @@ test "shape nerd fonts" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -810,14 +779,11 @@ test "shape inconsolata ligs" {
|
|||||||
try screen.testWriteString(">=");
|
try screen.testWriteString(">=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -836,14 +802,11 @@ test "shape inconsolata ligs" {
|
|||||||
try screen.testWriteString("===");
|
try screen.testWriteString("===");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -870,14 +833,11 @@ test "shape monaspace ligs" {
|
|||||||
try screen.testWriteString("===");
|
try screen.testWriteString("===");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -905,14 +865,11 @@ test "shape left-replaced lig in last run" {
|
|||||||
try screen.testWriteString("!==");
|
try screen.testWriteString("!==");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -940,14 +897,11 @@ test "shape left-replaced lig in early run" {
|
|||||||
try screen.testWriteString("!==X");
|
try screen.testWriteString("!==X");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
|
|
||||||
const run = (try it.next(alloc)).?;
|
const run = (try it.next(alloc)).?;
|
||||||
|
|
||||||
@@ -972,14 +926,11 @@ test "shape U+3C9 with JB Mono" {
|
|||||||
try screen.testWriteString("\u{03C9} foo");
|
try screen.testWriteString("\u{03C9} foo");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
|
|
||||||
var run_count: usize = 0;
|
var run_count: usize = 0;
|
||||||
var cell_count: usize = 0;
|
var cell_count: usize = 0;
|
||||||
@@ -1006,14 +957,11 @@ test "shape emoji width" {
|
|||||||
try screen.testWriteString("👍");
|
try screen.testWriteString("👍");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1057,14 +1005,11 @@ test "shape emoji width long" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 1 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 1 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1094,14 +1039,11 @@ test "shape variation selector VS15" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1130,14 +1072,11 @@ test "shape variation selector VS16" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1163,14 +1102,11 @@ test "shape with empty cells in between" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1202,14 +1138,11 @@ test "shape Chinese characters" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1243,14 +1176,11 @@ test "shape box glyphs" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1280,18 +1210,16 @@ test "shape selection boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
terminal.Selection.init(
|
.selection = terminal.Selection.init(
|
||||||
screen.pages.pin(.{ .active = .{ .x = 0, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 0, .y = 0 } }).?,
|
||||||
screen.pages.pin(.{ .active = .{ .x = screen.pages.cols - 1, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = screen.pages.cols - 1, .y = 0 } }).?,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
null,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1304,18 +1232,16 @@ test "shape selection boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
terminal.Selection.init(
|
.selection = terminal.Selection.init(
|
||||||
screen.pages.pin(.{ .active = .{ .x = 2, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 2, .y = 0 } }).?,
|
||||||
screen.pages.pin(.{ .active = .{ .x = screen.pages.cols - 1, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = screen.pages.cols - 1, .y = 0 } }).?,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
null,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1328,18 +1254,16 @@ test "shape selection boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
terminal.Selection.init(
|
.selection = terminal.Selection.init(
|
||||||
screen.pages.pin(.{ .active = .{ .x = 0, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 0, .y = 0 } }).?,
|
||||||
screen.pages.pin(.{ .active = .{ .x = 3, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 3, .y = 0 } }).?,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
null,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1352,18 +1276,16 @@ test "shape selection boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
terminal.Selection.init(
|
.selection = terminal.Selection.init(
|
||||||
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
||||||
screen.pages.pin(.{ .active = .{ .x = 3, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 3, .y = 0 } }).?,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
null,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1376,18 +1298,16 @@ test "shape selection boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
terminal.Selection.init(
|
.selection = terminal.Selection.init(
|
||||||
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
||||||
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
null,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1413,14 +1333,11 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1434,14 +1351,12 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
.cursor_x = 0,
|
||||||
0,
|
});
|
||||||
.{ .cursor = true },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1453,14 +1368,11 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
0,
|
|
||||||
.{ .cursor = false },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1475,14 +1387,12 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
.cursor_x = 1,
|
||||||
1,
|
});
|
||||||
.{ .cursor = true },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1494,14 +1404,11 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
1,
|
|
||||||
.{ .cursor = false },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1515,14 +1422,12 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
.cursor_x = 9,
|
||||||
9,
|
});
|
||||||
.{ .cursor = true },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1534,14 +1439,11 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
9,
|
|
||||||
.{ .cursor = false },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1568,14 +1470,11 @@ test "shape cursor boundary and colored emoji" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1588,14 +1487,12 @@ test "shape cursor boundary and colored emoji" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
.cursor_x = 0,
|
||||||
0,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1606,14 +1503,11 @@ test "shape cursor boundary and colored emoji" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
0,
|
|
||||||
.{ .cursor = false },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1624,14 +1518,12 @@ test "shape cursor boundary and colored emoji" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
.cursor_x = 1,
|
||||||
1,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1642,14 +1534,11 @@ test "shape cursor boundary and colored emoji" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
1,
|
|
||||||
.{ .cursor = false },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1673,14 +1562,11 @@ test "shape cell attribute change" {
|
|||||||
try screen.testWriteString(">=");
|
try screen.testWriteString(">=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1698,14 +1584,11 @@ test "shape cell attribute change" {
|
|||||||
try screen.testWriteString("=");
|
try screen.testWriteString("=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1724,14 +1607,11 @@ test "shape cell attribute change" {
|
|||||||
try screen.testWriteString("=");
|
try screen.testWriteString("=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1750,14 +1630,11 @@ test "shape cell attribute change" {
|
|||||||
try screen.testWriteString("=");
|
try screen.testWriteString("=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1775,14 +1652,11 @@ test "shape cell attribute change" {
|
|||||||
try screen.testWriteString("=");
|
try screen.testWriteString("=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1816,14 +1690,11 @@ test "shape high plane sprite font codepoint" {
|
|||||||
try screen.testWriteString("\u{1FB70}");
|
try screen.testWriteString("\u{1FB70}");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
// We should get one run
|
// We should get one run
|
||||||
const run = (try it.next(alloc)).?;
|
const run = (try it.next(alloc)).?;
|
||||||
// The run state should have the UTF-16 encoding of the character.
|
// The run state should have the UTF-16 encoding of the character.
|
||||||
|
@@ -90,21 +90,11 @@ pub const Shaper = struct {
|
|||||||
/// and assume the y value matches.
|
/// and assume the y value matches.
|
||||||
pub fn runIterator(
|
pub fn runIterator(
|
||||||
self: *Shaper,
|
self: *Shaper,
|
||||||
grid: *SharedGrid,
|
opts: font.shape.RunOptions,
|
||||||
screen: *const terminal.Screen,
|
|
||||||
row: terminal.Pin,
|
|
||||||
selection: ?terminal.Selection,
|
|
||||||
cursor_x: ?usize,
|
|
||||||
break_config: config.FontShapingBreak,
|
|
||||||
) font.shape.RunIterator {
|
) font.shape.RunIterator {
|
||||||
return .{
|
return .{
|
||||||
.hooks = .{ .shaper = self },
|
.hooks = .{ .shaper = self },
|
||||||
.grid = grid,
|
.opts = opts,
|
||||||
.screen = screen,
|
|
||||||
.row = row,
|
|
||||||
.selection = selection,
|
|
||||||
.cursor_x = cursor_x,
|
|
||||||
.break_config = break_config,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,14 +218,11 @@ test "run iterator" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |_| count += 1;
|
while (try it.next(alloc)) |_| count += 1;
|
||||||
try testing.expectEqual(@as(usize, 1), count);
|
try testing.expectEqual(@as(usize, 1), count);
|
||||||
@@ -248,14 +235,11 @@ test "run iterator" {
|
|||||||
try screen.testWriteString("ABCD EFG");
|
try screen.testWriteString("ABCD EFG");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |_| count += 1;
|
while (try it.next(alloc)) |_| count += 1;
|
||||||
try testing.expectEqual(@as(usize, 1), count);
|
try testing.expectEqual(@as(usize, 1), count);
|
||||||
@@ -269,14 +253,11 @@ test "run iterator" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |_| {
|
while (try it.next(alloc)) |_| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -322,14 +303,11 @@ test "run iterator: empty cells with background set" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
{
|
{
|
||||||
const run = (try it.next(alloc)).?;
|
const run = (try it.next(alloc)).?;
|
||||||
try testing.expectEqual(@as(u32, 3), shaper.hb_buf.getLength());
|
try testing.expectEqual(@as(u32, 3), shaper.hb_buf.getLength());
|
||||||
@@ -360,14 +338,11 @@ test "shape" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -390,14 +365,11 @@ test "shape inconsolata ligs" {
|
|||||||
try screen.testWriteString(">=");
|
try screen.testWriteString(">=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -416,14 +388,11 @@ test "shape inconsolata ligs" {
|
|||||||
try screen.testWriteString("===");
|
try screen.testWriteString("===");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -450,14 +419,11 @@ test "shape monaspace ligs" {
|
|||||||
try screen.testWriteString("===");
|
try screen.testWriteString("===");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -487,14 +453,11 @@ test "shape arabic forced LTR" {
|
|||||||
try screen.testWriteString(@embedFile("testdata/arabic.txt"));
|
try screen.testWriteString(@embedFile("testdata/arabic.txt"));
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -525,14 +488,11 @@ test "shape emoji width" {
|
|||||||
try screen.testWriteString("👍");
|
try screen.testWriteString("👍");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -578,14 +538,11 @@ test "shape emoji width long" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 1 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 1 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -617,14 +574,11 @@ test "shape variation selector VS15" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -655,14 +609,11 @@ test "shape variation selector VS16" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -690,14 +641,11 @@ test "shape with empty cells in between" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -729,14 +677,11 @@ test "shape Chinese characters" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -770,14 +715,11 @@ test "shape box glyphs" {
|
|||||||
|
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -808,18 +750,16 @@ test "shape selection boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
terminal.Selection.init(
|
.selection = terminal.Selection.init(
|
||||||
screen.pages.pin(.{ .active = .{ .x = 0, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 0, .y = 0 } }).?,
|
||||||
screen.pages.pin(.{ .active = .{ .x = screen.pages.cols - 1, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = screen.pages.cols - 1, .y = 0 } }).?,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
null,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -832,18 +772,16 @@ test "shape selection boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
terminal.Selection.init(
|
.selection = terminal.Selection.init(
|
||||||
screen.pages.pin(.{ .active = .{ .x = 2, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 2, .y = 0 } }).?,
|
||||||
screen.pages.pin(.{ .active = .{ .x = screen.pages.cols - 1, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = screen.pages.cols - 1, .y = 0 } }).?,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
null,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -856,18 +794,16 @@ test "shape selection boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
terminal.Selection.init(
|
.selection = terminal.Selection.init(
|
||||||
screen.pages.pin(.{ .active = .{ .x = 0, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 0, .y = 0 } }).?,
|
||||||
screen.pages.pin(.{ .active = .{ .x = 3, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 3, .y = 0 } }).?,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
null,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -880,18 +816,16 @@ test "shape selection boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
terminal.Selection.init(
|
.selection = terminal.Selection.init(
|
||||||
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
||||||
screen.pages.pin(.{ .active = .{ .x = 3, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 3, .y = 0 } }).?,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
null,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -904,18 +838,16 @@ test "shape selection boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
terminal.Selection.init(
|
.selection = terminal.Selection.init(
|
||||||
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
||||||
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
screen.pages.pin(.{ .active = .{ .x = 1, .y = 0 } }).?,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
null,
|
});
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -941,14 +873,11 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -962,14 +891,12 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
.cursor_x = 0,
|
||||||
0,
|
});
|
||||||
.{ .cursor = true },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -981,14 +908,11 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
0,
|
|
||||||
.{ .cursor = false },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1003,14 +927,12 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
.cursor_x = 1,
|
||||||
1,
|
});
|
||||||
.{ .cursor = true },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1022,14 +944,11 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
1,
|
|
||||||
.{ .cursor = false },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1043,14 +962,12 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
.cursor_x = 9,
|
||||||
9,
|
});
|
||||||
.{ .cursor = true },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1062,14 +979,11 @@ test "shape cursor boundary" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
9,
|
|
||||||
.{ .cursor = false },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1096,14 +1010,11 @@ test "shape cursor boundary and colored emoji" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1116,14 +1027,12 @@ test "shape cursor boundary and colored emoji" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
.cursor_x = 0,
|
||||||
0,
|
});
|
||||||
.{ .cursor = true },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1134,14 +1043,11 @@ test "shape cursor boundary and colored emoji" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
0,
|
|
||||||
.{ .cursor = false },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1152,14 +1058,12 @@ test "shape cursor boundary and colored emoji" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
.cursor_x = 1,
|
||||||
1,
|
});
|
||||||
.{ .cursor = true },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1170,14 +1074,11 @@ test "shape cursor boundary and colored emoji" {
|
|||||||
{
|
{
|
||||||
// Get our run iterator
|
// Get our run iterator
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
1,
|
|
||||||
.{ .cursor = false },
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1201,14 +1102,11 @@ test "shape cell attribute change" {
|
|||||||
try screen.testWriteString(">=");
|
try screen.testWriteString(">=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1226,14 +1124,11 @@ test "shape cell attribute change" {
|
|||||||
try screen.testWriteString("=");
|
try screen.testWriteString("=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1252,14 +1147,11 @@ test "shape cell attribute change" {
|
|||||||
try screen.testWriteString("=");
|
try screen.testWriteString("=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1278,14 +1170,11 @@ test "shape cell attribute change" {
|
|||||||
try screen.testWriteString("=");
|
try screen.testWriteString("=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
@@ -1303,14 +1192,11 @@ test "shape cell attribute change" {
|
|||||||
try screen.testWriteString("=");
|
try screen.testWriteString("=");
|
||||||
|
|
||||||
var shaper = &testdata.shaper;
|
var shaper = &testdata.shaper;
|
||||||
var it = shaper.runIterator(
|
var it = shaper.runIterator(.{
|
||||||
testdata.grid,
|
.grid = testdata.grid,
|
||||||
&screen,
|
.screen = &screen,
|
||||||
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
.row = screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
|
||||||
null,
|
});
|
||||||
null,
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
while (try it.next(alloc)) |run| {
|
while (try it.next(alloc)) |run| {
|
||||||
count += 1;
|
count += 1;
|
||||||
|
@@ -3,7 +3,6 @@ const assert = std.debug.assert;
|
|||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const trace = @import("tracy").trace;
|
const trace = @import("tracy").trace;
|
||||||
const font = @import("../main.zig");
|
const font = @import("../main.zig");
|
||||||
const config = @import("../../config.zig");
|
|
||||||
const Face = font.Face;
|
const Face = font.Face;
|
||||||
const Collection = font.Collection;
|
const Collection = font.Collection;
|
||||||
const DeferredFace = font.DeferredFace;
|
const DeferredFace = font.DeferredFace;
|
||||||
@@ -71,21 +70,11 @@ pub const Shaper = struct {
|
|||||||
|
|
||||||
pub fn runIterator(
|
pub fn runIterator(
|
||||||
self: *Shaper,
|
self: *Shaper,
|
||||||
grid: *SharedGrid,
|
opts: font.shape.RunOptions,
|
||||||
screen: *const terminal.Screen,
|
|
||||||
row: terminal.Pin,
|
|
||||||
selection: ?terminal.Selection,
|
|
||||||
cursor_x: ?usize,
|
|
||||||
break_config: config.FontShapingBreak,
|
|
||||||
) font.shape.RunIterator {
|
) font.shape.RunIterator {
|
||||||
return .{
|
return .{
|
||||||
.hooks = .{ .shaper = self },
|
.hooks = .{ .shaper = self },
|
||||||
.grid = grid,
|
.opts = opts,
|
||||||
.screen = screen,
|
|
||||||
.row = row,
|
|
||||||
.selection = selection,
|
|
||||||
.cursor_x = cursor_x,
|
|
||||||
.break_config = break_config,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,8 +6,6 @@ const shape = @import("../shape.zig");
|
|||||||
const terminal = @import("../../terminal/main.zig");
|
const terminal = @import("../../terminal/main.zig");
|
||||||
const autoHash = std.hash.autoHash;
|
const autoHash = std.hash.autoHash;
|
||||||
const Hasher = std.hash.Wyhash;
|
const Hasher = std.hash.Wyhash;
|
||||||
const configpkg = @import("../../config.zig");
|
|
||||||
const Config = configpkg.Config;
|
|
||||||
|
|
||||||
/// A single text run. A text run is only valid for one Shaper instance and
|
/// A single text run. A text run is only valid for one Shaper instance and
|
||||||
/// until the next run is created. A text run never goes across multiple
|
/// until the next run is created. A text run never goes across multiple
|
||||||
@@ -37,16 +35,11 @@ pub const TextRun = struct {
|
|||||||
/// RunIterator is an iterator that yields text runs.
|
/// RunIterator is an iterator that yields text runs.
|
||||||
pub const RunIterator = struct {
|
pub const RunIterator = struct {
|
||||||
hooks: font.Shaper.RunIteratorHook,
|
hooks: font.Shaper.RunIteratorHook,
|
||||||
grid: *font.SharedGrid,
|
opts: shape.RunOptions,
|
||||||
screen: *const terminal.Screen,
|
|
||||||
row: terminal.Pin,
|
|
||||||
selection: ?terminal.Selection = null,
|
|
||||||
cursor_x: ?usize = null,
|
|
||||||
break_config: configpkg.FontShapingBreak,
|
|
||||||
i: usize = 0,
|
i: usize = 0,
|
||||||
|
|
||||||
pub fn next(self: *RunIterator, alloc: Allocator) !?TextRun {
|
pub fn next(self: *RunIterator, alloc: Allocator) !?TextRun {
|
||||||
const cells = self.row.cells(.all);
|
const cells = self.opts.row.cells(.all);
|
||||||
|
|
||||||
// Trim the right side of a row that might be empty
|
// Trim the right side of a row that might be empty
|
||||||
const max: usize = max: {
|
const max: usize = max: {
|
||||||
@@ -61,7 +54,7 @@ pub const RunIterator = struct {
|
|||||||
// Invisible cells don't have any glyphs rendered,
|
// Invisible cells don't have any glyphs rendered,
|
||||||
// so we explicitly skip them in the shaping process.
|
// so we explicitly skip them in the shaping process.
|
||||||
while (self.i < max and
|
while (self.i < max and
|
||||||
self.row.style(&cells[self.i]).flags.invisible)
|
self.opts.row.style(&cells[self.i]).flags.invisible)
|
||||||
{
|
{
|
||||||
self.i += 1;
|
self.i += 1;
|
||||||
}
|
}
|
||||||
@@ -79,7 +72,7 @@ pub const RunIterator = struct {
|
|||||||
var hasher = Hasher.init(0);
|
var hasher = Hasher.init(0);
|
||||||
|
|
||||||
// Let's get our style that we'll expect for the run.
|
// Let's get our style that we'll expect for the run.
|
||||||
const style = self.row.style(&cells[self.i]);
|
const style = self.opts.row.style(&cells[self.i]);
|
||||||
|
|
||||||
// Go through cell by cell and accumulate while we build our run.
|
// Go through cell by cell and accumulate while we build our run.
|
||||||
var j: usize = self.i;
|
var j: usize = self.i;
|
||||||
@@ -89,9 +82,9 @@ pub const RunIterator = struct {
|
|||||||
|
|
||||||
// If we have a selection and we're at a boundary point, then
|
// If we have a selection and we're at a boundary point, then
|
||||||
// we break the run here.
|
// we break the run here.
|
||||||
if (self.selection) |unordered_sel| {
|
if (self.opts.selection) |unordered_sel| {
|
||||||
if (j > self.i) {
|
if (j > self.i) {
|
||||||
const sel = unordered_sel.ordered(self.screen, .forward);
|
const sel = unordered_sel.ordered(self.opts.screen, .forward);
|
||||||
const start_x = sel.start().x;
|
const start_x = sel.start().x;
|
||||||
const end_x = sel.end().x;
|
const end_x = sel.end().x;
|
||||||
|
|
||||||
@@ -145,7 +138,7 @@ pub const RunIterator = struct {
|
|||||||
// The style is different. We allow differing background
|
// The style is different. We allow differing background
|
||||||
// styles but any other change results in a new run.
|
// styles but any other change results in a new run.
|
||||||
const c1 = comparableStyle(style);
|
const c1 = comparableStyle(style);
|
||||||
const c2 = comparableStyle(self.row.style(&cells[j]));
|
const c2 = comparableStyle(self.opts.row.style(&cells[j]));
|
||||||
if (!c1.eql(c2)) break;
|
if (!c1.eql(c2)) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +158,7 @@ pub const RunIterator = struct {
|
|||||||
const presentation: ?font.Presentation = if (cell.hasGrapheme()) p: {
|
const presentation: ?font.Presentation = if (cell.hasGrapheme()) p: {
|
||||||
// We only check the FIRST codepoint because I believe the
|
// We only check the FIRST codepoint because I believe the
|
||||||
// presentation format must be directly adjacent to the codepoint.
|
// presentation format must be directly adjacent to the codepoint.
|
||||||
const cps = self.row.grapheme(cell) orelse break :p null;
|
const cps = self.opts.row.grapheme(cell) orelse break :p null;
|
||||||
assert(cps.len > 0);
|
assert(cps.len > 0);
|
||||||
if (cps[0] == 0xFE0E) break :p .text;
|
if (cps[0] == 0xFE0E) break :p .text;
|
||||||
if (cps[0] == 0xFE0F) break :p .emoji;
|
if (cps[0] == 0xFE0F) break :p .emoji;
|
||||||
@@ -178,38 +171,36 @@ pub const RunIterator = struct {
|
|||||||
break :emoji null;
|
break :emoji null;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (self.break_config.cursor) {
|
// If our cursor is on this line then we break the run around the
|
||||||
// If our cursor is on this line then we break the run around the
|
// cursor. This means that any row with a cursor has at least
|
||||||
// cursor. This means that any row with a cursor has at least
|
// three breaks: before, exactly the cursor, and after.
|
||||||
// three breaks: before, exactly the cursor, and after.
|
//
|
||||||
//
|
// We do not break a cell that is exactly the grapheme. If there
|
||||||
// We do not break a cell that is exactly the grapheme. If there
|
// are cells following that contain joiners, we allow those to
|
||||||
// are cells following that contain joiners, we allow those to
|
// break. This creates an effect where hovering over an emoji
|
||||||
// break. This creates an effect where hovering over an emoji
|
// such as a skin-tone emoji is fine, but hovering over the
|
||||||
// such as a skin-tone emoji is fine, but hovering over the
|
// joiners will show the joiners allowing you to modify the
|
||||||
// joiners will show the joiners allowing you to modify the
|
// emoji.
|
||||||
// emoji.
|
if (!cell.hasGrapheme()) {
|
||||||
if (!cell.hasGrapheme()) {
|
if (self.opts.cursor_x) |cursor_x| {
|
||||||
if (self.cursor_x) |cursor_x| {
|
// Exactly: self.i is the cursor and we iterated once. This
|
||||||
// Exactly: self.i is the cursor and we iterated once. This
|
// means that we started exactly at the cursor and did at
|
||||||
// means that we started exactly at the cursor and did at
|
// exactly one iteration. Why exactly one? Because we may
|
||||||
// exactly one iteration. Why exactly one? Because we may
|
// start at our cursor but do many if our cursor is exactly
|
||||||
// start at our cursor but do many if our cursor is exactly
|
// on an emoji.
|
||||||
// on an emoji.
|
if (self.i == cursor_x and j == self.i + 1) break;
|
||||||
if (self.i == cursor_x and j == self.i + 1) break;
|
|
||||||
|
|
||||||
// Before: up to and not including the cursor. This means
|
// Before: up to and not including the cursor. This means
|
||||||
// that we started before the cursor (self.i < cursor_x)
|
// that we started before the cursor (self.i < cursor_x)
|
||||||
// and j is now at the cursor meaning we haven't yet processed
|
// and j is now at the cursor meaning we haven't yet processed
|
||||||
// the cursor.
|
// the cursor.
|
||||||
if (self.i < cursor_x and j == cursor_x) {
|
if (self.i < cursor_x and j == cursor_x) {
|
||||||
assert(j > 0);
|
assert(j > 0);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
// After: after the cursor. We don't need to do anything
|
|
||||||
// special, we just let the run complete.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// After: after the cursor. We don't need to do anything
|
||||||
|
// special, we just let the run complete.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +223,7 @@ pub const RunIterator = struct {
|
|||||||
|
|
||||||
// Otherwise we need a fallback character. Prefer the
|
// Otherwise we need a fallback character. Prefer the
|
||||||
// official replacement character.
|
// official replacement character.
|
||||||
if (try self.grid.getIndex(
|
if (try self.opts.grid.getIndex(
|
||||||
alloc,
|
alloc,
|
||||||
0xFFFD, // replacement char
|
0xFFFD, // replacement char
|
||||||
font_style,
|
font_style,
|
||||||
@@ -240,7 +231,7 @@ pub const RunIterator = struct {
|
|||||||
)) |idx| break :font_info .{ .idx = idx, .fallback = 0xFFFD };
|
)) |idx| break :font_info .{ .idx = idx, .fallback = 0xFFFD };
|
||||||
|
|
||||||
// Fallback to space
|
// Fallback to space
|
||||||
if (try self.grid.getIndex(
|
if (try self.opts.grid.getIndex(
|
||||||
alloc,
|
alloc,
|
||||||
' ',
|
' ',
|
||||||
font_style,
|
font_style,
|
||||||
@@ -278,7 +269,7 @@ pub const RunIterator = struct {
|
|||||||
@intCast(cluster),
|
@intCast(cluster),
|
||||||
);
|
);
|
||||||
if (cell.hasGrapheme()) {
|
if (cell.hasGrapheme()) {
|
||||||
const cps = self.row.grapheme(cell).?;
|
const cps = self.opts.row.grapheme(cell).?;
|
||||||
for (cps) |cp| {
|
for (cps) |cp| {
|
||||||
// Do not send presentation modifiers
|
// Do not send presentation modifiers
|
||||||
if (cp == 0xFE0E or cp == 0xFE0F) continue;
|
if (cp == 0xFE0E or cp == 0xFE0F) continue;
|
||||||
@@ -303,7 +294,7 @@ pub const RunIterator = struct {
|
|||||||
.hash = hasher.final(),
|
.hash = hasher.final(),
|
||||||
.offset = @intCast(self.i),
|
.offset = @intCast(self.i),
|
||||||
.cells = @intCast(j - self.i),
|
.cells = @intCast(j - self.i),
|
||||||
.grid = self.grid,
|
.grid = self.opts.grid,
|
||||||
.font_index = current_font,
|
.font_index = current_font,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -331,7 +322,7 @@ pub const RunIterator = struct {
|
|||||||
cell.codepoint() == 0 or
|
cell.codepoint() == 0 or
|
||||||
cell.codepoint() == terminal.kitty.graphics.unicode.placeholder)
|
cell.codepoint() == terminal.kitty.graphics.unicode.placeholder)
|
||||||
{
|
{
|
||||||
return try self.grid.getIndex(
|
return try self.opts.grid.getIndex(
|
||||||
alloc,
|
alloc,
|
||||||
' ',
|
' ',
|
||||||
style,
|
style,
|
||||||
@@ -341,7 +332,7 @@ pub const RunIterator = struct {
|
|||||||
|
|
||||||
// Get the font index for the primary codepoint.
|
// Get the font index for the primary codepoint.
|
||||||
const primary_cp: u32 = cell.codepoint();
|
const primary_cp: u32 = cell.codepoint();
|
||||||
const primary = try self.grid.getIndex(
|
const primary = try self.opts.grid.getIndex(
|
||||||
alloc,
|
alloc,
|
||||||
primary_cp,
|
primary_cp,
|
||||||
style,
|
style,
|
||||||
@@ -354,7 +345,7 @@ pub const RunIterator = struct {
|
|||||||
|
|
||||||
// If this is a grapheme, we need to find a font that supports
|
// If this is a grapheme, we need to find a font that supports
|
||||||
// all of the codepoints in the grapheme.
|
// all of the codepoints in the grapheme.
|
||||||
const cps = self.row.grapheme(cell) orelse return primary;
|
const cps = self.opts.row.grapheme(cell) orelse return primary;
|
||||||
var candidates = try std.ArrayList(font.Collection.Index).initCapacity(alloc, cps.len + 1);
|
var candidates = try std.ArrayList(font.Collection.Index).initCapacity(alloc, cps.len + 1);
|
||||||
defer candidates.deinit();
|
defer candidates.deinit();
|
||||||
candidates.appendAssumeCapacity(primary);
|
candidates.appendAssumeCapacity(primary);
|
||||||
@@ -370,7 +361,7 @@ pub const RunIterator = struct {
|
|||||||
// to support the base presentation, since it is common for emoji
|
// to support the base presentation, since it is common for emoji
|
||||||
// fonts to support the base emoji with emoji presentation but not
|
// fonts to support the base emoji with emoji presentation but not
|
||||||
// certain ZWJ-combined characters like the male and female signs.
|
// certain ZWJ-combined characters like the male and female signs.
|
||||||
const idx = try self.grid.getIndex(
|
const idx = try self.opts.grid.getIndex(
|
||||||
alloc,
|
alloc,
|
||||||
cp,
|
cp,
|
||||||
style,
|
style,
|
||||||
@@ -381,11 +372,11 @@ pub const RunIterator = struct {
|
|||||||
|
|
||||||
// We need to find a candidate that has ALL of our codepoints
|
// We need to find a candidate that has ALL of our codepoints
|
||||||
for (candidates.items) |idx| {
|
for (candidates.items) |idx| {
|
||||||
if (!self.grid.hasCodepoint(idx, primary_cp, presentation)) continue;
|
if (!self.opts.grid.hasCodepoint(idx, primary_cp, presentation)) continue;
|
||||||
for (cps) |cp| {
|
for (cps) |cp| {
|
||||||
// Ignore Emoji ZWJs
|
// Ignore Emoji ZWJs
|
||||||
if (cp == 0xFE0E or cp == 0xFE0F or cp == 0x200D) continue;
|
if (cp == 0xFE0E or cp == 0xFE0F or cp == 0x200D) continue;
|
||||||
if (!self.grid.hasCodepoint(idx, cp, null)) break;
|
if (!self.opts.grid.hasCodepoint(idx, cp, null)) break;
|
||||||
} else {
|
} else {
|
||||||
// If the while completed, then we have a candidate that
|
// If the while completed, then we have a candidate that
|
||||||
// supports all of our codepoints.
|
// supports all of our codepoints.
|
||||||
|
@@ -4,7 +4,6 @@ const Allocator = std.mem.Allocator;
|
|||||||
const ziglyph = @import("ziglyph");
|
const ziglyph = @import("ziglyph");
|
||||||
const font = @import("../main.zig");
|
const font = @import("../main.zig");
|
||||||
const terminal = @import("../../terminal/main.zig");
|
const terminal = @import("../../terminal/main.zig");
|
||||||
const config = @import("../../config.zig");
|
|
||||||
|
|
||||||
const log = std.log.scoped(.font_shaper);
|
const log = std.log.scoped(.font_shaper);
|
||||||
|
|
||||||
@@ -62,19 +61,11 @@ pub const Shaper = struct {
|
|||||||
/// for a Shaper struct since they share state.
|
/// for a Shaper struct since they share state.
|
||||||
pub fn runIterator(
|
pub fn runIterator(
|
||||||
self: *Shaper,
|
self: *Shaper,
|
||||||
group: *font.GroupCache,
|
opts: font.shape.RunOptions,
|
||||||
row: terminal.Screen.Row,
|
|
||||||
selection: ?terminal.Selection,
|
|
||||||
cursor_x: ?usize,
|
|
||||||
break_config: config.FontShapingBreak,
|
|
||||||
) font.shape.RunIterator {
|
) font.shape.RunIterator {
|
||||||
return .{
|
return .{
|
||||||
.hooks = .{ .shaper = self },
|
.hooks = .{ .shaper = self },
|
||||||
.group = group,
|
.opts = opts,
|
||||||
.row = row,
|
|
||||||
.selection = selection,
|
|
||||||
.cursor_x = cursor_x,
|
|
||||||
.break_config = break_config,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -513,6 +513,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
font_thicken_strength: u8,
|
font_thicken_strength: u8,
|
||||||
font_features: std.ArrayListUnmanaged([:0]const u8),
|
font_features: std.ArrayListUnmanaged([:0]const u8),
|
||||||
font_styles: font.CodepointResolver.StyleStatus,
|
font_styles: font.CodepointResolver.StyleStatus,
|
||||||
|
font_shaping_break: configpkg.FontShapingBreak,
|
||||||
cursor_color: ?terminal.color.RGB,
|
cursor_color: ?terminal.color.RGB,
|
||||||
cursor_invert: bool,
|
cursor_invert: bool,
|
||||||
cursor_opacity: f64,
|
cursor_opacity: f64,
|
||||||
@@ -578,6 +579,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
.font_thicken_strength = config.@"font-thicken-strength",
|
.font_thicken_strength = config.@"font-thicken-strength",
|
||||||
.font_features = font_features.list,
|
.font_features = font_features.list,
|
||||||
.font_styles = font_styles,
|
.font_styles = font_styles,
|
||||||
|
.font_shaping_break = config.@"font-shaping-break",
|
||||||
|
|
||||||
.cursor_color = if (!cursor_invert and config.@"cursor-color" != null)
|
.cursor_color = if (!cursor_invert and config.@"cursor-color" != null)
|
||||||
config.@"cursor-color".?.toTerminalRGB()
|
config.@"cursor-color".?.toTerminalRGB()
|
||||||
@@ -2467,13 +2469,15 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Iterator of runs for shaping.
|
// Iterator of runs for shaping.
|
||||||
var run_iter = self.font_shaper.runIterator(
|
var run_iter_opts: font.shape.RunOptions = .{
|
||||||
self.font_grid,
|
.grid = self.font_grid,
|
||||||
screen,
|
.screen = screen,
|
||||||
row,
|
.row = row,
|
||||||
row_selection,
|
.selection = row_selection,
|
||||||
if (shape_cursor) screen.cursor.x else null,
|
.cursor_x = if (shape_cursor) screen.cursor.x else null,
|
||||||
);
|
};
|
||||||
|
run_iter_opts.applyBreakConfig(self.config.font_shaping_break);
|
||||||
|
var run_iter = self.font_shaper.runIterator(run_iter_opts);
|
||||||
var shaper_run: ?font.shape.TextRun = try run_iter.next(self.alloc);
|
var shaper_run: ?font.shape.TextRun = try run_iter.next(self.alloc);
|
||||||
var shaper_cells: ?[]const font.shape.Cell = null;
|
var shaper_cells: ?[]const font.shape.Cell = null;
|
||||||
var shaper_cells_i: usize = 0;
|
var shaper_cells_i: usize = 0;
|
||||||
|
Reference in New Issue
Block a user