Compare commits

...
2 Commits
Author SHA1 Message Date
chylex 0a9a48fadb Release version 0.6.10 2026-09-13 11:04:42 +02:00
chylex 36ecd772b1 Make vim-style binding for Move Up / Down work in all tables 2026-09-13 11:03:48 +02:00
2 changed files with 19 additions and 3 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ plugins {
} }
group = "com.chylex.intellij.keyboardmaster" group = "com.chylex.intellij.keyboardmaster"
version = "0.6.9" version = "0.6.10"
repositories { repositories {
mavenCentral() mavenCentral()
@@ -34,6 +34,9 @@ internal object VimTableNavigation {
KeyStroke.getKeyStroke('K') to IdeaAction("Table-selectPreviousRowExtendSelection"), KeyStroke.getKeyStroke('K') to IdeaAction("Table-selectPreviousRowExtendSelection"),
KeyStroke.getKeyStroke('l') to IdeaAction("Table-selectNextColumn"), KeyStroke.getKeyStroke('l') to IdeaAction("Table-selectNextColumn"),
KeyStroke.getKeyStroke('L') to IdeaAction("Table-selectNextColumnExtendSelection"), KeyStroke.getKeyStroke('L') to IdeaAction("Table-selectNextColumnExtendSelection"),
KeyStroke.getKeyStroke(' ') to StartEditingSelectedCell,
KeyStroke.getKeyStroke(KeyEvent.VK_J, KeyEvent.ALT_DOWN_MASK) to DispatchKeyEvent(KeyEvent.VK_DOWN, KeyEvent.CHAR_UNDEFINED, KeyEvent.ALT_DOWN_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_K, KeyEvent.ALT_DOWN_MASK) to DispatchKeyEvent(KeyEvent.VK_UP, KeyEvent.CHAR_UNDEFINED, KeyEvent.ALT_DOWN_MASK),
*withShiftModifier(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK) { ScrollVerticallyAndSelect(pages = -1.0F, extendSelection = it) }, *withShiftModifier(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK) { ScrollVerticallyAndSelect(pages = -1.0F, extendSelection = it) },
*withShiftModifier(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK) { ScrollVerticallyAndSelect(pages = +0.5F, extendSelection = it) }, *withShiftModifier(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK) { ScrollVerticallyAndSelect(pages = +0.5F, extendSelection = it) },
*withShiftModifier(KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK) { ScrollVerticallyAndSelect(pages = +1.0F, extendSelection = it) }, *withShiftModifier(KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK) { ScrollVerticallyAndSelect(pages = +1.0F, extendSelection = it) },
@@ -52,10 +55,9 @@ internal object VimTableNavigation {
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0) to IdeaAction("Git.CheckoutRevision"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0) to IdeaAction("Git.CheckoutRevision"),
) )
) )
private val GIT_REBASE_TABLE_ROOT_NODE = BASIC_ROOT_NODE + Parent( private val GIT_REBASE_TABLE_ROOT_NODE = BASIC_ROOT_NODE + Parent(
mapOf( mapOf(
KeyStroke.getKeyStroke(KeyEvent.VK_J, KeyEvent.ALT_DOWN_MASK) to DispatchKeyEvent(KeyEvent.VK_DOWN, KeyEvent.CHAR_UNDEFINED, KeyEvent.ALT_DOWN_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_K, KeyEvent.ALT_DOWN_MASK) to DispatchKeyEvent(KeyEvent.VK_UP, KeyEvent.CHAR_UNDEFINED, KeyEvent.ALT_DOWN_MASK),
KeyStroke.getKeyStroke('d') to DispatchKeyEvent(KeyEvent.VK_D, 'd', KeyEvent.ALT_DOWN_MASK), KeyStroke.getKeyStroke('d') to DispatchKeyEvent(KeyEvent.VK_D, 'd', KeyEvent.ALT_DOWN_MASK),
KeyStroke.getKeyStroke('e') to DispatchKeyEvent(KeyEvent.VK_E, 'e', KeyEvent.ALT_DOWN_MASK), KeyStroke.getKeyStroke('e') to DispatchKeyEvent(KeyEvent.VK_E, 'e', KeyEvent.ALT_DOWN_MASK),
KeyStroke.getKeyStroke('f') to DispatchKeyEvent(KeyEvent.VK_F, 'f', KeyEvent.ALT_DOWN_MASK), KeyStroke.getKeyStroke('f') to DispatchKeyEvent(KeyEvent.VK_F, 'f', KeyEvent.ALT_DOWN_MASK),
@@ -68,6 +70,7 @@ internal object VimTableNavigation {
fun install(component: JTable) { fun install(component: JTable) {
if (component.getUserData(KEY) == null) { if (component.getUserData(KEY) == null) {
component.putUserData(KEY, VimNavigationDispatcher(component, pickRootNode(component))) component.putUserData(KEY, VimNavigationDispatcher(component, pickRootNode(component)))
component.putClientProperty("JTable.autoStartsEdit", false)
} }
} }
@@ -104,6 +107,19 @@ internal object VimTableNavigation {
} }
} }
private object StartEditingSelectedCell : ActionNode<VimNavigationDispatcher<JTable>> {
override fun performAction(holder: VimNavigationDispatcher<JTable>, actionEvent: AnActionEvent, keyEvent: KeyEvent) {
val table = holder.component
if (table.isEditing) {
return
}
val rowIndex = table.selectionModel.leadSelectionIndex
val columnIndex = table.columnModel.selectionModel.leadSelectionIndex
table.editCellAt(rowIndex, columnIndex)
}
}
private data class DispatchKeyEvent(private val keyCode: Int, private val keyChar: Char, private val modifiers: Int) : ActionNode<VimNavigationDispatcher<JTable>> { private data class DispatchKeyEvent(private val keyCode: Int, private val keyChar: Char, private val modifiers: Int) : ActionNode<VimNavigationDispatcher<JTable>> {
override fun performAction(holder: VimNavigationDispatcher<JTable>, actionEvent: AnActionEvent, keyEvent: KeyEvent) { override fun performAction(holder: VimNavigationDispatcher<JTable>, actionEvent: AnActionEvent, keyEvent: KeyEvent) {
with(IdeEventQueue.getInstance().keyEventDispatcher) { with(IdeEventQueue.getInstance().keyEventDispatcher) {