Skip to content

Commit

Permalink
Add support for Windows ConPTY API
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Dec 27, 2018
1 parent e4db833 commit f20ce82
Show file tree
Hide file tree
Showing 10 changed files with 848 additions and 301 deletions.
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Expand Up @@ -58,8 +58,12 @@ x11-dl = "2"
[target.'cfg(windows)'.dependencies]
winpty = { path = "./winpty" }
mio-named-pipes = "0.1"
winapi = { version = "0.3.5", features = ["winuser", "synchapi", "roerrorapi", "winerror"]}
miow = "0.3"
winapi = { version = "0.3.5", features = ["impl-default", "winuser", "synchapi", "roerrorapi", "winerror", "wincon"]}
dunce = "0.1"
widestring = "0.4"
lazy_static = "1.1"
mio-anonymous-pipes = "0.1"

[target.'cfg(target_os = "macos")'.dependencies]
objc = "0.2.2"
Expand Down
11 changes: 11 additions & 0 deletions alacritty_windows.yml
Expand Up @@ -282,6 +282,17 @@ shell:
#args:
# - --login

# Use the Windows 10 native conpty backend.
# This will enable better color support and may resolve other issues,
# however this API and its implementation is still young and so is
# disabled by default, as performance and stability may not be as good
# as the winpty backend.
#
# If set to true and Alacritty cannot initialize the conpty API
# (for example on systems older than Windows 10 October 2018 update),
# then Alacritty will fall back to the winpty backend.
enable_experimental_conpty_backend: false

# Key bindings
#
# Key bindings are specified as a list of objects. Each binding will specify
Expand Down
13 changes: 13 additions & 0 deletions src/config.rs
Expand Up @@ -531,6 +531,12 @@ pub struct Config {
// TODO: DEPRECATED
#[serde(default, deserialize_with = "failure_default")]
unfocused_hollow_cursor: Option<bool>,

/// Enable experimental conpty backend instead of using winpty.
/// Will only take effect on Windows 10 Oct 2018 and later.
#[cfg(windows)]
#[serde(default, deserialize_with="failure_default")]
enable_experimental_conpty_backend: bool
}

fn failure_default_vec<'a, D, T>(deserializer: D) -> ::std::result::Result<Vec<T>, D::Error>
Expand Down Expand Up @@ -1680,6 +1686,13 @@ impl Config {
self.colors.cursor.cursor.map(|_| Color::Named(NamedColor::Cursor))
}

/// Enable experimental conpty backend (Windows only)
#[cfg(windows)]
#[inline]
pub fn enable_experimental_conpty_backend(&self) -> bool {
self.enable_experimental_conpty_backend
}

// Update the history size, used in ref tests
pub fn set_history(&mut self, history: u32) {
self.scrolling.history = history;
Expand Down
11 changes: 0 additions & 11 deletions src/lib.rs
Expand Up @@ -20,17 +20,6 @@
#[macro_use] extern crate log;
#[macro_use] extern crate serde_derive;

#[cfg(windows)]
extern crate mio_named_pipes;
#[cfg(windows)]
extern crate winapi;
#[cfg(windows)]
extern crate winpty;
#[cfg(windows)]
extern crate dunce;
#[cfg(windows)]
extern crate image;

#[cfg(target_os = "macos")]
#[macro_use]
extern crate objc;
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Expand Up @@ -157,9 +157,9 @@ fn run(
// and we need to be able to resize the PTY from the main thread while the IO
// thread owns the EventedRW object.
#[cfg(windows)]
let resize_handle = unsafe { &mut *pty.winpty.get() };
let mut resize_handle = pty.resize_handle();
#[cfg(not(windows))]
let resize_handle = &mut pty.fd.as_raw_fd();
let mut resize_handle = pty.fd.as_raw_fd();

// Create the pseudoterminal I/O loop
//
Expand Down Expand Up @@ -236,7 +236,7 @@ fn run(
//
// The second argument is a list of types that want to be notified
// of display size changes.
display.handle_resize(&mut terminal_lock, &config, &mut [resize_handle, &mut processor]);
display.handle_resize(&mut terminal_lock, &config, &mut [&mut resize_handle, &mut processor]);

drop(terminal_lock);

Expand Down

0 comments on commit f20ce82

Please sign in to comment.