configuration to control OSC 52

This commit is contained in:
Mitchell Hashimoto
2022-11-21 15:10:15 -08:00
parent ce778fefaf
commit b9f38cb18b
2 changed files with 16 additions and 0 deletions

View File

@ -607,6 +607,11 @@ pub fn handleMessage(self: *Window, msg: Message) !void {
}
fn clipboardRead(self: *const Window, kind: u8) !void {
if (!self.config.@"clipboard-read") {
log.info("application attempted to read clipboard, but 'clipboard-read' setting is off", .{});
return;
}
const data = glfw.getClipboardString() catch |err| {
log.warn("error reading clipboard: {}", .{err});
return;
@ -638,6 +643,11 @@ fn clipboardRead(self: *const Window, kind: u8) !void {
}
fn clipboardWrite(self: *const Window, data: []const u8) !void {
if (!self.config.@"clipboard-write") {
log.info("application attempted to write clipboard, but 'clipboard-write' setting is off", .{});
return;
}
const dec = std.base64.standard.Decoder;
// Build buffer

View File

@ -141,6 +141,12 @@ pub const Config = struct {
/// specified in the configuration "font-size" will be used.
@"window-inherit-font-size": bool = true,
/// Whether to allow programs running in the terminal to read/write to
/// the system clipboard (OSC 52, for googling). The default is to
/// disallow clipboard reading but allow writing.
@"clipboard-read": bool = false,
@"clipboard-write": bool = true,
/// Additional configuration files to read.
@"config-file": RepeatableString = .{},