Using uucode in a few places where it's easy.

pull/8757/head
Jacob Sandlund 2025-07-27 18:25:05 -04:00
parent 70bc29f815
commit fb2cab5aee
6 changed files with 16 additions and 19 deletions

View File

@ -42,8 +42,8 @@
.lazy = true,
},
.uucode = .{
.url = "https://github.com/jacobsandlund/uucode/archive/fdcd8582f050e3054091d3ce3c60bf7a78bc8830.tar.gz",
.hash = "uucode-0.0.0-ZZjBPpnZOgCLQD3BsYbQ4N6dGqR3CRKlOngOBB3YEU_j",
.url = "https://github.com/jacobsandlund/uucode/archive/539c710408cda93d2fa28825d67cb5685d963fc1.tar.gz",
.hash = "uucode-0.0.0-ZZjBPpz5OgBrcQOasHVZYLtDHcLPx9al7RH4QXJZ8XCK",
},
.zig_wayland = .{
// codeberg ifreund/zig-wayland

View File

@ -34,10 +34,10 @@ pub fn init(b: *std.Build, cfg: *const Config) !SharedDeps {
\\
\\pub const configs = [_]types.TableConfig{
\\ .override(&config.default, .{
\\ .fields = &.{"case_folding_simple"},
\\ }),
\\ .override(&config.default, .{
\\ .fields = &.{"alphabetic","lowercase","uppercase"},
\\ .fields = &.{
\\ "general_category",
\\ "has_emoji_presentation",
\\ },
\\ }),
\\};
\\

View File

@ -13,7 +13,7 @@ const CodepointResolver = @This();
const std = @import("std");
const Allocator = std.mem.Allocator;
const ziglyph = @import("ziglyph");
const uucode = @import("uucode");
const font = @import("main.zig");
const Atlas = font.Atlas;
const CodepointMap = font.CodepointMap;
@ -150,7 +150,7 @@ pub fn getIndex(
// we'll do this multiple times if we recurse, but this is a cached function
// call higher up (GroupCache) so this should be rare.
const p_mode: Collection.PresentationMode = if (p) |v| .{ .explicit = v } else .{
.default = if (ziglyph.emoji.isEmojiPresentation(@intCast(cp)))
.default = if (uucode.hasEmojiPresentation(@intCast(cp)))
.emoji
else
.text,

View File

@ -1,9 +1,9 @@
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const ziglyph = @import("ziglyph");
const font = @import("../main.zig");
const terminal = @import("../../terminal/main.zig");
const unicode = @import("../../unicode/main.zig");
const log = std.log.scoped(.font_shaper);
@ -111,7 +111,7 @@ pub const Shaper = struct {
// font ligatures. However, we do support grapheme clustering.
// This means we can render things like skin tone emoji but
// we can't render things like single glyph "=>".
var break_state: u3 = 0;
var break_state: unicode.GraphemeBreakState = .{};
var cp1: u21 = @intCast(codepoints[0]);
var start: usize = 0;
@ -126,7 +126,7 @@ pub const Shaper = struct {
const cp2: u21 = @intCast(codepoints[i]);
defer cp1 = cp2;
break :blk ziglyph.graphemeBreak(
break :blk unicode.graphemeBreak(
cp1,
cp2,
&break_state,

View File

@ -10,7 +10,6 @@ const oni = @import("oniguruma");
const crash = @import("crash/main.zig");
const renderer = @import("renderer.zig");
const apprt = @import("apprt.zig");
const uucode = @import("uucode");
/// We export the xev backend we want to use so that the rest of
/// Ghostty can import this once and have access to the proper
@ -55,11 +54,6 @@ pub const GlobalState = struct {
// std.log.err("[global init time] start={}us duration={}ns", .{ start_micro, end.since(start) / std.time.ns_per_us });
// }
std.log.err("XXX Uucode testing: {d}, {}\n", .{
uucode.case_folding_simple(65),
uucode.alphabetic(97),
});
// Initialize ourself to nothing so we don't have any extra state.
// IMPORTANT: this MUST be initialized before any log output because
// the log function uses the global state.

View File

@ -2,6 +2,7 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const ziglyph = @import("ziglyph");
const uucode = @import("uucode");
const font = @import("../font/main.zig");
const terminal = @import("../terminal/main.zig");
const renderer = @import("../renderer.zig");
@ -235,7 +236,8 @@ pub fn constraintWidth(cell_pin: terminal.Pin) u2 {
const cell = cell_pin.rowAndCell().cell;
const cp = cell.codepoint();
if (!ziglyph.general_category.isPrivateUse(cp) and
// If not a Co (Private Use) and not a Dingbats, use grid width.
if (uucode.generalCategory(cp) != .Co and
!ziglyph.blocks.isDingbats(cp))
{
return cell.gridWidth();
@ -259,7 +261,8 @@ pub fn constraintWidth(cell_pin: terminal.Pin) u2 {
// We consider powerline glyphs whitespace.
if (isPowerline(prev_cp)) break :prev;
if (ziglyph.general_category.isPrivateUse(prev_cp)) {
// If it's Private Use (Co) use 1 as the width.
if (uucode.generalCategory(prev_cp) == .Co) {
return 1;
}
}