add config option to select pty system

This commit is contained in:
Wez Furlong committed 2019-03-25 19:35:13 -07:00
1 parent cac06e5506
commit d040b94b62
3 files changed
+31 -4

No files matched your search

+5
View File
@@ -4,6 +4,7 @@ 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 serde_derive::*;
@@ -69,6 +70,9 @@ pub struct Config {
#[serde(default)]
pub front_end: FrontEndSelection,
#[serde(default)]
pub pty: PtySystemSelection,
/// When using the MuxServer, this specifies the path to the unix
/// domain socket to use to communicate with the mux server.
pub mux_server_unix_domain_socket_path: Option<String>,
@@ -104,6 +108,7 @@ impl Default for Config {
font_rules: Vec::new(),
font_system: FontSystemSelection::default(),
front_end: FrontEndSelection::default(),
pty: PtySystemSelection::default(),
colors: None,
scrollback_lines: None,
hyperlink_rules: default_hyperlink_rules(),
+2 -2
View File
@@ -28,7 +28,7 @@ mod font;
use crate::font::{FontConfiguration, FontSystemSelection};
mod pty;
use pty::{PtySize, PtySystemSelection};
use pty::PtySize;
use std::env;
/// Determine which shell to run.
@@ -200,7 +200,7 @@ fn spawn_tab(
let initial_pixel_width = 0;
let initial_pixel_height = 0;
let pty_sys = PtySystemSelection::default().get()?;
let pty_sys = config.pty.get()?;
let (master, slave) = pty_sys.openpty(PtySize {
rows: initial_rows,
cols: initial_cols,
+24 -2
View File
@@ -1,4 +1,5 @@
use failure::Error;
use serde_derive::*;
use std::io::Result as IoResult;
pub mod cmdbuilder;
@@ -82,6 +83,7 @@ impl Child for std::process::Child {
}
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, Deserialize)]
pub enum PtySystemSelection {
Unix,
ConPty,
@@ -93,7 +95,7 @@ impl PtySystemSelection {
pub fn get(&self) -> Result<Box<PtySystem>, Error> {
match self {
PtySystemSelection::Unix => Ok(Box::new(unix::UnixPtySystem {})),
_ => bail!("{:?} not available on unix"),
_ => bail!("{:?} not available on unix", self),
}
}
#[cfg(windows)]
@@ -101,7 +103,27 @@ impl PtySystemSelection {
match self {
PtySystemSelection::ConPty => Ok(Box::new(win::conpty::ConPtySystem {})),
PtySystemSelection::WinPty => Ok(Box::new(win::winpty::WinPtySystem {})),
_ => bail!("{:?} not available on Windows"),
_ => bail!("{:?} not available on Windows", self),
}
}
pub fn variants() -> Vec<&'static str> {
vec!["Unix", "ConPty", "WinPty"]
}
}
impl std::str::FromStr for PtySystemSelection {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_ref() {
"unix" => Ok(PtySystemSelection::Unix),
"winpty" => Ok(PtySystemSelection::WinPty),
"conpty" => Ok(PtySystemSelection::ConPty),
_ => Err(format_err!(
"{} is not a valid PtySystemSelection variant, possible values are {:?}",
s,
PtySystemSelection::variants()
)),
}
}
}