From 6e258ad2a4e31b8e98562e2891c435911aef7068 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Wed, 28 Dec 2022 14:12:24 -0500 Subject: [PATCH] Show off combined command --- src/main.rs | 1 - src/ui.rs | 31 ++++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index e7e784d..7a9272c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -131,7 +131,6 @@ impl CommandOptions { } } -// impl App<'_> { impl App { /// Constructs a new instance of `App` /// diff --git a/src/ui.rs b/src/ui.rs index 9d8ccaa..59dce98 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -32,30 +32,31 @@ pub fn draw(f: &mut Frame, app: &App) { event!(Level::INFO, "Rendering orig"); // lazy_render_rope_slice(chunks[0], render_states.stdout) - render_states.stdout = if let Some(text_orig_rope) = app.text_orig_rope.as_ref() { + + let stdin_title = if command_options.combined_command.is_empty() { + String::from("Input") + } else { + format!("Input ({})", command_options.combined_command) + }; + + render_states.stdin = if let Some(text_orig_rope) = app.text_orig_rope.as_ref() { lazy_render_rope_slice( f, chunks[0], render_states.stdin.as_ref(), text_orig_rope.slice(..), - "Output", + stdin_title.as_str(), ) } else { f.render_widget( Paragraph::new("! No Stdin !") .alignment(Alignment::Center) - .block(Block::default().title("Output").borders(Borders::ALL)), - chunks[0], // Layout::default() - // .direction(Direction::Vertical) - // .constraints( - // [ - // Constraint::Percentage(50), - // Constraint::Length(1), - // Constraint::Min(0), - // ] - // .as_ref(), - // ) - // .split(chunks[0])[1], + .block( + Block::default() + .title(stdin_title.as_str()) + .borders(Borders::ALL), + ), + chunks[0], ); Some(RenderState { // TODO @@ -161,7 +162,7 @@ fn lazy_render_rope_slice<'a, B: Backend>( output: Rect, previous_state: Option<&RenderState>, data: RopeSlice<'_>, - block_title: &'static str, + block_title: &str, ) -> Option { let data = data .lines()