mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
Merge remote-tracking branch 'upstream/main' into jacob/zg
This commit is contained in:
@ -14,26 +14,6 @@ struct TerminalEntity: AppEntity {
|
|||||||
@Property(title: "Kind")
|
@Property(title: "Kind")
|
||||||
var kind: Kind
|
var kind: Kind
|
||||||
|
|
||||||
@MainActor
|
|
||||||
@DeferredProperty(title: "Full Contents")
|
|
||||||
@available(macOS 26.0, *)
|
|
||||||
var screenContents: String? {
|
|
||||||
get async {
|
|
||||||
guard let surfaceView else { return nil }
|
|
||||||
return surfaceView.cachedScreenContents.get()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@MainActor
|
|
||||||
@DeferredProperty(title: "Visible Contents")
|
|
||||||
@available(macOS 26.0, *)
|
|
||||||
var visibleContents: String? {
|
|
||||||
get async {
|
|
||||||
guard let surfaceView else { return nil }
|
|
||||||
return surfaceView.cachedVisibleContents.get()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var screenshot: Image?
|
var screenshot: Image?
|
||||||
|
|
||||||
static var typeDisplayRepresentation: TypeDisplayRepresentation {
|
static var typeDisplayRepresentation: TypeDisplayRepresentation {
|
||||||
|
@ -148,6 +148,18 @@ const locales = [_][]const u8{
|
|||||||
|
|
||||||
You should then be able to run `zig build` and see your translations in action.
|
You should then be able to run `zig build` and see your translations in action.
|
||||||
|
|
||||||
|
Before opening a pull request with the new translation file, you should also add
|
||||||
|
your locale to the `CODEOWNERS` file. Find the `# Localization` section near the
|
||||||
|
bottom and add a line like so (where `xx_YY` is your locale):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
# Localization
|
||||||
|
/po/README_TRANSLATORS.md @ghostty-org/localization
|
||||||
|
/po/com.mitchellh.ghostty.pot @ghostty-org/localization
|
||||||
|
/po/zh_CN.UTF-8.po @ghostty-org/zh_CN
|
||||||
|
+/po/xx_YY.UTF-8.po @ghostty-org/xx_YY
|
||||||
|
```
|
||||||
|
|
||||||
## Style Guide
|
## Style Guide
|
||||||
|
|
||||||
These are general style guidelines for translations. Naturally, the specific
|
These are general style guidelines for translations. Naturally, the specific
|
||||||
|
@ -188,10 +188,31 @@ fn startPosix(self: *Command, arena: Allocator) !void {
|
|||||||
// Finally, replace our process.
|
// Finally, replace our process.
|
||||||
// Note: we must use the "p"-variant of exec here because we
|
// Note: we must use the "p"-variant of exec here because we
|
||||||
// do not guarantee our command is looked up already in the path.
|
// do not guarantee our command is looked up already in the path.
|
||||||
_ = posix.execvpeZ(self.path, argsZ, envp) catch null;
|
const err = posix.execvpeZ(self.path, argsZ, envp);
|
||||||
|
|
||||||
// If we are executing this code, the exec failed. In that scenario,
|
// If we are executing this code, the exec failed. We're in the
|
||||||
// we return a very specific error that can be detected to determine
|
// child process so there isn't much we can do. We try to output
|
||||||
|
// something reasonable. Its important to note we MUST NOT return
|
||||||
|
// any other error condition from here on out.
|
||||||
|
const stderr = std.io.getStdErr().writer();
|
||||||
|
switch (err) {
|
||||||
|
error.FileNotFound => stderr.print(
|
||||||
|
\\Requested executable not found. Please verify the command is on
|
||||||
|
\\the PATH and try again.
|
||||||
|
\\
|
||||||
|
,
|
||||||
|
.{},
|
||||||
|
) catch {},
|
||||||
|
|
||||||
|
else => stderr.print(
|
||||||
|
\\exec syscall failed with unexpected error: {}
|
||||||
|
\\
|
||||||
|
,
|
||||||
|
.{err},
|
||||||
|
) catch {},
|
||||||
|
}
|
||||||
|
|
||||||
|
// We return a very specific error that can be detected to determine
|
||||||
// we're in the child.
|
// we're in the child.
|
||||||
return error.ExecFailedInChild;
|
return error.ExecFailedInChild;
|
||||||
}
|
}
|
||||||
|
@ -1034,6 +1034,12 @@ fn childExited(self: *Surface, info: apprt.surface.Message.ChildExited) void {
|
|||||||
t.printString("Process exited. Press any key to close the terminal.") catch
|
t.printString("Process exited. Press any key to close the terminal.") catch
|
||||||
break :terminal;
|
break :terminal;
|
||||||
t.modes.set(.cursor_visible, false);
|
t.modes.set(.cursor_visible, false);
|
||||||
|
|
||||||
|
// We also want to ensure that normal keyboard encoding is on
|
||||||
|
// so that we can close the terminal. We close the terminal on
|
||||||
|
// any key press that encodes a character.
|
||||||
|
t.modes.set(.disable_keyboard, false);
|
||||||
|
t.screen.kitty_keyboard.set(.set, .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Waiting after command we stop here. The terminal is updated, our
|
// Waiting after command we stop here. The terminal is updated, our
|
||||||
@ -2129,14 +2135,6 @@ pub fn keyCallback(
|
|||||||
if (self.io.terminal.modes.get(.disable_keyboard)) return .consumed;
|
if (self.io.terminal.modes.get(.disable_keyboard)) return .consumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If our process is exited and we press a key then we close the
|
|
||||||
// surface. We may want to eventually move this to the apprt rather
|
|
||||||
// than in core.
|
|
||||||
if (self.child_exited and event.action == .press) {
|
|
||||||
self.close();
|
|
||||||
return .closed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this input event has text, then we hide the mouse if configured.
|
// If this input event has text, then we hide the mouse if configured.
|
||||||
// We only do this on pressed events to avoid hiding the mouse when we
|
// We only do this on pressed events to avoid hiding the mouse when we
|
||||||
// change focus due to a keybinding (i.e. switching tabs).
|
// change focus due to a keybinding (i.e. switching tabs).
|
||||||
@ -2231,6 +2229,14 @@ pub fn keyCallback(
|
|||||||
event,
|
event,
|
||||||
if (insp_ev) |*ev| ev else null,
|
if (insp_ev) |*ev| ev else null,
|
||||||
)) |write_req| {
|
)) |write_req| {
|
||||||
|
// If our process is exited and we press a key that results in
|
||||||
|
// an encoded value, we close the surface. We want to eventually
|
||||||
|
// move this behavior to the apprt probably.
|
||||||
|
if (self.child_exited) {
|
||||||
|
self.close();
|
||||||
|
return .closed;
|
||||||
|
}
|
||||||
|
|
||||||
errdefer write_req.deinit();
|
errdefer write_req.deinit();
|
||||||
self.io.queueMessage(switch (write_req) {
|
self.io.queueMessage(switch (write_req) {
|
||||||
.small => |v| .{ .write_small = v },
|
.small => |v| .{ .write_small = v },
|
||||||
|
@ -61,6 +61,13 @@ pub const compatibility = std.StaticStringMap(
|
|||||||
// Ghostty 1.2 removed the `hidden` value from `gtk-tabs-location` and
|
// Ghostty 1.2 removed the `hidden` value from `gtk-tabs-location` and
|
||||||
// moved it to `window-show-tab-bar`.
|
// moved it to `window-show-tab-bar`.
|
||||||
.{ "gtk-tabs-location", compatGtkTabsLocation },
|
.{ "gtk-tabs-location", compatGtkTabsLocation },
|
||||||
|
|
||||||
|
// Ghostty 1.2 lets you set `cell-foreground` and `cell-background`
|
||||||
|
// to match the cell foreground and background colors, respectively.
|
||||||
|
// This can be used with `cursor-color` and `cursor-text` to recreate
|
||||||
|
// this behavior. This applies to selection too.
|
||||||
|
.{ "cursor-invert-fg-bg", compatCursorInvertFgBg },
|
||||||
|
.{ "selection-invert-fg-bg", compatSelectionInvertFgBg },
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The font families to use.
|
/// The font families to use.
|
||||||
@ -590,16 +597,11 @@ foreground: Color = .{ .r = 0xFF, .g = 0xFF, .b = 0xFF },
|
|||||||
/// the selection color is just the inverted window background and foreground
|
/// the selection color is just the inverted window background and foreground
|
||||||
/// (note: not to be confused with the cell bg/fg).
|
/// (note: not to be confused with the cell bg/fg).
|
||||||
/// Specified as either hex (`#RRGGBB` or `RRGGBB`) or a named X11 color.
|
/// Specified as either hex (`#RRGGBB` or `RRGGBB`) or a named X11 color.
|
||||||
@"selection-foreground": ?Color = null,
|
/// Since version 1.2.0, this can also be set to `cell-foreground` to match
|
||||||
@"selection-background": ?Color = null,
|
/// the cell foreground color, or `cell-background` to match the cell
|
||||||
|
/// background color.
|
||||||
/// Swap the foreground and background colors of cells for selection. This
|
@"selection-foreground": ?TerminalColor = null,
|
||||||
/// option overrides the `selection-foreground` and `selection-background`
|
@"selection-background": ?TerminalColor = null,
|
||||||
/// options.
|
|
||||||
///
|
|
||||||
/// If you select across cells with differing foregrounds and backgrounds, the
|
|
||||||
/// selection color will vary across the selection.
|
|
||||||
@"selection-invert-fg-bg": bool = false,
|
|
||||||
|
|
||||||
/// Whether to clear selected text when typing. This defaults to `true`.
|
/// Whether to clear selected text when typing. This defaults to `true`.
|
||||||
/// This is typical behavior for most terminal emulators as well as
|
/// This is typical behavior for most terminal emulators as well as
|
||||||
@ -643,12 +645,20 @@ foreground: Color = .{ .r = 0xFF, .g = 0xFF, .b = 0xFF },
|
|||||||
palette: Palette = .{},
|
palette: Palette = .{},
|
||||||
|
|
||||||
/// The color of the cursor. If this is not set, a default will be chosen.
|
/// The color of the cursor. If this is not set, a default will be chosen.
|
||||||
/// Specified as either hex (`#RRGGBB` or `RRGGBB`) or a named X11 color.
|
///
|
||||||
@"cursor-color": ?Color = null,
|
/// Direct colors can be specified as either hex (`#RRGGBB` or `RRGGBB`)
|
||||||
|
/// or a named X11 color.
|
||||||
/// Swap the foreground and background colors of the cell under the cursor. This
|
///
|
||||||
/// option overrides the `cursor-color` and `cursor-text` options.
|
/// Additionally, special values can be used to set the color to match
|
||||||
@"cursor-invert-fg-bg": bool = false,
|
/// other colors at runtime:
|
||||||
|
///
|
||||||
|
/// * `cell-foreground` - Match the cell foreground color.
|
||||||
|
/// (Available since version 1.2.0)
|
||||||
|
///
|
||||||
|
/// * `cell-background` - Match the cell background color.
|
||||||
|
/// (Available since version 1.2.0)
|
||||||
|
///
|
||||||
|
@"cursor-color": ?TerminalColor = null,
|
||||||
|
|
||||||
/// The opacity level (opposite of transparency) of the cursor. A value of 1
|
/// The opacity level (opposite of transparency) of the cursor. A value of 1
|
||||||
/// is fully opaque and a value of 0 is fully transparent. A value less than 0
|
/// is fully opaque and a value of 0 is fully transparent. A value less than 0
|
||||||
@ -698,7 +708,10 @@ palette: Palette = .{},
|
|||||||
/// The color of the text under the cursor. If this is not set, a default will
|
/// The color of the text under the cursor. If this is not set, a default will
|
||||||
/// be chosen.
|
/// be chosen.
|
||||||
/// Specified as either hex (`#RRGGBB` or `RRGGBB`) or a named X11 color.
|
/// Specified as either hex (`#RRGGBB` or `RRGGBB`) or a named X11 color.
|
||||||
@"cursor-text": ?Color = null,
|
/// Since version 1.2.0, this can also be set to `cell-foreground` to match
|
||||||
|
/// the cell foreground color, or `cell-background` to match the cell
|
||||||
|
/// background color.
|
||||||
|
@"cursor-text": ?TerminalColor = null,
|
||||||
|
|
||||||
/// Enables the ability to move the cursor at prompts by using `alt+click` on
|
/// Enables the ability to move the cursor at prompts by using `alt+click` on
|
||||||
/// Linux and `option+click` on macOS.
|
/// Linux and `option+click` on macOS.
|
||||||
@ -3825,10 +3838,6 @@ pub fn parseManuallyHook(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// parseFieldManuallyFallback is a fallback called only when
|
|
||||||
/// parsing the field directly failed. It can be used to implement
|
|
||||||
/// backward compatibility. Since this is only called when parsing
|
|
||||||
/// fails, it doesn't impact happy-path performance.
|
|
||||||
fn compatGtkTabsLocation(
|
fn compatGtkTabsLocation(
|
||||||
self: *Config,
|
self: *Config,
|
||||||
alloc: Allocator,
|
alloc: Allocator,
|
||||||
@ -3846,6 +3855,51 @@ fn compatGtkTabsLocation(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn compatCursorInvertFgBg(
|
||||||
|
self: *Config,
|
||||||
|
alloc: Allocator,
|
||||||
|
key: []const u8,
|
||||||
|
value_: ?[]const u8,
|
||||||
|
) bool {
|
||||||
|
_ = alloc;
|
||||||
|
assert(std.mem.eql(u8, key, "cursor-invert-fg-bg"));
|
||||||
|
|
||||||
|
// We don't do anything if the value is unset, which is technically
|
||||||
|
// not EXACTLY the same as prior behavior since it would fallback
|
||||||
|
// to doing whatever cursor-color/cursor-text were set to, but
|
||||||
|
// I don't want to store what that is separately so this is close
|
||||||
|
// enough.
|
||||||
|
//
|
||||||
|
// Realistically, these fields were mutually exclusive so anyone
|
||||||
|
// relying on that behavior should just upgrade to the new
|
||||||
|
// cursor-color/cursor-text fields.
|
||||||
|
const set = cli.args.parseBool(value_ orelse "t") catch return false;
|
||||||
|
if (set) {
|
||||||
|
self.@"cursor-color" = .@"cell-foreground";
|
||||||
|
self.@"cursor-text" = .@"cell-background";
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn compatSelectionInvertFgBg(
|
||||||
|
self: *Config,
|
||||||
|
alloc: Allocator,
|
||||||
|
key: []const u8,
|
||||||
|
value_: ?[]const u8,
|
||||||
|
) bool {
|
||||||
|
_ = alloc;
|
||||||
|
assert(std.mem.eql(u8, key, "selection-invert-fg-bg"));
|
||||||
|
|
||||||
|
const set = cli.args.parseBool(value_ orelse "t") catch return false;
|
||||||
|
if (set) {
|
||||||
|
self.@"selection-foreground" = .@"cell-background";
|
||||||
|
self.@"selection-background" = .@"cell-foreground";
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a shallow copy of this config. This will share all the memory
|
/// Create a shallow copy of this config. This will share all the memory
|
||||||
/// allocated with the previous config but will have a new arena for
|
/// allocated with the previous config but will have a new arena for
|
||||||
/// any changes or new allocations. The config should have `deinit`
|
/// any changes or new allocations. The config should have `deinit`
|
||||||
@ -4408,6 +4462,65 @@ pub const Color = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Represents color values that can also reference special color
|
||||||
|
/// values such as "cell-foreground" or "cell-background".
|
||||||
|
pub const TerminalColor = union(enum) {
|
||||||
|
color: Color,
|
||||||
|
@"cell-foreground",
|
||||||
|
@"cell-background",
|
||||||
|
|
||||||
|
pub fn parseCLI(input_: ?[]const u8) !TerminalColor {
|
||||||
|
const input = input_ orelse return error.ValueRequired;
|
||||||
|
if (std.mem.eql(u8, input, "cell-foreground")) return .@"cell-foreground";
|
||||||
|
if (std.mem.eql(u8, input, "cell-background")) return .@"cell-background";
|
||||||
|
return .{ .color = try Color.parseCLI(input) };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Used by Formatter
|
||||||
|
pub fn formatEntry(self: TerminalColor, formatter: anytype) !void {
|
||||||
|
switch (self) {
|
||||||
|
.color => try self.color.formatEntry(formatter),
|
||||||
|
|
||||||
|
.@"cell-foreground",
|
||||||
|
.@"cell-background",
|
||||||
|
=> try formatter.formatEntry([:0]const u8, @tagName(self)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test "parseCLI" {
|
||||||
|
const testing = std.testing;
|
||||||
|
|
||||||
|
try testing.expectEqual(
|
||||||
|
TerminalColor{ .color = Color{ .r = 78, .g = 42, .b = 132 } },
|
||||||
|
try TerminalColor.parseCLI("#4e2a84"),
|
||||||
|
);
|
||||||
|
try testing.expectEqual(
|
||||||
|
TerminalColor{ .color = Color{ .r = 0, .g = 0, .b = 0 } },
|
||||||
|
try TerminalColor.parseCLI("black"),
|
||||||
|
);
|
||||||
|
try testing.expectEqual(
|
||||||
|
TerminalColor.@"cell-foreground",
|
||||||
|
try TerminalColor.parseCLI("cell-foreground"),
|
||||||
|
);
|
||||||
|
try testing.expectEqual(
|
||||||
|
TerminalColor.@"cell-background",
|
||||||
|
try TerminalColor.parseCLI("cell-background"),
|
||||||
|
);
|
||||||
|
|
||||||
|
try testing.expectError(error.InvalidValue, TerminalColor.parseCLI("a"));
|
||||||
|
}
|
||||||
|
|
||||||
|
test "formatConfig" {
|
||||||
|
const testing = std.testing;
|
||||||
|
var buf = std.ArrayList(u8).init(testing.allocator);
|
||||||
|
defer buf.deinit();
|
||||||
|
|
||||||
|
var sc: TerminalColor = .@"cell-foreground";
|
||||||
|
try sc.formatEntry(formatterpkg.entryFormatter("a", buf.writer()));
|
||||||
|
try testing.expectEqualSlices(u8, "a = cell-foreground\n", buf.items);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
pub const ColorList = struct {
|
pub const ColorList = struct {
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
@ -5341,7 +5454,14 @@ pub const Keybinds = struct {
|
|||||||
.mods = mods,
|
.mods = mods,
|
||||||
},
|
},
|
||||||
.{ .goto_tab = (i - start) + 1 },
|
.{ .goto_tab = (i - start) + 1 },
|
||||||
.{ .performable = true },
|
.{
|
||||||
|
// On macOS we keep this not performable so that the
|
||||||
|
// keyboard shortcuts in tabs work. In the future the
|
||||||
|
// correct fix is to fix the reverse mapping lookup
|
||||||
|
// to allow us to lookup performable keybinds
|
||||||
|
// conditionally.
|
||||||
|
.performable = !builtin.target.os.tag.isDarwin(),
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
try self.set.putFlags(
|
try self.set.putFlags(
|
||||||
@ -5351,7 +5471,10 @@ pub const Keybinds = struct {
|
|||||||
.mods = mods,
|
.mods = mods,
|
||||||
},
|
},
|
||||||
.{ .last_tab = {} },
|
.{ .last_tab = {} },
|
||||||
.{ .performable = true },
|
.{
|
||||||
|
// See comment above with the numeric goto_tab
|
||||||
|
.performable = !builtin.target.os.tag.isDarwin(),
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8105,3 +8228,51 @@ test "theme specifying light/dark sets theme usage in conditional state" {
|
|||||||
try testing.expect(cfg._conditional_set.contains(.theme));
|
try testing.expect(cfg._conditional_set.contains(.theme));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "compatibility: removed cursor-invert-fg-bg" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
{
|
||||||
|
var cfg = try Config.default(alloc);
|
||||||
|
defer cfg.deinit();
|
||||||
|
var it: TestIterator = .{ .data = &.{
|
||||||
|
"--cursor-invert-fg-bg",
|
||||||
|
} };
|
||||||
|
try cfg.loadIter(alloc, &it);
|
||||||
|
try cfg.finalize();
|
||||||
|
|
||||||
|
try testing.expectEqual(
|
||||||
|
TerminalColor.@"cell-foreground",
|
||||||
|
cfg.@"cursor-color",
|
||||||
|
);
|
||||||
|
try testing.expectEqual(
|
||||||
|
TerminalColor.@"cell-background",
|
||||||
|
cfg.@"cursor-text",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test "compatibility: removed selection-invert-fg-bg" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
{
|
||||||
|
var cfg = try Config.default(alloc);
|
||||||
|
defer cfg.deinit();
|
||||||
|
var it: TestIterator = .{ .data = &.{
|
||||||
|
"--selection-invert-fg-bg",
|
||||||
|
} };
|
||||||
|
try cfg.loadIter(alloc, &it);
|
||||||
|
try cfg.finalize();
|
||||||
|
|
||||||
|
try testing.expectEqual(
|
||||||
|
TerminalColor.@"cell-background",
|
||||||
|
cfg.@"selection-foreground",
|
||||||
|
);
|
||||||
|
try testing.expectEqual(
|
||||||
|
TerminalColor.@"cell-foreground",
|
||||||
|
cfg.@"selection-background",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -133,12 +133,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
/// This is cursor color as set in the user's config, if any. If no cursor color
|
/// This is cursor color as set in the user's config, if any. If no cursor color
|
||||||
/// is set in the user's config, then the cursor color is determined by the
|
/// is set in the user's config, then the cursor color is determined by the
|
||||||
/// current foreground color.
|
/// current foreground color.
|
||||||
default_cursor_color: ?terminal.color.RGB,
|
default_cursor_color: ?configpkg.Config.TerminalColor,
|
||||||
|
|
||||||
/// When `cursor_color` is null, swap the foreground and background colors of
|
|
||||||
/// the cell under the cursor for the cursor color. Otherwise, use the default
|
|
||||||
/// foreground color as the cursor color.
|
|
||||||
cursor_invert: bool,
|
|
||||||
|
|
||||||
/// The current set of cells to render. This is rebuilt on every frame
|
/// The current set of cells to render. This is rebuilt on every frame
|
||||||
/// but we keep this around so that we don't reallocate. Each set of
|
/// but we keep this around so that we don't reallocate. Each set of
|
||||||
@ -514,16 +509,14 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
font_features: std.ArrayListUnmanaged([:0]const u8),
|
font_features: std.ArrayListUnmanaged([:0]const u8),
|
||||||
font_styles: font.CodepointResolver.StyleStatus,
|
font_styles: font.CodepointResolver.StyleStatus,
|
||||||
font_shaping_break: configpkg.FontShapingBreak,
|
font_shaping_break: configpkg.FontShapingBreak,
|
||||||
cursor_color: ?terminal.color.RGB,
|
cursor_color: ?configpkg.Config.TerminalColor,
|
||||||
cursor_invert: bool,
|
|
||||||
cursor_opacity: f64,
|
cursor_opacity: f64,
|
||||||
cursor_text: ?terminal.color.RGB,
|
cursor_text: ?configpkg.Config.TerminalColor,
|
||||||
background: terminal.color.RGB,
|
background: terminal.color.RGB,
|
||||||
background_opacity: f64,
|
background_opacity: f64,
|
||||||
foreground: terminal.color.RGB,
|
foreground: terminal.color.RGB,
|
||||||
selection_background: ?terminal.color.RGB,
|
selection_background: ?configpkg.Config.TerminalColor,
|
||||||
selection_foreground: ?terminal.color.RGB,
|
selection_foreground: ?configpkg.Config.TerminalColor,
|
||||||
invert_selection_fg_bg: bool,
|
|
||||||
bold_is_bright: bool,
|
bold_is_bright: bool,
|
||||||
min_contrast: f32,
|
min_contrast: f32,
|
||||||
padding_color: configpkg.WindowPaddingColor,
|
padding_color: configpkg.WindowPaddingColor,
|
||||||
@ -571,8 +564,6 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
config.link.links.items,
|
config.link.links.items,
|
||||||
);
|
);
|
||||||
|
|
||||||
const cursor_invert = config.@"cursor-invert-fg-bg";
|
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.background_opacity = @max(0, @min(1, config.@"background-opacity")),
|
.background_opacity = @max(0, @min(1, config.@"background-opacity")),
|
||||||
.font_thicken = config.@"font-thicken",
|
.font_thicken = config.@"font-thicken",
|
||||||
@ -581,36 +572,18 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
.font_styles = font_styles,
|
.font_styles = font_styles,
|
||||||
.font_shaping_break = config.@"font-shaping-break",
|
.font_shaping_break = config.@"font-shaping-break",
|
||||||
|
|
||||||
.cursor_color = if (!cursor_invert and config.@"cursor-color" != null)
|
.cursor_color = config.@"cursor-color",
|
||||||
config.@"cursor-color".?.toTerminalRGB()
|
.cursor_text = config.@"cursor-text",
|
||||||
else
|
|
||||||
null,
|
|
||||||
|
|
||||||
.cursor_invert = cursor_invert,
|
|
||||||
|
|
||||||
.cursor_text = if (config.@"cursor-text") |txt|
|
|
||||||
txt.toTerminalRGB()
|
|
||||||
else
|
|
||||||
null,
|
|
||||||
|
|
||||||
.cursor_opacity = @max(0, @min(1, config.@"cursor-opacity")),
|
.cursor_opacity = @max(0, @min(1, config.@"cursor-opacity")),
|
||||||
|
|
||||||
.background = config.background.toTerminalRGB(),
|
.background = config.background.toTerminalRGB(),
|
||||||
.foreground = config.foreground.toTerminalRGB(),
|
.foreground = config.foreground.toTerminalRGB(),
|
||||||
.invert_selection_fg_bg = config.@"selection-invert-fg-bg",
|
|
||||||
.bold_is_bright = config.@"bold-is-bright",
|
.bold_is_bright = config.@"bold-is-bright",
|
||||||
.min_contrast = @floatCast(config.@"minimum-contrast"),
|
.min_contrast = @floatCast(config.@"minimum-contrast"),
|
||||||
.padding_color = config.@"window-padding-color",
|
.padding_color = config.@"window-padding-color",
|
||||||
|
|
||||||
.selection_background = if (config.@"selection-background") |bg|
|
.selection_background = config.@"selection-background",
|
||||||
bg.toTerminalRGB()
|
.selection_foreground = config.@"selection-foreground",
|
||||||
else
|
|
||||||
null,
|
|
||||||
|
|
||||||
.selection_foreground = if (config.@"selection-foreground") |bg|
|
|
||||||
bg.toTerminalRGB()
|
|
||||||
else
|
|
||||||
null,
|
|
||||||
|
|
||||||
.custom_shaders = custom_shaders,
|
.custom_shaders = custom_shaders,
|
||||||
.bg_image = bg_image,
|
.bg_image = bg_image,
|
||||||
@ -703,7 +676,6 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
.default_background_color = options.config.background,
|
.default_background_color = options.config.background,
|
||||||
.cursor_color = null,
|
.cursor_color = null,
|
||||||
.default_cursor_color = options.config.cursor_color,
|
.default_cursor_color = options.config.cursor_color,
|
||||||
.cursor_invert = options.config.cursor_invert,
|
|
||||||
|
|
||||||
// Render state
|
// Render state
|
||||||
.cells = .{},
|
.cells = .{},
|
||||||
@ -2079,8 +2051,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
// Set our new colors
|
// Set our new colors
|
||||||
self.default_background_color = config.background;
|
self.default_background_color = config.background;
|
||||||
self.default_foreground_color = config.foreground;
|
self.default_foreground_color = config.foreground;
|
||||||
self.default_cursor_color = if (!config.cursor_invert) config.cursor_color else null;
|
self.default_cursor_color = config.cursor_color;
|
||||||
self.cursor_invert = config.cursor_invert;
|
|
||||||
|
|
||||||
const bg_image_config_changed =
|
const bg_image_config_changed =
|
||||||
self.config.bg_image_fit != config.bg_image_fit or
|
self.config.bg_image_fit != config.bg_image_fit or
|
||||||
@ -2577,28 +2548,31 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
else
|
else
|
||||||
false;
|
false;
|
||||||
|
|
||||||
|
// The `_style` suffixed values are the colors based on
|
||||||
|
// the cell style (SGR), before applying any additional
|
||||||
|
// configuration, inversions, selections, etc.
|
||||||
const bg_style = style.bg(cell, color_palette);
|
const bg_style = style.bg(cell, color_palette);
|
||||||
const fg_style = style.fg(color_palette, self.config.bold_is_bright) orelse self.foreground_color orelse self.default_foreground_color;
|
const fg_style = style.fg(
|
||||||
|
color_palette,
|
||||||
|
self.config.bold_is_bright,
|
||||||
|
) orelse self.foreground_color orelse self.default_foreground_color;
|
||||||
|
|
||||||
// The final background color for the cell.
|
// The final background color for the cell.
|
||||||
const bg = bg: {
|
const bg = bg: {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
break :bg if (self.config.invert_selection_fg_bg)
|
// If we have an explicit selection background color
|
||||||
if (style.flags.inverse)
|
// specified int he config, use that
|
||||||
// Cell is selected with invert selection fg/bg
|
if (self.config.selection_background) |v| {
|
||||||
// enabled, and the cell has the inverse style
|
break :bg switch (v) {
|
||||||
// flag, so they cancel out and we get the normal
|
.color => |color| color.toTerminalRGB(),
|
||||||
// bg color.
|
.@"cell-foreground" => if (style.flags.inverse) bg_style else fg_style,
|
||||||
bg_style
|
.@"cell-background" => if (style.flags.inverse) fg_style else bg_style,
|
||||||
else
|
};
|
||||||
// If it doesn't have the inverse style
|
}
|
||||||
// flag then we use the fg color instead.
|
|
||||||
fg_style
|
// If no configuration, then our selection background
|
||||||
else
|
// is our foreground color.
|
||||||
// If we don't have invert selection fg/bg set then we
|
break :bg self.foreground_color orelse self.default_foreground_color;
|
||||||
// just use the selection background if set, otherwise
|
|
||||||
// the default fg color.
|
|
||||||
break :bg self.config.selection_background orelse self.foreground_color orelse self.default_foreground_color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not selected
|
// Not selected
|
||||||
@ -2618,20 +2592,31 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const fg = fg: {
|
const fg = fg: {
|
||||||
if (selected and !self.config.invert_selection_fg_bg) {
|
// Our happy-path non-selection background color
|
||||||
// If we don't have invert selection fg/bg set
|
// is our style or our configured defaults.
|
||||||
// then we just use the selection foreground if
|
const final_bg = bg_style orelse
|
||||||
// set, otherwise the default bg color.
|
self.background_color orelse
|
||||||
break :fg self.config.selection_foreground orelse self.background_color orelse self.default_background_color;
|
self.default_background_color;
|
||||||
}
|
|
||||||
|
|
||||||
// Whether we need to use the bg color as our fg color:
|
// Whether we need to use the bg color as our fg color:
|
||||||
|
// - Cell is selected, inverted, and set to cell-foreground
|
||||||
|
// - Cell is selected, not inverted, and set to cell-background
|
||||||
// - Cell is inverted and not selected
|
// - Cell is inverted and not selected
|
||||||
// - Cell is selected and not inverted
|
if (selected) {
|
||||||
// Note: if selected then invert sel fg / bg must be
|
// Use the selection foreground if set
|
||||||
// false since we separately handle it if true above.
|
if (self.config.selection_foreground) |v| {
|
||||||
break :fg if (style.flags.inverse != selected)
|
break :fg switch (v) {
|
||||||
bg_style orelse self.background_color orelse self.default_background_color
|
.color => |color| color.toTerminalRGB(),
|
||||||
|
.@"cell-foreground" => if (style.flags.inverse) final_bg else fg_style,
|
||||||
|
.@"cell-background" => if (style.flags.inverse) fg_style else final_bg,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
break :fg self.background_color orelse self.default_background_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
break :fg if (style.flags.inverse)
|
||||||
|
final_bg
|
||||||
else
|
else
|
||||||
fg_style;
|
fg_style;
|
||||||
};
|
};
|
||||||
@ -2817,18 +2802,35 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
|
|
||||||
// Prepare the cursor cell contents.
|
// Prepare the cursor cell contents.
|
||||||
const style = cursor_style_ orelse break :cursor;
|
const style = cursor_style_ orelse break :cursor;
|
||||||
const cursor_color = self.cursor_color orelse self.default_cursor_color orelse color: {
|
const cursor_color = cursor_color: {
|
||||||
if (self.cursor_invert) {
|
// If an explicit cursor color was set by OSC 12, use that.
|
||||||
// Use the foreground color from the cell under the cursor, if any.
|
if (self.cursor_color) |v| break :cursor_color v;
|
||||||
const sty = screen.cursor.page_pin.style(screen.cursor.page_cell);
|
|
||||||
break :color if (sty.flags.inverse)
|
// Use our configured color if specified
|
||||||
// If the cell is reversed, use background color instead.
|
if (self.default_cursor_color) |v| switch (v) {
|
||||||
(sty.bg(screen.cursor.page_cell, color_palette) orelse self.background_color orelse self.default_background_color)
|
.color => |color| break :cursor_color color.toTerminalRGB(),
|
||||||
else
|
inline .@"cell-foreground",
|
||||||
(sty.fg(color_palette, self.config.bold_is_bright) orelse self.foreground_color orelse self.default_foreground_color);
|
.@"cell-background",
|
||||||
} else {
|
=> |_, tag| {
|
||||||
break :color self.foreground_color orelse self.default_foreground_color;
|
const sty = screen.cursor.page_pin.style(screen.cursor.page_cell);
|
||||||
}
|
const fg_style = sty.fg(
|
||||||
|
color_palette,
|
||||||
|
self.config.bold_is_bright,
|
||||||
|
) orelse self.foreground_color orelse self.default_foreground_color;
|
||||||
|
const bg_style = sty.bg(
|
||||||
|
screen.cursor.page_cell,
|
||||||
|
color_palette,
|
||||||
|
) orelse self.background_color orelse self.default_background_color;
|
||||||
|
|
||||||
|
break :cursor_color switch (tag) {
|
||||||
|
.color => unreachable,
|
||||||
|
.@"cell-foreground" => if (sty.flags.inverse) bg_style else fg_style,
|
||||||
|
.@"cell-background" => if (sty.flags.inverse) fg_style else bg_style,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
break :cursor_color self.foreground_color orelse self.default_foreground_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.addCursor(screen, style, cursor_color);
|
self.addCursor(screen, style, cursor_color);
|
||||||
@ -2853,18 +2855,25 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
.wide, .spacer_tail => true,
|
.wide, .spacer_tail => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const uniform_color = if (self.cursor_invert) blk: {
|
const uniform_color = if (self.config.cursor_text) |txt| blk: {
|
||||||
// Use the background color from the cell under the cursor, if any.
|
// If cursor-text is set, then compute the correct color.
|
||||||
|
// Otherwise, use the background color.
|
||||||
|
if (txt == .color) {
|
||||||
|
// Use the color set by cursor-text, if any.
|
||||||
|
break :blk txt.color.toTerminalRGB();
|
||||||
|
}
|
||||||
|
|
||||||
const sty = screen.cursor.page_pin.style(screen.cursor.page_cell);
|
const sty = screen.cursor.page_pin.style(screen.cursor.page_cell);
|
||||||
break :blk if (sty.flags.inverse)
|
const fg_style = sty.fg(color_palette, self.config.bold_is_bright) orelse self.foreground_color orelse self.default_foreground_color;
|
||||||
// If the cell is reversed, use foreground color instead.
|
const bg_style = sty.bg(screen.cursor.page_cell, color_palette) orelse self.background_color orelse self.default_background_color;
|
||||||
(sty.fg(color_palette, self.config.bold_is_bright) orelse self.foreground_color orelse self.default_foreground_color)
|
|
||||||
else
|
break :blk switch (txt) {
|
||||||
(sty.bg(screen.cursor.page_cell, color_palette) orelse self.background_color orelse self.default_background_color);
|
// If the cell is reversed, use the opposite cell color instead.
|
||||||
} else if (self.config.cursor_text) |txt|
|
.@"cell-foreground" => if (sty.flags.inverse) bg_style else fg_style,
|
||||||
txt
|
.@"cell-background" => if (sty.flags.inverse) fg_style else bg_style,
|
||||||
else
|
else => unreachable,
|
||||||
self.background_color orelse self.default_background_color;
|
};
|
||||||
|
} else self.background_color orelse self.default_background_color;
|
||||||
|
|
||||||
self.uniforms.cursor_color = .{
|
self.uniforms.cursor_color = .{
|
||||||
uniform_color.r,
|
uniform_color.r,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "common.glsl"
|
#include "common.glsl"
|
||||||
|
|
||||||
// Position the origin to the upper left
|
// Position the origin to the upper left
|
||||||
layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord;
|
layout(origin_upper_left) in vec4 gl_FragCoord;
|
||||||
|
|
||||||
// Must declare this output for some versions of OpenGL.
|
// Must declare this output for some versions of OpenGL.
|
||||||
layout(location = 0) out vec4 out_FragColor;
|
layout(location = 0) out vec4 out_FragColor;
|
||||||
|
@ -90,15 +90,13 @@ pub fn threadEnter(
|
|||||||
// Start our subprocess
|
// Start our subprocess
|
||||||
const pty_fds = self.subprocess.start(alloc) catch |err| {
|
const pty_fds = self.subprocess.start(alloc) catch |err| {
|
||||||
// If we specifically got this error then we are in the forked
|
// If we specifically got this error then we are in the forked
|
||||||
// process and our child failed to execute. In that case
|
// process and our child failed to execute. If we DIDN'T
|
||||||
if (err != error.Termio) return err;
|
// get this specific error then we're in the parent and
|
||||||
|
// we need to bubble it up.
|
||||||
|
if (err != error.ExecFailedInChild) return err;
|
||||||
|
|
||||||
// Output an error message about the exec faililng and exit.
|
// We're in the child. Nothing more we can do but abnormal exit.
|
||||||
// This generally should NOT happen because we always wrap
|
// The Command will output some additional information.
|
||||||
// our command execution either in login (macOS) or /bin/sh
|
|
||||||
// (Linux) which are usually guaranteed to exist. Still, we
|
|
||||||
// want to handle this scenario.
|
|
||||||
execFailedInChild() catch {};
|
|
||||||
posix.exit(1);
|
posix.exit(1);
|
||||||
};
|
};
|
||||||
errdefer self.subprocess.stop();
|
errdefer self.subprocess.stop();
|
||||||
@ -272,25 +270,6 @@ pub fn resize(
|
|||||||
return try self.subprocess.resize(grid_size, screen_size);
|
return try self.subprocess.resize(grid_size, screen_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This outputs an error message when exec failed and we are the
|
|
||||||
/// child process. This returns so the caller should probably exit
|
|
||||||
/// after calling this.
|
|
||||||
///
|
|
||||||
/// Note that this usually is only called under very very rare
|
|
||||||
/// circumstances because we wrap our command execution in login
|
|
||||||
/// (macOS) or /bin/sh (Linux). So this output can be pretty crude
|
|
||||||
/// because it should never happen. Notably, this is not the error
|
|
||||||
/// users see when `command` is invalid.
|
|
||||||
fn execFailedInChild() !void {
|
|
||||||
const stderr = std.io.getStdErr().writer();
|
|
||||||
try stderr.writeAll("exec failed\n");
|
|
||||||
try stderr.writeAll("press any key to exit\n");
|
|
||||||
|
|
||||||
var buf: [1]u8 = undefined;
|
|
||||||
var reader = std.io.getStdIn().reader();
|
|
||||||
_ = try reader.read(&buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn processExitCommon(td: *termio.Termio.ThreadData, exit_code: u32) void {
|
fn processExitCommon(td: *termio.Termio.ThreadData, exit_code: u32) void {
|
||||||
assert(td.backend == .exec);
|
assert(td.backend == .exec);
|
||||||
const execdata = &td.backend.exec;
|
const execdata = &td.backend.exec;
|
||||||
@ -847,6 +826,15 @@ const Subprocess = struct {
|
|||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
|
|
||||||
|
// Propagate the current working directory (CWD) to the shell, enabling
|
||||||
|
// the shell to display the current directory name rather than the
|
||||||
|
// resolved path for symbolic links. This is important and based
|
||||||
|
// on the same behavior in Konsole and Kitty (see the linked issues):
|
||||||
|
// https://bugs.kde.org/show_bug.cgi?id=242114
|
||||||
|
// https://github.com/kovidgoyal/kitty/issues/1595
|
||||||
|
// https://github.com/ghostty-org/ghostty/discussions/7769
|
||||||
|
if (cwd) |pwd| try env.put("PWD", pwd);
|
||||||
|
|
||||||
// If we have a cgroup, then we copy that into our arena so the
|
// If we have a cgroup, then we copy that into our arena so the
|
||||||
// memory remains valid when we start.
|
// memory remains valid when we start.
|
||||||
const linux_cgroup: Command.LinuxCgroup = cgroup: {
|
const linux_cgroup: Command.LinuxCgroup = cgroup: {
|
||||||
@ -886,6 +874,12 @@ const Subprocess = struct {
|
|||||||
} {
|
} {
|
||||||
assert(self.pty == null and self.command == null);
|
assert(self.pty == null and self.command == null);
|
||||||
|
|
||||||
|
// This function is funny because on POSIX systems it can
|
||||||
|
// fail in the forked process. This is flipped to true if
|
||||||
|
// we're in an error state in the forked process (child
|
||||||
|
// process).
|
||||||
|
var in_child: bool = false;
|
||||||
|
|
||||||
// Create our pty
|
// Create our pty
|
||||||
var pty = try Pty.open(.{
|
var pty = try Pty.open(.{
|
||||||
.ws_row = @intCast(self.grid_size.rows),
|
.ws_row = @intCast(self.grid_size.rows),
|
||||||
@ -894,14 +888,14 @@ const Subprocess = struct {
|
|||||||
.ws_ypixel = @intCast(self.screen_size.height),
|
.ws_ypixel = @intCast(self.screen_size.height),
|
||||||
});
|
});
|
||||||
self.pty = pty;
|
self.pty = pty;
|
||||||
errdefer {
|
errdefer if (!in_child) {
|
||||||
if (comptime builtin.os.tag != .windows) {
|
if (comptime builtin.os.tag != .windows) {
|
||||||
_ = posix.close(pty.slave);
|
_ = posix.close(pty.slave);
|
||||||
}
|
}
|
||||||
|
|
||||||
pty.deinit();
|
pty.deinit();
|
||||||
self.pty = null;
|
self.pty = null;
|
||||||
}
|
};
|
||||||
|
|
||||||
log.debug("starting command command={s}", .{self.args});
|
log.debug("starting command command={s}", .{self.args});
|
||||||
|
|
||||||
@ -1004,7 +998,22 @@ const Subprocess = struct {
|
|||||||
.data = self,
|
.data = self,
|
||||||
.linux_cgroup = self.linux_cgroup,
|
.linux_cgroup = self.linux_cgroup,
|
||||||
};
|
};
|
||||||
try cmd.start(alloc);
|
|
||||||
|
cmd.start(alloc) catch |err| {
|
||||||
|
// We have to do this because start on Windows can't
|
||||||
|
// ever return ExecFailedInChild
|
||||||
|
const StartError = error{ExecFailedInChild} || @TypeOf(err);
|
||||||
|
switch (@as(StartError, err)) {
|
||||||
|
// If we fail in our child we need to flag it so our
|
||||||
|
// errdefers don't run.
|
||||||
|
error.ExecFailedInChild => {
|
||||||
|
in_child = true;
|
||||||
|
return err;
|
||||||
|
},
|
||||||
|
|
||||||
|
else => return err,
|
||||||
|
}
|
||||||
|
};
|
||||||
errdefer killCommand(&cmd) catch |err| {
|
errdefer killCommand(&cmd) catch |err| {
|
||||||
log.warn("error killing command during cleanup err={}", .{err});
|
log.warn("error killing command during cleanup err={}", .{err});
|
||||||
};
|
};
|
||||||
|
@ -163,8 +163,7 @@ pub const DerivedConfig = struct {
|
|||||||
image_storage_limit: usize,
|
image_storage_limit: usize,
|
||||||
cursor_style: terminalpkg.CursorStyle,
|
cursor_style: terminalpkg.CursorStyle,
|
||||||
cursor_blink: ?bool,
|
cursor_blink: ?bool,
|
||||||
cursor_color: ?configpkg.Config.Color,
|
cursor_color: ?configpkg.Config.TerminalColor,
|
||||||
cursor_invert: bool,
|
|
||||||
foreground: configpkg.Config.Color,
|
foreground: configpkg.Config.Color,
|
||||||
background: configpkg.Config.Color,
|
background: configpkg.Config.Color,
|
||||||
osc_color_report_format: configpkg.Config.OSCColorReportFormat,
|
osc_color_report_format: configpkg.Config.OSCColorReportFormat,
|
||||||
@ -185,7 +184,6 @@ pub const DerivedConfig = struct {
|
|||||||
.cursor_style = config.@"cursor-style",
|
.cursor_style = config.@"cursor-style",
|
||||||
.cursor_blink = config.@"cursor-style-blink",
|
.cursor_blink = config.@"cursor-style-blink",
|
||||||
.cursor_color = config.@"cursor-color",
|
.cursor_color = config.@"cursor-color",
|
||||||
.cursor_invert = config.@"cursor-invert-fg-bg",
|
|
||||||
.foreground = config.foreground,
|
.foreground = config.foreground,
|
||||||
.background = config.background,
|
.background = config.background,
|
||||||
.osc_color_report_format = config.@"osc-color-report-format",
|
.osc_color_report_format = config.@"osc-color-report-format",
|
||||||
@ -265,10 +263,16 @@ pub fn init(self: *Termio, alloc: Allocator, opts: termio.Options) !void {
|
|||||||
// Create our stream handler. This points to memory in self so it
|
// Create our stream handler. This points to memory in self so it
|
||||||
// isn't safe to use until self.* is set.
|
// isn't safe to use until self.* is set.
|
||||||
const handler: StreamHandler = handler: {
|
const handler: StreamHandler = handler: {
|
||||||
const default_cursor_color = if (!opts.config.cursor_invert and opts.config.cursor_color != null)
|
const default_cursor_color: ?terminalpkg.color.RGB = color: {
|
||||||
opts.config.cursor_color.?.toTerminalRGB()
|
if (opts.config.cursor_color) |color| switch (color) {
|
||||||
else
|
.color => break :color color.color.toTerminalRGB(),
|
||||||
null;
|
.@"cell-foreground",
|
||||||
|
.@"cell-background",
|
||||||
|
=> {},
|
||||||
|
};
|
||||||
|
|
||||||
|
break :color null;
|
||||||
|
};
|
||||||
|
|
||||||
break :handler .{
|
break :handler .{
|
||||||
.alloc = alloc,
|
.alloc = alloc,
|
||||||
|
@ -121,10 +121,16 @@ pub const StreamHandler = struct {
|
|||||||
self.default_background_color = config.background.toTerminalRGB();
|
self.default_background_color = config.background.toTerminalRGB();
|
||||||
self.default_cursor_style = config.cursor_style;
|
self.default_cursor_style = config.cursor_style;
|
||||||
self.default_cursor_blink = config.cursor_blink;
|
self.default_cursor_blink = config.cursor_blink;
|
||||||
self.default_cursor_color = if (!config.cursor_invert and config.cursor_color != null)
|
self.default_cursor_color = color: {
|
||||||
config.cursor_color.?.toTerminalRGB()
|
if (config.cursor_color) |color| switch (color) {
|
||||||
else
|
.color => break :color color.color.toTerminalRGB(),
|
||||||
null;
|
.@"cell-foreground",
|
||||||
|
.@"cell-background",
|
||||||
|
=> {},
|
||||||
|
};
|
||||||
|
|
||||||
|
break :color null;
|
||||||
|
};
|
||||||
|
|
||||||
// If our cursor is the default, then we update it immediately.
|
// If our cursor is the default, then we update it immediately.
|
||||||
if (self.default_cursor) self.setCursorStyle(.default) catch |err| {
|
if (self.default_cursor) self.setCursorStyle(.default) catch |err| {
|
||||||
|
Reference in New Issue
Block a user