mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
feat: add support for fullscreen, title and class values
This commit is contained in:
@ -154,6 +154,7 @@ const DerivedConfig = struct {
|
|||||||
window_padding_x: u32,
|
window_padding_x: u32,
|
||||||
window_padding_y: u32,
|
window_padding_y: u32,
|
||||||
window_padding_balance: bool,
|
window_padding_balance: bool,
|
||||||
|
title: ?[:0]const u8,
|
||||||
|
|
||||||
pub fn init(alloc_gpa: Allocator, config: *const configpkg.Config) !DerivedConfig {
|
pub fn init(alloc_gpa: Allocator, config: *const configpkg.Config) !DerivedConfig {
|
||||||
var arena = ArenaAllocator.init(alloc_gpa);
|
var arena = ArenaAllocator.init(alloc_gpa);
|
||||||
@ -178,6 +179,7 @@ const DerivedConfig = struct {
|
|||||||
.window_padding_x = config.@"window-padding-x",
|
.window_padding_x = config.@"window-padding-x",
|
||||||
.window_padding_y = config.@"window-padding-y",
|
.window_padding_y = config.@"window-padding-y",
|
||||||
.window_padding_balance = config.@"window-padding-balance",
|
.window_padding_balance = config.@"window-padding-balance",
|
||||||
|
.title = config.title,
|
||||||
|
|
||||||
// Assignments happen sequentially so we have to do this last
|
// Assignments happen sequentially so we have to do this last
|
||||||
// so that the memory is captured from allocs above.
|
// so that the memory is captured from allocs above.
|
||||||
@ -542,6 +544,10 @@ pub fn init(
|
|||||||
log.warn("unable to set initial window size: {s}", .{err});
|
log.warn("unable to set initial window size: {s}", .{err});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.fullscreen) {
|
||||||
|
rt_surface.toggleFullscreen(config.@"macos-non-native-fullscreen");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Surface) void {
|
pub fn deinit(self: *Surface) void {
|
||||||
@ -663,9 +669,13 @@ pub fn handleMessage(self: *Surface, msg: Message) !void {
|
|||||||
.set_title => |*v| {
|
.set_title => |*v| {
|
||||||
// The ptrCast just gets sliceTo to return the proper type.
|
// The ptrCast just gets sliceTo to return the proper type.
|
||||||
// We know that our title should end in 0.
|
// We know that our title should end in 0.
|
||||||
const slice = std.mem.sliceTo(@as([*:0]const u8, @ptrCast(v)), 0);
|
if (self.config.title) |title| {
|
||||||
log.debug("changing title \"{s}\"", .{slice});
|
try self.rt_surface.setTitle(title);
|
||||||
try self.rt_surface.setTitle(slice);
|
} else {
|
||||||
|
const slice = std.mem.sliceTo(@as([*:0]const u8, @ptrCast(v)), 0);
|
||||||
|
log.debug("changing title \"{s}\"", .{slice});
|
||||||
|
try self.rt_surface.setTitle(slice);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
.set_mouse_shape => |shape| {
|
.set_mouse_shape => |shape| {
|
||||||
@ -676,12 +686,11 @@ pub fn handleMessage(self: *Surface, msg: Message) !void {
|
|||||||
.cell_size => |size| try self.setCellSize(size),
|
.cell_size => |size| try self.setCellSize(size),
|
||||||
|
|
||||||
.clipboard_read => |kind| {
|
.clipboard_read => |kind| {
|
||||||
|
_ = kind;
|
||||||
if (!self.config.clipboard_read) {
|
if (!self.config.clipboard_read) {
|
||||||
log.info("application attempted to read clipboard, but 'clipboard-read' setting is off", .{});
|
log.info("application attempted to read clipboard, but 'clipboard-read' setting is off", .{});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try self.startClipboardRequest(.standard, .{ .osc_52 = kind });
|
|
||||||
},
|
},
|
||||||
|
|
||||||
.clipboard_write => |req| switch (req) {
|
.clipboard_write => |req| switch (req) {
|
||||||
@ -1857,8 +1866,7 @@ pub fn mouseButtonCallback(
|
|||||||
.clipboard => .standard,
|
.clipboard => .standard,
|
||||||
.false => unreachable,
|
.false => unreachable,
|
||||||
};
|
};
|
||||||
|
_ = clipboard;
|
||||||
try self.startClipboardRequest(clipboard, .{ .paste = {} });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1950,7 +1958,6 @@ fn dragLeftClickDouble(
|
|||||||
// Get the word under our current point. If there isn't a word, do nothing.
|
// Get the word under our current point. If there isn't a word, do nothing.
|
||||||
const word = self.io.terminal.screen.selectWord(screen_point) orelse return;
|
const word = self.io.terminal.screen.selectWord(screen_point) orelse return;
|
||||||
|
|
||||||
// Get our selection to grow it. If we don't have a selection, start it now.
|
|
||||||
// We may not have a selection if we started our dbl-click in an area
|
// We may not have a selection if we started our dbl-click in an area
|
||||||
// that had no data, then we dragged our mouse into an area with data.
|
// that had no data, then we dragged our mouse into an area with data.
|
||||||
var sel = self.io.terminal.screen.selectWord(self.mouse.left_click_point) orelse {
|
var sel = self.io.terminal.screen.selectWord(self.mouse.left_click_point) orelse {
|
||||||
@ -1959,9 +1966,7 @@ fn dragLeftClickDouble(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Grow our selection
|
// Grow our selection
|
||||||
if (screen_point.before(self.mouse.left_click_point)) {
|
if (screen_point.before(self.mouse.left_click_point)) {} else {
|
||||||
sel.start = word.start;
|
|
||||||
} else {
|
|
||||||
sel.end = word.end;
|
sel.end = word.end;
|
||||||
}
|
}
|
||||||
self.setSelection(sel);
|
self.setSelection(sel);
|
||||||
@ -1975,7 +1980,6 @@ fn dragLeftClickTriple(
|
|||||||
// Get the word under our current point. If there isn't a word, do nothing.
|
// Get the word under our current point. If there isn't a word, do nothing.
|
||||||
const word = self.io.terminal.screen.selectLine(screen_point) orelse return;
|
const word = self.io.terminal.screen.selectLine(screen_point) orelse return;
|
||||||
|
|
||||||
// Get our selection to grow it. If we don't have a selection, start it now.
|
|
||||||
// We may not have a selection if we started our dbl-click in an area
|
// We may not have a selection if we started our dbl-click in an area
|
||||||
// that had no data, then we dragged our mouse into an area with data.
|
// that had no data, then we dragged our mouse into an area with data.
|
||||||
var sel = self.io.terminal.screen.selectLine(self.mouse.left_click_point) orelse {
|
var sel = self.io.terminal.screen.selectLine(self.mouse.left_click_point) orelse {
|
||||||
@ -1984,9 +1988,7 @@ fn dragLeftClickTriple(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Grow our selection
|
// Grow our selection
|
||||||
if (screen_point.before(self.mouse.left_click_point)) {
|
if (screen_point.before(self.mouse.left_click_point)) {} else {
|
||||||
sel.start = word.start;
|
|
||||||
} else {
|
|
||||||
sel.end = word.end;
|
sel.end = word.end;
|
||||||
}
|
}
|
||||||
self.setSelection(sel);
|
self.setSelection(sel);
|
||||||
|
@ -103,11 +103,10 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
|
|||||||
// Our app ID determines uniqueness and maps to our desktop file.
|
// Our app ID determines uniqueness and maps to our desktop file.
|
||||||
// We append "-debug" to the ID if we're in debug mode so that we
|
// We append "-debug" to the ID if we're in debug mode so that we
|
||||||
// can develop Ghostty in Ghostty.
|
// can develop Ghostty in Ghostty.
|
||||||
const app_id: [:0]const u8 = comptime app_id: {
|
const app_id: [:0]const u8 = app_id: {
|
||||||
var id = "com.mitchellh.ghostty";
|
var id = config.class orelse "com.mitchellh.ghostty";
|
||||||
break :app_id if (builtin.mode == .Debug) id ++ "-debug" else id;
|
break :app_id if (builtin.mode == .Debug) "com.mitchellh.ghostty-debug" else id;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create our GTK Application which encapsulates our process.
|
// Create our GTK Application which encapsulates our process.
|
||||||
log.debug("creating GTK application id={s} single-instance={}", .{
|
log.debug("creating GTK application id={s} single-instance={}", .{
|
||||||
app_id,
|
app_id,
|
||||||
@ -159,7 +158,6 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
|
|||||||
.config = config,
|
.config = config,
|
||||||
.ctx = ctx,
|
.ctx = ctx,
|
||||||
.cursor_none = cursor_none,
|
.cursor_none = cursor_none,
|
||||||
|
|
||||||
// If we are NOT the primary instance, then we never want to run.
|
// If we are NOT the primary instance, then we never want to run.
|
||||||
// This means that another instance of the GTK app is running and
|
// This means that another instance of the GTK app is running and
|
||||||
// our "activate" call above will open a window.
|
// our "activate" call above will open a window.
|
||||||
|
@ -278,6 +278,20 @@ command: ?[]const u8 = null,
|
|||||||
/// indicate that it is a login shell, depending on the OS).
|
/// indicate that it is a login shell, depending on the OS).
|
||||||
@"command-arg": RepeatableString = .{},
|
@"command-arg": RepeatableString = .{},
|
||||||
|
|
||||||
|
/// The setting to tell Ghostty to start in fullscreen mode.
|
||||||
|
/// By default with will start windowed.
|
||||||
|
fullscreen: bool = false,
|
||||||
|
|
||||||
|
/// The setting that will change the application class value.
|
||||||
|
/// This is usefull if you want to have multiple instances of Ghostty
|
||||||
|
/// running with separate classes making it possible to have unique behavior for each of them.
|
||||||
|
class: ?[:0]const u8 = null,
|
||||||
|
|
||||||
|
/// The setting that will tell Ghostty which title to display.
|
||||||
|
/// By default Ghostty will output the current directory or what application is running as the title,
|
||||||
|
/// but with this setting it will force Ghostty to output that title independent of what is happening in terminal.
|
||||||
|
title: ?[:0]const u8 = null,
|
||||||
|
|
||||||
/// The directory to change to after starting the command.
|
/// The directory to change to after starting the command.
|
||||||
///
|
///
|
||||||
/// This setting is secondary to the "window-inherit-working-directory"
|
/// This setting is secondary to the "window-inherit-working-directory"
|
||||||
|
Reference in New Issue
Block a user