summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAnton Simonov <asimonov215@gmail.com>2023-07-01 19:30:41 +0300
committerGitHub <noreply@github.com>2023-07-01 12:30:41 -0400
commit09bd69e4b1094f0ed9df40ce7c890e1bf55af7f4 (patch)
tree5c8982f013a7c84d176750f8af2f229f28d61491 /src
parent93061c472d4d735ea48bb729216bb5a61fe92a64 (diff)
Migrate termion lib from v1 to v2. Mouse feature turn on by default (#349)
* Migrate termion lib from v1 to v2 * Refactor termion with mouse support * Mouse feature is turn on by default in cargo * Refactor: simplification * Update notify to v6 stable. No problems so far * Update lib open to v5 * lib trash bump from v2 to v3 * Updated dependencies and planned migrations of 2 libs
Diffstat (limited to 'src')
-rw-r--r--src/ui/backend.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/ui/backend.rs b/src/ui/backend.rs
index 8180072..e67b5e9 100644
--- a/src/ui/backend.rs
+++ b/src/ui/backend.rs
@@ -2,6 +2,7 @@ use std::io::{self, stdout, Write};
use termion::raw::{IntoRawMode, RawTerminal};
use termion::screen::AlternateScreen;
+use termion::screen::IntoAlternateScreen;
use tui::backend::TermionBackend;
use tui::widgets::Widget;
@@ -9,7 +10,7 @@ use tui::widgets::Widget;
use termion::input::MouseTerminal;
trait New {
- fn new() -> std::io::Result<Self>
+ fn new() -> io::Result<Self>
where
Self: Sized;
}
@@ -18,20 +19,20 @@ trait New {
type Screen = MouseTerminal<AlternateScreen<RawTerminal<std::io::Stdout>>>;
#[cfg(feature = "mouse")]
impl New for Screen {
- fn new() -> std::io::Result<Self> {
- let stdout = std::io::stdout().into_raw_mode()?;
- let alt_screen = MouseTerminal::from(AlternateScreen::from(stdout));
- return Ok(alt_screen);
+ // Returns alternate screen
+ fn new() -> io::Result<Self> {
+ let stdout = io::stdout().into_raw_mode()?;
+ Ok(MouseTerminal::from(stdout.into_alternate_screen().unwrap()))
}
}
#[cfg(not(feature = "mouse"))]
type Screen = AlternateScreen<RawTerminal<std::io::Stdout>>;
#[cfg(not(feature = "mouse"))]
impl New for Screen {
+ // Returns alternate screen
fn new() -> io::Result<Self> {
let stdout = std::io::stdout().into_raw_mode()?;
- let alt_screen = AlternateScreen::from(stdout);
- Ok(alt_screen)
+ Ok(stdout.into_alternate_screen().unwrap())
}
}