mirror of
https://github.com/chylex/IntelliJ-Keyboard-Master.git
synced 2026-10-16 23:33:57 +02:00
Compare commits
4
Commits
b616326357
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a9a48fadb
|
||
|
|
36ecd772b1
|
||
|
|
0cb030f7ee
|
||
|
|
825f4c39fe
|
+1
-1
@@ -6,7 +6,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.chylex.intellij.keyboardmaster"
|
group = "com.chylex.intellij.keyboardmaster"
|
||||||
version = "0.6.8"
|
version = "0.6.10"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ internal interface KeyStrokeNode<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun isCharEvent(keyEvent: KeyEvent): Boolean {
|
private fun isCharEvent(keyEvent: KeyEvent): Boolean {
|
||||||
return keyEvent.keyChar != KeyEvent.CHAR_UNDEFINED && keyEvent.keyCode != KeyEvent.VK_ENTER && (keyEvent.modifiersEx and KeyEvent.CTRL_DOWN_MASK) == 0
|
return keyEvent.keyChar != KeyEvent.CHAR_UNDEFINED && keyEvent.keyCode != KeyEvent.VK_ENTER && (keyEvent.modifiersEx and (KeyEvent.CTRL_DOWN_MASK or KeyEvent.ALT_DOWN_MASK)) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isCodeEvent(keyEvent: KeyEvent): Boolean {
|
private fun isCodeEvent(keyEvent: KeyEvent): Boolean {
|
||||||
|
|||||||
+42
-1
@@ -8,6 +8,7 @@ import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimCo
|
|||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimCommonNavigation.scrollBy
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimCommonNavigation.scrollBy
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimCommonNavigation.scrollByPages
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimCommonNavigation.scrollByPages
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimCommonNavigation.withShiftModifier
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimCommonNavigation.withShiftModifier
|
||||||
|
import com.intellij.ide.IdeEventQueue
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||||
import com.intellij.openapi.ui.getUserData
|
import com.intellij.openapi.ui.getUserData
|
||||||
import com.intellij.openapi.ui.putUserData
|
import com.intellij.openapi.ui.putUserData
|
||||||
@@ -33,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,15 +56,30 @@ internal object VimTableNavigation {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val GIT_REBASE_TABLE_ROOT_NODE = BASIC_ROOT_NODE + Parent(
|
||||||
|
mapOf(
|
||||||
|
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('f') to DispatchKeyEvent(KeyEvent.VK_F, 'f', KeyEvent.ALT_DOWN_MASK),
|
||||||
|
KeyStroke.getKeyStroke('p') to DispatchKeyEvent(KeyEvent.VK_P, 'p', KeyEvent.ALT_DOWN_MASK),
|
||||||
|
KeyStroke.getKeyStroke('r') to DispatchKeyEvent(KeyEvent.VK_R, 'r', KeyEvent.ALT_DOWN_MASK),
|
||||||
|
KeyStroke.getKeyStroke('s') to DispatchKeyEvent(KeyEvent.VK_S, 's', KeyEvent.ALT_DOWN_MASK),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pickRootNode(component: JTable) = when (component) {
|
private fun pickRootNode(component: JTable) = when (component) {
|
||||||
is VcsLogGraphTable -> GIT_LOG_TABLE_ROOT_NODE
|
is VcsLogGraphTable -> GIT_LOG_TABLE_ROOT_NODE
|
||||||
else -> BASIC_ROOT_NODE
|
else -> when {
|
||||||
|
component::class.java.name.contains("GitInteractiveRebase") -> GIT_REBASE_TABLE_ROOT_NODE
|
||||||
|
else -> BASIC_ROOT_NODE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private data class ScrollVerticallyAndSelect(private val pages: Float, private val extendSelection: Boolean) : ActionNode<VimNavigationDispatcher<JTable>> {
|
private data class ScrollVerticallyAndSelect(private val pages: Float, private val extendSelection: Boolean) : ActionNode<VimNavigationDispatcher<JTable>> {
|
||||||
@@ -87,4 +106,26 @@ internal object VimTableNavigation {
|
|||||||
table.scrollRectToVisible(adjustedRect)
|
table.scrollRectToVisible(adjustedRect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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>> {
|
||||||
|
override fun performAction(holder: VimNavigationDispatcher<JTable>, actionEvent: AnActionEvent, keyEvent: KeyEvent) {
|
||||||
|
with(IdeEventQueue.getInstance().keyEventDispatcher) {
|
||||||
|
dispatchKeyEvent(KeyEvent(holder.component, KeyEvent.KEY_PRESSED, keyEvent.`when`, modifiers, keyCode, keyChar))
|
||||||
|
dispatchKeyEvent(KeyEvent(holder.component, KeyEvent.KEY_RELEASED, keyEvent.`when`, modifiers, keyCode, keyChar))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user