diff options
author | Sam Tay <samctay@pm.me> | 2022-08-24 13:40:35 -0700 |
---|---|---|
committer | Sam Tay <samctay@pm.me> | 2022-08-24 17:21:58 -0700 |
commit | 55964a28bdccd05f1c607ea122d38a8bb3839c7f (patch) | |
tree | abc42a95e101f6547df906fc58300c5b36ed9267 | |
parent | 10ed5b0e873cc5db17cb2387d758b2f3dea4f5ab (diff) |
Add help text, closes #24
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/tui/app.rs | 24 |
2 files changed, 14 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d2ed537..661e02b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 #### Added - Allow `o` keybinding from the lucky prompt. +- Permanent help text ([#24](https://github.com/samtay/so/issues/24)). #### Fixed - Hardcoded stackoverflow link diff --git a/src/tui/app.rs b/src/tui/app.rs index 95bf089..0f05d2c 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -8,7 +8,7 @@ use cursive::theme::{BaseColor, Color, Effect, Style}; use cursive::traits::{Nameable, Scrollable}; use cursive::utils::markup::StyledString; use cursive::utils::span::SpannedString; -use cursive::views::{Dialog, TextView, ViewRef}; +use cursive::views::{Dialog, LinearLayout, TextView, ViewRef}; use cursive::Cursive; use cursive::XY; @@ -77,16 +77,17 @@ impl App { s.call_on_name(NAME_ANSWER_VIEW, |v: &mut MdView| v.set_content(&a.body)); }); - siv.add_layer( - LayoutView::new( - 1, - question_list_view, - question_view, - answer_list_view, - answer_view, - ) - .add_vim_bindings(), - ); + let main_layout = LayoutView::new( + 1, + question_list_view, + question_view, + answer_list_view, + answer_view, + ) + .add_vim_bindings(); + let hint_text = TextView::new("? help \u{00B7} q quit"); + + siv.add_layer(LinearLayout::vertical().child(main_layout).child(hint_text)); let cb = siv.call_on_name(NAME_QUESTION_LIST, |v: &mut ListView| v.select(0)); if let Some(cb) = cb { @@ -154,6 +155,7 @@ impl App { } }); + // Close any open dialogs siv.add_global_callback(Event::Key(Key::Esc), |s| { if let Some(pos) = s.screen_mut().find_layer_from_name(NAME_HELP_VIEW) { s.screen_mut().remove_layer(pos); |