mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
Merge pull request #1443 from mitchellh/mode-2027
config: grapheme-width-method sets mode 2027
This commit is contained in:
@ -208,7 +208,7 @@ const c = @cImport({
|
|||||||
/// reset, this configuration will be used again.
|
/// reset, this configuration will be used again.
|
||||||
///
|
///
|
||||||
/// This configuration can be changed at runtime but will not affect existing
|
/// This configuration can be changed at runtime but will not affect existing
|
||||||
/// printed cells. Only new cells will use the new configuration.
|
/// terminals. Only new terminals will use the new configuration.
|
||||||
@"grapheme-width-method": GraphemeWidthMethod = .unicode,
|
@"grapheme-width-method": GraphemeWidthMethod = .unicode,
|
||||||
|
|
||||||
/// A named theme to use. The available themes are currently hardcoded to the
|
/// A named theme to use. The available themes are currently hardcoded to the
|
||||||
|
@ -119,9 +119,6 @@ flags: packed struct {
|
|||||||
/// then we want to capture the shift key for the mouse protocol
|
/// then we want to capture the shift key for the mouse protocol
|
||||||
/// if the configuration allows it.
|
/// if the configuration allows it.
|
||||||
mouse_shift_capture: enum { null, false, true } = .null,
|
mouse_shift_capture: enum { null, false, true } = .null,
|
||||||
|
|
||||||
/// If true, we perform grapheme clustering even if mode 2027 is disabled.
|
|
||||||
default_grapheme_cluster: bool = false,
|
|
||||||
} = .{},
|
} = .{},
|
||||||
|
|
||||||
/// The event types that can be reported for mouse-related activities.
|
/// The event types that can be reported for mouse-related activities.
|
||||||
@ -746,10 +743,7 @@ pub fn print(self: *Terminal, c: u21) !void {
|
|||||||
// This is MUCH slower than the normal path so the conditional below is
|
// This is MUCH slower than the normal path so the conditional below is
|
||||||
// purposely ordered in least-likely to most-likely so we can drop out
|
// purposely ordered in least-likely to most-likely so we can drop out
|
||||||
// as quickly as possible.
|
// as quickly as possible.
|
||||||
if (c > 255 and
|
if (c > 255 and self.modes.get(.grapheme_cluster) and self.screen.cursor.x > 0) grapheme: {
|
||||||
(self.modes.get(.grapheme_cluster) or self.flags.default_grapheme_cluster) and
|
|
||||||
self.screen.cursor.x > 0)
|
|
||||||
grapheme: {
|
|
||||||
const row = self.screen.getRow(.{ .active = self.screen.cursor.y });
|
const row = self.screen.getRow(.{ .active = self.screen.cursor.y });
|
||||||
|
|
||||||
// We need the previous cell to determine if we're at a grapheme
|
// We need the previous cell to determine if we're at a grapheme
|
||||||
@ -891,9 +885,7 @@ pub fn print(self: *Terminal, c: u21) !void {
|
|||||||
// If we have grapheme clustering enabled, we don't blindly attach
|
// If we have grapheme clustering enabled, we don't blindly attach
|
||||||
// any zero width character to our cells and we instead just ignore
|
// any zero width character to our cells and we instead just ignore
|
||||||
// it.
|
// it.
|
||||||
if (self.modes.get(.grapheme_cluster) or
|
if (self.modes.get(.grapheme_cluster)) return;
|
||||||
self.flags.default_grapheme_cluster)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// If we're at cell zero, then this is malformed data and we don't
|
// If we're at cell zero, then this is malformed data and we don't
|
||||||
// print anything or even store this. Zero-width characters are ALWAYS
|
// print anything or even store this. Zero-width characters are ALWAYS
|
||||||
|
@ -135,7 +135,13 @@ pub fn init(alloc: Allocator, opts: termio.Options) !Exec {
|
|||||||
errdefer term.deinit(alloc);
|
errdefer term.deinit(alloc);
|
||||||
term.default_palette = opts.config.palette;
|
term.default_palette = opts.config.palette;
|
||||||
term.color_palette.colors = opts.config.palette;
|
term.color_palette.colors = opts.config.palette;
|
||||||
term.flags.default_grapheme_cluster = opts.config.grapheme_width_method == .unicode;
|
|
||||||
|
// Setup our initial grapheme cluster support if enabled. We use a
|
||||||
|
// switch to ensure we get a compiler error if more cases are added.
|
||||||
|
switch (opts.config.grapheme_width_method) {
|
||||||
|
.unicode => term.modes.set(.grapheme_cluster, true),
|
||||||
|
.wcswidth => {},
|
||||||
|
}
|
||||||
|
|
||||||
// Set the image size limits
|
// Set the image size limits
|
||||||
try term.screen.kitty_images.setLimit(alloc, opts.config.image_storage_limit);
|
try term.screen.kitty_images.setLimit(alloc, opts.config.image_storage_limit);
|
||||||
@ -373,8 +379,6 @@ pub fn changeConfig(self: *Exec, config: *DerivedConfig) !void {
|
|||||||
// - command, working-directory: we never restart the underlying
|
// - command, working-directory: we never restart the underlying
|
||||||
// process so we don't care or need to know about these.
|
// process so we don't care or need to know about these.
|
||||||
|
|
||||||
self.terminal.flags.default_grapheme_cluster = config.grapheme_width_method == .unicode;
|
|
||||||
|
|
||||||
// Update the default palette. Note this will only apply to new colors drawn
|
// Update the default palette. Note this will only apply to new colors drawn
|
||||||
// since we decode all palette colors to RGB on usage.
|
// since we decode all palette colors to RGB on usage.
|
||||||
self.terminal.default_palette = config.palette;
|
self.terminal.default_palette = config.palette;
|
||||||
|
Reference in New Issue
Block a user