1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 05:12:40 +03:00

move mux to its own crate

This commit is contained in:
Wez Furlong 2020-10-02 17:42:49 -07:00
parent 9a48f7f536
commit a511abb1c2
34 changed files with 152 additions and 106 deletions

24
Cargo.lock generated
View File

@ -2044,6 +2044,28 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "mux"
version = "0.1.0"
dependencies = [
"anyhow",
"async-trait",
"bintree",
"config",
"downcast-rs",
"log",
"portable-pty",
"promise",
"rangeset",
"ratelim",
"regex",
"serde",
"termwiz",
"thiserror",
"url",
"wezterm-term",
]
[[package]]
name = "nb-connect"
version = "1.0.1"
@ -4070,7 +4092,6 @@ dependencies = [
"async-trait",
"base64 0.10.1",
"base91",
"bintree",
"bitflags 1.2.1",
"bstr 0.2.13",
"cc",
@ -4105,6 +4126,7 @@ dependencies = [
"luahelper",
"metrics",
"mlua",
"mux",
"notify-rust",
"objc",
"open",

View File

@ -22,7 +22,6 @@ allsorts = "0.4"
async-task = "1.2"
async-trait = "0.1"
anyhow = "1.0"
bintree = { path = "bintree" }
thiserror = "1.0"
base64 = "0.10"
base91 = { path = "base91" }
@ -47,6 +46,7 @@ libc = "0.2"
log = "0.4"
lru = "0.5"
luahelper = { path = "luahelper" }
mux = { path = "mux" }
open = "1.2"
pulldown-cmark = "0.7"
metrics = { version="0.12", features=["std"]}

25
mux/Cargo.toml Normal file
View File

@ -0,0 +1,25 @@
[package]
name = "mux"
version = "0.1.0"
authors = ["Wez Furlong <wez@wezfurlong.org>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0"
async-trait = "0.1"
bintree = { path = "../bintree" }
config = { path = "../config" }
downcast-rs = "1.0"
log = "0.4"
portable-pty = { path = "../pty", features = ["serde_support"]}
promise = { path = "../promise" }
rangeset = { path = "../rangeset" }
ratelim= { path = "../ratelim" }
regex = "1"
serde = {version="1.0", features = ["rc", "derive"]}
termwiz = { path = "../termwiz" }
thiserror = "1.0"
url = "2"
wezterm-term = { path = "../term", features=["use_serde"] }

View File

@ -5,11 +5,11 @@
//! container or actually remote, running on the other end
//! of an ssh session somewhere.
use crate::mux::localtab::LocalPane;
use crate::mux::pane::{alloc_pane_id, Pane, PaneId};
use crate::mux::tab::{SplitDirection, Tab, TabId};
use crate::mux::window::WindowId;
use crate::mux::Mux;
use crate::localtab::LocalPane;
use crate::pane::{alloc_pane_id, Pane, PaneId};
use crate::tab::{SplitDirection, Tab, TabId};
use crate::window::WindowId;
use crate::Mux;
use anyhow::{bail, Error};
use async_trait::async_trait;
use config::configuration;
@ -146,7 +146,7 @@ impl Domain for LocalDomain {
size.pixel_height as usize,
std::sync::Arc::new(config::TermConfig {}),
"WezTerm",
crate::wezterm_version(),
config::wezterm_version(),
Box::new(writer),
);
@ -228,7 +228,7 @@ impl Domain for LocalDomain {
split_size.second.pixel_height as usize,
std::sync::Arc::new(config::TermConfig {}),
"WezTerm",
crate::wezterm_version(),
config::wezterm_version(),
Box::new(writer),
);

View File

@ -1,6 +1,6 @@
use crate::mux::pane::{Pane, PaneId};
use crate::mux::tab::{Tab, TabId};
use crate::mux::window::{Window, WindowId};
use crate::pane::{Pane, PaneId};
use crate::tab::{Tab, TabId};
use crate::window::{Window, WindowId};
use anyhow::{anyhow, Error};
use domain::{Domain, DomainId};
use log::error;

View File

@ -1,6 +1,6 @@
use crate::mux::domain::DomainId;
use crate::mux::pane::{Pane, PaneId, Pattern, SearchResult};
use crate::mux::renderable::Renderable;
use crate::domain::DomainId;
use crate::pane::{Pane, PaneId, Pattern, SearchResult};
use crate::renderable::Renderable;
use anyhow::Error;
use async_trait::async_trait;
use portable_pty::{Child, MasterPty, PtySize};

View File

@ -1,6 +1,6 @@
use crate::mux::domain::DomainId;
use crate::mux::renderable::Renderable;
use crate::mux::Mux;
use crate::domain::DomainId;
use crate::renderable::Renderable;
use crate::Mux;
use async_trait::async_trait;
use downcast_rs::{impl_downcast, Downcast};
use portable_pty::PtySize;

View File

@ -1,6 +1,6 @@
use crate::mux::domain::DomainId;
use crate::mux::pane::*;
use crate::mux::{Mux, WindowId};
use crate::domain::DomainId;
use crate::pane::*;
use crate::{Mux, WindowId};
use bintree::PathBranch;
use config::keyassignment::PaneDirection;
use portable_pty::PtySize;
@ -1458,7 +1458,7 @@ impl Into<String> for SerdeUrl {
#[cfg(test)]
mod test {
use super::*;
use crate::mux::renderable::Renderable;
use crate::renderable::Renderable;
use url::Url;
use wezterm_term::color::ColorPalette;
use wezterm_term::{KeyCode, KeyModifiers, MouseEvent};

View File

@ -1,4 +1,4 @@
use crate::mux::{Tab, TabId};
use crate::{Tab, TabId};
use std::rc::Rc;
use std::sync::Arc;
use wezterm_term::Clipboard;

View File

@ -1,10 +1,10 @@
use crate::font::FontConfiguration;
use crate::frontend::FrontEnd;
use crate::mux::tab::Tab;
use crate::mux::window::WindowId as MuxWindowId;
use crate::mux::Mux;
use ::window::*;
use config::configuration;
use mux::tab::Tab;
use mux::window::WindowId as MuxWindowId;
use mux::Mux;
use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};

View File

@ -1,8 +1,8 @@
use crate::mux::pane::PaneId;
use crate::mux::tab::TabId;
use crate::mux::window::WindowId;
use crate::mux::Mux;
use crate::termwiztermtab::TermWizTerminal;
use mux::pane::PaneId;
use mux::tab::TabId;
use mux::window::WindowId;
use mux::Mux;
use termwiz::color::ColorAttribute;
use termwiz::input::{InputEvent, KeyCode, KeyEvent};
use termwiz::surface::{Change, Position};

View File

@ -1,8 +1,8 @@
use crate::frontend::gui::selection::{SelectionCoordinate, SelectionRange};
use crate::frontend::gui::termwindow::TermWindow;
use crate::mux::domain::DomainId;
use crate::mux::pane::{Pane, PaneId};
use crate::mux::renderable::*;
use mux::domain::DomainId;
use mux::pane::{Pane, PaneId};
use mux::renderable::*;
use portable_pty::PtySize;
use rangeset::RangeSet;
use std::cell::{RefCell, RefMut};

View File

@ -6,14 +6,14 @@
//! time of writing our window layer doesn't provide an API for context
//! menus.
use crate::frontend::gui::termwindow::{ClipboardHelper, SpawnWhere, TermWindow};
use crate::mux::domain::{DomainId, DomainState};
use crate::mux::tab::TabId;
use crate::mux::window::WindowId;
use crate::mux::Mux;
use crate::termwiztermtab::TermWizTerminal;
use anyhow::anyhow;
use config::configuration;
use config::keyassignment::{SpawnCommand, SpawnTabDomain};
use mux::domain::{DomainId, DomainState};
use mux::tab::TabId;
use mux::window::WindowId;
use mux::Mux;
use portable_pty::PtySize;
use termwiz::cell::{AttributeChange, CellAttributes};
use termwiz::color::ColorAttribute;

View File

@ -1,7 +1,7 @@
use crate::frontend::gui::termwindow::TermWindow;
use crate::mux::pane::{Pane, PaneId};
use crate::mux::tab::{Tab, TabId};
use crate::termwiztermtab::{allocate, TermWizTerminal};
use mux::pane::{Pane, PaneId};
use mux::tab::{Tab, TabId};
use std::pin::Pin;
use std::rc::Rc;

View File

@ -1,8 +1,8 @@
use crate::frontend::gui::selection::{SelectionCoordinate, SelectionRange};
use crate::frontend::gui::termwindow::TermWindow;
use crate::mux::domain::DomainId;
use crate::mux::pane::{Pane, PaneId, Pattern, SearchResult};
use crate::mux::renderable::*;
use mux::domain::DomainId;
use mux::pane::{Pane, PaneId, Pattern, SearchResult};
use mux::renderable::*;
use portable_pty::PtySize;
use rangeset::RangeSet;
use std::cell::{RefCell, RefMut};

View File

@ -1,8 +1,8 @@
use crate::mux::tab::TabId;
use crate::mux::window::WindowId;
use crate::mux::Mux;
use crate::termwiztermtab::TermWizTerminal;
use anyhow::anyhow;
use mux::tab::TabId;
use mux::window::WindowId;
use mux::Mux;
use termwiz::cell::{AttributeChange, CellAttributes};
use termwiz::color::ColorAttribute;
use termwiz::input::{InputEvent, KeyCode, KeyEvent, MouseButtons, MouseEvent};

View File

@ -1,5 +1,5 @@
use crate::mux::renderable::Renderable;
use ::window::*;
use mux::renderable::Renderable;
use portable_pty::PtySize;
use wezterm_term::StableRowIndex;

View File

@ -1,7 +1,7 @@
// The range_plus_one lint can't see when the LHS is not compatible with
// and inclusive range
#![cfg_attr(feature = "cargo-clippy", allow(clippy::range_plus_one))]
use crate::mux::renderable::Renderable;
use mux::renderable::Renderable;
use std::ops::Range;
use termwiz::surface::line::DoubleClickRange;
use wezterm_term::StableRowIndex;

View File

@ -1,5 +1,5 @@
use crate::mux::window::Window as MuxWindow;
use config::{ConfigHandle, TabBarColors};
use mux::window::Window as MuxWindow;
use std::cell::Ref;
use termwiz::cell::unicode_column_width;
use termwiz::cell::{Cell, CellAttributes};

View File

@ -14,12 +14,6 @@ use crate::frontend::gui::overlay::{
use crate::frontend::gui::scrollbar::*;
use crate::frontend::gui::selection::*;
use crate::frontend::gui::tabbar::{TabBarItem, TabBarState};
use crate::mux::domain::{DomainId, DomainState};
use crate::mux::pane::{Pane, PaneId};
use crate::mux::renderable::{RenderableDimensions, StableCursorPosition};
use crate::mux::tab::{PositionedPane, PositionedSplit, SplitDirection, Tab, TabId};
use crate::mux::window::WindowId as MuxWindowId;
use crate::mux::Mux;
use ::wezterm_term::input::MouseButton as TMB;
use ::wezterm_term::input::MouseEventKind as TMEK;
use ::window::bitmaps::atlas::{OutOfTextureSpace, SpriteSlice};
@ -37,6 +31,12 @@ use config::keyassignment::{
};
use config::{configuration, ConfigHandle, TextStyle};
use lru::LruCache;
use mux::domain::{DomainId, DomainState};
use mux::pane::{Pane, PaneId};
use mux::renderable::{RenderableDimensions, StableCursorPosition};
use mux::tab::{PositionedPane, PositionedSplit, SplitDirection, Tab, TabId};
use mux::window::WindowId as MuxWindowId;
use mux::Mux;
use portable_pty::{CommandBuilder, PtySize};
use std::any::Any;
use std::cell::{RefCell, RefMut};

View File

@ -1,8 +1,8 @@
use crate::font::FontConfiguration;
use crate::mux::tab::Tab;
use crate::mux::window::WindowId;
use anyhow::Error;
use downcast_rs::{impl_downcast, Downcast};
use mux::tab::Tab;
use mux::window::WindowId;
use std::cell::RefCell;
use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};

View File

@ -1,13 +1,13 @@
//! Implements the multiplexer server frontend
use crate::font::FontConfiguration;
use crate::frontend::FrontEnd;
use crate::mux::tab::Tab;
use crate::mux::window::WindowId;
use crate::mux::Mux;
use crate::server::listener::spawn_listener;
use anyhow::{bail, Error};
use crossbeam::channel::{unbounded as channel, Receiver};
use log::info;
use mux::tab::Tab;
use mux::window::WindowId;
use mux::Mux;
use promise::*;
use std::rc::Rc;

View File

@ -4,6 +4,10 @@
use crate::server::listener::umask;
use anyhow::{anyhow, bail};
use config::{wezterm_version, SshParameters};
use mux::domain::{Domain, LocalDomain};
use mux::pane::PaneId;
use mux::tab::SplitDirection;
use mux::Mux;
use promise::spawn::block_on;
use std::ffi::OsString;
use std::io::{Read, Write};
@ -20,7 +24,6 @@ mod connui;
mod frontend;
use config::keyassignment;
mod markdown;
mod mux;
mod server;
mod ssh;
mod stats;
@ -29,10 +32,6 @@ mod update;
use crate::frontend::activity::Activity;
use crate::frontend::{front_end, FrontEndSelection};
use crate::mux::domain::{Domain, LocalDomain};
use crate::mux::pane::PaneId;
use crate::mux::tab::SplitDirection;
use crate::mux::Mux;
use crate::server::client::{unix_connect_with_retry, Client};
use crate::server::domain::{ClientDomain, ClientDomainConfig};
use portable_pty::cmdbuilder::CommandBuilder;

View File

@ -1,7 +1,4 @@
use crate::connui::ConnectionUI;
use crate::mux::domain::{alloc_domain_id, DomainId};
use crate::mux::pane::PaneId;
use crate::mux::Mux;
use crate::server::codec::*;
use crate::server::domain::{ClientDomain, ClientDomainConfig};
use crate::server::pollable::*;
@ -13,6 +10,9 @@ use config::{configuration, SshDomain, TlsDomainClient, UnixDomain};
use crossbeam::channel::TryRecvError;
use filedescriptor::{poll, pollfd, AsRawSocketDescriptor};
use log::info;
use mux::domain::{alloc_domain_id, DomainId};
use mux::pane::PaneId;
use mux::Mux;
use openssl::ssl::{SslConnector, SslFiletype, SslMethod};
use openssl::x509::X509;
use portable_pty::{CommandBuilder, NativePtySystem, PtySystem};

View File

@ -11,14 +11,14 @@
#![allow(dead_code)]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::range_plus_one))]
use crate::mux::domain::DomainId;
use crate::mux::pane::PaneId;
use crate::mux::renderable::{RenderableDimensions, StableCursorPosition};
use crate::mux::tab::{PaneNode, SerdeUrl, SplitDirection, TabId};
use crate::mux::window::WindowId;
use anyhow::{bail, Context as _, Error};
use leb128;
use log::debug;
use mux::domain::DomainId;
use mux::pane::PaneId;
use mux::renderable::{RenderableDimensions, StableCursorPosition};
use mux::tab::{PaneNode, SerdeUrl, SplitDirection, TabId};
use mux::window::WindowId;
use portable_pty::{CommandBuilder, PtySize};
use rangeset::*;
use serde::{Deserialize, Serialize};
@ -683,12 +683,12 @@ pub struct GetLinesResponse {
#[derive(Deserialize, Serialize, PartialEq, Debug)]
pub struct SearchScrollbackRequest {
pub pane_id: PaneId,
pub pattern: crate::mux::pane::Pattern,
pub pattern: mux::pane::Pattern,
}
#[derive(Deserialize, Serialize, PartialEq, Debug)]
pub struct SearchScrollbackResponse {
pub results: Vec<crate::mux::pane::SearchResult>,
pub results: Vec<mux::pane::SearchResult>,
}
#[cfg(test)]

View File

@ -1,11 +1,6 @@
use crate::connui::ConnectionUI;
use crate::font::FontConfiguration;
use crate::frontend::front_end;
use crate::mux::domain::{alloc_domain_id, Domain, DomainId, DomainState};
use crate::mux::pane::{Pane, PaneId};
use crate::mux::tab::{SplitDirection, Tab, TabId};
use crate::mux::window::WindowId;
use crate::mux::Mux;
use crate::server::client::Client;
use crate::server::codec::{ListPanesResponse, Spawn, SplitPane};
use crate::server::tab::ClientPane;
@ -13,6 +8,11 @@ use anyhow::{anyhow, bail};
use async_trait::async_trait;
use config::keyassignment::SpawnTabDomain;
use config::{SshDomain, TlsDomainClient, UnixDomain};
use mux::domain::{alloc_domain_id, Domain, DomainId, DomainState};
use mux::pane::{Pane, PaneId};
use mux::tab::{SplitDirection, Tab, TabId};
use mux::window::WindowId;
use mux::Mux;
use portable_pty::{CommandBuilder, PtySize};
use promise::spawn::{join_handle_result, spawn_into_new_thread};
use std::cell::RefCell;

View File

@ -1,4 +1,3 @@
use crate::mux::{Mux, MuxNotification};
use crate::server::codec::*;
use crate::server::listener::sessionhandler::SessionHandler;
use crate::server::pollable::*;
@ -6,6 +5,7 @@ use anyhow::{bail, Context, Error};
use crossbeam::channel::TryRecvError;
use filedescriptor::poll;
use log::error;
use mux::{Mux, MuxNotification};
use std::collections::HashSet;
pub struct ClientSession<S: ReadAndWrite> {

View File

@ -1,12 +1,12 @@
use crate::mux::pane::{Pane, PaneId};
use crate::mux::renderable::{RenderableDimensions, StableCursorPosition};
use crate::mux::tab::TabId;
use crate::mux::Mux;
use crate::server::codec::*;
use crate::server::listener::PKI;
use crate::server::pollable::*;
use anyhow::anyhow;
use config::keyassignment::SpawnTabDomain;
use mux::pane::{Pane, PaneId};
use mux::renderable::{RenderableDimensions, StableCursorPosition};
use mux::tab::TabId;
use mux::Mux;
use portable_pty::PtySize;
use promise::spawn::spawn_into_main_thread;
use rangeset::RangeSet;
@ -253,7 +253,7 @@ impl SessionHandler {
}
Pdu::SearchScrollbackRequest(SearchScrollbackRequest { pane_id, pattern }) => {
use crate::mux::pane::Pattern;
use mux::pane::Pattern;
async fn do_search(pane_id: TabId, pattern: Pattern) -> anyhow::Result<Pdu> {
let mux = Mux::get().unwrap();

View File

@ -1,7 +1,3 @@
use crate::mux::domain::DomainId;
use crate::mux::pane::{alloc_pane_id, Pane, PaneId, Pattern, SearchResult};
use crate::mux::renderable::{Renderable, RenderableDimensions};
use crate::mux::tab::TabId;
use crate::server::codec::*;
use crate::server::domain::ClientInner;
use crate::server::tab::mousestate::MouseState;
@ -11,6 +7,10 @@ use async_trait::async_trait;
use config::configuration;
use filedescriptor::Pipe;
use log::info;
use mux::domain::DomainId;
use mux::pane::{alloc_pane_id, Pane, PaneId, Pattern, SearchResult};
use mux::renderable::{Renderable, RenderableDimensions};
use mux::tab::TabId;
use portable_pty::PtySize;
use ratelim::RateLimiter;
use std::cell::RefCell;

View File

@ -1,6 +1,6 @@
use crate::mux::tab::TabId;
use crate::server::client::Client;
use crate::server::codec::*;
use mux::tab::TabId;
use std::cell::RefCell;
use std::collections::VecDeque;
use std::rc::Rc;

View File

@ -1,12 +1,12 @@
use crate::mux::renderable::{Renderable, RenderableDimensions, StableCursorPosition};
use crate::mux::tab::TabId;
use crate::mux::Mux;
use crate::server::codec::*;
use crate::server::domain::ClientInner;
use crate::server::tab::clienttab::ClientPane;
use anyhow::anyhow;
use config::{configuration, ConfigHandle};
use lru::LruCache;
use mux::renderable::{Renderable, RenderableDimensions, StableCursorPosition};
use mux::tab::TabId;
use mux::Mux;
use promise::BrokenPromise;
use rangeset::*;
use ratelim::RateLimiter;
@ -350,7 +350,7 @@ impl RenderableInner {
if !dirty.is_empty() {
Mux::get()
.unwrap()
.notify(crate::mux::MuxNotification::PaneOutput(self.local_pane_id));
.notify(mux::MuxNotification::PaneOutput(self.local_pane_id));
}
let mut to_fetch = RangeSet::new();

View File

@ -1,12 +1,12 @@
use crate::connui::ConnectionUI;
use crate::mux::domain::{alloc_domain_id, Domain, DomainId, DomainState};
use crate::mux::localtab::LocalPane;
use crate::mux::pane::{alloc_pane_id, Pane, PaneId};
use crate::mux::tab::{SplitDirection, Tab, TabId};
use crate::mux::window::WindowId;
use crate::mux::Mux;
use anyhow::{anyhow, bail, Context, Error};
use async_trait::async_trait;
use mux::domain::{alloc_domain_id, Domain, DomainId, DomainState};
use mux::localtab::LocalPane;
use mux::pane::{alloc_pane_id, Pane, PaneId};
use mux::tab::{SplitDirection, Tab, TabId};
use mux::window::WindowId;
use mux::Mux;
use portable_pty::cmdbuilder::CommandBuilder;
use portable_pty::{PtySize, PtySystem};
use promise::{Future, Promise};

View File

@ -5,16 +5,16 @@
use crate::font::FontConfiguration;
use crate::frontend::front_end;
use crate::mux::domain::{alloc_domain_id, Domain, DomainId, DomainState};
use crate::mux::pane::{alloc_pane_id, Pane, PaneId};
use crate::mux::renderable::Renderable;
use crate::mux::tab::{SplitDirection, Tab, TabId};
use crate::mux::window::WindowId;
use crate::mux::Mux;
use anyhow::{bail, Error};
use async_trait::async_trait;
use crossbeam::channel::{unbounded as channel, Receiver, Sender};
use filedescriptor::{FileDescriptor, Pipe};
use mux::domain::{alloc_domain_id, Domain, DomainId, DomainState};
use mux::pane::{alloc_pane_id, Pane, PaneId};
use mux::renderable::Renderable;
use mux::tab::{SplitDirection, Tab, TabId};
use mux::window::WindowId;
use mux::Mux;
use portable_pty::*;
use std::cell::RefCell;
use std::cell::RefMut;