push help view to stack instead of making it a separate screen
fixes #157
This commit is contained in:
@@ -87,6 +87,7 @@ pub enum Command {
|
|||||||
Move(MoveMode, Option<i32>),
|
Move(MoveMode, Option<i32>),
|
||||||
Shift(ShiftMode, Option<i32>),
|
Shift(ShiftMode, Option<i32>),
|
||||||
Search(String),
|
Search(String),
|
||||||
|
Help,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Command {
|
impl fmt::Display for Command {
|
||||||
@@ -126,6 +127,7 @@ impl fmt::Display for Command {
|
|||||||
Command::Move(mode, amount) => format!("move {} {}", mode, amount.unwrap_or(1)),
|
Command::Move(mode, amount) => format!("move {} {}", mode, amount.unwrap_or(1)),
|
||||||
Command::Shift(mode, amount) => format!("shift {} {}", mode, amount.unwrap_or(1)),
|
Command::Shift(mode, amount) => format!("shift {} {}", mode, amount.unwrap_or(1)),
|
||||||
Command::Search(term) => format!("search {}", term),
|
Command::Search(term) => format!("search {}", term),
|
||||||
|
Command::Help => "help".to_string(),
|
||||||
};
|
};
|
||||||
write!(f, "{}", repr)
|
write!(f, "{}", repr)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use crate::library::Library;
|
|||||||
use crate::queue::{Queue, RepeatSetting};
|
use crate::queue::{Queue, RepeatSetting};
|
||||||
use crate::spotify::{Spotify, VOLUME_PERCENT};
|
use crate::spotify::{Spotify, VOLUME_PERCENT};
|
||||||
use crate::traits::ViewExt;
|
use crate::traits::ViewExt;
|
||||||
|
use crate::ui::help::HelpView;
|
||||||
use crate::ui::layout::Layout;
|
use crate::ui::layout::Layout;
|
||||||
use cursive::event::{Event, Key};
|
use cursive::event::{Event, Key};
|
||||||
use cursive::traits::View;
|
use cursive::traits::View;
|
||||||
@@ -139,6 +140,11 @@ impl CommandManager {
|
|||||||
self.spotify.set_volume(volume);
|
self.spotify.set_volume(volume);
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
Command::Help => {
|
||||||
|
let view = Box::new(HelpView::new(self.keybindings().clone()));
|
||||||
|
s.call_on_name("main", move |v: &mut Layout| v.push_view(view));
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
Command::Search(_)
|
Command::Search(_)
|
||||||
| Command::Move(_, _)
|
| Command::Move(_, _)
|
||||||
| Command::Shift(_, _)
|
| Command::Shift(_, _)
|
||||||
@@ -248,7 +254,7 @@ impl CommandManager {
|
|||||||
kb.insert("F1".into(), Command::Focus("queue".into()));
|
kb.insert("F1".into(), Command::Focus("queue".into()));
|
||||||
kb.insert("F2".into(), Command::Focus("search".into()));
|
kb.insert("F2".into(), Command::Focus("search".into()));
|
||||||
kb.insert("F3".into(), Command::Focus("library".into()));
|
kb.insert("F3".into(), Command::Focus("library".into()));
|
||||||
kb.insert("?".into(), Command::Focus("help".into()));
|
kb.insert("?".into(), Command::Help);
|
||||||
kb.insert("Backspace".into(), Command::Back);
|
kb.insert("Backspace".into(), Command::Back);
|
||||||
|
|
||||||
kb.insert("o".into(), Command::Open(TargetMode::Selected));
|
kb.insert("o".into(), Command::Open(TargetMode::Selected));
|
||||||
|
|||||||
@@ -222,16 +222,13 @@ fn main() {
|
|||||||
|
|
||||||
let queueview = ui::queue::QueueView::new(queue.clone(), library.clone());
|
let queueview = ui::queue::QueueView::new(queue.clone(), library.clone());
|
||||||
|
|
||||||
let helpview = ui::help::HelpView::new(cmd_manager.keybindings().clone());
|
|
||||||
|
|
||||||
let status =
|
let status =
|
||||||
ui::statusbar::StatusBar::new(queue.clone(), library, cfg.use_nerdfont.unwrap_or(false));
|
ui::statusbar::StatusBar::new(queue.clone(), library, cfg.use_nerdfont.unwrap_or(false));
|
||||||
|
|
||||||
let mut layout = ui::layout::Layout::new(status, &event_manager, theme)
|
let mut layout = ui::layout::Layout::new(status, &event_manager, theme)
|
||||||
.view("search", search.with_name("search"), "Search")
|
.view("search", search.with_name("search"), "Search")
|
||||||
.view("library", libraryview.with_name("library"), "Library")
|
.view("library", libraryview.with_name("library"), "Library")
|
||||||
.view("queue", queueview, "Queue")
|
.view("queue", queueview, "Queue");
|
||||||
.view("help", helpview, "Help");
|
|
||||||
|
|
||||||
// initial view is library
|
// initial view is library
|
||||||
layout.set_view("library");
|
layout.set_view("library");
|
||||||
|
|||||||
@@ -42,4 +42,8 @@ impl ViewWrapper for HelpView {
|
|||||||
wrap_impl!(self.view: ScrollView<TextView>);
|
wrap_impl!(self.view: ScrollView<TextView>);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ViewExt for HelpView {}
|
impl ViewExt for HelpView {
|
||||||
|
fn title(&self) -> String {
|
||||||
|
"Help".to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user