Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
resolver = "2"
members = [
"crates/alacritty_terminal",
"crates/egui-term",
"crates/egui-toast",
"nxshell",
Expand All @@ -18,8 +19,9 @@ categories = ["terminal", "egui"]
keywords = ["terminal", "egui"]

[workspace.dependencies]
alacritty_terminal = { git = "https://github.com/alacritty/alacritty" }
anyhow = "1"
base64 = "0.22"
bitflags = "2"
catppuccin-egui = { version = "5.6", default-features = false }
chrono = "0.4"
copypasta = "0.10"
Expand All @@ -31,21 +33,34 @@ egui_form = "0.6"
egui-phosphor = "0.10"
egui-theme-switch = "0.4"
garde = "0.22"
home = "0.5"
homedir = "0.3"
indexmap = "2"
libc = "0.2"
log = "0.4"
miow = "0.6"
open = "5"
orion = "0.17"
parking_lot = "0.12"
piper = "0.2"
polling = "3"
regex = "1"
regex-automata = "0.4"
rusqlite = "0.33"
rustix = "0.38"
rustix = { version = "1", default-features = false }
rustix-openpty = "0.2"
serde = "1"
serde_json = "1"
signal-hook = "0.3"
smol = "2"
thiserror = "2"
tracing = "0.1"
tracing-subscriber = "0.3"
unicode-width = "0.2"
vte = { version = "0.15", default-features = false }
wezterm-ssh = { git = "https://github.com/iamazy/wezterm.git", branch = "nxssh" }
windows = "0.59"
windows-sys = "0.59"
wgpu = "25"

[profile.release]
Expand Down
48 changes: 48 additions & 0 deletions crates/alacritty_terminal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[package]
name = "alacritty_terminal"
authors = ["Christian Duerr <[email protected]>", "Joe Wilm <[email protected]>"]
edition.workspace = true
version.workspace = true
license.workspace = true
documentation.workspace = true
homepage.workspace = true
repository.workspace = true
categories.workspace = true
keywords.workspace = true

[features]
default = ["serde"]
serde = ["dep:serde", "bitflags/serde", "vte/serde"]

[dependencies]
base64.workspace = true
bitflags.workspace = true
home.workspace = true
libc.workspace = true
log.workspace = true
parking_lot.workspace = true
polling.workspace = true
regex-automata.workspace = true
unicode-width.workspace = true
vte = { workspace = true, features = ["std", "ansi"] }
serde = { workspace = true, features = ["derive", "rc"], optional = true }

[target.'cfg(unix)'.dependencies]
rustix-openpty.workspace = true
rustix = { workspace = true, features = ["std"] }
signal-hook.workspace = true

[target.'cfg(windows)'.dependencies]
piper.workspace = true
miow.workspace = true
windows-sys = { workspace = true, features = [
"Win32_System_Console",
"Win32_Foundation",
"Win32_Security",
"Win32_System_LibraryLoader",
"Win32_System_Threading",
"Win32_System_WindowsProgramming",
] }

[dev-dependencies]
serde_json.workspace = true
3 changes: 3 additions & 0 deletions crates/alacritty_terminal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# alacritty_terminal

fork from [alacritty](https://github.com/alacritty/alacritty)
112 changes: 112 additions & 0 deletions crates/alacritty_terminal/src/event.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
use std::borrow::Cow;
use std::fmt::{self, Debug, Formatter};
use std::sync::Arc;

use crate::term::ClipboardType;
use crate::vte::ansi::Rgb;

/// 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 correctly 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 correctly transform the RGB color into the
/// expected escape sequence format.
ColorRequest(usize, Arc<dyn Fn(Rgb) -> String + Sync + Send + 'static>),

/// Write some text to the PTY.
PtyWrite(String),

/// Request to write the text area size.
TextAreaSizeRequest(Arc<dyn Fn(WindowSize) -> String + Sync + Send + 'static>),

/// Cursor blinking state has changed.
CursorBlinkingChange,

/// New terminal content available.
Wakeup,

/// Terminal bell ring.
Bell,

/// Shutdown request.
Exit,

/// Child process exited with an error code.
ChildExit(i32),
}

impl Debug for Event {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Event::ClipboardStore(ty, text) => write!(f, "ClipboardStore({ty:?}, {text})"),
Event::ClipboardLoad(ty, _) => write!(f, "ClipboardLoad({ty:?})"),
Event::TextAreaSizeRequest(_) => write!(f, "TextAreaSizeRequest"),
Event::ColorRequest(index, _) => write!(f, "ColorRequest({index})"),
Event::PtyWrite(text) => write!(f, "PtyWrite({text})"),
Event::Title(title) => write!(f, "Title({title})"),
Event::CursorBlinkingChange => write!(f, "CursorBlinkingChange"),
Event::MouseCursorDirty => write!(f, "MouseCursorDirty"),
Event::ResetTitle => write!(f, "ResetTitle"),
Event::Wakeup => write!(f, "Wakeup"),
Event::Bell => write!(f, "Bell"),
Event::Exit => write!(f, "Exit"),
Event::ChildExit(code) => write!(f, "ChildExit({code})"),
}
}
}

/// Byte sequences are sent to a `Notify` in response to some events.
pub trait Notify {
/// Notify that an escape sequence should be written to the PTY.
///
/// TODO this needs to be able to error somehow.
fn notify<B: Into<Cow<'static, [u8]>>>(&self, _: B);
}

#[derive(Copy, Clone, Debug)]
pub struct WindowSize {
pub num_lines: u16,
pub num_cols: u16,
pub cell_width: u16,
pub cell_height: u16,
}

/// Types that are interested in when the display is resized.
pub trait OnResize {
fn on_resize(&mut self, window_size: WindowSize);
}

/// Event Loop for notifying the renderer about terminal events.
pub trait EventListener {
fn send_event(&self, _event: Event) {}
}

/// Null sink for events.
pub struct VoidListener;

impl EventListener for VoidListener {}
Loading
Loading