mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
Merge pull request #1269 from mitchellh/p3
macos: support Display P3 colorspace through configuration
This commit is contained in:
@ -162,7 +162,15 @@ class TerminalController: NSWindowController, NSWindowDelegate,
|
|||||||
// Terminals typically operate in sRGB color space and macOS defaults
|
// Terminals typically operate in sRGB color space and macOS defaults
|
||||||
// to "native" which is typically P3. There is a lot more resources
|
// to "native" which is typically P3. There is a lot more resources
|
||||||
// covered in thie GitHub issue: https://github.com/mitchellh/ghostty/pull/376
|
// covered in thie GitHub issue: https://github.com/mitchellh/ghostty/pull/376
|
||||||
window.colorSpace = NSColorSpace.sRGB
|
// Ghostty defaults to sRGB but this can be overridden.
|
||||||
|
switch (ghostty.windowColorspace) {
|
||||||
|
case "display-p3":
|
||||||
|
window.colorSpace = .displayP3
|
||||||
|
case "srgb":
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
window.colorSpace = .sRGB
|
||||||
|
}
|
||||||
|
|
||||||
// If we have only a single surface (no splits) and that surface requested
|
// If we have only a single surface (no splits) and that surface requested
|
||||||
// an initial size then we set it here now.
|
// an initial size then we set it here now.
|
||||||
|
@ -65,6 +65,16 @@ extension Ghostty {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// window-colorspace
|
||||||
|
var windowColorspace: String {
|
||||||
|
guard let config = self.config else { return "" }
|
||||||
|
var v: UnsafePointer<Int8>? = nil
|
||||||
|
let key = "window-colorspace"
|
||||||
|
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return "" }
|
||||||
|
guard let ptr = v else { return "" }
|
||||||
|
return String(cString: ptr)
|
||||||
|
}
|
||||||
|
|
||||||
/// window-save-state
|
/// window-save-state
|
||||||
var windowSaveState: String {
|
var windowSaveState: String {
|
||||||
guard let config = self.config else { return "" }
|
guard let config = self.config else { return "" }
|
||||||
|
@ -587,6 +587,15 @@ keybind: Keybinds = .{},
|
|||||||
/// This is currently only supported on macOS and linux.
|
/// This is currently only supported on macOS and linux.
|
||||||
@"window-theme": WindowTheme = .system,
|
@"window-theme": WindowTheme = .system,
|
||||||
|
|
||||||
|
/// The colorspace to use for the terminal window. The default is "srgb"
|
||||||
|
/// but this can also be set to "display-p3" to use the Display P3
|
||||||
|
/// colorspace.
|
||||||
|
///
|
||||||
|
/// Changing this value at runtime will only affect new windows.
|
||||||
|
///
|
||||||
|
/// This setting is only supported on macOS.
|
||||||
|
@"window-colorspace": WindowColorspace = .srgb,
|
||||||
|
|
||||||
/// The initial window size. This size is in terminal grid cells by default.
|
/// The initial window size. This size is in terminal grid cells by default.
|
||||||
///
|
///
|
||||||
/// We don't currently support specifying a size in pixels but a future
|
/// We don't currently support specifying a size in pixels but a future
|
||||||
@ -2835,6 +2844,12 @@ pub const WindowTheme = enum {
|
|||||||
dark,
|
dark,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// See window-colorspace
|
||||||
|
pub const WindowColorspace = enum {
|
||||||
|
srgb,
|
||||||
|
@"display-p3",
|
||||||
|
};
|
||||||
|
|
||||||
/// See gtk-single-instance
|
/// See gtk-single-instance
|
||||||
pub const GtkSingleInstance = enum {
|
pub const GtkSingleInstance = enum {
|
||||||
desktop,
|
desktop,
|
||||||
|
Reference in New Issue
Block a user