mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
terminal: cell returns empty for Kitty placeholder
So we don't render the replacement char
This commit is contained in:
@ -379,7 +379,11 @@ pub fn print(self: *Terminal, c: u21) !void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("c={x} grapheme attach to left={}", .{ c, prev.left });
|
log.debug("c={X} grapheme attach to left={} primary_cp={X}", .{
|
||||||
|
c,
|
||||||
|
prev.left,
|
||||||
|
prev.cell.codepoint(),
|
||||||
|
});
|
||||||
self.screen.cursorMarkDirty();
|
self.screen.cursorMarkDirty();
|
||||||
try self.screen.appendGrapheme(prev.cell, c);
|
try self.screen.appendGrapheme(prev.cell, c);
|
||||||
return;
|
return;
|
||||||
|
@ -21,6 +21,7 @@ pub usingnamespace @import("graphics_exec.zig");
|
|||||||
pub usingnamespace @import("graphics_image.zig");
|
pub usingnamespace @import("graphics_image.zig");
|
||||||
pub usingnamespace @import("graphics_storage.zig");
|
pub usingnamespace @import("graphics_storage.zig");
|
||||||
pub const diacritics = @import("graphics_diacritics.zig");
|
pub const diacritics = @import("graphics_diacritics.zig");
|
||||||
|
pub const placeholder = diacritics.placeholder;
|
||||||
|
|
||||||
test {
|
test {
|
||||||
@import("std").testing.refAllDecls(@This());
|
@import("std").testing.refAllDecls(@This());
|
||||||
|
@ -2,6 +2,9 @@ const std = @import("std");
|
|||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
|
|
||||||
|
/// Codepoint for the unicode placeholder character.
|
||||||
|
pub const placeholder: u21 = 0x10EEEE;
|
||||||
|
|
||||||
/// Get the row/col index for a diacritic codepoint.
|
/// Get the row/col index for a diacritic codepoint.
|
||||||
pub fn get(cp: u21) ?usize {
|
pub fn get(cp: u21) ?usize {
|
||||||
return std.sort.binarySearch(u21, cp, diacritics, {}, (struct {
|
return std.sort.binarySearch(u21, cp, diacritics, {}, (struct {
|
||||||
|
@ -8,6 +8,7 @@ const posix = std.posix;
|
|||||||
const fastmem = @import("../fastmem.zig");
|
const fastmem = @import("../fastmem.zig");
|
||||||
const color = @import("color.zig");
|
const color = @import("color.zig");
|
||||||
const hyperlink = @import("hyperlink.zig");
|
const hyperlink = @import("hyperlink.zig");
|
||||||
|
const kitty = @import("kitty.zig");
|
||||||
const sgr = @import("sgr.zig");
|
const sgr = @import("sgr.zig");
|
||||||
const style = @import("style.zig");
|
const style = @import("style.zig");
|
||||||
const size = @import("size.zig");
|
const size = @import("size.zig");
|
||||||
@ -1673,11 +1674,18 @@ pub const Cell = packed struct(u64) {
|
|||||||
return @as(u64, @bitCast(self)) == 0;
|
return @as(u64, @bitCast(self)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if this cell represents a cell with text to render.
|
||||||
|
///
|
||||||
|
/// Cases this returns false:
|
||||||
|
/// - Cell text is blank
|
||||||
|
/// - Cell is styled but only with a background color and no text
|
||||||
|
/// - Cell has a unicode placeholder for Kitty graphics protocol
|
||||||
pub fn hasText(self: Cell) bool {
|
pub fn hasText(self: Cell) bool {
|
||||||
return switch (self.content_tag) {
|
return switch (self.content_tag) {
|
||||||
.codepoint,
|
.codepoint,
|
||||||
.codepoint_grapheme,
|
.codepoint_grapheme,
|
||||||
=> self.content.codepoint != 0,
|
=> self.content.codepoint != 0 and
|
||||||
|
self.content.codepoint != kitty.graphics.placeholder,
|
||||||
|
|
||||||
.bg_color_palette,
|
.bg_color_palette,
|
||||||
.bg_color_rgb,
|
.bg_color_rgb,
|
||||||
@ -1709,7 +1717,8 @@ pub const Cell = packed struct(u64) {
|
|||||||
return self.style_id != style.default_id;
|
return self.style_id != style.default_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the cell has no text or styling.
|
/// Returns true if the cell has no text or styling. This also returns
|
||||||
|
/// true if the cell represents a Kitty graphics unicode placeholder.
|
||||||
pub fn isEmpty(self: Cell) bool {
|
pub fn isEmpty(self: Cell) bool {
|
||||||
return switch (self.content_tag) {
|
return switch (self.content_tag) {
|
||||||
// Textual cells are empty if they have no text and are narrow.
|
// Textual cells are empty if they have no text and are narrow.
|
||||||
@ -2641,3 +2650,12 @@ test "Page verifyIntegrity zero cols" {
|
|||||||
page.verifyIntegrity(testing.allocator),
|
page.verifyIntegrity(testing.allocator),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Cell isEmpty for kitty placeholder" {
|
||||||
|
var c: Cell = .{
|
||||||
|
.content_tag = .codepoint_grapheme,
|
||||||
|
.content = .{ .codepoint = kitty.graphics.placeholder },
|
||||||
|
};
|
||||||
|
try testing.expectEqual(@as(u21, kitty.graphics.placeholder), c.codepoint());
|
||||||
|
try testing.expect(c.isEmpty());
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user