stylistic tweaks

This commit is contained in:
Mitchell Hashimoto
2023-11-11 15:15:52 -08:00
parent e7bc9958da
commit 2489ef4c13
4 changed files with 33 additions and 23 deletions

View File

@ -472,7 +472,9 @@ extension Ghostty {
let pb = NSPasteboard.general let pb = NSPasteboard.general
pb.declareTypes([.string], owner: nil) pb.declareTypes([.string], owner: nil)
pb.setString(valueStr, forType: .string) pb.setString(valueStr, forType: .string)
} else { return
}
NotificationCenter.default.post( NotificationCenter.default.post(
name: Notification.confirmClipboard, name: Notification.confirmClipboard,
object: surface, object: surface,
@ -482,7 +484,6 @@ extension Ghostty {
] ]
) )
} }
}
static func reloadConfig(_ userdata: UnsafeMutableRawPointer?) -> ghostty_config_t? { static func reloadConfig(_ userdata: UnsafeMutableRawPointer?) -> ghostty_config_t? {
guard let newConfig = Self.loadConfig() else { guard let newConfig = Self.loadConfig() else {

View File

@ -2532,8 +2532,18 @@ pub fn completeClipboardRequest(
) !void { ) !void {
switch (req) { switch (req) {
.paste => try self.completeClipboardPaste(data, confirmed), .paste => try self.completeClipboardPaste(data, confirmed),
.osc_52_read => |clipboard| try self.completeClipboardReadOSC52(data, clipboard, confirmed),
.osc_52_write => |clipboard| try self.rt_surface.setClipboardString(data, clipboard, !confirmed), .osc_52_read => |clipboard| try self.completeClipboardReadOSC52(
data,
clipboard,
confirmed,
),
.osc_52_write => |clipboard| try self.rt_surface.setClipboardString(
data,
clipboard,
!confirmed,
),
} }
} }

View File

@ -507,8 +507,6 @@ pub const Surface = struct {
) void { ) void {
const alloc = self.app.core_app.alloc; const alloc = self.app.core_app.alloc;
const request_type: apprt.ClipboardRequestType = state.*;
// Attempt to complete the request, but we may request // Attempt to complete the request, but we may request
// confirmation. // confirmation.
self.core_surface.completeClipboardRequest( self.core_surface.completeClipboardRequest(
@ -523,7 +521,7 @@ pub const Surface = struct {
self.opts.userdata, self.opts.userdata,
str.ptr, str.ptr,
state, state,
request_type, state.*,
); );
return; return;

View File

@ -520,7 +520,9 @@ pub fn setClipboardString(
if (!confirm) { if (!confirm) {
const clipboard = getClipboard(@ptrCast(self.gl_area), clipboard_type); const clipboard = getClipboard(@ptrCast(self.gl_area), clipboard_type);
c.gdk_clipboard_set_text(clipboard, val.ptr); c.gdk_clipboard_set_text(clipboard, val.ptr);
} else { return;
}
ClipboardConfirmationWindow.create( ClipboardConfirmationWindow.create(
self.app, self.app,
val, val,
@ -529,7 +531,6 @@ pub fn setClipboardString(
) catch |window_err| { ) catch |window_err| {
log.err("failed to create clipboard confirmation window err={}", .{window_err}); log.err("failed to create clipboard confirmation window err={}", .{window_err});
}; };
}
} }
const ClipboardRequest = struct { const ClipboardRequest = struct {