Skip to content

Commit

Permalink
feat(tui): use stdout for rendering (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun authored Oct 10, 2024
1 parent fd081f0 commit cb27463
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn start_tui(analyzer: Analyzer, args: Args) -> Result<()> {
state.set_tab(args.tab);

// Initialize the terminal user interface.
let backend = CrosstermBackend::new(io::stderr());
let backend = CrosstermBackend::new(io::stdout());
let terminal = Terminal::new(backend)?;
let events = EventHandler::new(250);
state.analyzer.extract_strings(events.sender.clone());
Expand Down
8 changes: 4 additions & 4 deletions src/tui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<B: Backend> Tui<B> {
/// It enables the raw mode and sets terminal properties.
pub fn init(&mut self) -> Result<()> {
terminal::enable_raw_mode()?;
ratatui::crossterm::execute!(io::stderr(), EnterAlternateScreen, EnableMouseCapture)?;
ratatui::crossterm::execute!(io::stdout(), EnterAlternateScreen, EnableMouseCapture)?;
panic::set_hook(Box::new(move |panic| {
Self::reset().expect("failed to reset the terminal");
better_panic::Settings::auto()
Expand Down Expand Up @@ -99,8 +99,8 @@ impl<B: Backend> Tui<B> {
/// It disables the raw mode and reverts back the terminal properties.
pub fn reset() -> Result<()> {
terminal::disable_raw_mode()?;
ratatui::crossterm::execute!(io::stderr(), LeaveAlternateScreen, DisableMouseCapture)?;
Terminal::new(CrosstermBackend::new(io::stderr()))?.show_cursor()?;
ratatui::crossterm::execute!(io::stdout(), LeaveAlternateScreen, DisableMouseCapture)?;
Terminal::new(CrosstermBackend::new(io::stdout()))?.show_cursor()?;
Ok(())
}

Expand All @@ -109,7 +109,7 @@ impl<B: Backend> Tui<B> {
/// It disables the raw mode and reverts back the terminal properties.
pub fn exit(&mut self) -> Result<()> {
terminal::disable_raw_mode()?;
ratatui::crossterm::execute!(io::stderr(), LeaveAlternateScreen, DisableMouseCapture)?;
ratatui::crossterm::execute!(io::stdout(), LeaveAlternateScreen, DisableMouseCapture)?;
self.terminal.show_cursor()?;
self.events.stop();
Ok(())
Expand Down

0 comments on commit cb27463

Please sign in to comment.