Skip to content

Commit 68e356e

Browse files
authored
chore: maintain alacritty_terminal independently (#40)
1 parent fd1e638 commit 68e356e

File tree

208 files changed

+17907
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+17907
-6
lines changed

Cargo.toml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[workspace]
22
resolver = "2"
33
members = [
4+
"crates/alacritty_terminal",
45
"crates/egui-term",
56
"crates/egui-toast",
67
"nxshell",
@@ -18,8 +19,9 @@ categories = ["terminal", "egui"]
1819
keywords = ["terminal", "egui"]
1920

2021
[workspace.dependencies]
21-
alacritty_terminal = { git = "https://github.com/alacritty/alacritty" }
2222
anyhow = "1"
23+
base64 = "0.22"
24+
bitflags = "2"
2325
catppuccin-egui = { version = "5.6", default-features = false }
2426
chrono = "0.4"
2527
copypasta = "0.10"
@@ -31,21 +33,34 @@ egui_form = "0.6"
3133
egui-phosphor = "0.10"
3234
egui-theme-switch = "0.4"
3335
garde = "0.22"
36+
home = "0.5"
3437
homedir = "0.3"
3538
indexmap = "2"
39+
libc = "0.2"
40+
log = "0.4"
41+
miow = "0.6"
3642
open = "5"
3743
orion = "0.17"
3844
parking_lot = "0.12"
45+
piper = "0.2"
3946
polling = "3"
47+
regex = "1"
48+
regex-automata = "0.4"
4049
rusqlite = "0.33"
41-
rustix = "0.38"
50+
rustix = { version = "1", default-features = false }
51+
rustix-openpty = "0.2"
52+
serde = "1"
53+
serde_json = "1"
4254
signal-hook = "0.3"
4355
smol = "2"
4456
thiserror = "2"
4557
tracing = "0.1"
4658
tracing-subscriber = "0.3"
59+
unicode-width = "0.2"
60+
vte = { version = "0.15", default-features = false }
4761
wezterm-ssh = { git = "https://github.com/iamazy/wezterm.git", branch = "nxssh" }
4862
windows = "0.59"
63+
windows-sys = "0.59"
4964
wgpu = "25"
5065

5166
[profile.release]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[package]
2+
name = "alacritty_terminal"
3+
authors = ["Christian Duerr <[email protected]>", "Joe Wilm <[email protected]>"]
4+
edition.workspace = true
5+
version.workspace = true
6+
license.workspace = true
7+
documentation.workspace = true
8+
homepage.workspace = true
9+
repository.workspace = true
10+
categories.workspace = true
11+
keywords.workspace = true
12+
13+
[features]
14+
default = ["serde"]
15+
serde = ["dep:serde", "bitflags/serde", "vte/serde"]
16+
17+
[dependencies]
18+
base64.workspace = true
19+
bitflags.workspace = true
20+
home.workspace = true
21+
libc.workspace = true
22+
log.workspace = true
23+
parking_lot.workspace = true
24+
polling.workspace = true
25+
regex-automata.workspace = true
26+
unicode-width.workspace = true
27+
vte = { workspace = true, features = ["std", "ansi"] }
28+
serde = { workspace = true, features = ["derive", "rc"], optional = true }
29+
30+
[target.'cfg(unix)'.dependencies]
31+
rustix-openpty.workspace = true
32+
rustix = { workspace = true, features = ["std"] }
33+
signal-hook.workspace = true
34+
35+
[target.'cfg(windows)'.dependencies]
36+
piper.workspace = true
37+
miow.workspace = true
38+
windows-sys = { workspace = true, features = [
39+
"Win32_System_Console",
40+
"Win32_Foundation",
41+
"Win32_Security",
42+
"Win32_System_LibraryLoader",
43+
"Win32_System_Threading",
44+
"Win32_System_WindowsProgramming",
45+
] }
46+
47+
[dev-dependencies]
48+
serde_json.workspace = true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# alacritty_terminal
2+
3+
fork from [alacritty](https://github.com/alacritty/alacritty)
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
use std::borrow::Cow;
2+
use std::fmt::{self, Debug, Formatter};
3+
use std::sync::Arc;
4+
5+
use crate::term::ClipboardType;
6+
use crate::vte::ansi::Rgb;
7+
8+
/// Terminal event.
9+
///
10+
/// These events instruct the UI over changes that can't be handled by the terminal emulation layer
11+
/// itself.
12+
#[derive(Clone)]
13+
pub enum Event {
14+
/// Grid has changed possibly requiring a mouse cursor shape change.
15+
MouseCursorDirty,
16+
17+
/// Window title change.
18+
Title(String),
19+
20+
/// Reset to the default window title.
21+
ResetTitle,
22+
23+
/// Request to store a text string in the clipboard.
24+
ClipboardStore(ClipboardType, String),
25+
26+
/// Request to write the contents of the clipboard to the PTY.
27+
///
28+
/// The attached function is a formatter which will correctly transform the clipboard content
29+
/// into the expected escape sequence format.
30+
ClipboardLoad(
31+
ClipboardType,
32+
Arc<dyn Fn(&str) -> String + Sync + Send + 'static>,
33+
),
34+
35+
/// Request to write the RGB value of a color to the PTY.
36+
///
37+
/// The attached function is a formatter which will correctly transform the RGB color into the
38+
/// expected escape sequence format.
39+
ColorRequest(usize, Arc<dyn Fn(Rgb) -> String + Sync + Send + 'static>),
40+
41+
/// Write some text to the PTY.
42+
PtyWrite(String),
43+
44+
/// Request to write the text area size.
45+
TextAreaSizeRequest(Arc<dyn Fn(WindowSize) -> String + Sync + Send + 'static>),
46+
47+
/// Cursor blinking state has changed.
48+
CursorBlinkingChange,
49+
50+
/// New terminal content available.
51+
Wakeup,
52+
53+
/// Terminal bell ring.
54+
Bell,
55+
56+
/// Shutdown request.
57+
Exit,
58+
59+
/// Child process exited with an error code.
60+
ChildExit(i32),
61+
}
62+
63+
impl Debug for Event {
64+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
65+
match self {
66+
Event::ClipboardStore(ty, text) => write!(f, "ClipboardStore({ty:?}, {text})"),
67+
Event::ClipboardLoad(ty, _) => write!(f, "ClipboardLoad({ty:?})"),
68+
Event::TextAreaSizeRequest(_) => write!(f, "TextAreaSizeRequest"),
69+
Event::ColorRequest(index, _) => write!(f, "ColorRequest({index})"),
70+
Event::PtyWrite(text) => write!(f, "PtyWrite({text})"),
71+
Event::Title(title) => write!(f, "Title({title})"),
72+
Event::CursorBlinkingChange => write!(f, "CursorBlinkingChange"),
73+
Event::MouseCursorDirty => write!(f, "MouseCursorDirty"),
74+
Event::ResetTitle => write!(f, "ResetTitle"),
75+
Event::Wakeup => write!(f, "Wakeup"),
76+
Event::Bell => write!(f, "Bell"),
77+
Event::Exit => write!(f, "Exit"),
78+
Event::ChildExit(code) => write!(f, "ChildExit({code})"),
79+
}
80+
}
81+
}
82+
83+
/// Byte sequences are sent to a `Notify` in response to some events.
84+
pub trait Notify {
85+
/// Notify that an escape sequence should be written to the PTY.
86+
///
87+
/// TODO this needs to be able to error somehow.
88+
fn notify<B: Into<Cow<'static, [u8]>>>(&self, _: B);
89+
}
90+
91+
#[derive(Copy, Clone, Debug)]
92+
pub struct WindowSize {
93+
pub num_lines: u16,
94+
pub num_cols: u16,
95+
pub cell_width: u16,
96+
pub cell_height: u16,
97+
}
98+
99+
/// Types that are interested in when the display is resized.
100+
pub trait OnResize {
101+
fn on_resize(&mut self, window_size: WindowSize);
102+
}
103+
104+
/// Event Loop for notifying the renderer about terminal events.
105+
pub trait EventListener {
106+
fn send_event(&self, _event: Event) {}
107+
}
108+
109+
/// Null sink for events.
110+
pub struct VoidListener;
111+
112+
impl EventListener for VoidListener {}

0 commit comments

Comments
 (0)