aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/event.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2021-01-24 21:45:36 +0000
committerGitHub <noreply@github.com>2021-01-24 21:45:36 +0000
commit530de00049c2afcc562d36ccdb3e6afa2fe396a5 (patch)
tree3dabbcef3fc4a2041f9027d82243aa0d70928153 /alacritty_terminal/src/event.rs
parent7291702f6b4fff10f2470f084abe0785b95659a0 (diff)
downloadalacritty-530de00049c2afcc562d36ccdb3e6afa2fe396a5.tar.gz
alacritty-530de00049c2afcc562d36ccdb3e6afa2fe396a5.zip
Move renderable cell transformation to alacritty
This refactors a large chunk of the alacritty_terminal API to expose all data necessary for rendering uniformly through the `renderable_content` call. This also no longer transforms the cells for rendering by a GUI but instead just reports the content from a terminal emulation perspective. The transformation into renderable cells is now done inside the alacritty crate. Since the terminal itself only ever needs to know about modified color RGB values, the configuration for colors was moved to the alacritty UI code.
Diffstat (limited to 'alacritty_terminal/src/event.rs')
-rw-r--r--alacritty_terminal/src/event.rs38
1 files changed, 37 insertions, 1 deletions
diff --git a/alacritty_terminal/src/event.rs b/alacritty_terminal/src/event.rs
index 351b7bc2..a1252570 100644
--- a/alacritty_terminal/src/event.rs
+++ b/alacritty_terminal/src/event.rs
@@ -2,18 +2,49 @@ use std::borrow::Cow;
use std::fmt::{self, Debug, Formatter};
use std::sync::Arc;
+use crate::term::color::Rgb;
use crate::term::{ClipboardType, SizeInfo};
+/// Terminal event.
+///
+/// These events instruct the UI over changes that can't be handled by the terminal emulation layer
+/// itself.
#[derive(Clone)]
pub enum Event {
+ /// Grid has changed possibly requiring a mouse cursor shape change.
MouseCursorDirty,
+
+ /// Window title change.
Title(String),
+
+ /// Reset to the default window title.
ResetTitle,
+
+ /// Request to store a text string in the clipboard.
ClipboardStore(ClipboardType, String),
+
+ /// Request to write the contents of the clipboard to the PTY.
+ ///
+ /// The attached function is a formatter which will corectly transform the clipboard content
+ /// into the expected escape sequence format.
ClipboardLoad(ClipboardType, Arc<dyn Fn(&str) -> String + Sync + Send + 'static>),
+
+ /// Request to write the RGB value of a color to the PTY.
+ ///
+ /// The attached function is a formatter which will corectly transform the RGB color into the
+ /// expected escape sequence format.
+ ColorRequest(usize, Arc<dyn Fn(Rgb) -> String + Sync + Send + 'static>),
+
+ /// Cursor blinking state has changed.
CursorBlinkingChange(bool),
+
+ /// New terminal content available.
Wakeup,
+
+ /// Terminal bell ring.
Bell,
+
+ /// Shutdown request.
Exit,
}
@@ -25,6 +56,7 @@ impl Debug for Event {
Event::ResetTitle => write!(f, "ResetTitle"),
Event::ClipboardStore(ty, text) => write!(f, "ClipboardStore({:?}, {})", ty, text),
Event::ClipboardLoad(ty, _) => write!(f, "ClipboardLoad({:?})", ty),
+ Event::ColorRequest(index, _) => write!(f, "ColorRequest({})", index),
Event::Wakeup => write!(f, "Wakeup"),
Event::Bell => write!(f, "Bell"),
Event::Exit => write!(f, "Exit"),
@@ -48,5 +80,9 @@ pub trait OnResize {
/// Event Loop for notifying the renderer about terminal events.
pub trait EventListener {
- fn send_event(&self, event: Event);
+ fn send_event(&self, _event: Event) {}
}
+
+/// Placeholder implementation for tests.
+#[cfg(test)]
+impl EventListener for () {}