Skip to content

Commit

Permalink
move pty to its own crate in preparation for publishing
Browse files Browse the repository at this point in the history
Refs: #27
  • Loading branch information
wez committed May 20, 2019
1 parent c207142 commit 7bf1d99
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 17 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ leb128 = "0.2"
libc = "0.2"
open = "1.2"
palette = "0.4"
portable-pty = { path = "pty", features = ["serde_support"]}
promise = { path = "promise" }
rayon = "1.0"
serde = {version="1.0", features = ["rc"]}
Expand Down
33 changes: 33 additions & 0 deletions pty/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "portable-pty"
version = "0.1.0"
authors = ["Wez Furlong"]
edition = "2018"
repository = "https://github.com/wez/wezterm"
description = "Cross platform pty interface"
license = "MIT"
documentation = "https://docs.rs/portable-pty"

[dependencies]
failure = "0.1"
failure_derive = "0.1"
libc = "0.2"
serde_derive = {version="1.0", optional=true}
serde = {version="1.0", optional=true}

[features]
default = []
serde_support = ["serde", "serde_derive"]

[target."cfg(windows)".dependencies]
shared_library = "0.1"
uds_windows = "0.1"
winapi = { version = "0.3", features = [
"winuser",
"consoleapi",
"handleapi",
"fileapi",
"namedpipeapi",
"synchapi",
]}

File renamed without changes.
6 changes: 4 additions & 2 deletions src/pty/mod.rs → pty/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use failure::Error;
use failure::{bail, format_err, Error};
#[cfg(feature = "serde_support")]
use serde_derive::*;
use std::io::Result as IoResult;

Expand Down Expand Up @@ -83,7 +84,8 @@ impl Child for std::process::Child {
}

#[allow(dead_code)]
#[derive(Debug, Clone, Copy, Deserialize)]
#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "serde_support", derive(Deserialize))]
pub enum PtySystemSelection {
Unix,
ConPty,
Expand Down
4 changes: 2 additions & 2 deletions src/pty/unix.rs → pty/src/unix.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Working with pseudo-terminals

use crate::pty::{Child, CommandBuilder, MasterPty, PtySize, PtySystem, SlavePty};
use failure::Error;
use crate::{Child, CommandBuilder, MasterPty, PtySize, PtySystem, SlavePty};
use failure::{bail, Error};
use libc::{self, winsize};
use std::io;
use std::mem;
Expand Down
4 changes: 2 additions & 2 deletions src/pty/win/conpty.rs → pty/src/win/conpty.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::ownedhandle::OwnedHandle;
use super::WinChild;
use crate::pty::cmdbuilder::CommandBuilder;
use crate::pty::{Child, MasterPty, PtySize, PtySystem, SlavePty};
use crate::cmdbuilder::CommandBuilder;
use crate::{Child, MasterPty, PtySize, PtySystem, SlavePty};
use failure::Error;
use lazy_static::lazy_static;
use shared_library::shared_library;
Expand Down
2 changes: 1 addition & 1 deletion src/pty/win/mod.rs → pty/src/win/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::pty::{Child, ExitStatus};
use crate::{Child, ExitStatus};
use std::io::{Error as IoError, Result as IoResult};
use winapi::shared::minwindef::DWORD;
use winapi::um::minwinbase::STILL_ACTIVE;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/pty/win/winpty/mod.rs → pty/src/win/winpty/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::ownedhandle::OwnedHandle;
use super::WinChild;
use crate::pty::cmdbuilder::CommandBuilder;
use crate::pty::{Child, MasterPty, PtySize, PtySystem, SlavePty};
use crate::cmdbuilder::CommandBuilder;
use crate::{Child, MasterPty, PtySize, PtySystem, SlavePty};
use failure::Error;
use safe::{AgentFlags, MouseMode, SpawnConfig, SpawnFlags, Timeout, WinPty, WinPtyConfig};
use std::ffi::OsString;
Expand Down
2 changes: 1 addition & 1 deletion src/pty/win/winpty/safe.rs → pty/src/win/winpty/safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! https://github.com/rprichard/winpty/blob/master/src/include/winpty.h
#![allow(dead_code)]
use super::sys::*;
use crate::pty::win::ownedhandle::OwnedHandle;
use crate::win::ownedhandle::OwnedHandle;
use bitflags::bitflags;
use failure::{format_err, Error};
use std::ffi::{OsStr, OsString};
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
use crate::font::FontSystemSelection;
use crate::frontend::FrontEndSelection;
use crate::get_shell;
use crate::pty::CommandBuilder;
use crate::pty::PtySystemSelection;
use failure::{err_msg, Error};
use lazy_static::lazy_static;
use portable_pty::{CommandBuilder, PtySystemSelection};
use serde_derive::*;
use std;
use std::ffi::OsStr;
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/guicommon/localtab.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::mux::renderable::Renderable;
use crate::mux::tab::{alloc_tab_id, Tab, TabId};
use crate::pty::{Child, MasterPty, PtySize};
use failure::Error;
use portable_pty::{Child, MasterPty, PtySize};
use std::cell::{RefCell, RefMut};
use term::{KeyCode, KeyModifiers, MouseEvent, Terminal, TerminalHost};

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/guicommon/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::mux::window::WindowId;
use crate::mux::Mux;
use crate::opengl::render::Renderer;
use crate::opengl::textureatlas::OutOfTextureSpace;
use crate::pty::{PtySize, PtySystemSelection};
use failure::Error;
use glium;
use portable_pty::{PtySize, PtySystemSelection};
use std::rc::Rc;
use std::sync::Arc;

Expand Down
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ use crate::mux::Mux;
mod font;
use crate::font::{FontConfiguration, FontSystemSelection};

mod pty;
use pty::PtySize;
use portable_pty::PtySize;
use std::env;

/// Determine which shell to run.
Expand Down
2 changes: 1 addition & 1 deletion src/mux/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::config::Config;
use crate::pty::ExitStatus;
use failure::Error;
use portable_pty::ExitStatus;
use promise::{Executor, Future};
use std::cell::{Ref, RefCell, RefMut};
use std::collections::HashMap;
Expand Down

0 comments on commit 7bf1d99

Please sign in to comment.