Skip to content

Commit

Permalink
Implement OSC 52 escape code events
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Mar 13, 2024
1 parent 032804f commit e24826e
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright 2023 System76 <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only

use alacritty_terminal::{
event::Event as TermEvent, term::color::Colors as TermColors, term::Config as TermConfig, tty,
};
use alacritty_terminal::{event::Event as TermEvent, term, term::color::Colors as TermColors, tty};
use cosmic::{
app::{message, Command, Core, Settings},
cosmic_config::{self, ConfigSet, CosmicConfigEntry},
Expand Down Expand Up @@ -133,7 +131,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
None
};

let term_config = TermConfig::default();
let term_config = term::Config::default();
// Set up environmental variables for terminal
tty::setup_env();
// Override TERM for better compatibility
Expand Down Expand Up @@ -166,7 +164,7 @@ pub struct Flags {
config_handler: Option<cosmic_config::Config>,
config: Config,
startup_options: Option<tty::Options>,
term_config: TermConfig,
term_config: term::Config,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
Expand Down Expand Up @@ -379,7 +377,7 @@ pub struct App {
find_search_value: String,
term_event_tx_opt: Option<mpsc::Sender<(pane_grid::Pane, segmented_button::Entity, TermEvent)>>,
startup_options: Option<tty::Options>,
term_config: TermConfig,
term_config: term::Config,
color_scheme_errors: Vec<String>,
color_scheme_expanded: Option<(ColorSchemeKind, ColorSchemeId)>,
color_scheme_renaming: Option<(ColorSchemeKind, ColorSchemeId, String)>,
Expand Down Expand Up @@ -2136,6 +2134,31 @@ impl Application for App {
TermEvent::Bell => {
//TODO: audible or visible bell options?
}
TermEvent::ClipboardLoad(kind, callback) => {
match kind {
term::ClipboardType::Clipboard => {
log::info!("clipboard load");
return clipboard::read(move |data_opt| {
//TODO: what to do when data_opt is None?
callback(&data_opt.unwrap_or_default());
// We don't need to do anything else
message::none()
});
}
term::ClipboardType::Selection => {
log::info!("TODO: load selection");
}
}
}
TermEvent::ClipboardStore(kind, data) => match kind {
term::ClipboardType::Clipboard => {
log::info!("clipboard store");
return clipboard::write(data);
}
term::ClipboardType::Selection => {
log::info!("TODO: store selection");
}
},
TermEvent::ColorRequest(index, f) => {
if let Some(tab_model) = self.pane_model.panes.get(pane) {
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
Expand All @@ -2146,6 +2169,9 @@ impl Application for App {
}
}
}
TermEvent::CursorBlinkingChange => {
//TODO: should we blink the cursor?
}
TermEvent::Exit => {
return self.update(Message::TabClose(Some(entity)));
}
Expand Down Expand Up @@ -2205,9 +2231,6 @@ impl Application for App {
}
}
}
_ => {
log::warn!("TODO: {:?}", event);
}
}
}
Message::TermEventTx(term_event_tx) => {
Expand Down

0 comments on commit e24826e

Please sign in to comment.