mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-13 20:53:07 +00:00
Crossterm: define platform-dependant Stdout type
This commit is contained in:
parent
f1fe477e6d
commit
237c6c8e33
@ -7,7 +7,7 @@
|
|||||||
use std::{
|
use std::{
|
||||||
cell::{Cell, RefCell, RefMut},
|
cell::{Cell, RefCell, RefMut},
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{self, BufWriter, Stdout, Write},
|
io::{self, BufWriter, Write},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,15 +36,18 @@ use crate::{
|
|||||||
vec::Vec2,
|
vec::Vec2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
type Stdout = io::Stdout;
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
type Stdout = File;
|
||||||
|
|
||||||
/// Backend using crossterm
|
/// Backend using crossterm
|
||||||
pub struct Backend {
|
pub struct Backend {
|
||||||
current_style: Cell<theme::ColorPair>,
|
current_style: Cell<theme::ColorPair>,
|
||||||
last_button: Option<MouseButton>,
|
last_button: Option<MouseButton>,
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
stdout: RefCell<BufWriter<Stdout>>,
|
stdout: RefCell<BufWriter<Stdout>>,
|
||||||
#[cfg(unix)]
|
|
||||||
stdout: RefCell<BufWriter<File>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CMouseButton> for MouseButton {
|
impl From<CMouseButton> for MouseButton {
|
||||||
@ -234,12 +237,6 @@ impl Backend {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
fn stdout_mut(&self) -> RefMut<BufWriter<File>> {
|
|
||||||
self.stdout.borrow_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
fn stdout_mut(&self) -> RefMut<BufWriter<Stdout>> {
|
fn stdout_mut(&self) -> RefMut<BufWriter<Stdout>> {
|
||||||
self.stdout.borrow_mut()
|
self.stdout.borrow_mut()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user