diff options
author | David Hewitt <1939362+davidhewitt@users.noreply.github.com> | 2020-01-02 11:49:27 +0000 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2020-01-02 11:49:27 +0000 |
commit | f632919134414e31ffd3ae9b5732d673deb0adf5 (patch) | |
tree | 59e74ceabba1d08a5d5966502dda113b11143fc2 /alacritty_terminal/src/tty/windows/mod.rs | |
parent | 77acb26d7328f678b26c8aff2ee5706d78949c44 (diff) | |
download | r-alacritty-f632919134414e31ffd3ae9b5732d673deb0adf5.tar.gz r-alacritty-f632919134414e31ffd3ae9b5732d673deb0adf5.tar.bz2 r-alacritty-f632919134414e31ffd3ae9b5732d673deb0adf5.zip |
Clean up Windows PTY string handling
Removes widestring and dunce dependencies, reduces some code duplication
and corrects a few typos.
Diffstat (limited to 'alacritty_terminal/src/tty/windows/mod.rs')
-rw-r--r-- | alacritty_terminal/src/tty/windows/mod.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/alacritty_terminal/src/tty/windows/mod.rs b/alacritty_terminal/src/tty/windows/mod.rs index f5e0e61f..03e2a3cd 100644 --- a/alacritty_terminal/src/tty/windows/mod.rs +++ b/alacritty_terminal/src/tty/windows/mod.rs @@ -12,7 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +use std::ffi::OsStr; use std::io::{self, Read, Write}; +use std::iter::once; +use std::os::windows::ffi::OsStrExt; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::TryRecvError; @@ -22,7 +25,7 @@ use mio_named_pipes::NamedPipe; use log::info; -use crate::config::Config; +use crate::config::{Config, Shell}; use crate::event::OnResize; use crate::term::SizeInfo; use crate::tty::windows::child::ChildExitWatcher; @@ -298,3 +301,19 @@ impl OnResize for Pty { } } } + +fn cmdline<C>(config: &Config<C>) -> String { + let default_shell = Shell::new("powershell"); + let shell = config.shell.as_ref().unwrap_or(&default_shell); + + once(shell.program.as_ref()) + .chain(shell.args.iter().map(|a| a.as_ref())) + .collect::<Vec<_>>() + .join(" ") +} + +/// Converts the string slice into a Windows-standard representation for "W"- +/// suffixed function variants, which accept UTF-16 encoded string values. +pub fn win32_string<S: AsRef<OsStr> + ?Sized>(value: &S) -> Vec<u16> { + OsStr::new(value).encode_wide().chain(once(0)).collect() +} |