Skip to content

Commit

Permalink
Handle ctrl+w hotkey
Browse files Browse the repository at this point in the history
  • Loading branch information
l4l committed Dec 22, 2020
1 parent 74c3407 commit 3524df6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ These cannot be configured yet, so the following keys are handled:
- **Up**/**Down** — select item at the menu;
- **Return** — launches selected app;
- **Ctrl+]** — clears the input.
- **Ctrl+w** — erases a single word (i.e. until first alphanumeric symbol).
11 changes: 11 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ impl State {
ctrl: true,
..
} => self.input_buf.clear(),
KeyPress {
keysym: keysyms::XKB_KEY_w,
ctrl: true,
..
} => {
if let Some(pos) = self.input_buf.rfind(|x: char| !x.is_alphanumeric()) {
self.input_buf.truncate(pos);
} else {
self.input_buf.clear();
}
}
KeyPress { sym: Some(sym), .. } if !sym.is_control() && !event.ctrl => {
self.input_buf.push(sym)
}
Expand Down

0 comments on commit 3524df6

Please sign in to comment.