OSC 52: Clipboard Control (#52)

This adds support for OSC 52 -- applications can read/write the clipboard. Due to the security risk of this, the default configuration allows for writing but _not reading_. This is configurable using two new settings: `clipboard-read` and `clipboard-write` (both booleans).
This commit is contained in:
Mitchell Hashimoto
2022-11-21 15:12:00 -08:00
committed by GitHub
parent 173aff1e80
commit 56de5846f4
7 changed files with 147 additions and 6 deletions

View File

@@ -1,9 +1,14 @@
const App = @import("../App.zig");
const Window = @import("../Window.zig");
const renderer = @import("../renderer.zig");
const termio = @import("../termio.zig");
/// The message types that can be sent to a single window.
pub const Message = union(enum) {
/// Represents a write request. Magic number comes from the max size
/// we want this union to be.
pub const WriteReq = termio.MessageData(u8, 256);
/// Set the title of the window.
/// TODO: we should change this to a "WriteReq" style structure in
/// the termio message so that we can more efficiently send strings
@@ -12,6 +17,12 @@ pub const Message = union(enum) {
/// Change the cell size.
cell_size: renderer.CellSize,
/// Read the clipboard and write to the pty.
clipboard_read: u8,
/// Write the clipboard contents.
clipboard_write: WriteReq,
};
/// A window mailbox.