Skip to content

Commit 1536c9e

Browse files
committed
add help message with examples
1 parent 54f9f49 commit 1536c9e

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

oryx-tui/src/section/metrics.rs

+42-14
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use tui_input::{backend::crossterm::EventHandler, Input};
1313
use ratatui::{
1414
layout::{Alignment, Constraint, Direction, Flex, Layout, Margin, Rect},
1515
style::{Color, Style, Stylize},
16-
text::Line,
16+
text::{Line, Text},
1717
widgets::{
1818
Bar, BarChart, BarGroup, Block, BorderType, Borders, Cell, Clear, HighlightSpacing,
1919
Padding, Row, Scrollbar, ScrollbarOrientation, ScrollbarState, Table,
@@ -385,7 +385,7 @@ impl Metrics {
385385
.direction(Direction::Vertical)
386386
.constraints([
387387
Constraint::Fill(1),
388-
Constraint::Length(9),
388+
Constraint::Length(10), // Form
389389
Constraint::Fill(1),
390390
])
391391
.flex(ratatui::layout::Flex::SpaceBetween)
@@ -401,6 +401,16 @@ impl Metrics {
401401
.flex(ratatui::layout::Flex::SpaceBetween)
402402
.split(layout[1])[1];
403403

404+
let (form_block, message_block) = {
405+
let chunks = Layout::default()
406+
.direction(Direction::Vertical)
407+
.constraints([Constraint::Fill(1), Constraint::Length(3)])
408+
.flex(ratatui::layout::Flex::SpaceBetween)
409+
.split(block);
410+
411+
(chunks[0], chunks[1])
412+
};
413+
404414
//TODO: Center
405415
let rows = [
406416
Row::new(vec![
@@ -438,19 +448,37 @@ impl Metrics {
438448
)
439449
.column_spacing(2)
440450
.flex(Flex::SpaceBetween)
441-
.highlight_spacing(HighlightSpacing::Always)
442-
.block(
443-
Block::default()
444-
.title(" Metrics Explorer ")
445-
.bold()
446-
.title_alignment(ratatui::layout::Alignment::Center)
447-
.borders(Borders::all())
448-
.border_type(ratatui::widgets::BorderType::Thick)
449-
.border_style(Style::default().green())
450-
.padding(Padding::uniform(1)),
451-
);
451+
.highlight_spacing(HighlightSpacing::Always);
452+
453+
let help_message =
454+
Text::styled("💡Examples: 443, 8080, 5555-9999", Style::new().dark_gray()).centered();
452455

453456
frame.render_widget(Clear, block);
454-
frame.render_widget(table, block);
457+
frame.render_widget(
458+
table,
459+
form_block.inner(Margin {
460+
horizontal: 2,
461+
vertical: 0,
462+
}),
463+
);
464+
frame.render_widget(
465+
help_message,
466+
message_block.inner(Margin {
467+
horizontal: 2,
468+
vertical: 0,
469+
}),
470+
);
471+
472+
frame.render_widget(
473+
Block::default()
474+
.title(" Metrics Explorer ")
475+
.bold()
476+
.title_alignment(ratatui::layout::Alignment::Center)
477+
.borders(Borders::all())
478+
.border_type(ratatui::widgets::BorderType::Thick)
479+
.border_style(Style::default().green())
480+
.padding(Padding::uniform(1)),
481+
block,
482+
);
455483
}
456484
}

0 commit comments

Comments
 (0)