fix: config option command_key not working
This commit is contained in:
committed by
Henrik Friedrichsen
parent
ac0bcb4420
commit
6c990b5bda
@@ -14,6 +14,7 @@ use crate::serialization::{Serializer, CBOR, TOML};
|
||||
|
||||
pub const CLIENT_ID: &str = "d420a117a32841c2b3474932e49fb54b";
|
||||
pub const CACHE_VERSION: u16 = 1;
|
||||
pub const DEFAULT_COMMAND_KEY: char = ':';
|
||||
|
||||
/// The playback state when ncspot is started.
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
|
||||
@@ -17,7 +17,7 @@ use unicode_width::UnicodeWidthStr;
|
||||
use crate::application::UserData;
|
||||
use crate::command::{self, Command, JumpMode};
|
||||
use crate::commands::CommandResult;
|
||||
use crate::config::Config;
|
||||
use crate::config::{self, Config};
|
||||
use crate::events;
|
||||
use crate::ext_traits::CursiveExt;
|
||||
use crate::traits::{IntoBoxedViewExt, ViewExt};
|
||||
@@ -358,28 +358,43 @@ impl View for Layout {
|
||||
|
||||
fn on_event(&mut self, event: Event) -> EventResult {
|
||||
match event {
|
||||
Event::Char(':') | Event::Char('/') => {
|
||||
let result = if let Some(view) = self.get_current_view_mut() {
|
||||
view.on_event(event.relativized((0, 1)))
|
||||
} else {
|
||||
EventResult::Ignored
|
||||
};
|
||||
|
||||
if let EventResult::Ignored = result {
|
||||
if let Event::Char(':') = event {
|
||||
let command_key = self.configuration.values().command_key.unwrap_or(':');
|
||||
self.enable_cmdline(command_key);
|
||||
} else {
|
||||
self.enable_jump();
|
||||
}
|
||||
} else {
|
||||
return EventResult::Ignored;
|
||||
}
|
||||
}
|
||||
Event::Key(Key::Esc) if self.cmdline_focus => self.clear_cmdline(),
|
||||
_ if self.cmdline_focus => {
|
||||
return self.command_line_handle_event(event);
|
||||
}
|
||||
Event::Char(character)
|
||||
if !self.cmdline_focus
|
||||
&& (character
|
||||
== self
|
||||
.configuration
|
||||
.values()
|
||||
.command_key
|
||||
.unwrap_or(config::DEFAULT_COMMAND_KEY)
|
||||
|| character == '/') =>
|
||||
{
|
||||
let result = self
|
||||
.get_current_view_mut()
|
||||
.map(|view| view.on_event(event))
|
||||
.unwrap_or(EventResult::Ignored);
|
||||
|
||||
if let EventResult::Ignored = result {
|
||||
let command_key = self
|
||||
.configuration
|
||||
.values()
|
||||
.command_key
|
||||
.unwrap_or(config::DEFAULT_COMMAND_KEY);
|
||||
|
||||
if character == command_key {
|
||||
self.enable_cmdline(command_key);
|
||||
} else if character == '/' {
|
||||
self.enable_jump();
|
||||
} else {
|
||||
return EventResult::Ignored;
|
||||
}
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Event::Mouse {
|
||||
position,
|
||||
event: mouse_event,
|
||||
|
||||
Reference in New Issue
Block a user