1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-27 15:37:29 +03:00

move Tab trait to mux module

This commit is contained in:
Wez Furlong 2019-03-07 23:39:10 +00:00
parent 431e32d719
commit a1bdddd8e5
9 changed files with 45 additions and 31 deletions

View File

@ -4,10 +4,11 @@ use crate::config::Config;
use crate::failure::Error;
use crate::font::FontConfiguration;
use crate::guicommon::host::{HostHelper, HostImpl, TabHost};
use crate::guicommon::tabs::{Tab, TabId, Tabs};
use crate::guicommon::tabs::Tabs;
use crate::guicommon::window::{Dimensions, TerminalWindow};
use crate::guiloop::glutinloop::GuiEventLoop;
use crate::guiloop::SessionTerminated;
use crate::mux::tab::{Tab, TabId};
use crate::opengl::render::Renderer;
use glium;
use glium::glutin::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};

View File

@ -1,5 +1,5 @@
use super::window::TerminalWindow;
use crate::guicommon::tabs::Tab;
use crate::mux::tab::Tab;
use clipboard::{ClipboardContext, ClipboardProvider};
use failure::Error;
use std::ops::{Deref, DerefMut};

View File

@ -1,33 +1,11 @@
use crate::mux::renderable::Renderable;
use crate::mux::tab::{alloc_tab_id, Tab, TabId};
use crate::{Child, MasterPty};
use failure::Error;
use std::cell::{RefCell, RefMut};
use std::rc::Rc;
use term::{KeyCode, KeyModifiers, MouseEvent, Terminal, TerminalHost};
static TAB_ID: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT;
pub type TabId = usize;
pub trait Tab {
fn tab_id(&self) -> TabId;
fn renderer(&self) -> RefMut<Renderable>;
fn get_title(&self) -> String;
fn send_paste(&self, text: &str) -> Result<(), Error>;
fn reader(&self) -> Result<Box<std::io::Read + Send>, Error>;
fn writer(&self) -> RefMut<std::io::Write>;
fn resize(
&self,
rows: u16,
cols: u16,
pixel_width: u16,
pixel_height: u16,
) -> Result<(), Error>;
fn key_down(&self, key: KeyCode, mods: KeyModifiers) -> Result<(), Error>;
fn mouse_event(&self, event: MouseEvent, host: &mut TerminalHost) -> Result<(), Error>;
fn advance_bytes(&self, buf: &[u8], host: &mut TerminalHost);
fn is_dead(&self) -> bool;
}
pub struct LocalTab {
tab_id: TabId,
terminal: RefCell<Terminal>,
@ -104,7 +82,7 @@ impl Tab for LocalTab {
impl LocalTab {
pub fn new(terminal: Terminal, process: Child, pty: MasterPty) -> Self {
let tab_id = TAB_ID.fetch_add(1, ::std::sync::atomic::Ordering::Relaxed);
let tab_id = alloc_tab_id();
Self {
tab_id,
terminal: RefCell::new(terminal),

View File

@ -1,6 +1,7 @@
use crate::config::Config;
use crate::font::FontConfiguration;
use crate::guicommon::tabs::{LocalTab, Tab, TabId, Tabs};
use crate::guicommon::tabs::{LocalTab, Tabs};
use crate::mux::tab::{Tab, TabId};
use crate::opengl::render::Renderer;
use crate::opengl::textureatlas::OutOfTextureSpace;
use crate::openpty;

View File

@ -3,9 +3,9 @@ use crate::config::Config;
use crate::font::{FontConfiguration, FontSystemSelection};
use crate::gliumwindows;
pub use crate::gliumwindows::GliumTerminalWindow;
use crate::guicommon::tabs::Tab;
use crate::guicommon::window::TerminalWindow;
use crate::guiloop::SessionTerminated;
use crate::mux::tab::Tab;
use crate::mux::Mux;
use crate::spawn_tab;
use failure::Error;

View File

@ -1,7 +1,7 @@
use super::ExitStatus;
use crate::config::Config;
use crate::font::FontConfiguration;
use crate::guicommon::tabs::Tab;
use crate::mux::tab::Tab;
use crate::mux::Mux;
use failure::Error;
use promise::Executor;

View File

@ -23,9 +23,10 @@ mod guiloop;
mod mux;
mod opengl;
mod server;
use crate::guicommon::tabs::{LocalTab, Tab};
use crate::guicommon::tabs::LocalTab;
use crate::guiloop::GuiSelection;
use crate::guiloop::GuiSystem;
use crate::mux::tab::Tab;
use crate::mux::Mux;
mod font;

View File

@ -1,4 +1,3 @@
use crate::guicommon::tabs::{Tab, TabId};
use failure::Error;
use promise::{Executor, Future};
use std::cell::RefCell;
@ -10,6 +9,9 @@ use term::TerminalHost;
use termwiz::hyperlink::Hyperlink;
pub mod renderable;
pub mod tab;
use crate::mux::tab::{Tab, TabId};
#[derive(Default)]
pub struct Mux {

31
src/mux/tab.rs Normal file
View File

@ -0,0 +1,31 @@
use crate::mux::renderable::Renderable;
use failure::Error;
use std::cell::RefMut;
use term::{KeyCode, KeyModifiers, MouseEvent, TerminalHost};
static TAB_ID: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT;
pub type TabId = usize;
pub fn alloc_tab_id() -> TabId {
TAB_ID.fetch_add(1, ::std::sync::atomic::Ordering::Relaxed)
}
pub trait Tab {
fn tab_id(&self) -> TabId;
fn renderer(&self) -> RefMut<Renderable>;
fn get_title(&self) -> String;
fn send_paste(&self, text: &str) -> Result<(), Error>;
fn reader(&self) -> Result<Box<std::io::Read + Send>, Error>;
fn writer(&self) -> RefMut<std::io::Write>;
fn resize(
&self,
rows: u16,
cols: u16,
pixel_width: u16,
pixel_height: u16,
) -> Result<(), Error>;
fn key_down(&self, key: KeyCode, mods: KeyModifiers) -> Result<(), Error>;
fn mouse_event(&self, event: MouseEvent, host: &mut TerminalHost) -> Result<(), Error>;
fn advance_bytes(&self, buf: &[u8], host: &mut TerminalHost);
fn is_dead(&self) -> bool;
}