Introduce action for copying into clipboard
parent
cc2c45ff4e
commit
ef06e3d02c
|
|
@ -4845,6 +4845,11 @@ fn writeScreenFile(
|
||||||
const path = try tmp_dir.dir.realpath(filename, &path_buf);
|
const path = try tmp_dir.dir.realpath(filename, &path_buf);
|
||||||
|
|
||||||
switch (write_action) {
|
switch (write_action) {
|
||||||
|
.copy => {
|
||||||
|
const pathZ = try self.alloc.dupeZ(u8, path);
|
||||||
|
defer self.alloc.free(pathZ);
|
||||||
|
try self.rt_surface.setClipboardString(pathZ, .standard, false);
|
||||||
|
},
|
||||||
.open => try internal_os.open(self.alloc, .text, path),
|
.open => try internal_os.open(self.alloc, .text, path),
|
||||||
.paste => self.io.queueMessage(try termio.Message.writeReq(
|
.paste => self.io.queueMessage(try termio.Message.writeReq(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
|
|
|
||||||
|
|
@ -5032,6 +5032,12 @@ pub const Keybinds = struct {
|
||||||
.{ .reset_font_size = {} },
|
.{ .reset_font_size = {} },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
try self.set.put(
|
||||||
|
alloc,
|
||||||
|
.{ .key = .{ .unicode = 'j' }, .mods = .{ .shift = true, .ctrl = true, .super = true } },
|
||||||
|
.{ .write_screen_file = .copy },
|
||||||
|
);
|
||||||
|
|
||||||
try self.set.put(
|
try self.set.put(
|
||||||
alloc,
|
alloc,
|
||||||
.{ .key = .{ .unicode = 'j' }, .mods = inputpkg.ctrlOrSuper(.{ .shift = true }) },
|
.{ .key = .{ .unicode = 'j' }, .mods = inputpkg.ctrlOrSuper(.{ .shift = true }) },
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,10 @@ pub const Action = union(enum) {
|
||||||
///
|
///
|
||||||
/// Valid actions are:
|
/// Valid actions are:
|
||||||
///
|
///
|
||||||
|
/// - `copy`
|
||||||
|
///
|
||||||
|
/// Copy the file path into the clipboard.
|
||||||
|
///
|
||||||
/// - `paste`
|
/// - `paste`
|
||||||
///
|
///
|
||||||
/// Paste the file path into the terminal.
|
/// Paste the file path into the terminal.
|
||||||
|
|
@ -813,6 +817,7 @@ pub const Action = union(enum) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const WriteScreenAction = enum {
|
pub const WriteScreenAction = enum {
|
||||||
|
copy,
|
||||||
paste,
|
paste,
|
||||||
open,
|
open,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,11 @@ fn actionCommands(action: Action.Key) []const Command {
|
||||||
}},
|
}},
|
||||||
|
|
||||||
.write_screen_file => comptime &.{
|
.write_screen_file => comptime &.{
|
||||||
|
.{
|
||||||
|
.action = .{ .write_screen_file = .copy },
|
||||||
|
.title = "Copy Screen to Temporary File and Copy Path",
|
||||||
|
.description = "Copy the screen contents to a temporary file and copy the path to the clipboard.",
|
||||||
|
},
|
||||||
.{
|
.{
|
||||||
.action = .{ .write_screen_file = .paste },
|
.action = .{ .write_screen_file = .paste },
|
||||||
.title = "Copy Screen to Temporary File and Paste Path",
|
.title = "Copy Screen to Temporary File and Paste Path",
|
||||||
|
|
@ -217,6 +222,11 @@ fn actionCommands(action: Action.Key) []const Command {
|
||||||
},
|
},
|
||||||
|
|
||||||
.write_selection_file => comptime &.{
|
.write_selection_file => comptime &.{
|
||||||
|
.{
|
||||||
|
.action = .{ .write_selection_file = .copy },
|
||||||
|
.title = "Copy Selection to Temporary File and Copy Path",
|
||||||
|
.description = "Copy the selection contents to a temporary file and copy the path to the clipboard.",
|
||||||
|
},
|
||||||
.{
|
.{
|
||||||
.action = .{ .write_selection_file = .paste },
|
.action = .{ .write_selection_file = .paste },
|
||||||
.title = "Copy Selection to Temporary File and Paste Path",
|
.title = "Copy Selection to Temporary File and Paste Path",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue