summaryrefslogtreecommitdiff
path: root/src/main/kotlin/me/kyren223/harpoonforjb
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/me/kyren223/harpoonforjb')
-rw-r--r--src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsConfigurable.kt3
-rw-r--r--src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsState.kt1
-rw-r--r--src/main/kotlin/me/kyren223/harpoonforjb/HarpoonQuickMenuSelectAction.kt14
-rw-r--r--src/main/kotlin/me/kyren223/harpoonforjb/HarpoonToggleQuickMenuAction.kt19
-rw-r--r--src/main/kotlin/me/kyren223/harpoonforjb/SettingsData.kt11
5 files changed, 48 insertions, 0 deletions
diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsConfigurable.kt b/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsConfigurable.kt
index 5d50bb9..4ece20e 100644
--- a/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsConfigurable.kt
+++ b/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsConfigurable.kt
@@ -21,6 +21,7 @@ class AppSettingsConfigurable : Configurable {
if (settings.harpoonWidth != this.settings!!.getHarpoonWidth()) return true
if (settings.harpoonHeight != this.settings!!.getHarpoonHeight()) return true
if (settings.harpoonFontSize != this.settings!!.getHarpoonFontSize()) return true
+ if (settings.harpoonEnterToSelect != this.settings!!.getHarpoonEnterToSelect()) return true
return false
}
@@ -29,6 +30,7 @@ class AppSettingsConfigurable : Configurable {
settings.harpoonWidth = this.settings!!.getHarpoonWidth()
settings.harpoonHeight = this.settings!!.getHarpoonHeight()
settings.harpoonFontSize = this.settings!!.getHarpoonFontSize()
+ settings.harpoonEnterToSelect = this.settings!!.getHarpoonEnterToSelect()
}
override fun reset() {
@@ -39,6 +41,7 @@ class AppSettingsConfigurable : Configurable {
this.settings!!.setHarpoonWidth(settings.harpoonWidth)
this.settings!!.setHarpoonHeight(settings.harpoonHeight)
this.settings!!.setHarpoonFontSize(settings.harpoonFontSize)
+ this.settings!!.setHarpoonEnterToSelect(settings.harpoonEnterToSelect)
}
override fun disposeUIResources() {
diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsState.kt b/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsState.kt
index 5699d53..ea3eabd 100644
--- a/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsState.kt
+++ b/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsState.kt
@@ -10,6 +10,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil
@State(name = "me.kyren223.harpoonforjb.AppSettingsState", storages = [Storage("SdkSettingsPlugin.xml")])
class AppSettingsState : PersistentStateComponent<AppSettingsState?> {
+ var harpoonEnterToSelect = true
var harpoonWidth = 800
var harpoonHeight = 400
var harpoonFontSize = 20
diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonQuickMenuSelectAction.kt b/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonQuickMenuSelectAction.kt
new file mode 100644
index 0000000..8ba8c6c
--- /dev/null
+++ b/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonQuickMenuSelectAction.kt
@@ -0,0 +1,14 @@
+package me.kyren223.harpoonforjb
+
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.maddyhome.idea.vim.api.injector
+import com.maddyhome.idea.vim.command.MappingMode
+import com.maddyhome.idea.vim.key.MappingOwner.Plugin.Companion.get
+
+class HarpoonQuickMenuSelectAction : AnAction() {
+ override fun actionPerformed(e: AnActionEvent) {
+ HarpoonState.quickMenuSelect()
+ }
+
+}
diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonToggleQuickMenuAction.kt b/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonToggleQuickMenuAction.kt
index fbf00bd..66e58b0 100644
--- a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonToggleQuickMenuAction.kt
+++ b/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonToggleQuickMenuAction.kt
@@ -2,11 +2,30 @@ package me.kyren223.harpoonforjb
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
+import com.maddyhome.idea.vim.api.injector
+import com.maddyhome.idea.vim.command.MappingMode
+import com.maddyhome.idea.vim.key.MappingOwner
class HarpoonToggleQuickMenuAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
+ if (!remapped) remap()
if (e.project != null) {
HarpoonState.toggleQuickMenu(e.project!!)
}
}
+
+ private fun remap() {
+ if (!AppSettingsState.instance.harpoonEnterToSelect) return
+ val keys = injector.parser.parseKeys(":action HarpoonQuickMenuSelect<cr>")
+ val keyGroup = injector.keyGroup
+ keyGroup.putKeyMapping(MappingMode.NVO,
+ injector.parser.parseKeys("<cr>"),
+ MappingOwner.Plugin.get("HarpoonForJB"), keys, false
+ )
+ remapped = true
+ }
+
+ companion object {
+ var remapped = false
+ }
}
diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/SettingsData.kt b/src/main/kotlin/me/kyren223/harpoonforjb/SettingsData.kt
index 3749661..3e0c60f 100644
--- a/src/main/kotlin/me/kyren223/harpoonforjb/SettingsData.kt
+++ b/src/main/kotlin/me/kyren223/harpoonforjb/SettingsData.kt
@@ -1,6 +1,7 @@
package me.kyren223.harpoonforjb
import com.intellij.ui.JBIntSpinner
+import com.intellij.ui.components.JBCheckBox
import com.intellij.ui.components.JBLabel
import com.intellij.util.ui.FormBuilder
import javax.swing.JPanel
@@ -11,12 +12,14 @@ class SettingsData {
private val harpoonWidth: JBIntSpinner = JBIntSpinner(800, 1, 5000, 10)
private val harpoonHeight: JBIntSpinner = JBIntSpinner(400, 1, 5000, 10)
private val harpoonFontSize: JBIntSpinner = JBIntSpinner(20, 1, 100)
+ private val harpoonEnter: JBCheckBox = JBCheckBox()
init {
panel = FormBuilder.createFormBuilder()
.addLabeledComponent(JBLabel("Harpoon width"), harpoonWidth, 1, false)
.addLabeledComponent(JBLabel("Harpoon height"), harpoonHeight, 1, false)
.addLabeledComponent(JBLabel("Harpoon font size"), harpoonFontSize, 1, false)
+ .addLabeledComponent(JBLabel("Press enter to select item in the QuickMenu"), harpoonEnter, 1, false)
.addComponentFillVertically(JPanel(), 0)
.panel
}
@@ -33,6 +36,10 @@ class SettingsData {
return harpoonFontSize.number
}
+ fun getHarpoonEnterToSelect(): Boolean {
+ return harpoonEnter.isSelected
+ }
+
fun setHarpoonWidth(width: Int) {
harpoonWidth.number = width
}
@@ -44,4 +51,8 @@ class SettingsData {
fun setHarpoonFontSize(fontSize: Int) {
harpoonFontSize.number = fontSize
}
+
+ fun setHarpoonEnterToSelect(enter: Boolean) {
+ harpoonEnter.isSelected = enter
+ }
}