mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-20 05:39:52 -07:00
Window keybindings should be mapped in Visual mode (#37)
This commit is contained in:
parent
8eef8787cc
commit
4c5c57e26c
4 changed files with 324 additions and 12 deletions
|
@ -7,7 +7,9 @@ use modalkit::{
|
|||
input::key::TerminalKey,
|
||||
};
|
||||
|
||||
use crate::base::{IambAction, Keybindings};
|
||||
use crate::base::{IambAction, IambInfo, Keybindings};
|
||||
|
||||
type IambStep = InputStep<IambInfo>;
|
||||
|
||||
/// Find the boundaries for a Matrix username, room alias, or room ID.
|
||||
///
|
||||
|
@ -44,19 +46,27 @@ pub fn setup_keybindings() -> Keybindings {
|
|||
(EdgeRepeat::Once, ctrl_w.clone()),
|
||||
(EdgeRepeat::Once, ctrl_z),
|
||||
];
|
||||
let zoom = InputStep::new().actions(vec![WindowAction::ZoomToggle.into()]);
|
||||
let zoom = IambStep::new()
|
||||
.actions(vec![WindowAction::ZoomToggle.into()])
|
||||
.goto(VimMode::Normal);
|
||||
|
||||
ism.add_mapping(VimMode::Normal, &cwz, &zoom);
|
||||
ism.add_mapping(VimMode::Visual, &cwz, &zoom);
|
||||
ism.add_mapping(VimMode::Normal, &cwcz, &zoom);
|
||||
ism.add_mapping(VimMode::Visual, &cwcz, &zoom);
|
||||
|
||||
let cwm = vec![
|
||||
(EdgeRepeat::Once, ctrl_w.clone()),
|
||||
(EdgeRepeat::Once, key_m_lc),
|
||||
];
|
||||
let cwcm = vec![(EdgeRepeat::Once, ctrl_w), (EdgeRepeat::Once, ctrl_m)];
|
||||
let stoggle = InputStep::new().actions(vec![IambAction::ToggleScrollbackFocus.into()]);
|
||||
let stoggle = IambStep::new()
|
||||
.actions(vec![IambAction::ToggleScrollbackFocus.into()])
|
||||
.goto(VimMode::Normal);
|
||||
ism.add_mapping(VimMode::Normal, &cwm, &stoggle);
|
||||
ism.add_mapping(VimMode::Visual, &cwm, &stoggle);
|
||||
ism.add_mapping(VimMode::Normal, &cwcm, &stoggle);
|
||||
ism.add_mapping(VimMode::Visual, &cwcm, &stoggle);
|
||||
|
||||
return ism;
|
||||
}
|
||||
|
|
|
@ -591,7 +591,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
|
|||
let needle = match ctx.get_search_regex() {
|
||||
Some(re) => re,
|
||||
None => {
|
||||
let lsearch = store.registers.get(&Register::LastSearch);
|
||||
let lsearch = store.registers.get(&Register::LastSearch)?;
|
||||
let lsearch = lsearch.value.to_string();
|
||||
|
||||
Regex::new(lsearch.as_ref())?
|
||||
|
@ -677,7 +677,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
|
|||
let needle = match ctx.get_search_regex() {
|
||||
Some(re) => re,
|
||||
None => {
|
||||
let lsearch = store.registers.get(&Register::LastSearch);
|
||||
let lsearch = store.registers.get(&Register::LastSearch)?;
|
||||
let lsearch = lsearch.value.to_string();
|
||||
|
||||
Regex::new(lsearch.as_ref())?
|
||||
|
@ -725,7 +725,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
|
|||
flags |= RegisterPutFlags::APPEND;
|
||||
}
|
||||
|
||||
store.registers.put(®ister, cell, flags);
|
||||
store.registers.put(®ister, cell, flags)?;
|
||||
}
|
||||
|
||||
return Ok(None);
|
||||
|
@ -733,7 +733,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
|
|||
|
||||
// Everything else is a modifying action.
|
||||
EditAction::ChangeCase(_) => Err(EditError::ReadOnly),
|
||||
EditAction::ChangeNumber(_) => Err(EditError::ReadOnly),
|
||||
EditAction::ChangeNumber(_, _) => Err(EditError::ReadOnly),
|
||||
EditAction::Delete => Err(EditError::ReadOnly),
|
||||
EditAction::Format => Err(EditError::ReadOnly),
|
||||
EditAction::Indent(_) => Err(EditError::ReadOnly),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue