Skip to content

Commit

Permalink
feat: termion 2
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Oct 16, 2023
1 parent df94b2a commit af555c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ bitflags = "2.4"
crossterm = { version = "0.27", optional = true }
lazy-regex = "3"
serde = { version = "^1", features = ["derive"], optional = true }
termion = { version = "^1.5", optional = true }
termion = { version = "^2", optional = true }
thiserror = "^1.0.0"
tui = { version = "0.19", default-features = false, optional = true }
ratatui = { version = "0.23", default-features = false, optional = true }
tuirealm_derive = { version = "^1.0.0", optional = true }

[dev-dependencies]
pretty_assertions = "^1"
toml = "^0.7"
toml = "^0.8"
tempfile = "^3"

[features]
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/termion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use crate::tui::{Frame as TuiFrame, Terminal as TuiTerminal};

/// Frame represents the Frame where the view will be displayed in
pub type Frame<'a> =
TuiFrame<'a, TermionBackend<AlternateScreen<MouseTerminal<RawTerminal<Stdout>>>>>;
TuiFrame<'a, TermionBackend<MouseTerminal<AlternateScreen<RawTerminal<Stdout>>>>>;

/// Terminal must be used to interact with the terminal in tui applications
pub type Terminal =
TuiTerminal<TermionBackend<AlternateScreen<MouseTerminal<RawTerminal<Stdout>>>>>;
TuiTerminal<TermionBackend<MouseTerminal<AlternateScreen<RawTerminal<Stdout>>>>>;
14 changes: 7 additions & 7 deletions src/adapter/termion/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ use std::io::stdout;

use termion::input::MouseTerminal;
use termion::raw::IntoRawMode;
#[cfg(target_family = "unix")]
use termion::screen::AlternateScreen;
use termion::screen::IntoAlternateScreen;

use crate::terminal::{TerminalBridge, TerminalError, TerminalResult};
use crate::tui::backend::TermionBackend;
use crate::Terminal;

impl TerminalBridge {
pub(crate) fn adapt_new_terminal() -> TerminalResult<Terminal> {
let screen = stdout()
let stdout = stdout()
.into_raw_mode()
.map_err(|_| TerminalError::CannotConnectStdout)
.map(MouseTerminal::from)
.map(AlternateScreen::from)?;
Terminal::new(TermionBackend::new(screen)).map_err(|_| TerminalError::CannotConnectStdout)
.map_err(|_| TerminalError::CannotConnectStdout)?
.into_alternate_screen()
.map_err(|_| TerminalError::CannotConnectStdout)?;
let stdout = MouseTerminal::from(stdout);
Terminal::new(TermionBackend::new(stdout)).map_err(|_| TerminalError::CannotConnectStdout)
}

pub(crate) fn adapt_enter_alternate_screen(&mut self) -> TerminalResult<()> {
Expand Down

0 comments on commit af555c8

Please sign in to comment.