fix search command and update docs

fixes #353
This commit is contained in:
Henrik Friedrichsen
2021-01-02 22:18:41 +01:00
parent 919a245649
commit 3c66379cc6
4 changed files with 11 additions and 8 deletions

View File

@@ -144,9 +144,9 @@ are supported:
* a | asc | ascending
* d | desc | descending
The screens can be opened with `queue`, `search`, `playlists` and `log`, whereas
`search` can be supplied with a search term that will be entered after opening
the search view.
The screens can be opened with `focus <queue|search|library>`.
The `search` command can be supplied with a search term that will be
entered after opening the search view.
To close the commandprompt at any time, press `esc`.

View File

@@ -258,9 +258,7 @@ pub fn parse(input: &str) -> Option<Command> {
})
.map(Command::Open),
"jump" => Some(Command::Jump(JumpMode::Query(args.join(" ")))),
"search" => args
.get(0)
.map(|query| Command::Search((*query).to_string())),
"search" => Some(Command::Search(args.join(" "))),
"shift" => {
let amount = args.get(1).and_then(|amount| amount.parse().ok());

View File

@@ -195,8 +195,7 @@ impl CommandManager {
}
Ok(None)
}
Command::Search(_)
| Command::Jump(_)
Command::Jump(_)
| Command::Move(_, _)
| Command::Shift(_, _)
| Command::Play

View File

@@ -293,6 +293,12 @@ impl View for Layout {
impl ViewExt for Layout {
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
match cmd {
Command::Search(_) => {
self.set_view("search");
self.get_current_screen_mut()
.map(|search| search.view.on_command(s, cmd));
Ok(CommandResult::Consumed(None))
}
Command::Focus(view) => {
if self.views.keys().any(|k| k == view) {
self.set_view(view.clone());