mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-07-31 03:59:07 +02:00
VIM-171 Add support for window cycling
Adds following keystrokes: <C-W>w <C-W><C-W> next window <C-W>W previous window With number both commands go to window with specified index.
This commit is contained in:
parent
095fdf07c5
commit
f46c3b0aa9
resources/META-INF
src/com/maddyhome/idea/vim
@ -321,6 +321,8 @@
|
||||
<action id="VimWindowSplitHorizontal" class="com.maddyhome.idea.vim.action.window.HorizontalSplitAction" text="Split window horizontally"/>
|
||||
<action id="VimWindowClose" class="com.maddyhome.idea.vim.action.window.CloseWindowAction" text="Close current window"/>
|
||||
<action id="VimWindowOnly" class="com.maddyhome.idea.vim.action.window.WindowOnlyAction" text="Close all windows except current"/>
|
||||
<action id="VimWindowNext" class="com.maddyhome.idea.vim.action.window.WindowNextAction" text="Select next window"/>
|
||||
<action id="VimWindowPrev" class="com.maddyhome.idea.vim.action.window.WindowPrevAction" text="Select previous window"/>
|
||||
|
||||
<!-- Search -->
|
||||
<action id="VimSearchFwdEntry" class="com.maddyhome.idea.vim.action.motion.search.SearchEntryFwdAction" text="Search Forward"/>
|
||||
|
@ -681,8 +681,17 @@ public class RegisterActions {
|
||||
new Shortcut(new KeyStroke[]{ KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK),
|
||||
KeyStroke.getKeyStroke('o') }));
|
||||
parser.registerAction(MappingMode.N, "VimWindowOnly", Command.Type.OTHER_READONLY,
|
||||
new Shortcut(new KeyStroke[]{ KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK),
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK) }));
|
||||
parser.registerAction(MappingMode.N, "VimWindowNext", Command.Type.OTHER_READONLY,
|
||||
new Shortcut(new KeyStroke[]{ KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK),
|
||||
KeyStroke.getKeyStroke('w') }));
|
||||
parser.registerAction(MappingMode.N, "VimWindowNext", Command.Type.OTHER_READONLY,
|
||||
new Shortcut(new KeyStroke[]{ KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK),
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK) }));
|
||||
parser.registerAction(MappingMode.N, "VimWindowPrev", Command.Type.OTHER_READONLY,
|
||||
new Shortcut(new KeyStroke[]{ KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK),
|
||||
KeyStroke.getKeyStroke('W') }));
|
||||
|
||||
// Macro Actions
|
||||
parser.registerAction(MappingMode.N, "VimPlaybackLastRegister", Command.Type.OTHER_WRITABLE,
|
||||
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WindowNextAction extends EditorAction {
|
||||
public WindowNextAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
if (cmd.getRawCount() == 0) {
|
||||
VimPlugin.getWindow().selectNextWindow(context);
|
||||
} else {
|
||||
VimPlugin.getWindow().selectWindow(context, cmd.getCount());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2014 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.window;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WindowPrevAction extends EditorAction {
|
||||
public WindowPrevAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends EditorActionHandlerBase {
|
||||
@Override
|
||||
protected boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
if (cmd.getRawCount() == 0) {
|
||||
VimPlugin.getWindow().selectPreviousWindow(context);
|
||||
} else {
|
||||
VimPlugin.getWindow().selectWindow(context, cmd.getCount());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -53,6 +53,29 @@ public class WindowGroup {
|
||||
}
|
||||
}
|
||||
|
||||
public void selectNextWindow(@NotNull DataContext context) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
|
||||
final EditorWindow current = fileEditorManager.getCurrentWindow();
|
||||
fileEditorManager.getNextWindow(current).setAsCurrentWindow(true);
|
||||
}
|
||||
|
||||
public void selectPreviousWindow(@NotNull DataContext context) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
|
||||
final EditorWindow current = fileEditorManager.getCurrentWindow();
|
||||
fileEditorManager.getPrevWindow(current).setAsCurrentWindow(true);
|
||||
}
|
||||
|
||||
public void selectWindow(DataContext context, int index) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
|
||||
EditorWindow[] windows = fileEditorManager.getWindows();
|
||||
if (index - 1 < windows.length) {
|
||||
windows[index - 1].setAsCurrentWindow(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void splitWindowHorizontal(@NotNull DataContext context, String filename) {
|
||||
splitWindow(SwingConstants.HORIZONTAL, context, filename);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user