aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/term/mod.rs
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2023-07-22 18:31:35 +0000
committerGitHub <noreply@github.com>2023-07-22 18:31:35 +0000
commit0c94e4ae7b413a8ae4e37882f0d483d2e259bd44 (patch)
treee689b92d23d0b61b6c83d00d329581d51ecd296a /alacritty_terminal/src/term/mod.rs
parentf2e543880f75f92421e34a186ea44d8f32cbd52a (diff)
downloadr-alacritty-0c94e4ae7b413a8ae4e37882f0d483d2e259bd44.tar.gz
r-alacritty-0c94e4ae7b413a8ae4e37882f0d483d2e259bd44.tar.bz2
r-alacritty-0c94e4ae7b413a8ae4e37882f0d483d2e259bd44.zip
Add `terminal` config section to control OSCs
Some environments demand certain OSC sequences to be disabled or some escape sequence could require handling which is out of scope of alacritty, but could be done by external script (OSC 777). Added section for now just handles the `OSC 52` sequence and changes its default to be `OnlyCopy`, which is handy for remote copy, but `Paste` is redundant because normal `Paste` hotkey could be used as well. Fixes #3386. Co-authored-by: Christian Duerr <contact@christianduerr.com>
Diffstat (limited to 'alacritty_terminal/src/term/mod.rs')
-rw-r--r--alacritty_terminal/src/term/mod.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 7c4abb57..2e66b402 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -12,7 +12,7 @@ use vte::ansi::{Hyperlink as VteHyperlink, Rgb as VteRgb};
use crate::ansi::{
self, Attr, CharsetIndex, Color, CursorShape, CursorStyle, Handler, NamedColor, StandardCharset,
};
-use crate::config::Config;
+use crate::config::{Config, Osc52, Terminal};
use crate::event::{Event, EventListener};
use crate::grid::{Dimensions, Grid, GridIterator, Scroll};
use crate::index::{self, Boundary, Column, Direction, Line, Point, Side};
@@ -304,6 +304,9 @@ pub struct Term<T> {
/// Information about damaged cells.
damage: TermDamageState,
+
+ /// Config directly for the terminal.
+ config: Terminal,
}
impl<T> Term<T> {
@@ -363,6 +366,7 @@ impl<T> Term<T> {
title_stack: Vec::new(),
selection: None,
damage,
+ config: config.terminal.clone(),
}
}
@@ -461,6 +465,8 @@ impl<T> Term<T> {
self.grid.update_history(config.scrolling.history() as usize);
}
+ self.config = config.terminal.clone();
+
// Damage everything on config updates.
self.mark_fully_damaged();
}
@@ -1539,6 +1545,11 @@ impl<T: EventListener> Handler for Term<T> {
/// Store data into clipboard.
#[inline]
fn clipboard_store(&mut self, clipboard: u8, base64: &[u8]) {
+ if !matches!(self.config.osc52, Osc52::OnlyCopy | Osc52::CopyPaste) {
+ debug!("Denied osc52 store");
+ return;
+ }
+
let clipboard_type = match clipboard {
b'c' => ClipboardType::Clipboard,
b'p' | b's' => ClipboardType::Selection,
@@ -1555,6 +1566,11 @@ impl<T: EventListener> Handler for Term<T> {
/// Load data from clipboard.
#[inline]
fn clipboard_load(&mut self, clipboard: u8, terminator: &str) {
+ if !matches!(self.config.osc52, Osc52::OnlyPaste | Osc52::CopyPaste) {
+ debug!("Denied osc52 load");
+ return;
+ }
+
let clipboard_type = match clipboard {
b'c' => ClipboardType::Clipboard,
b'p' | b's' => ClipboardType::Selection,