mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-24 04:36:10 +03:00
core: add config option to invert fg and bg of cell when selected
This commit is contained in:
@ -165,6 +165,13 @@ foreground: Color = .{ .r = 0xFF, .g = 0xFF, .b = 0xFF },
|
||||
@"selection-foreground": ?Color = null,
|
||||
@"selection-background": ?Color = null,
|
||||
|
||||
/// Inverts the cell color from foreground to background,
|
||||
/// and from background to foreground.
|
||||
/// This option does not take in consideration the color
|
||||
/// values defined for "selection-foreground" and "selection-background"
|
||||
/// as it will use the foreground and background of the cell.
|
||||
@"invert-selection-fg-bg": bool = false,
|
||||
|
||||
/// Color palette for the 256 color form that many terminal applications
|
||||
/// use. The syntax of this configuration is "N=HEXCODE" where "n"
|
||||
/// is 0 to 255 (for the 256 colors) and HEXCODE is a typical RGB
|
||||
|
@ -237,6 +237,7 @@ pub const DerivedConfig = struct {
|
||||
foreground: terminal.color.RGB,
|
||||
selection_background: ?terminal.color.RGB,
|
||||
selection_foreground: ?terminal.color.RGB,
|
||||
invert_selection_fg_bg: bool,
|
||||
|
||||
pub fn init(
|
||||
alloc_gpa: Allocator,
|
||||
@ -275,6 +276,7 @@ pub const DerivedConfig = struct {
|
||||
|
||||
.background = config.background.toTerminalRGB(),
|
||||
.foreground = config.foreground.toTerminalRGB(),
|
||||
.invert_selection_fg_bg = config.@"invert-selection-fg-bg",
|
||||
|
||||
.selection_background = if (config.@"selection-background") |bg|
|
||||
bg.toTerminalRGB()
|
||||
@ -1088,8 +1090,8 @@ pub fn updateCell(
|
||||
const colors: BgFg = colors: {
|
||||
// If we are selected, we our colors are just inverted fg/bg
|
||||
const selection_res: ?BgFg = if (selected) .{
|
||||
.bg = self.config.selection_background orelse self.foreground_color,
|
||||
.fg = self.config.selection_foreground orelse self.background_color,
|
||||
.bg = if (self.config.invert_selection_fg_bg) cell.fg else self.config.selection_background orelse self.foreground_color,
|
||||
.fg = if (self.config.invert_selection_fg_bg) cell.bg else self.config.selection_foreground orelse self.background_color,
|
||||
} else null;
|
||||
|
||||
const res: BgFg = selection_res orelse if (!cell.attrs.inverse) .{
|
||||
|
Reference in New Issue
Block a user