mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
apprt: propagate OSC10/11 (set term fore/background color) through to apprt
This is to allow the running apprt to set the UI theme to match the terminal application coloring.
This commit is contained in:
@ -512,6 +512,20 @@ typedef struct {
|
|||||||
ghostty_input_trigger_s trigger;
|
ghostty_input_trigger_s trigger;
|
||||||
} ghostty_action_key_sequence_s;
|
} ghostty_action_key_sequence_s;
|
||||||
|
|
||||||
|
// apprt.action.SetBackground
|
||||||
|
typedef struct {
|
||||||
|
uint8_t r;
|
||||||
|
uint8_t g;
|
||||||
|
uint8_t b;
|
||||||
|
} ghostty_action_set_background_s;
|
||||||
|
|
||||||
|
// apprt.action.SetForeground
|
||||||
|
typedef struct {
|
||||||
|
uint8_t r;
|
||||||
|
uint8_t g;
|
||||||
|
uint8_t b;
|
||||||
|
} ghostty_action_set_foreground_s;
|
||||||
|
|
||||||
// apprt.Action.Key
|
// apprt.Action.Key
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GHOSTTY_ACTION_NEW_WINDOW,
|
GHOSTTY_ACTION_NEW_WINDOW,
|
||||||
@ -545,6 +559,8 @@ typedef enum {
|
|||||||
GHOSTTY_ACTION_QUIT_TIMER,
|
GHOSTTY_ACTION_QUIT_TIMER,
|
||||||
GHOSTTY_ACTION_SECURE_INPUT,
|
GHOSTTY_ACTION_SECURE_INPUT,
|
||||||
GHOSTTY_ACTION_KEY_SEQUENCE,
|
GHOSTTY_ACTION_KEY_SEQUENCE,
|
||||||
|
GHOSTTY_ACTION_SET_BACKGROUND,
|
||||||
|
GHOSTTY_ACTION_SET_FOREGROUND,
|
||||||
} ghostty_action_tag_e;
|
} ghostty_action_tag_e;
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
@ -567,6 +583,8 @@ typedef union {
|
|||||||
ghostty_action_quit_timer_e quit_timer;
|
ghostty_action_quit_timer_e quit_timer;
|
||||||
ghostty_action_secure_input_e secure_input;
|
ghostty_action_secure_input_e secure_input;
|
||||||
ghostty_action_key_sequence_s key_sequence;
|
ghostty_action_key_sequence_s key_sequence;
|
||||||
|
ghostty_action_set_background_s set_background;
|
||||||
|
ghostty_action_set_foreground_s set_foreground;
|
||||||
} ghostty_action_u;
|
} ghostty_action_u;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -799,6 +799,22 @@ pub fn handleMessage(self: *Surface, msg: Message) !void {
|
|||||||
}, .unlocked);
|
}, .unlocked);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
.set_background => |color| {
|
||||||
|
try self.rt_app.performAction(
|
||||||
|
.{ .surface = self },
|
||||||
|
.set_background,
|
||||||
|
.{ .r = color.r, .g = color.g, .b = color.b },
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
.set_foreground => |color| {
|
||||||
|
try self.rt_app.performAction(
|
||||||
|
.{ .surface = self },
|
||||||
|
.set_background,
|
||||||
|
.{ .r = color.r, .g = color.g, .b = color.b },
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
.set_mouse_shape => |shape| {
|
.set_mouse_shape => |shape| {
|
||||||
log.debug("changing mouse shape: {}", .{shape});
|
log.debug("changing mouse shape: {}", .{shape});
|
||||||
try self.rt_app.performAction(
|
try self.rt_app.performAction(
|
||||||
|
@ -186,6 +186,12 @@ pub const Action = union(Key) {
|
|||||||
/// key mode because other input may be ignored.
|
/// key mode because other input may be ignored.
|
||||||
key_sequence: KeySequence,
|
key_sequence: KeySequence,
|
||||||
|
|
||||||
|
/// The terminal background color was changed.
|
||||||
|
set_background: SetBackground,
|
||||||
|
|
||||||
|
/// The terminal foreground color was changed.
|
||||||
|
set_foreground: SetForeground,
|
||||||
|
|
||||||
/// Sync with: ghostty_action_tag_e
|
/// Sync with: ghostty_action_tag_e
|
||||||
pub const Key = enum(c_int) {
|
pub const Key = enum(c_int) {
|
||||||
new_window,
|
new_window,
|
||||||
@ -219,6 +225,8 @@ pub const Action = union(Key) {
|
|||||||
quit_timer,
|
quit_timer,
|
||||||
secure_input,
|
secure_input,
|
||||||
key_sequence,
|
key_sequence,
|
||||||
|
set_background,
|
||||||
|
set_foreground,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Sync with: ghostty_action_u
|
/// Sync with: ghostty_action_u
|
||||||
@ -448,3 +456,15 @@ pub const KeySequence = union(enum) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const SetBackground = extern struct {
|
||||||
|
r: u8,
|
||||||
|
g: u8,
|
||||||
|
b: u8,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const SetForeground = extern struct {
|
||||||
|
r: u8,
|
||||||
|
g: u8,
|
||||||
|
b: u8,
|
||||||
|
};
|
||||||
|
@ -223,6 +223,8 @@ pub const App = struct {
|
|||||||
.mouse_over_link,
|
.mouse_over_link,
|
||||||
.cell_size,
|
.cell_size,
|
||||||
.renderer_health,
|
.renderer_health,
|
||||||
|
.set_foreground,
|
||||||
|
.set_background,
|
||||||
=> log.info("unimplemented action={}", .{action}),
|
=> log.info("unimplemented action={}", .{action}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,6 +485,8 @@ pub fn performAction(
|
|||||||
.key_sequence,
|
.key_sequence,
|
||||||
.render_inspector,
|
.render_inspector,
|
||||||
.renderer_health,
|
.renderer_health,
|
||||||
|
.set_foreground,
|
||||||
|
.set_background,
|
||||||
=> log.warn("unimplemented action={}", .{action}),
|
=> log.warn("unimplemented action={}", .{action}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,12 @@ pub const Message = union(enum) {
|
|||||||
/// unless the surface exits.
|
/// unless the surface exits.
|
||||||
password_input: bool,
|
password_input: bool,
|
||||||
|
|
||||||
|
/// The terminal background color was changed.
|
||||||
|
set_background: terminal.color.RGB,
|
||||||
|
|
||||||
|
/// The terminal foreground color was changed.
|
||||||
|
set_foreground: terminal.color.RGB,
|
||||||
|
|
||||||
pub const ReportTitleStyle = enum {
|
pub const ReportTitleStyle = enum {
|
||||||
csi_21_t,
|
csi_21_t,
|
||||||
|
|
||||||
|
@ -1215,12 +1215,14 @@ pub const StreamHandler = struct {
|
|||||||
_ = self.renderer_mailbox.push(.{
|
_ = self.renderer_mailbox.push(.{
|
||||||
.foreground_color = color,
|
.foreground_color = color,
|
||||||
}, .{ .forever = {} });
|
}, .{ .forever = {} });
|
||||||
|
self.surfaceMessageWriter(.{ .set_background = color });
|
||||||
},
|
},
|
||||||
.background => {
|
.background => {
|
||||||
self.background_color = color;
|
self.background_color = color;
|
||||||
_ = self.renderer_mailbox.push(.{
|
_ = self.renderer_mailbox.push(.{
|
||||||
.background_color = color,
|
.background_color = color,
|
||||||
}, .{ .forever = {} });
|
}, .{ .forever = {} });
|
||||||
|
self.surfaceMessageWriter(.{ .set_background = color });
|
||||||
},
|
},
|
||||||
.cursor => {
|
.cursor => {
|
||||||
self.cursor_color = color;
|
self.cursor_color = color;
|
||||||
|
Reference in New Issue
Block a user