-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Printing and scrolling through output
- Loading branch information
1 parent
4c1214d
commit 56eb529
Showing
5 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use anyhow::Result; | ||
|
||
use crate::app_state::AppState; | ||
|
||
pub fn execute(app_state: &mut AppState) -> Result<()> { | ||
let command = app_state.ui_state.user_input.clone(); | ||
app_state | ||
.ui_state | ||
.output | ||
.push(format!("Executing: {}", command)); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
use ratatui::widgets::{Block, BorderType, Borders, Paragraph, Widget}; | ||
use ratatui::{ | ||
text::Line, | ||
widgets::{Block, BorderType, Borders, Padding, Paragraph, Widget}, | ||
}; | ||
|
||
use crate::app_state::AppState; | ||
|
||
pub(super) fn build(app_state: &AppState) -> impl Widget { | ||
let block = Block::default() | ||
.title("Output") | ||
.borders(Borders::ALL) | ||
.border_type(BorderType::Rounded); | ||
.border_type(BorderType::Rounded) | ||
.padding(Padding::horizontal(1)); | ||
|
||
Paragraph::new(app_state.ui_state.output.clone()).block(block) | ||
let output = app_state | ||
.ui_state | ||
.output | ||
.iter() | ||
.rev() | ||
.map(|s| Line::from(s.clone())) | ||
.collect::<Vec<_>>(); | ||
|
||
Paragraph::new(output) | ||
.block(block) | ||
.scroll((app_state.ui_state.output_offset, 0)) | ||
} |