Skip to content

Commit 1d0aae2

Browse files
committed
dropped the File backend in favour of stdout
1 parent 115916b commit 1d0aae2

File tree

2 files changed

+5
-29
lines changed
  • anathema-backend/src/tui
  • anathema-runtime/src/runtime

2 files changed

+5
-29
lines changed

anathema-backend/src/tui/mod.rs

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,9 @@ pub mod events;
2828
mod screen;
2929
mod style;
3030

31-
fn output() -> (Stdout, File) {
32-
let output = std::io::stdout();
33-
34-
#[cfg(not(windows))]
35-
use std::os::fd::AsFd as _;
36-
#[cfg(windows)]
37-
use std::os::windows::io::AsHandle as _;
38-
39-
#[cfg(windows)]
40-
let owned = output.as_handle().try_clone_to_owned().expect("ownable handle");
41-
42-
#[cfg(not(windows))]
43-
let owned = output.as_fd().try_clone_to_owned().expect("ownable fd");
44-
45-
let file = File::from(owned);
46-
(output, file)
47-
}
48-
4931
/// Backend builder for a tui backend.
5032
pub struct TuiBackendBuilder {
51-
_stdout: Stdout,
52-
output: File,
33+
output: Stdout,
5334
hide_cursor: bool,
5435
enable_raw_mode: bool,
5536
enable_alt_screen: bool,
@@ -98,8 +79,7 @@ impl TuiBackendBuilder {
9879

9980
let backend = TuiBackend {
10081
screen,
101-
_stdout: self._stdout,
102-
output: BufWriter::new(self.output),
82+
output: self.output,
10383
events: Events,
10484

10585
hide_cursor: self.hide_cursor,
@@ -115,8 +95,7 @@ impl TuiBackendBuilder {
11595
/// Terminal backend
11696
pub struct TuiBackend {
11797
screen: Screen,
118-
_stdout: Stdout,
119-
output: BufWriter<File>,
98+
output: Stdout,
12099
events: Events,
121100

122101
// Settings
@@ -129,11 +108,8 @@ pub struct TuiBackend {
129108
impl TuiBackend {
130109
/// Create a new instance of the tui backend.
131110
pub fn builder() -> TuiBackendBuilder {
132-
let (_stdout, output) = output();
133-
134111
TuiBackendBuilder {
135-
_stdout,
136-
output,
112+
output: std::io::stdout(),
137113
hide_cursor: false,
138114
enable_raw_mode: false,
139115
enable_alt_screen: false,

anathema-runtime/src/runtime/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ impl<'rt, 'bp, G: GlobalEventHandler> Frame<'rt, 'bp, G> {
399399
for mut cmd in commands {
400400
// Blur the current component if the message is a `Focus` message
401401
if let CommandKind::Focus = cmd.kind {
402-
if let Some(current) = &self.tabindex {
402+
if let Some(current) = self.tabindex.take() {
403403
self.with_component(current.widget_id, current.state_id, |comp, children, ctx| {
404404
comp.dyn_component.any_blur(children, ctx)
405405
});

0 commit comments

Comments
 (0)