maybe fix the windows build for anyhow changes
This commit is contained in:
1 parent
c6e4d31e47
commit
4fdee2baf0
5 files changed
+17
-18
No files matched your search
@@ -1,7 +1,7 @@
|
||||
use super::WinChild;
|
||||
use crate::cmdbuilder::CommandBuilder;
|
||||
use crate::{Child, MasterPty, PtyPair, PtySize, PtySystem, SlavePty};
|
||||
use failure::{bail, ensure, Error, Fallible};
|
||||
use anyhow::{bail, ensure, Error};
|
||||
use filedescriptor::{FileDescriptor, OwnedHandle, Pipe};
|
||||
use lazy_static::lazy_static;
|
||||
use shared_library::shared_library;
|
||||
@@ -26,7 +26,7 @@ const PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE: usize = 0x00020016;
|
||||
|
||||
pub struct ConPtySystem {}
|
||||
impl PtySystem for ConPtySystem {
|
||||
fn openpty(&self, size: PtySize) -> Fallible<PtyPair> {
|
||||
fn openpty(&self, size: PtySize) -> anyhow::Result<PtyPair> {
|
||||
let stdin = Pipe::new()?;
|
||||
let stdout = Pipe::new()?;
|
||||
|
||||
@@ -224,7 +224,7 @@ pub struct ConPtySlavePty {
|
||||
}
|
||||
|
||||
impl MasterPty for ConPtyMasterPty {
|
||||
fn resize(&self, size: PtySize) -> Fallible<()> {
|
||||
fn resize(&self, size: PtySize) -> anyhow::Result<()> {
|
||||
let mut inner = self.inner.lock().unwrap();
|
||||
inner.resize(size.rows, size.cols, size.pixel_width, size.pixel_height)
|
||||
}
|
||||
@@ -234,7 +234,7 @@ impl MasterPty for ConPtyMasterPty {
|
||||
Ok(inner.size.clone())
|
||||
}
|
||||
|
||||
fn try_clone_reader(&self) -> Fallible<Box<dyn std::io::Read + Send>> {
|
||||
fn try_clone_reader(&self) -> anyhow::Result<Box<dyn std::io::Read + Send>> {
|
||||
Ok(Box::new(self.inner.lock().unwrap().readable.try_clone()?))
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ impl io::Write for ConPtyMasterPty {
|
||||
}
|
||||
|
||||
impl SlavePty for ConPtySlavePty {
|
||||
fn spawn_command(&self, cmd: CommandBuilder) -> Fallible<Box<dyn Child>> {
|
||||
fn spawn_command(&self, cmd: CommandBuilder) -> anyhow::Result<Box<dyn Child>> {
|
||||
let inner = self.inner.lock().unwrap();
|
||||
|
||||
let mut si: STARTUPINFOEXW = unsafe { mem::zeroed() };
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::win::winpty::safe::{
|
||||
AgentFlags, MouseMode, SpawnConfig, SpawnFlags, Timeout, WinPty, WinPtyConfig,
|
||||
};
|
||||
use crate::{Child, MasterPty, PtyPair, PtySize, PtySystem, SlavePty};
|
||||
use failure::{bail, Fallible};
|
||||
use anyhow::bail;
|
||||
use filedescriptor::FileDescriptor;
|
||||
use log::debug;
|
||||
use std::ffi::OsString;
|
||||
@@ -32,7 +32,7 @@ pub struct WinPtySlavePty {
|
||||
}
|
||||
|
||||
impl MasterPty for WinPtyMasterPty {
|
||||
fn resize(&self, size: PtySize) -> Fallible<()> {
|
||||
fn resize(&self, size: PtySize) -> anyhow::Result<()> {
|
||||
let mut inner = self.inner.lock().unwrap();
|
||||
if inner.pty.set_size(size.cols as i32, size.rows as i32)? {
|
||||
inner.size = size;
|
||||
@@ -42,11 +42,11 @@ impl MasterPty for WinPtyMasterPty {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_size(&self) -> Fallible<PtySize> {
|
||||
fn get_size(&self) -> anyhow::Result<PtySize> {
|
||||
Ok(self.inner.lock().unwrap().size)
|
||||
}
|
||||
|
||||
fn try_clone_reader(&self) -> Fallible<Box<dyn std::io::Read + Send>> {
|
||||
fn try_clone_reader(&self) -> anyhow::Result<Box<dyn std::io::Read + Send>> {
|
||||
Ok(Box::new(self.inner.lock().unwrap().reader.try_clone()?))
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ impl std::io::Write for WinPtyMasterPty {
|
||||
}
|
||||
|
||||
impl SlavePty for WinPtySlavePty {
|
||||
fn spawn_command(&self, cmd: CommandBuilder) -> Fallible<Box<dyn Child>> {
|
||||
fn spawn_command(&self, cmd: CommandBuilder) -> anyhow::Result<Box<dyn Child>> {
|
||||
let (exe, cmdline) = cmd.cmdline()?;
|
||||
let cmd_os = OsString::from_wide(&cmdline);
|
||||
debug!(
|
||||
@@ -91,7 +91,7 @@ impl SlavePty for WinPtySlavePty {
|
||||
|
||||
pub struct WinPtySystem {}
|
||||
impl PtySystem for WinPtySystem {
|
||||
fn openpty(&self, size: PtySize) -> Fallible<PtyPair> {
|
||||
fn openpty(&self, size: PtySize) -> anyhow::Result<PtyPair> {
|
||||
let mut config = WinPtyConfig::new(AgentFlags::empty())?;
|
||||
|
||||
config.set_initial_size(size.cols as i32, size.rows as i32);
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
//! https://github.com/rprichard/winpty/blob/master/src/include/winpty.h
|
||||
#![allow(dead_code)]
|
||||
use super::sys::*;
|
||||
use anyhow::{bail, ensure, Error};
|
||||
use bitflags::bitflags;
|
||||
use failure::{bail, ensure, format_err, Error};
|
||||
use filedescriptor::{FileDescriptor, OwnedHandle};
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::os::windows::ffi::{OsStrExt, OsStringExt};
|
||||
@@ -58,7 +58,7 @@ fn wstr_to_osstr(wstr: LPCWSTR) -> Result<OsString, Error> {
|
||||
fn wstr_to_string(wstr: LPCWSTR) -> Result<String, Error> {
|
||||
ensure!(!wstr.is_null(), "LPCWSTR is null");
|
||||
let slice = unsafe { std::slice::from_raw_parts(wstr, libc::wcslen(wstr)) };
|
||||
String::from_utf16(slice).map_err(|e| format_err!("String::from_utf16: {}", e))
|
||||
String::from_utf16(slice).map_err(|e| anyhow!("String::from_utf16: {}", e))
|
||||
}
|
||||
|
||||
fn check_err<T>(err: winpty_error_ptr_t, value: T) -> Result<T, Error> {
|
||||
|
||||
@@ -5,7 +5,6 @@ use crate::cell::{AttributeChange, CellAttributes, Underline};
|
||||
use crate::color::{AnsiColor, ColorAttribute};
|
||||
use crate::surface::{Change, Position};
|
||||
use crate::terminal::windows::{ConsoleInputHandle, ConsoleOutputHandle};
|
||||
use failure;
|
||||
use num;
|
||||
use std::io::{Read, Write};
|
||||
use winapi::um::wincon::{
|
||||
@@ -117,7 +116,7 @@ impl WindowsConsoleRenderer {
|
||||
changes: &[Change],
|
||||
_read: &mut A,
|
||||
out: &mut B,
|
||||
) -> Result<(), failure::Error> {
|
||||
) -> anyhow::Result<()> {
|
||||
for change in changes {
|
||||
match change {
|
||||
Change::ClearScreen(color) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::istty::IsTty;
|
||||
use failure::{bail, format_err, Error, Fallible};
|
||||
use anyhow::{anyhow, bail, Error};
|
||||
use filedescriptor::{FileDescriptor, OwnedHandle};
|
||||
use std::cmp::{max, min};
|
||||
use std::collections::VecDeque;
|
||||
@@ -460,7 +460,7 @@ impl Terminal for WindowsTerminal {
|
||||
)
|
||||
}
|
||||
|
||||
fn set_cooked_mode(&mut self) -> Fallible<()> {
|
||||
fn set_cooked_mode(&mut self) -> anyhow::Result<()> {
|
||||
let mode = self.input_handle.get_input_mode()?;
|
||||
|
||||
self.input_handle.set_input_mode(
|
||||
@@ -526,7 +526,7 @@ impl Terminal for WindowsTerminal {
|
||||
fn flush(&mut self) -> Result<(), Error> {
|
||||
self.output_handle
|
||||
.flush()
|
||||
.map_err(|e| format_err!("flush failed: {}", e))
|
||||
.map_err(|e| anyhow!("flush failed: {}", e))
|
||||
}
|
||||
|
||||
fn poll_input(&mut self, wait: Option<Duration>) -> Result<Option<InputEvent>, Error> {
|
||||
|
||||
Reference in new issue
Block a user