summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/tty/windows/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty_terminal/src/tty/windows/mod.rs')
-rw-r--r--alacritty_terminal/src/tty/windows/mod.rs40
1 files changed, 15 insertions, 25 deletions
diff --git a/alacritty_terminal/src/tty/windows/mod.rs b/alacritty_terminal/src/tty/windows/mod.rs
index e112d305..9e2f722b 100644
--- a/alacritty_terminal/src/tty/windows/mod.rs
+++ b/alacritty_terminal/src/tty/windows/mod.rs
@@ -38,16 +38,15 @@ pub fn is_conpty() -> bool {
IS_CONPTY.load(Ordering::Relaxed)
}
-#[derive(Clone)]
-pub enum PtyHandle {
- Winpty(winpty::WinptyHandle),
- Conpty(conpty::ConptyHandle),
+enum PtyBackend {
+ Winpty(winpty::Agent),
+ Conpty(conpty::Conpty),
}
pub struct Pty {
- // XXX: Handle is required to be the first field, to ensure correct drop order. Dropping
- // `conout` before `handle` will cause a deadlock.
- handle: PtyHandle,
+ // XXX: Backend is required to be the first field, to ensure correct drop order. Dropping
+ // `conout` before `backend` will cause a deadlock.
+ backend: PtyBackend,
// TODO: It's on the roadmap for the Conpty API to support Overlapped I/O.
// See https://github.com/Microsoft/console/issues/262
// When support for that lands then it should be possible to use
@@ -60,12 +59,6 @@ pub struct Pty {
child_watcher: ChildExitWatcher,
}
-impl Pty {
- pub fn resize_handle(&self) -> impl OnResize {
- self.handle.clone()
- }
-}
-
pub fn new<C>(config: &Config<C>, size: &SizeInfo, window_id: Option<usize>) -> Pty {
if let Some(pty) = conpty::new(config, size, window_id) {
info!("Using Conpty agent");
@@ -189,18 +182,6 @@ impl Write for EventedWritablePipe {
}
}
-impl OnResize for PtyHandle {
- fn on_resize(&mut self, sizeinfo: &SizeInfo) {
- match self {
- PtyHandle::Winpty(w) => w.resize(sizeinfo),
- PtyHandle::Conpty(c) => {
- let mut handle = c.clone();
- handle.on_resize(sizeinfo)
- },
- }
- }
-}
-
impl EventedReadWrite for Pty {
type Reader = EventedReadablePipe;
type Writer = EventedWritablePipe;
@@ -308,3 +289,12 @@ impl EventedPty for Pty {
}
}
}
+
+impl OnResize for Pty {
+ fn on_resize(&mut self, size: &SizeInfo) {
+ match &mut self.backend {
+ PtyBackend::Winpty(w) => w.on_resize(size),
+ PtyBackend::Conpty(c) => c.on_resize(size),
+ }
+ }
+}