diff options
author | Canop <cano.petrole@gmail.com> | 2019-10-29 21:24:30 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2019-10-29 21:24:30 +0100 |
commit | 9882589d942986386cf5f4eafe02f027924db952 (patch) | |
tree | 2140b7a0a4fb0678e348e4a0080c7f3f31128029 | |
parent | cc75ea49789b5f2e16566b563ebce8da15575ef8 (diff) |
totally runs in stderr or a subshell, with mouse events
I contributed to crossterm for this. This new broot version
will be published once the new version of crossterm is
published.
-rw-r--r-- | src/app.rs | 24 | ||||
-rw-r--r-- | src/displayable_tree.rs | 3 | ||||
-rw-r--r-- | src/screens.rs | 9 |
3 files changed, 17 insertions, 19 deletions
@@ -10,7 +10,12 @@ use std::io::Write; use crossterm::{ - cursor, EnterAlternateScreen, queue, LeaveAlternateScreen, + cursor, + DisableMouseCapture, + EnableMouseCapture, + EnterAlternateScreen, + queue, + LeaveAlternateScreen, }; use termimad::EventSource; @@ -231,6 +236,7 @@ impl App { /// called exactly once at end run, cleans the writer (which /// is usually stdout or stderr) fn end(&mut self, writer: &mut W) ->Result<Option<Launchable>, ProgramError> { + queue!(writer, DisableMouseCapture)?; queue!(writer, cursor::Show)?; queue!(writer, LeaveAlternateScreen)?; writer.flush()?; @@ -246,21 +252,17 @@ impl App { skin: Skin, ) -> Result<Option<Launchable>, ProgramError> { - // we listen for events in a separate thread so that we can go on listening - // when a long search is running, and interrupt it if needed - - // mouse_support=true is the last case of having - // things written on stdout when there should not - - let mouse_support = false; // FIXME move to args - let event_source = EventSource::new(mouse_support)?; - let rx_events = event_source.receiver(); - queue!(writer, EnterAlternateScreen)?; queue!(writer, cursor::Hide)?; debug!("we're on screen"); let mut screen = Screen::new(con, skin)?; + // we listen for events in a separate thread so that we can go on listening + // when a long search is running, and interrupt it if needed + queue!(writer, EnableMouseCapture)?; + let event_source = EventSource::new()?; + let rx_events = event_source.receiver(); + // create the initial state if let Some(bs) = BrowserState::new( con.launch_args.root.clone(), diff --git a/src/displayable_tree.rs b/src/displayable_tree.rs index e16831d..194e7b0 100644 --- a/src/displayable_tree.rs +++ b/src/displayable_tree.rs @@ -5,13 +5,12 @@ use std::os::unix::fs::MetadataExt; use chrono::{offset::Local, DateTime}; use crossterm::{ - Clear, - ClearType, Color, Output, cursor, queue, SetBg, + terminal::{Clear, ClearType}, }; use termimad::{ CompoundStyle, diff --git a/src/screens.rs b/src/screens.rs index 07917bb..3e6ab6e 100644 --- a/src/screens.rs +++ b/src/screens.rs @@ -1,7 +1,9 @@ use std::io::Write; use crossterm::{ - Clear, ClearType, cursor, queue, + cursor, + terminal::{Clear, ClearType}, + queue, }; use termimad::{Area, CompoundStyle, InputField}; @@ -66,8 +68,3 @@ impl Screen { Ok(()) } } - -//impl Drop for Screen { -// fn drop(&mut self) { -// } -//} |