mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-21 23:05:20 +00:00
move copyTitleToClipboard logic into Surface
This commit is contained in:
@@ -1901,15 +1901,7 @@ const Action = struct {
|
||||
pub fn copyTitleToClipboard(target: apprt.Target) bool {
|
||||
return switch (target) {
|
||||
.app => false,
|
||||
.surface => |v| surface: {
|
||||
const title = v.rt_surface.surface.getEffectiveTitle() orelse break :surface false;
|
||||
if (title.len == 0) break :surface false;
|
||||
v.rt_surface.surface.setClipboard(.standard, &.{.{
|
||||
.mime = "text/plain",
|
||||
.data = title,
|
||||
}}, false);
|
||||
break :surface true;
|
||||
},
|
||||
.surface => |v| v.rt_surface.gobj().copyTitleToClipboard(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1989,6 +1989,17 @@ pub const Surface = extern struct {
|
||||
return priv.title_override orelse priv.title;
|
||||
}
|
||||
|
||||
/// Copies the effective title to the clipboard.
|
||||
pub fn copyTitleToClipboard(self: *Self) bool {
|
||||
const title = self.getEffectiveTitle() orelse return false;
|
||||
if (title.len == 0) return false;
|
||||
self.setClipboard(.standard, &.{.{
|
||||
.mime = "text/plain",
|
||||
.data = title,
|
||||
}}, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Set the title for this surface, copies the value. This should always
|
||||
/// be the title as set by the terminal program, not any manually set
|
||||
/// title. For manually set titles see `setTitleOverride`.
|
||||
|
||||
Reference in New Issue
Block a user