mirror of
https://github.com/chylex/IntelliJ-Keyboard-Master.git
synced 2024-11-25 10:42:46 +01:00
Compare commits
2 Commits
af04cc2bbe
...
95fca176ba
Author | SHA1 | Date | |
---|---|---|---|
95fca176ba | |||
9edd0f782d |
@ -1,8 +1,6 @@
|
|||||||
package com.chylex.intellij.keyboardmaster
|
package com.chylex.intellij.keyboardmaster
|
||||||
|
|
||||||
import com.chylex.intellij.keyboardmaster.configuration.PluginConfiguration
|
|
||||||
import com.chylex.intellij.keyboardmaster.feature.codeCompletion.CodeCompletionPopupKeyHandler
|
import com.chylex.intellij.keyboardmaster.feature.codeCompletion.CodeCompletionPopupKeyHandler
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigation
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.startup.ProjectActivity
|
import com.intellij.openapi.startup.ProjectActivity
|
||||||
@ -14,20 +12,13 @@ class PluginStartup : ProjectActivity {
|
|||||||
if (!isInitialized) {
|
if (!isInitialized) {
|
||||||
isInitialized = true
|
isInitialized = true
|
||||||
|
|
||||||
PluginConfiguration.load()
|
|
||||||
|
|
||||||
val application = ApplicationManager.getApplication()
|
val application = ApplicationManager.getApplication()
|
||||||
if (application.isUnitTestMode) {
|
if (application.isUnitTestMode) {
|
||||||
initialize()
|
CodeCompletionPopupKeyHandler.registerRawHandler()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
application.invokeLater(::initialize)
|
application.invokeLater(CodeCompletionPopupKeyHandler.Companion::registerRawHandler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initialize() {
|
|
||||||
CodeCompletionPopupKeyHandler.registerRawHandler()
|
|
||||||
VimNavigation.register()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.chylex.intellij.keyboardmaster.configuration
|
package com.chylex.intellij.keyboardmaster.configuration
|
||||||
|
|
||||||
import com.intellij.openapi.options.Configurable
|
import com.intellij.openapi.options.Configurable
|
||||||
import com.intellij.openapi.ui.Messages
|
|
||||||
import com.intellij.ui.components.JBCheckBox
|
|
||||||
import com.intellij.ui.components.JBTextField
|
import com.intellij.ui.components.JBTextField
|
||||||
import com.intellij.ui.dsl.builder.panel
|
import com.intellij.ui.dsl.builder.panel
|
||||||
import javax.swing.JComponent
|
import javax.swing.JComponent
|
||||||
@ -14,14 +12,6 @@ class PluginConfigurable : Configurable {
|
|||||||
private val codeCompletionNextPageShortcut = JBTextField(2)
|
private val codeCompletionNextPageShortcut = JBTextField(2)
|
||||||
private val codeCompletionPrevPageShortcut = JBTextField(2)
|
private val codeCompletionPrevPageShortcut = JBTextField(2)
|
||||||
|
|
||||||
private val enableVimNavigation = JBCheckBox("Vim-style navigation in lists / trees / tables").also { checkBox ->
|
|
||||||
checkBox.addActionListener {
|
|
||||||
if (!checkBox.isSelected) {
|
|
||||||
Messages.showInfoMessage(checkBox, "Vim-style navigation will be disabled after restarting the IDE.", "Keyboard Master")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDisplayName(): String {
|
override fun getDisplayName(): String {
|
||||||
return "Keyboard Master"
|
return "Keyboard Master"
|
||||||
}
|
}
|
||||||
@ -33,10 +23,6 @@ class PluginConfigurable : Configurable {
|
|||||||
row("Next page shortcut:") { cell(codeCompletionNextPageShortcut) }
|
row("Next page shortcut:") { cell(codeCompletionNextPageShortcut) }
|
||||||
row("Prev page shortcut:") { cell(codeCompletionPrevPageShortcut) }
|
row("Prev page shortcut:") { cell(codeCompletionPrevPageShortcut) }
|
||||||
}
|
}
|
||||||
|
|
||||||
group("Navigation") {
|
|
||||||
row { cell(enableVimNavigation) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return component
|
return component
|
||||||
@ -51,8 +37,6 @@ class PluginConfigurable : Configurable {
|
|||||||
it.codeCompletionItemShortcuts = codeCompletionItemShortcuts.text
|
it.codeCompletionItemShortcuts = codeCompletionItemShortcuts.text
|
||||||
it.codeCompletionNextPageShortcut = codeCompletionNextPageShortcut.text.firstOrNull()?.code ?: 0
|
it.codeCompletionNextPageShortcut = codeCompletionNextPageShortcut.text.firstOrNull()?.code ?: 0
|
||||||
it.codeCompletionPrevPageShortcut = codeCompletionPrevPageShortcut.text.firstOrNull()?.code ?: 0
|
it.codeCompletionPrevPageShortcut = codeCompletionPrevPageShortcut.text.firstOrNull()?.code ?: 0
|
||||||
|
|
||||||
it.enableVimNavigation = enableVimNavigation.isSelected
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,8 +45,6 @@ class PluginConfigurable : Configurable {
|
|||||||
codeCompletionItemShortcuts.text = it.codeCompletionItemShortcuts
|
codeCompletionItemShortcuts.text = it.codeCompletionItemShortcuts
|
||||||
codeCompletionNextPageShortcut.text = it.codeCompletionNextPageShortcut.let { code -> if (code == 0) "" else code.toChar().toString() }
|
codeCompletionNextPageShortcut.text = it.codeCompletionNextPageShortcut.let { code -> if (code == 0) "" else code.toChar().toString() }
|
||||||
codeCompletionPrevPageShortcut.text = it.codeCompletionPrevPageShortcut.let { code -> if (code == 0) "" else code.toChar().toString() }
|
codeCompletionPrevPageShortcut.text = it.codeCompletionPrevPageShortcut.let { code -> if (code == 0) "" else code.toChar().toString() }
|
||||||
|
|
||||||
enableVimNavigation.isSelected = it.enableVimNavigation
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.chylex.intellij.keyboardmaster.configuration
|
package com.chylex.intellij.keyboardmaster.configuration
|
||||||
|
|
||||||
import com.chylex.intellij.keyboardmaster.feature.codeCompletion.CodeCompletionPopupConfiguration
|
import com.chylex.intellij.keyboardmaster.feature.codeCompletion.CodeCompletionPopupConfiguration
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigation
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.components.PersistentStateComponent
|
import com.intellij.openapi.components.PersistentStateComponent
|
||||||
import com.intellij.openapi.components.State
|
import com.intellij.openapi.components.State
|
||||||
@ -17,8 +16,6 @@ class PluginConfiguration : PersistentStateComponent<PluginConfiguration> {
|
|||||||
var codeCompletionNextPageShortcut: Int = '0'.code
|
var codeCompletionNextPageShortcut: Int = '0'.code
|
||||||
var codeCompletionPrevPageShortcut: Int = 0
|
var codeCompletionPrevPageShortcut: Int = 0
|
||||||
|
|
||||||
var enableVimNavigation = false
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val instance: PluginConfiguration
|
private val instance: PluginConfiguration
|
||||||
get() = ApplicationManager.getApplication().getService(PluginConfiguration::class.java)
|
get() = ApplicationManager.getApplication().getService(PluginConfiguration::class.java)
|
||||||
@ -37,7 +34,6 @@ class PluginConfiguration : PersistentStateComponent<PluginConfiguration> {
|
|||||||
|
|
||||||
private fun update(instance: PluginConfiguration) = with(instance) {
|
private fun update(instance: PluginConfiguration) = with(instance) {
|
||||||
CodeCompletionPopupConfiguration.updateShortcuts(codeCompletionItemShortcuts, codeCompletionNextPageShortcut, codeCompletionPrevPageShortcut)
|
CodeCompletionPopupConfiguration.updateShortcuts(codeCompletionItemShortcuts, codeCompletionNextPageShortcut, codeCompletionPrevPageShortcut)
|
||||||
VimNavigation.setEnabled(enableVimNavigation)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.chylex.intellij.keyboardmaster.feature.codeCompletion
|
package com.chylex.intellij.keyboardmaster.feature.codeCompletion
|
||||||
|
|
||||||
|
import com.chylex.intellij.keyboardmaster.configuration.PluginConfiguration
|
||||||
import com.intellij.util.containers.IntIntHashMap
|
import com.intellij.util.containers.IntIntHashMap
|
||||||
|
|
||||||
object CodeCompletionPopupConfiguration {
|
object CodeCompletionPopupConfiguration {
|
||||||
@ -13,6 +14,10 @@ object CodeCompletionPopupConfiguration {
|
|||||||
val itemShortcutCount
|
val itemShortcutCount
|
||||||
get() = hintTexts.size
|
get() = hintTexts.size
|
||||||
|
|
||||||
|
init {
|
||||||
|
PluginConfiguration.load()
|
||||||
|
}
|
||||||
|
|
||||||
fun updateShortcuts(itemShortcutChars: String, nextPageShortcutCode: Int, previousPageShortcutCode: Int) {
|
fun updateShortcuts(itemShortcutChars: String, nextPageShortcutCode: Int, previousPageShortcutCode: Int) {
|
||||||
charToShortcutMap.clear()
|
charToShortcutMap.clear()
|
||||||
|
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
package com.chylex.intellij.keyboardmaster.feature.vimNavigation
|
package com.chylex.intellij.keyboardmaster.feature.vimNavigation
|
||||||
|
|
||||||
import com.intellij.ui.popup.WizardPopup
|
|
||||||
import javax.swing.JComponent
|
import javax.swing.JComponent
|
||||||
|
|
||||||
internal interface ComponentHolder {
|
internal interface ComponentHolder {
|
||||||
val component: JComponent
|
val component: JComponent
|
||||||
|
|
||||||
val popup: WizardPopup?
|
|
||||||
get() = null
|
|
||||||
}
|
}
|
||||||
|
@ -4,62 +4,28 @@ import com.chylex.intellij.keyboardmaster.PluginDisposableService
|
|||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimListNavigation
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimListNavigation
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimTableNavigation
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimTableNavigation
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimTreeNavigation
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.components.VimTreeNavigation
|
||||||
|
import com.intellij.ide.ApplicationInitializedListener
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.ui.UiInterceptors
|
import com.intellij.ui.UiInterceptors
|
||||||
import com.intellij.util.ui.StartupUiUtil
|
import com.intellij.util.ui.StartupUiUtil
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import java.awt.AWTEvent
|
import java.awt.AWTEvent
|
||||||
import java.awt.event.FocusEvent
|
import java.awt.event.FocusEvent
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
|
||||||
import javax.swing.JList
|
import javax.swing.JList
|
||||||
import javax.swing.JTable
|
import javax.swing.JTable
|
||||||
import javax.swing.JTree
|
import javax.swing.JTree
|
||||||
import javax.swing.KeyStroke
|
|
||||||
import javax.swing.UIManager
|
|
||||||
|
|
||||||
object VimNavigation {
|
@Suppress("UnstableApiUsage")
|
||||||
private val isEnabled = AtomicBoolean(false)
|
internal class VimNavigationApplicationListener : ApplicationInitializedListener {
|
||||||
private var originalPopupBindings: Array<*>? = null
|
override suspend fun execute(asyncScope: CoroutineScope) {
|
||||||
|
|
||||||
fun register() {
|
|
||||||
val disposable = ApplicationManager.getApplication().getService(PluginDisposableService::class.java)
|
val disposable = ApplicationManager.getApplication().getService(PluginDisposableService::class.java)
|
||||||
|
|
||||||
StartupUiUtil.addAwtListener(::handleEvent, AWTEvent.FOCUS_EVENT_MASK, disposable)
|
StartupUiUtil.addAwtListener(::handleEvent, AWTEvent.FOCUS_EVENT_MASK, disposable)
|
||||||
UiInterceptors.registerPersistent(disposable, PopupInterceptor)
|
UiInterceptors.registerPersistent(disposable, PopupInterceptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setEnabled(enabled: Boolean) {
|
|
||||||
if (!isEnabled.compareAndSet(!enabled, enabled)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enabled) {
|
|
||||||
val originalBindings = (UIManager.get("PopupMenu.selectedWindowInputMapBindings") as Array<*>).also { originalPopupBindings = it }
|
|
||||||
val updatedBindings = mutableListOf(*originalBindings)
|
|
||||||
|
|
||||||
updatedBindings.add(KeyStroke.getKeyStroke('h'))
|
|
||||||
updatedBindings.add("selectParent")
|
|
||||||
|
|
||||||
updatedBindings.add(KeyStroke.getKeyStroke('j'))
|
|
||||||
updatedBindings.add("selectNext")
|
|
||||||
|
|
||||||
updatedBindings.add(KeyStroke.getKeyStroke('k'))
|
|
||||||
updatedBindings.add("selectPrevious")
|
|
||||||
|
|
||||||
updatedBindings.add(KeyStroke.getKeyStroke('l'))
|
|
||||||
updatedBindings.add("selectChild")
|
|
||||||
|
|
||||||
updatedBindings.add(KeyStroke.getKeyStroke('q'))
|
|
||||||
updatedBindings.add("cancel")
|
|
||||||
|
|
||||||
UIManager.put("PopupMenu.selectedWindowInputMapBindings", updatedBindings.toTypedArray())
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
UIManager.put("PopupMenu.selectedWindowInputMapBindings", originalPopupBindings)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleEvent(event: AWTEvent) {
|
private fun handleEvent(event: AWTEvent) {
|
||||||
if (event is FocusEvent && event.id == FocusEvent.FOCUS_GAINED && isEnabled.get()) {
|
if (event is FocusEvent && event.id == FocusEvent.FOCUS_GAINED) {
|
||||||
when (val source = event.source) {
|
when (val source = event.source) {
|
||||||
is JList<*> -> VimListNavigation.install(source)
|
is JList<*> -> VimListNavigation.install(source)
|
||||||
is JTree -> VimTreeNavigation.install(source)
|
is JTree -> VimTreeNavigation.install(source)
|
@ -3,13 +3,8 @@ package com.chylex.intellij.keyboardmaster.feature.vimNavigation
|
|||||||
import com.chylex.intellij.keyboardmaster.PluginDisposableService
|
import com.chylex.intellij.keyboardmaster.PluginDisposableService
|
||||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.project.DumbAwareAction
|
import com.intellij.openapi.project.DumbAwareAction
|
||||||
import com.intellij.openapi.wm.ex.ToolWindowManagerEx
|
|
||||||
import com.intellij.pom.Navigatable
|
|
||||||
import com.intellij.toolWindow.InternalDecoratorImpl
|
|
||||||
import com.intellij.ui.SpeedSearchBase
|
import com.intellij.ui.SpeedSearchBase
|
||||||
import com.intellij.ui.speedSearch.SpeedSearch
|
import com.intellij.ui.speedSearch.SpeedSearch
|
||||||
import com.intellij.ui.speedSearch.SpeedSearchActivator
|
import com.intellij.ui.speedSearch.SpeedSearchActivator
|
||||||
@ -49,7 +44,7 @@ internal open class VimNavigationDispatcher<T : JComponent>(final override val c
|
|||||||
final override fun actionPerformed(e: AnActionEvent) {
|
final override fun actionPerformed(e: AnActionEvent) {
|
||||||
val keyEvent = e.inputEvent as? KeyEvent ?: return
|
val keyEvent = e.inputEvent as? KeyEvent ?: return
|
||||||
|
|
||||||
if (keyEvent.id == KeyEvent.KEY_PRESSED && handleSpecialKeyPress(keyEvent, e.dataContext)) {
|
if (keyEvent.id == KeyEvent.KEY_PRESSED && handleSpecialKeyPress(keyEvent)) {
|
||||||
currentNode = rootNode
|
currentNode = rootNode
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -63,32 +58,23 @@ internal open class VimNavigationDispatcher<T : JComponent>(final override val c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleSpecialKeyPress(keyEvent: KeyEvent, dataContext: DataContext): Boolean {
|
private fun handleSpecialKeyPress(keyEvent: KeyEvent): Boolean {
|
||||||
if (keyEvent.keyCode == KeyEvent.VK_ESCAPE) {
|
if (keyEvent.keyCode == KeyEvent.VK_ESCAPE) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyEvent.keyCode == KeyEvent.VK_ENTER) {
|
if (keyEvent.keyCode == KeyEvent.VK_ENTER) {
|
||||||
handleEnterKeyPress(dataContext)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleEnterKeyPress(dataContext: DataContext) {
|
|
||||||
if (isSearching.compareAndSet(true, false)) {
|
if (isSearching.compareAndSet(true, false)) {
|
||||||
when (val supply = SpeedSearchSupply.getSupply(component)) {
|
when (val supply = SpeedSearchSupply.getSupply(component)) {
|
||||||
is SpeedSearchBase<*> -> supply.hidePopup()
|
is SpeedSearchBase<*> -> supply.hidePopup()
|
||||||
is SpeedSearch -> supply.reset()
|
is SpeedSearch -> supply.reset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
val navigatables = dataContext.getData(CommonDataKeys.NAVIGATABLE_ARRAY)?.filter(Navigatable::canNavigate).orEmpty()
|
return true
|
||||||
for ((index, navigatable) in navigatables.withIndex()) {
|
|
||||||
navigatable.navigate(index == navigatables.lastIndex)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
final override fun update(e: AnActionEvent) {
|
final override fun update(e: AnActionEvent) {
|
||||||
@ -105,23 +91,7 @@ internal open class VimNavigationDispatcher<T : JComponent>(final override val c
|
|||||||
val speedSearch = SpeedSearchSupply.getSupply(holder.component, true) as? SpeedSearchActivator ?: return
|
val speedSearch = SpeedSearchSupply.getSupply(holder.component, true) as? SpeedSearchActivator ?: return
|
||||||
if (speedSearch.isAvailable) {
|
if (speedSearch.isAvailable) {
|
||||||
holder.isSearching.set(true)
|
holder.isSearching.set(true)
|
||||||
speedSearch.activate()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UnstableApiUsage")
|
|
||||||
class CloseParentPopupOrToolWindow<T : JComponent> : KeyStrokeNode.ActionNode<VimNavigationDispatcher<T>> {
|
|
||||||
override fun performAction(holder: VimNavigationDispatcher<T>, actionEvent: AnActionEvent, keyEvent: KeyEvent) {
|
|
||||||
val popup = holder.popup
|
|
||||||
if (popup != null) {
|
|
||||||
popup.cancel()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val project = actionEvent.project ?: return
|
|
||||||
val decorator = InternalDecoratorImpl.findNearestDecorator(holder.component) ?: return
|
|
||||||
ToolWindowManagerEx.getInstanceEx(project).hideToolWindow(decorator.toolWindowId, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.chylex.intellij.keyboardmaster.feature.vimNavigation.components
|
|||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.IdeaAction
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.IdeaAction
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.Parent
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.Parent
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher.CloseParentPopupOrToolWindow
|
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher.StartSearch
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher.StartSearch
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.ui.getUserData
|
import com.intellij.openapi.ui.getUserData
|
||||||
@ -31,18 +30,18 @@ internal object VimListNavigation {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
KeyStroke.getKeyStroke('G') to IdeaAction("List-selectLastRow"),
|
KeyStroke.getKeyStroke('G') to IdeaAction("List-selectLastRow"),
|
||||||
KeyStroke.getKeyStroke('h') to IdeaAction("List-selectPreviousColumn"),
|
|
||||||
KeyStroke.getKeyStroke('j') to IdeaAction("List-selectNextRow"),
|
KeyStroke.getKeyStroke('j') to IdeaAction("List-selectNextRow"),
|
||||||
KeyStroke.getKeyStroke('k') to IdeaAction("List-selectPreviousRow"),
|
KeyStroke.getKeyStroke('k') to IdeaAction("List-selectPreviousRow"),
|
||||||
KeyStroke.getKeyStroke('l') to IdeaAction("List-selectNextColumn"),
|
|
||||||
KeyStroke.getKeyStroke('m') to IdeaAction("ShowPopupMenu"),
|
KeyStroke.getKeyStroke('m') to IdeaAction("ShowPopupMenu"),
|
||||||
KeyStroke.getKeyStroke('q') to CloseParentPopupOrToolWindow(),
|
KeyStroke.getKeyStroke('o') to IdeaAction("List-selectNextColumn"),
|
||||||
|
KeyStroke.getKeyStroke('q') to IdeaAction("HideActiveWindow"),
|
||||||
|
KeyStroke.getKeyStroke('x') to IdeaAction("List-selectPreviousColumn"),
|
||||||
KeyStroke.getKeyStroke('/') to StartSearch(),
|
KeyStroke.getKeyStroke('/') to StartSearch(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun install(component: JList<*>) {
|
fun install(component: JList<*>) {
|
||||||
if (component.getUserData(KEY) == null && component.javaClass.enclosingClass.let { it == null || !WizardPopup::class.java.isAssignableFrom(it) }) {
|
if (component.getUserData(KEY) == null && component.javaClass.enclosingClass.let { it == null || WizardPopup::class.java.isAssignableFrom(it) }) {
|
||||||
component.putUserData(KEY, VimNavigationDispatcher(component, ROOT_NODE))
|
component.putUserData(KEY, VimNavigationDispatcher(component, ROOT_NODE))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,7 +53,7 @@ internal object VimListNavigation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("serial")
|
@Suppress("serial")
|
||||||
private class VimPopupListNavigationDispatcher(component: JList<*>, override val popup: WizardPopup) : VimNavigationDispatcher<JList<*>>(component, ROOT_NODE) {
|
private class VimPopupListNavigationDispatcher(component: JList<*>, popup: WizardPopup) : VimNavigationDispatcher<JList<*>>(component, ROOT_NODE) {
|
||||||
init {
|
init {
|
||||||
val speedSearch = SpeedSearchSupply.getSupply(component, true) as? SpeedSearch
|
val speedSearch = SpeedSearchSupply.getSupply(component, true) as? SpeedSearch
|
||||||
if (speedSearch != null) {
|
if (speedSearch != null) {
|
||||||
|
@ -3,7 +3,6 @@ package com.chylex.intellij.keyboardmaster.feature.vimNavigation.components
|
|||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.IdeaAction
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.IdeaAction
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.Parent
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.Parent
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher.CloseParentPopupOrToolWindow
|
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher.StartSearch
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher.StartSearch
|
||||||
import com.intellij.openapi.ui.getUserData
|
import com.intellij.openapi.ui.getUserData
|
||||||
import com.intellij.openapi.ui.putUserData
|
import com.intellij.openapi.ui.putUserData
|
||||||
@ -29,7 +28,7 @@ internal object VimTableNavigation {
|
|||||||
KeyStroke.getKeyStroke('k') to IdeaAction("Table-selectPreviousRow"),
|
KeyStroke.getKeyStroke('k') to IdeaAction("Table-selectPreviousRow"),
|
||||||
KeyStroke.getKeyStroke('l') to IdeaAction("Table-selectNextColumn"),
|
KeyStroke.getKeyStroke('l') to IdeaAction("Table-selectNextColumn"),
|
||||||
KeyStroke.getKeyStroke('m') to IdeaAction("ShowPopupMenu"),
|
KeyStroke.getKeyStroke('m') to IdeaAction("ShowPopupMenu"),
|
||||||
KeyStroke.getKeyStroke('q') to CloseParentPopupOrToolWindow(),
|
KeyStroke.getKeyStroke('q') to IdeaAction("HideActiveWindow"),
|
||||||
KeyStroke.getKeyStroke('/') to StartSearch(),
|
KeyStroke.getKeyStroke('/') to StartSearch(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -4,7 +4,6 @@ import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.Ac
|
|||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.IdeaAction
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.IdeaAction
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.Parent
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.KeyStrokeNode.Parent
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher.CloseParentPopupOrToolWindow
|
|
||||||
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher.StartSearch
|
import com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationDispatcher.StartSearch
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||||
import com.intellij.openapi.ui.getUserData
|
import com.intellij.openapi.ui.getUserData
|
||||||
@ -29,15 +28,13 @@ internal object VimTreeNavigation {
|
|||||||
KeyStroke.getKeyStroke('G') to IdeaAction("Tree-selectLast"),
|
KeyStroke.getKeyStroke('G') to IdeaAction("Tree-selectLast"),
|
||||||
KeyStroke.getKeyStroke('j') to IdeaAction("Tree-selectNext"),
|
KeyStroke.getKeyStroke('j') to IdeaAction("Tree-selectNext"),
|
||||||
KeyStroke.getKeyStroke('j', KeyEvent.ALT_DOWN_MASK) to IdeaAction("Tree-selectNextSibling"),
|
KeyStroke.getKeyStroke('j', KeyEvent.ALT_DOWN_MASK) to IdeaAction("Tree-selectNextSibling"),
|
||||||
KeyStroke.getKeyStroke('J') to SelectLastSibling,
|
|
||||||
KeyStroke.getKeyStroke('k') to IdeaAction("Tree-selectPrevious"),
|
KeyStroke.getKeyStroke('k') to IdeaAction("Tree-selectPrevious"),
|
||||||
KeyStroke.getKeyStroke('k', KeyEvent.ALT_DOWN_MASK) to IdeaAction("Tree-selectPreviousSibling"),
|
KeyStroke.getKeyStroke('k', KeyEvent.ALT_DOWN_MASK) to IdeaAction("Tree-selectPreviousSibling"),
|
||||||
KeyStroke.getKeyStroke('K') to SelectFirstSibling,
|
|
||||||
KeyStroke.getKeyStroke('m') to IdeaAction("ShowPopupMenu"),
|
KeyStroke.getKeyStroke('m') to IdeaAction("ShowPopupMenu"),
|
||||||
KeyStroke.getKeyStroke('o') to ExpandOrCollapseTreeNode,
|
KeyStroke.getKeyStroke('o') to ExpandOrCollapseTreeNode,
|
||||||
KeyStroke.getKeyStroke('O') to IdeaAction("FullyExpandTreeNode"),
|
KeyStroke.getKeyStroke('O') to IdeaAction("FullyExpandTreeNode"),
|
||||||
KeyStroke.getKeyStroke('p') to IdeaAction("Tree-selectParentNoCollapse"),
|
KeyStroke.getKeyStroke('p') to IdeaAction("Tree-selectParentNoCollapse"),
|
||||||
KeyStroke.getKeyStroke('q') to CloseParentPopupOrToolWindow(),
|
KeyStroke.getKeyStroke('q') to IdeaAction("HideActiveWindow"),
|
||||||
KeyStroke.getKeyStroke('x') to CollapseSelfOrParentNode,
|
KeyStroke.getKeyStroke('x') to CollapseSelfOrParentNode,
|
||||||
KeyStroke.getKeyStroke('X') to IdeaAction("CollapseTreeNode"),
|
KeyStroke.getKeyStroke('X') to IdeaAction("CollapseTreeNode"),
|
||||||
KeyStroke.getKeyStroke('/') to StartSearch(),
|
KeyStroke.getKeyStroke('/') to StartSearch(),
|
||||||
@ -80,42 +77,4 @@ internal object VimTreeNavigation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private data object SelectFirstSibling : ActionNode<VimNavigationDispatcher<JTree>> {
|
|
||||||
override fun performAction(holder: VimNavigationDispatcher<JTree>, actionEvent: AnActionEvent, keyEvent: KeyEvent) {
|
|
||||||
val tree = holder.component
|
|
||||||
val path = tree.selectionPath ?: return
|
|
||||||
|
|
||||||
val parentPath = path.parentPath ?: return
|
|
||||||
val parentRow = tree.getRowForPath(parentPath)
|
|
||||||
|
|
||||||
tree.setSelectionRow(parentRow + 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private data object SelectLastSibling : ActionNode<VimNavigationDispatcher<JTree>> {
|
|
||||||
override fun performAction(holder: VimNavigationDispatcher<JTree>, actionEvent: AnActionEvent, keyEvent: KeyEvent) {
|
|
||||||
val tree = holder.component
|
|
||||||
val path = tree.selectionPath ?: return
|
|
||||||
|
|
||||||
val siblingPathCount = path.pathCount
|
|
||||||
var testRow = tree.getRowForPath(path)
|
|
||||||
var targetRow = testRow
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
testRow++
|
|
||||||
|
|
||||||
val testPath = tree.getPathForRow(testRow) ?: break
|
|
||||||
val testPathCount = testPath.pathCount
|
|
||||||
if (testPathCount < siblingPathCount) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
else if (testPathCount == siblingPathCount) {
|
|
||||||
targetRow = testRow
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tree.setSelectionRow(targetRow)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
<applicationService serviceImplementation="com.chylex.intellij.keyboardmaster.configuration.PluginConfiguration" />
|
<applicationService serviceImplementation="com.chylex.intellij.keyboardmaster.configuration.PluginConfiguration" />
|
||||||
<applicationConfigurable parentId="tools" instance="com.chylex.intellij.keyboardmaster.configuration.PluginConfigurable" id="com.chylex.keyboardmaster" displayName="Keyboard Master" />
|
<applicationConfigurable parentId="tools" instance="com.chylex.intellij.keyboardmaster.configuration.PluginConfigurable" id="com.chylex.keyboardmaster" displayName="Keyboard Master" />
|
||||||
|
<applicationInitializedListener implementation="com.chylex.intellij.keyboardmaster.feature.vimNavigation.VimNavigationApplicationListener" />
|
||||||
<postStartupActivity implementation="com.chylex.intellij.keyboardmaster.PluginStartup" order="last" />
|
<postStartupActivity implementation="com.chylex.intellij.keyboardmaster.PluginStartup" order="last" />
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user