aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/config/Config.zig
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-07-16 23:28:05 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-07-16 23:29:28 +0300
commit4a3302d19a2baa3a33e910e0088c24e780905b90 (patch)
treedcaf76fae1c82102d933c9225b17ca7ac5d3a847 /vendor/libghostty-vt/src/config/Config.zig
parent550e9f8cc085f428429f5cf2da0bb2dba897e8b8 (diff)
chore: update vendored libghostty-vt
refs #276
Diffstat (limited to 'vendor/libghostty-vt/src/config/Config.zig')
-rw-r--r--vendor/libghostty-vt/src/config/Config.zig129
1 files changed, 59 insertions, 70 deletions
diff --git a/vendor/libghostty-vt/src/config/Config.zig b/vendor/libghostty-vt/src/config/Config.zig
index 66b8c605..d6a038d9 100644
--- a/vendor/libghostty-vt/src/config/Config.zig
+++ b/vendor/libghostty-vt/src/config/Config.zig
@@ -51,7 +51,6 @@ const terminal = struct {
const color = @import("../terminal/color.zig");
const selection_codepoints = @import("../terminal/selection_codepoints.zig");
const style = @import("../terminal/style.zig");
- const x11_color = @import("../terminal/x11_color.zig");
};
const log = std.log.scoped(.config);
@@ -1374,10 +1373,17 @@ input: RepeatableReadableIO = .{},
/// When this limit is reached, the oldest lines are removed from the
/// scrollback.
///
-/// Scrollback currently exists completely in memory. This means that the
-/// larger this value, the larger potential memory usage. Scrollback is
-/// allocated lazily up to this limit, so if you set this to a very large
-/// value, it will not immediately consume a lot of memory.
+/// Scrollback is stored in memory and allocated lazily up to this limit, so
+/// setting a very large limit does not immediately consume that amount of
+/// memory. On supported systems with scrollback compression enabled, Ghostty
+/// attempts to compress fully historical pages which are not currently visible
+/// while the terminal is idle. This can reduce physical memory usage, depending
+/// on the contents of the scrollback.
+///
+/// This limit always measures the uncompressed logical size of the terminal
+/// pages. Compression does not allow Ghostty to retain more history than the
+/// configured limit. Accessing compressed history restores it transparently
+/// and may increase the terminal's physical memory usage again.
///
/// This size is per terminal surface, not for the entire application.
///
@@ -1385,7 +1391,31 @@ input: RepeatableReadableIO = .{},
/// This is a future planned feature.
///
/// This can be changed at runtime but will only affect new terminal surfaces.
-@"scrollback-limit": usize = 10_000_000, // 10MB
+@"scrollback-limit": usize = 50_000_000, // 50MB
+
+/// Whether to compress scrollback pages while the terminal is idle.
+///
+/// Ghostty does its best to only compress when idle and decompress
+/// as needed. This means that compression doesn't lower IO throughput.
+/// We recommend you keep it on.
+///
+/// The scrollback limit remains an uncompressed logical limit regardless of
+/// this setting, so disabling compression can increase physical memory usage
+/// but does not change how much history is retained.
+///
+/// Text-heavy terminal history generally compresses to approximately 10% to
+/// 30% of its uncompressed page memory, corresponding to a 70% to 90% reduction
+/// in physical memory for pages which are compressed. Compression savings are
+/// content-dependent.
+///
+/// Note that the way Ghostty works is that we compress and discard the
+/// physical/resident memory but we retain virtual mappings. You will not
+/// see a decrease in virtual memory usage, but you will see a decrease
+/// in physical/memory usage.
+///
+/// Changing this at runtime affects future compression work. Pages which are
+/// already compressed remain compressed until their contents are accessed.
+@"scrollback-compression": bool = true,
/// Control when the scrollbar is shown to scroll the scrollback buffer.
///
@@ -3657,6 +3687,14 @@ else
/// which is the old style.
@"gtk-wide-tabs": bool = true,
+/// If `true` (default), then two-finger horizontal scrolling on a touchpad
+/// will switch between tabs. Scrolling left goes to the next tab and
+/// scrolling right goes to the previous tab. Set this to `false` to
+/// disable this behavior.
+///
+/// Available since 1.4.0.
+@"gtk-horizontal-tab-scroll": bool = true,
+
/// Custom CSS files to be loaded.
///
/// GTK CSS documentation can be found at the following links:
@@ -5433,16 +5471,8 @@ pub const Color = struct {
pub fn parseCLI(input_: ?[]const u8) !Color {
const input = input_ orelse return error.ValueRequired;
- // Trim any whitespace before processing
- const trimmed = std.mem.trim(u8, input, " \t");
-
- if (terminal.x11_color.map.get(trimmed)) |rgb| return .{
- .r = rgb.r,
- .g = rgb.g,
- .b = rgb.b,
- };
-
- return fromHex(trimmed);
+ const rgb: terminal.color.RGB = terminal.color.RGB.parse(input) catch return error.InvalidValue;
+ return .{ .r = rgb.r, .g = rgb.g, .b = rgb.b };
}
/// Deep copy of the struct. Required by Config.
@@ -5473,48 +5503,15 @@ pub const Color = struct {
) catch error.OutOfMemory;
}
- /// fromHex parses a color from a hex value such as #RRGGBB. The "#"
- /// is optional.
- pub fn fromHex(input: []const u8) !Color {
- // Trim the beginning '#' if it exists
- const trimmed = if (input.len != 0 and input[0] == '#') input[1..] else input;
- if (trimmed.len != 6 and trimmed.len != 3) return error.InvalidValue;
-
- // Expand short hex values to full hex values
- const rgb: []const u8 = if (trimmed.len == 3) &.{
- trimmed[0], trimmed[0],
- trimmed[1], trimmed[1],
- trimmed[2], trimmed[2],
- } else trimmed;
-
- // Parse the colors two at a time.
- var result: Color = undefined;
- comptime var i: usize = 0;
- inline while (i < 6) : (i += 2) {
- const v: u8 =
- ((try std.fmt.charToDigit(rgb[i], 16)) * 16) +
- try std.fmt.charToDigit(rgb[i + 1], 16);
-
- @field(result, switch (i) {
- 0 => "r",
- 2 => "g",
- 4 => "b",
- else => unreachable,
- }) = v;
- }
-
- return result;
- }
-
- test "fromHex" {
+ test "parseCLI hex" {
const testing = std.testing;
- try testing.expectEqual(Color{ .r = 0, .g = 0, .b = 0 }, try Color.fromHex("#000000"));
- try testing.expectEqual(Color{ .r = 10, .g = 11, .b = 12 }, try Color.fromHex("#0A0B0C"));
- try testing.expectEqual(Color{ .r = 10, .g = 11, .b = 12 }, try Color.fromHex("0A0B0C"));
- try testing.expectEqual(Color{ .r = 255, .g = 255, .b = 255 }, try Color.fromHex("FFFFFF"));
- try testing.expectEqual(Color{ .r = 255, .g = 255, .b = 255 }, try Color.fromHex("FFF"));
- try testing.expectEqual(Color{ .r = 51, .g = 68, .b = 85 }, try Color.fromHex("#345"));
+ try testing.expectEqual(Color{ .r = 0, .g = 0, .b = 0 }, try Color.parseCLI("#000000"));
+ try testing.expectEqual(Color{ .r = 10, .g = 11, .b = 12 }, try Color.parseCLI("#0A0B0C"));
+ try testing.expectEqual(Color{ .r = 10, .g = 11, .b = 12 }, try Color.parseCLI("0A0B0C"));
+ try testing.expectEqual(Color{ .r = 255, .g = 255, .b = 255 }, try Color.parseCLI("FFFFFF"));
+ try testing.expectEqual(Color{ .r = 255, .g = 255, .b = 255 }, try Color.parseCLI("FFF"));
+ try testing.expectEqual(Color{ .r = 51, .g = 68, .b = 85 }, try Color.parseCLI("#345"));
}
test "parseCLI from name" {
@@ -5860,20 +5857,12 @@ pub const Palette = struct {
input: ?[]const u8,
) !void {
const value = input orelse return error.ValueRequired;
- const eqlIdx = std.mem.indexOf(u8, value, "=") orelse
- return error.InvalidValue;
-
- // Parse the key part (trim whitespace)
- const key = try std.fmt.parseInt(
- u8,
- std.mem.trim(u8, value[0..eqlIdx], " \t"),
- 0,
- );
-
- // Parse the color part (Color.parseCLI will handle whitespace)
- const rgb = try Color.parseCLI(value[eqlIdx + 1 ..]);
- self.value[key] = .{ .r = rgb.r, .g = rgb.g, .b = rgb.b };
- self.mask.set(key);
+ const entry = terminal.color.parsePaletteEntry(value) catch |err| switch (err) {
+ error.Overflow => return error.Overflow,
+ error.InvalidFormat => return error.InvalidValue,
+ };
+ self.value[entry.index] = entry.color;
+ self.mask.set(entry.index);
}
/// Deep copy of the struct. Required by Config.