Skip to content

Commit

Permalink
OSC 52
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas committed Jun 29, 2021
1 parent 82fc28a commit f5cc704
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ app = true

[features]
embed_runtime = ["helix-core/embed_runtime"]
osc52 = ["base64"]

[[bin]]
name = "hx"
Expand Down Expand Up @@ -54,3 +55,5 @@ toml = "0.5"

serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }

base64 = "0.13.0"
12 changes: 10 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use std::{

use once_cell::sync::Lazy;
use serde::de::{self, Deserialize, Deserializer};
extern crate base64;

pub struct Context<'a> {
pub selected_register: helix_view::RegisterSelection,
Expand Down Expand Up @@ -2657,7 +2658,10 @@ fn yank_joined_to_clipboard_impl(editor: &mut Editor, separator: &str) {
);

let joined = values.join(separator);

#[cfg(feature = "osc52")]
{
print!("\x1B]52;c;{}\x07", base64::encode(joined.clone().as_bytes()));
}
if let Err(e) = editor.clipboard_provider.set_contents(joined) {
log::error!("Couldn't set system clipboard content: {:?}", e);
}
Expand All @@ -2677,11 +2681,15 @@ fn yank_main_selection_to_clipboard_impl(editor: &mut Editor) {
.selection(view.id)
.primary()
.fragment(doc.text().slice(..));

#[cfg(feature = "osc52")]
{
print!("\x1B]52;c;{}\x07", base64::encode(value.clone().as_bytes()));
}
if let Err(e) = editor.clipboard_provider.set_contents(value.into_owned()) {
log::error!("Couldn't set system clipboard content: {:?}", e);
}


editor.set_status("yanked main selection to system clipboard".to_owned());
}

Expand Down

0 comments on commit f5cc704

Please sign in to comment.