feat(tui): add context-sensitive keybinds on bottom border of each panel
This commit is contained in:
1 parent
e5de3c14fc
commit
b0738761c9
5 files changed
+89
-8
No files matched your search
@@ -219,19 +219,25 @@ pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea, state: &mut A
|
|||||||
THEME.colors.border_unfocused
|
THEME.colors.border_unfocused
|
||||||
};
|
};
|
||||||
|
|
||||||
let block = Block::default()
|
let mut block = Block::default()
|
||||||
.title(styled_title("Account", true))
|
.title(styled_title("Account", true))
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_type(BorderType::Rounded)
|
.border_type(BorderType::Rounded)
|
||||||
.border_style(Style::default().fg(color));
|
.border_style(Style::default().fg(color));
|
||||||
|
|
||||||
|
if focused == FocusedArea::Account {
|
||||||
|
block = block.title_bottom(
|
||||||
|
super::popups::keybind_line(&[("⏎", " select"), ("a", " add"), ("d", " del")])
|
||||||
|
.alignment(ratatui::layout::Alignment::Right),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let inner = block.inner(area);
|
let inner = block.inner(area);
|
||||||
frame.render_widget(block, area);
|
frame.render_widget(block, area);
|
||||||
|
|
||||||
if state.store.accounts.is_empty() {
|
if state.store.accounts.is_empty() {
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
Paragraph::new("No accounts.")
|
Paragraph::new("No accounts.").style(Style::default().fg(THEME.colors.text_idle)),
|
||||||
.style(Style::default().fg(THEME.colors.text_idle)),
|
|
||||||
inner,
|
inner,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -138,6 +138,51 @@ pub fn render(
|
|||||||
block = block.title_top(sl);
|
block = block.title_top(sl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if is_focused {
|
||||||
|
let kb: &[(&str, &str)] = match tab {
|
||||||
|
ContentTab::Mods | ContentTab::ResourcePacks | ContentTab::Shaders => &[
|
||||||
|
("j/k", " nav"),
|
||||||
|
("⏎", " toggle"),
|
||||||
|
("S+⏎", " dir"),
|
||||||
|
("h/l", " tabs"),
|
||||||
|
("/", " search"),
|
||||||
|
],
|
||||||
|
ContentTab::Worlds => &[
|
||||||
|
("j/k", " nav"),
|
||||||
|
("S+⏎", " dir"),
|
||||||
|
("h/l", " tabs"),
|
||||||
|
("/", " search"),
|
||||||
|
],
|
||||||
|
ContentTab::Screenshots => &[
|
||||||
|
("S+HJKL", " grid"),
|
||||||
|
("⏎", " open"),
|
||||||
|
("S+⏎", " dir"),
|
||||||
|
("h/l", " tabs"),
|
||||||
|
("/", " search"),
|
||||||
|
],
|
||||||
|
ContentTab::Logs => {
|
||||||
|
if logs_state.viewer_focused {
|
||||||
|
&[
|
||||||
|
("S+JK", " scroll"),
|
||||||
|
("g/G", " top/bot"),
|
||||||
|
("Esc", " back"),
|
||||||
|
("/", " search"),
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
&[
|
||||||
|
("S+JK", " nav"),
|
||||||
|
("⏎", " view"),
|
||||||
|
("h/l", " tabs"),
|
||||||
|
("/", " search"),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
block = block.title_bottom(
|
||||||
|
super::popups::keybind_line(kb).alignment(ratatui::layout::Alignment::Right),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let content_area = block.inner(area);
|
let content_area = block.inner(area);
|
||||||
frame.render_widget(block, area);
|
frame.render_widget(block, area);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::Rect,
|
layout::{Alignment, Rect},
|
||||||
style::Style,
|
style::Style,
|
||||||
widgets::{Block, BorderType, Borders, Paragraph},
|
widgets::{Block, BorderType, Borders},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -19,10 +19,19 @@ pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea) {
|
|||||||
|
|
||||||
let block = Block::default()
|
let block = Block::default()
|
||||||
.title(styled_title("Details", true))
|
.title(styled_title("Details", true))
|
||||||
|
.title_bottom(
|
||||||
|
super::popups::keybind_line(&[
|
||||||
|
("P", " profiles"),
|
||||||
|
("C", " content"),
|
||||||
|
("A", " account"),
|
||||||
|
("S", " logs"),
|
||||||
|
("q", " quit"),
|
||||||
|
])
|
||||||
|
.alignment(Alignment::Right),
|
||||||
|
)
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_type(BorderType::Rounded)
|
.border_type(BorderType::Rounded)
|
||||||
.border_style(Style::default().fg(color));
|
.border_style(Style::default().fg(color));
|
||||||
|
|
||||||
let widget = Paragraph::new("TEST CONTENT").block(block);
|
frame.render_widget(block, area);
|
||||||
frame.render_widget(widget, area);
|
|
||||||
}
|
}
|
||||||
@@ -207,6 +207,20 @@ pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea, state: &mut S
|
|||||||
block = block.title_top(search_line);
|
block = block.title_top(search_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if focused == FocusedArea::Profiles {
|
||||||
|
block = block.title_bottom(
|
||||||
|
super::popups::keybind_line(&[
|
||||||
|
("l", " launch"),
|
||||||
|
("⏎", " content"),
|
||||||
|
("a", " add"),
|
||||||
|
("d", " del"),
|
||||||
|
("/", " search"),
|
||||||
|
("Esc", " kill"),
|
||||||
|
])
|
||||||
|
.alignment(ratatui::layout::Alignment::Right),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let scrollbar_area = Rect {
|
let scrollbar_area = Rect {
|
||||||
x: area.x + area.width.saturating_sub(1),
|
x: area.x + area.width.saturating_sub(1),
|
||||||
y: area.y + 1,
|
y: area.y + 1,
|
||||||
|
|||||||
@@ -25,12 +25,19 @@ pub fn render(
|
|||||||
THEME.colors.border_unfocused
|
THEME.colors.border_unfocused
|
||||||
};
|
};
|
||||||
|
|
||||||
let block = Block::default()
|
let mut block = Block::default()
|
||||||
.title(styled_title("Status", true))
|
.title(styled_title("Status", true))
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_type(BorderType::Rounded)
|
.border_type(BorderType::Rounded)
|
||||||
.border_style(Style::default().fg(border_color));
|
.border_style(Style::default().fg(border_color));
|
||||||
|
|
||||||
|
if focused == FocusedArea::Status {
|
||||||
|
block = block.title_bottom(
|
||||||
|
super::popups::keybind_line(&[("S", " expand")])
|
||||||
|
.alignment(ratatui::layout::Alignment::Right),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let state = match PROGRESS.lock() {
|
let state = match PROGRESS.lock() {
|
||||||
Ok(s) => s.clone(),
|
Ok(s) => s.clone(),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
|||||||
Reference in new issue
Block a user