Skip to content

Commit

Permalink
Back button
Browse files Browse the repository at this point in the history
  • Loading branch information
ahqsoftwares committed Feb 2, 2025
1 parent 9ff43e2 commit 74425c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lead_docs_cli/src/viewer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cursive::{
event::Key, menu::Tree, theme::Theme, view::Resizable, views::{Dialog, SelectView, TextContent, TextView}, Cursive, CursiveExt
event::Key, menu::Tree, theme::Theme, view::{Resizable, Scrollable}, views::{Dialog, SelectView, TextContent, TextView}, Cursive, CursiveExt
};
use select::{open_pkg, sel_method, select_pkg, show_doc};

Expand Down Expand Up @@ -99,6 +99,8 @@ pub fn run_cursive() {
}

pub fn home(siv: &mut Cursive) {
while let Some(_) = siv.pop_layer() {}

let len = siv.menubar().len();
siv.menubar().remove(len - 1);
siv.menubar().add_leaf(
Expand Down Expand Up @@ -137,6 +139,7 @@ pub fn home(siv: &mut Cursive) {
.on_submit(move |c, v| {
handle(c, *v);
})
.scrollable()
.fixed_size((20, 6)),
)
.title("Select")
Expand Down
12 changes: 8 additions & 4 deletions lead_docs_cli/src/viewer/select.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cursive::{utils::markup::markdown::parse, view::{Resizable, Scrollable}, views::{Dialog, SelectView, TextView}, Cursive, With};

use crate::utils::{docs::{self, PackageEntry}, package::Package};
use super::{ApplicationRoot, ApplicationState, RawPtr};
use super::{home, ApplicationRoot, ApplicationState, RawPtr};

pub fn select_pkg(c: &mut Cursive) {
while let Some(_) = c.pop_layer() {}
Expand Down Expand Up @@ -35,9 +35,10 @@ pub fn select_pkg(c: &mut Cursive) {

c.add_layer(
Dialog::around(
view
view.scrollable()
)
.title("Select package")
.button("↰ Back", |siv| home(siv))
.dismiss_button("Close")
.full_screen(),
);
Expand Down Expand Up @@ -71,9 +72,10 @@ pub fn open_pkg(c: &mut Cursive) {

c.add_layer(
Dialog::around(
view
view.scrollable()
)
.title(unsafe { &*name })
.button("↰ Back", |siv| select_pkg(siv))
.dismiss_button("Close")
.full_screen(),
);
Expand Down Expand Up @@ -108,9 +110,10 @@ pub fn sel_method(c: &mut Cursive) {

c.add_layer(
Dialog::around(
view
view.scrollable()
)
.title(name)
.button("↰ Back", |siv| open_pkg(siv))
.dismiss_button("Close")
.full_screen(),
);
Expand Down Expand Up @@ -139,6 +142,7 @@ pub fn show_doc(c: &mut Cursive) {
.scrollable()
)
.title(name)
.button("↰ Back", |siv| sel_method(siv))
.dismiss_button("Close")
.full_screen(),
);
Expand Down

0 comments on commit 74425c1

Please sign in to comment.