mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-23 04:06:13 +03:00
terminal/kitty: support cells with no diacritics
This commit is contained in:
@ -31,14 +31,17 @@ pub const PlacementIterator = struct {
|
|||||||
|
|
||||||
pub fn next(self: *PlacementIterator) ?Placement {
|
pub fn next(self: *PlacementIterator) ?Placement {
|
||||||
while (self.row) |*row| {
|
while (self.row) |*row| {
|
||||||
|
// This row flag is set on rows that have the virtual placeholder
|
||||||
|
if (!row.rowAndCell().row.kitty_virtual_placeholder) {
|
||||||
|
self.row = self.row_it.next();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Our current run. A run is always only a single row. This
|
// Our current run. A run is always only a single row. This
|
||||||
// assumption is built-in to our logic so if we want to change
|
// assumption is built-in to our logic so if we want to change
|
||||||
// this later we have to redo the logic; tests should cover;
|
// this later we have to redo the logic; tests should cover;
|
||||||
var run: ?IncompletePlacement = null;
|
var run: ?IncompletePlacement = null;
|
||||||
|
|
||||||
// A row must have graphemes to possibly have virtual placements
|
|
||||||
// since virtual placements are done via diacritics.
|
|
||||||
if (row.rowAndCell().row.grapheme) {
|
|
||||||
// Iterate over our remaining cells and find one with a placeholder.
|
// Iterate over our remaining cells and find one with a placeholder.
|
||||||
const cells = row.cells(.right);
|
const cells = row.cells(.right);
|
||||||
for (cells, row.x..) |*cell, x| {
|
for (cells, row.x..) |*cell, x| {
|
||||||
@ -56,10 +59,6 @@ pub const PlacementIterator = struct {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: we need to support non-grapheme cells that just
|
|
||||||
// do continuations all the way through.
|
|
||||||
assert(cell.hasGrapheme());
|
|
||||||
|
|
||||||
// If we don't have a previous run, then we save this
|
// If we don't have a previous run, then we save this
|
||||||
// incomplete one, start a run, and move on.
|
// incomplete one, start a run, and move on.
|
||||||
const curr = IncompletePlacement.init(row, cell);
|
const curr = IncompletePlacement.init(row, cell);
|
||||||
@ -84,7 +83,6 @@ pub const PlacementIterator = struct {
|
|||||||
run = prev;
|
run = prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// We move to the next row no matter what
|
// We move to the next row no matter what
|
||||||
self.row = self.row_it.next();
|
self.row = self.row_it.next();
|
||||||
@ -730,6 +728,33 @@ test "unicode placement: continuation with no col" {
|
|||||||
try testing.expect(it.next() == null);
|
try testing.expect(it.next() == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "unicode placement: continuation with no diacritics" {
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
var t = try terminal.Terminal.init(alloc, .{ .rows = 5, .cols = 10 });
|
||||||
|
defer t.deinit(alloc);
|
||||||
|
t.modes.set(.grapheme_cluster, true);
|
||||||
|
|
||||||
|
// Three cells. They'll continue even though they're explicit
|
||||||
|
try t.printString("\u{10EEEE}");
|
||||||
|
try t.printString("\u{10EEEE}");
|
||||||
|
try t.printString("\u{10EEEE}");
|
||||||
|
|
||||||
|
// Get our top left pin
|
||||||
|
const pin = t.screen.pages.getTopLeft(.viewport);
|
||||||
|
|
||||||
|
// Should have exactly one placement
|
||||||
|
var it = placementIterator(pin, null);
|
||||||
|
{
|
||||||
|
const p = it.next().?;
|
||||||
|
try testing.expectEqual(0, p.image_id);
|
||||||
|
try testing.expectEqual(0, p.placement_id);
|
||||||
|
try testing.expectEqual(0, p.row);
|
||||||
|
try testing.expectEqual(0, p.col);
|
||||||
|
try testing.expectEqual(3, p.width);
|
||||||
|
}
|
||||||
|
try testing.expect(it.next() == null);
|
||||||
|
}
|
||||||
|
|
||||||
test "unicode placement: run ending" {
|
test "unicode placement: run ending" {
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
var t = try terminal.Terminal.init(alloc, .{ .rows = 5, .cols = 10 });
|
var t = try terminal.Terminal.init(alloc, .{ .rows = 5, .cols = 10 });
|
||||||
|
Reference in New Issue
Block a user