-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] changed the render method to take impl FrameWrapperInstance ins…
…tead of Frame<B>
- Loading branch information
1 parent
495eae4
commit 57d729b
Showing
2 changed files
with
49 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,63 @@ | ||
use ratatui::{ | ||
backend::Backend, | ||
layout::{Constraint, Direction, Layout, Rect}, | ||
style::{Color, Style}, | ||
widgets::{Block, Borders, Clear, Paragraph}, | ||
Frame, | ||
}; | ||
|
||
use crate::runner::FrameWrapperInterface; | ||
|
||
pub struct HelpWindow; | ||
|
||
impl HelpWindow { | ||
pub fn new() -> Self { | ||
HelpWindow | ||
} | ||
|
||
pub fn render<B: Backend>(&self, f: &mut Frame<B>, area: Rect) { | ||
let block = Block::default() | ||
.title("Help") | ||
.borders(Borders::ALL) | ||
.style(Style::default().fg(Color::White).bg(Color::Black)); | ||
|
||
let inner_area = block.inner(area); | ||
|
||
let chunks = Layout::default() | ||
.direction(Direction::Vertical) | ||
.constraints([ | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
]) | ||
.split(inner_area); | ||
|
||
let help_text = vec![ | ||
"Navigation:", | ||
"s - Start/unpause the test", | ||
"Esc - Pause the test", | ||
"q - Quit", | ||
"", | ||
"Configuration:", | ||
"--duration <seconds> - Set test duration", | ||
"--numbers - Include numbers in the test", | ||
"--uppercase - Include uppercase letters", | ||
"Run 'donkeytype help' for more options", | ||
]; | ||
|
||
for (i, &text) in help_text.iter().enumerate() { | ||
let paragraph = Paragraph::new(text).style(Style::default().fg(Color::White)); | ||
f.render_widget(paragraph, chunks[i]); | ||
pub fn render(&self, frame: &mut impl FrameWrapperInterface, area: Rect) { | ||
let block = Block::default() | ||
.title("Help") | ||
.borders(Borders::ALL) | ||
.style(Style::default().fg(Color::White).bg(Color::Black)); | ||
|
||
let inner_area = block.inner(area); | ||
|
||
let chunks = Layout::default() | ||
.direction(Direction::Vertical) | ||
.constraints([ | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
Constraint::Length(1), | ||
]) | ||
.split(inner_area); | ||
|
||
let help_text = vec![ | ||
"Navigation:", | ||
"s - Start/unpause the test", | ||
"Esc - Pause the test", | ||
"q - Quit", | ||
"", | ||
"Configuration:", | ||
"--duration <seconds> - Set test duration", | ||
"--numbers - Include numbers in the test", | ||
"--uppercase - Include uppercase letters", | ||
"Run 'donkeytype help' for more options", | ||
]; | ||
|
||
// Render Clear widget first | ||
frame.render_widget(Clear, area); | ||
|
||
// Render block | ||
frame.render_widget(block, area); | ||
|
||
// Render text paragraphs | ||
for (i, &text) in help_text.iter().enumerate() { | ||
let paragraph = Paragraph::new(text).style(Style::default().fg(Color::White)); | ||
frame.render_widget(paragraph, chunks[i]); | ||
} | ||
} | ||
|
||
f.render_widget(Clear, area); | ||
f.render_widget(block, area); | ||
} | ||
} |
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