aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/tty/windows
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2021-11-22 21:34:09 +0300
committerGitHub <noreply@github.com>2021-11-22 18:34:09 +0000
commit8681f71084894db6d1e258be17db1f80bb669314 (patch)
tree24d3c0ced916d2d171fd03f50cd34dcda8f0aa06 /alacritty_terminal/src/tty/windows
parentc89939b5d14e581e1aeaa940d81843192e0abc79 (diff)
downloadalacritty-8681f71084894db6d1e258be17db1f80bb669314.tar.gz
alacritty-8681f71084894db6d1e258be17db1f80bb669314.zip
Add parameters to `msg create-window` subcommand
Alacritty's `msg create-window` subcommand would previously inherit all the CLI parameters from the original executable. However not only could this lead to unexpected behavior, it also prevents multi-window users from making use of parameters like `-e`, `--working-directory`, or `--hold`. This is solved by adding a JSON-based message format to the IPC socket messages which instructs the Alacritty server on which CLI parameters should be used to create the new window. Fixes #5562. Fixes #5561. Fixes #5560.
Diffstat (limited to 'alacritty_terminal/src/tty/windows')
-rw-r--r--alacritty_terminal/src/tty/windows/conpty.rs6
-rw-r--r--alacritty_terminal/src/tty/windows/mod.rs12
2 files changed, 9 insertions, 9 deletions
diff --git a/alacritty_terminal/src/tty/windows/conpty.rs b/alacritty_terminal/src/tty/windows/conpty.rs
index 002022ea..9556be8b 100644
--- a/alacritty_terminal/src/tty/windows/conpty.rs
+++ b/alacritty_terminal/src/tty/windows/conpty.rs
@@ -15,7 +15,7 @@ use winapi::um::processthreadsapi::{
use winapi::um::winbase::{EXTENDED_STARTUPINFO_PRESENT, STARTF_USESTDHANDLES, STARTUPINFOEXW};
use winapi::um::wincontypes::{COORD, HPCON};
-use crate::config::Config;
+use crate::config::PtyConfig;
use crate::event::OnResize;
use crate::grid::Dimensions;
use crate::term::SizeInfo;
@@ -40,7 +40,7 @@ impl Drop for Conpty {
// The ConPTY handle can be sent between threads.
unsafe impl Send for Conpty {}
-pub fn new<C>(config: &Config<C>, size: &SizeInfo) -> Option<Pty> {
+pub fn new(config: &PtyConfig, size: &SizeInfo) -> Option<Pty> {
let mut pty_handle = 0 as HPCON;
// Passing 0 as the size parameter allows the "system default" buffer
@@ -136,7 +136,7 @@ pub fn new<C>(config: &Config<C>, size: &SizeInfo) -> Option<Pty> {
}
}
- let cmdline = win32_string(&cmdline(&config));
+ let cmdline = win32_string(&cmdline(config));
let cwd = config.working_directory.as_ref().map(win32_string);
let mut proc_info: PROCESS_INFORMATION = Default::default();
diff --git a/alacritty_terminal/src/tty/windows/mod.rs b/alacritty_terminal/src/tty/windows/mod.rs
index 644253f4..0cc6a8bc 100644
--- a/alacritty_terminal/src/tty/windows/mod.rs
+++ b/alacritty_terminal/src/tty/windows/mod.rs
@@ -1,10 +1,10 @@
use std::ffi::OsStr;
-use std::io;
+use std::io::{self, Error, ErrorKind, Result};
use std::iter::once;
use std::os::windows::ffi::OsStrExt;
use std::sync::mpsc::TryRecvError;
-use crate::config::{Config, Program};
+use crate::config::{Program, PtyConfig};
use crate::event::OnResize;
use crate::term::SizeInfo;
use crate::tty::windows::child::ChildExitWatcher;
@@ -28,8 +28,8 @@ pub struct Pty {
child_watcher: ChildExitWatcher,
}
-pub fn new<C>(config: &Config<C>, size: &SizeInfo, _window_id: Option<usize>) -> Pty {
- conpty::new(config, size).expect("Failed to create ConPTY backend")
+pub fn new(config: &PtyConfig, size: &SizeInfo, _window_id: Option<usize>) -> Result<Pty> {
+ conpty::new(config, size).ok_or_else(|| Error::new(ErrorKind::Other, "failed to spawn conpty"))
}
impl Pty {
@@ -165,11 +165,11 @@ impl OnResize for Pty {
}
}
-fn cmdline<C>(config: &Config<C>) -> String {
+fn cmdline(config: &PtyConfig) -> String {
let default_shell = Program::Just("powershell".to_owned());
let shell = config.shell.as_ref().unwrap_or(&default_shell);
- once(shell.program().as_ref())
+ once(shell.program())
.chain(shell.args().iter().map(|a| a.as_ref()))
.collect::<Vec<_>>()
.join(" ")