on master help sign in
add wonly -- window only (#1057)

* add wonly * Update book/src/keymap.md Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> * add `wonly` to space w mode too * remove the TODO Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

commit4d22454386d52d14f626b209016a71f119cc1cbf authorBob <QiBaobin@users.noreply.github.com> dateThu 11 Nov 2021, 10:32 (5 years ago) parentc7cb752
3 files changed+18
book/src/keymap.md+1 helix-term/src/commands.rs+15 helix-term/src/keymap.rs+2
book/src/keymap.md+1
@@ -194,6 +194,7 @@ This layer is similar to vim keybindings as kakoune does not support window.
194194| `k`, `Ctrl-k`, `up` | Move to split above | `jump_view_up` |
195195| `l`, `Ctrl-l`, `right` | Move to right split | `jump_view_right` |
196196| `q`, `Ctrl-q` | Close current window | `wclose` |
197+| `o`, `Ctrl-o` | Only keep the current window, closing all the others | `wonly` |
197198
198199#### Space mode
199200
helix-term/src/commands.rs+15
@@ -320,6 +320,7 @@ impl Command {
320320 hsplit, "Horizontal bottom split",
321321 vsplit, "Vertical right split",
322322 wclose, "Close window",
323+ wonly, "Current window only",
323324 select_register, "Select register",
324325 align_view_middle, "Align view middle",
325326 align_view_top, "Align view top",
@@ -4723,6 +4724,20 @@ fn wclose(cx: &mut Context) {
47234724 cx.editor.close(view_id, /* close_buffer */ false);
47244725}
47254726
4727+fn wonly(cx: &mut Context) {
4728+ let views = cx
4729+ .editor
4730+ .tree
4731+ .views()
4732+ .map(|(v, focus)| (v.id, focus))
4733+ .collect::<Vec<_>>();
4734+ for (view_id, focus) in views {
4735+ if !focus {
4736+ cx.editor.close(view_id, /* close_buffer */ false);
4737+ }
4738+ }
4739+}
4740+
47264741fn select_register(cx: &mut Context) {
47274742 cx.on_next_key(move |cx, event| {
47284743 if let Some(ch) = event.char() {
helix-term/src/keymap.rs+2
@@ -583,6 +583,7 @@ impl Default for Keymaps {
583583 "C-s" | "s" => hsplit,
584584 "C-v" | "v" => vsplit,
585585 "C-q" | "q" => wclose,
586+ "C-o" | "o" => wonly,
586587 "C-h" | "h" | "left" => jump_view_left,
587588 "C-j" | "j" | "down" => jump_view_down,
588589 "C-k" | "k" | "up" => jump_view_up,
@@ -609,6 +610,7 @@ impl Default for Keymaps {
609610 "C-s" | "s" => hsplit,
610611 "C-v" | "v" => vsplit,
611612 "C-q" | "q" => wclose,
613+ "C-o" | "o" => wonly,
612614 "C-h" | "h" | "left" => jump_view_left,
613615 "C-j" | "j" | "down" => jump_view_down,
614616 "C-k" | "k" | "up" => jump_view_up,