From 9b9c0f0594209b8c4ecdb7901293734ccf567437 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Thu, 9 May 2024 18:09:24 +0300 Subject: Finished implementing all the settings, mapping menu, trident list menu, and fixed all the bugs/issues. Added more index actions for a total of 10 actions (compared to the original 4). Updated README.md and TODO.md. Changed version to 2.0.0. Versions now follow the semver standard. which means that for each major version there will be backwards incompatible changes. for minor versions there will be new features and bug fixes. and for patch versions there will be bug fixes only. --- .../me/kyren223/trident/actions/AppendAction.kt | 16 -------- .../me/kyren223/trident/actions/SelectAction.kt | 44 ---------------------- .../trident/actions/TridentAppendAction.kt | 16 ++++++++ .../kyren223/trident/actions/TridentListAction.kt | 20 ---------- .../trident/actions/TridentListSelectAction.kt | 5 +-- .../trident/actions/TridentSelectAction.kt | 44 ++++++++++++++++++++++ 6 files changed, 61 insertions(+), 84 deletions(-) delete mode 100644 src/main/kotlin/me/kyren223/trident/actions/AppendAction.kt delete mode 100644 src/main/kotlin/me/kyren223/trident/actions/SelectAction.kt create mode 100644 src/main/kotlin/me/kyren223/trident/actions/TridentAppendAction.kt create mode 100644 src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt (limited to 'src/main/kotlin/me/kyren223/trident/actions') diff --git a/src/main/kotlin/me/kyren223/trident/actions/AppendAction.kt b/src/main/kotlin/me/kyren223/trident/actions/AppendAction.kt deleted file mode 100644 index 1b9a2b4..0000000 --- a/src/main/kotlin/me/kyren223/trident/actions/AppendAction.kt +++ /dev/null @@ -1,16 +0,0 @@ -package me.kyren223.trident.actions - -import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.actionSystem.PlatformDataKeys -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VirtualFile -import me.kyren223.trident.utils.TridentList - -class AppendAction : AnAction() { - override fun actionPerformed(e: AnActionEvent) { - val project: Project = e.project ?: return - val file: VirtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return - TridentList.append(project, file) - } -} diff --git a/src/main/kotlin/me/kyren223/trident/actions/SelectAction.kt b/src/main/kotlin/me/kyren223/trident/actions/SelectAction.kt deleted file mode 100644 index 37617c4..0000000 --- a/src/main/kotlin/me/kyren223/trident/actions/SelectAction.kt +++ /dev/null @@ -1,44 +0,0 @@ -package me.kyren223.trident.actions - -import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.actionSystem.PlatformDataKeys -import com.intellij.openapi.fileEditor.FileEditorManager -import me.kyren223.trident.utils.TridentList - -class SelectAction : AnAction() { - override fun actionPerformed(e: AnActionEvent) { - val project = e.project ?: return - var index = when (val actionId = e.actionManager.getId(this)) { - NEXT -> { - val file = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return - val current = TridentList.getIndexOfFile(project, file) ?: return - current + 1 - } - - PREV -> { - val file = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return - val current = TridentList.getIndexOfFile(project, file) ?: return - current - 1 - } - - else -> { - getIndex(actionId!!) - } - } - - val file = TridentList.select(project, index) ?: return - FileEditorManager.getInstance(project).openFile(file, true) - } - - private fun getIndex(actionId: String): Int { - return actionId.substring(SELECT.length).toInt() - 1 - } - - companion object { - const val NEXT = "TridentSelectNext" - const val PREV = "TridentSelectPrev" - const val SELECT = "TridentSelect" - } -} - diff --git a/src/main/kotlin/me/kyren223/trident/actions/TridentAppendAction.kt b/src/main/kotlin/me/kyren223/trident/actions/TridentAppendAction.kt new file mode 100644 index 0000000..1b0d33a --- /dev/null +++ b/src/main/kotlin/me/kyren223/trident/actions/TridentAppendAction.kt @@ -0,0 +1,16 @@ +package me.kyren223.trident.actions + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.PlatformDataKeys +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile +import me.kyren223.trident.utils.TridentList + +class TridentAppendAction : AnAction() { + override fun actionPerformed(e: AnActionEvent) { + val project: Project = e.project ?: return + val file: VirtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return + TridentList.append(project, file) + } +} diff --git a/src/main/kotlin/me/kyren223/trident/actions/TridentListAction.kt b/src/main/kotlin/me/kyren223/trident/actions/TridentListAction.kt index cef0bf2..0d733f3 100644 --- a/src/main/kotlin/me/kyren223/trident/actions/TridentListAction.kt +++ b/src/main/kotlin/me/kyren223/trident/actions/TridentListAction.kt @@ -2,32 +2,12 @@ package me.kyren223.trident.actions 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 -import me.kyren223.trident.data.SettingsState import me.kyren223.trident.ui.TridentListMenu class TridentListAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { - if (!remapped) remap() val project = e.project ?: return TridentListMenu.open(project) } - // TODO move the remap to somewhere else - private fun remap() { - if (!SettingsState.instance.enterToSelect) return - val keys = injector.parser.parseKeys(":action TridentQuickMenuSelect") - val keyGroup = injector.keyGroup - keyGroup.putKeyMapping(MappingMode.NVO, - injector.parser.parseKeys(""), - MappingOwner.Plugin.get("Trident"), keys, false - ) - remapped = true - } - - companion object { - var remapped = false - } } diff --git a/src/main/kotlin/me/kyren223/trident/actions/TridentListSelectAction.kt b/src/main/kotlin/me/kyren223/trident/actions/TridentListSelectAction.kt index d1dfd2d..1b68a59 100644 --- a/src/main/kotlin/me/kyren223/trident/actions/TridentListSelectAction.kt +++ b/src/main/kotlin/me/kyren223/trident/actions/TridentListSelectAction.kt @@ -3,12 +3,9 @@ package me.kyren223.trident.actions import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import me.kyren223.trident.ui.TridentListMenu -import me.kyren223.trident.utils.TridentList class TridentListSelectAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { - val project = e.project ?: return - TridentList.select(project, TridentListMenu.line) + TridentListMenu.instance?.select() } - } diff --git a/src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt b/src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt new file mode 100644 index 0000000..60973f2 --- /dev/null +++ b/src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt @@ -0,0 +1,44 @@ +package me.kyren223.trident.actions + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.PlatformDataKeys +import com.intellij.openapi.fileEditor.FileEditorManager +import me.kyren223.trident.utils.TridentList + +class TridentSelectAction : AnAction() { + override fun actionPerformed(e: AnActionEvent) { + val project = e.project ?: return + val index = when (val actionId = e.actionManager.getId(this)) { + NEXT -> { + val file = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return + val current = TridentList.getIndexOfFile(project, file) ?: return + current + 1 + } + + PREV -> { + val file = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return + val current = TridentList.getIndexOfFile(project, file) ?: return + current - 1 + } + + else -> { + getIndex(actionId!!) + } + } + + val file = TridentList.select(project, index) ?: return + FileEditorManager.getInstance(project).openFile(file, true) + } + + private fun getIndex(actionId: String): Int { + return actionId.substring(SELECT.length).toInt() - 1 + } + + companion object { + const val NEXT = "TridentSelectNext" + const val PREV = "TridentSelectPrev" + const val SELECT = "TridentSelect" + } +} + -- cgit v1.3.1