summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyren223 <ulmliad223@gmail.com>2024-08-23 00:31:20 +0300
committerKyren223 <ulmliad223@gmail.com>2024-08-23 00:32:15 +0300
commit7451f83d6685073d10df9bae5c957fdb55dcdc53 (patch)
treedb9a10dcb117263aebcf03b74b5ad68d466d5287
parent43346334c56e47e619d40108a07dd8dc651b11fd (diff)
fix: issues with IdeaVim version 2.16.0, everything should work now
-rw-r--r--.gitignore90
-rw-r--r--LICENSE40
-rw-r--r--build.gradle.kts93
-rw-r--r--gradle.properties12
-rw-r--r--gradle/wrapper/gradle-wrapper.properties10
-rw-r--r--gradlew468
-rw-r--r--gradlew.bat178
-rw-r--r--settings.gradle.kts16
-rw-r--r--src/main/kotlin/me/kyren223/trident/actions/TridentAppendAction.kt32
-rw-r--r--src/main/kotlin/me/kyren223/trident/actions/TridentListAction.kt26
-rw-r--r--src/main/kotlin/me/kyren223/trident/actions/TridentListSelectAction.kt22
-rw-r--r--src/main/kotlin/me/kyren223/trident/actions/TridentMappingsAction.kt24
-rw-r--r--src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt88
-rw-r--r--src/main/kotlin/me/kyren223/trident/data/Settings.kt66
-rw-r--r--src/main/kotlin/me/kyren223/trident/data/SettingsData.kt350
-rw-r--r--src/main/kotlin/me/kyren223/trident/tests/MappingsExpansionTest.kt82
-rw-r--r--src/main/kotlin/me/kyren223/trident/tests/SplitTest.kt120
-rw-r--r--src/main/kotlin/me/kyren223/trident/ui/SettingsConfigurable.kt134
-rw-r--r--src/main/kotlin/me/kyren223/trident/ui/TridentListMenu.kt204
-rw-r--r--src/main/kotlin/me/kyren223/trident/ui/TridentMappingsMenu.kt171
-rw-r--r--src/main/kotlin/me/kyren223/trident/utils/TridentUtils.kt390
-rw-r--r--src/main/kotlin/me/kyren223/trident/utils/Utils.kt42
-rw-r--r--src/main/resources/META-INF/Trident-IdeaVim.xml4
-rw-r--r--src/main/resources/META-INF/plugin.xml264
-rw-r--r--src/main/resources/META-INF/pluginIcon.svg52
25 files changed, 1484 insertions, 1494 deletions
diff --git a/.gitignore b/.gitignore
index b478fb0..7e8e4b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,45 +1,45 @@
-.gradle
-build/
-!gradle/wrapper/gradle-wrapper.jar
-!**/src/main/**/build/
-!**/src/test/**/build/
-
-### IntelliJ IDEA ###
-.idea/modules.xml
-.idea/jarRepositories.xml
-.idea/compiler.xml
-.idea/libraries/
-*.iws
-*.iml
-*.ipr
-out/
-!**/src/main/**/out/
-!**/src/test/**/out/
-
-### Eclipse ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-.sts4-cache
-bin/
-!**/src/main/**/bin/
-!**/src/test/**/bin/
-
-### NetBeans ###
-/nbproject/private/
-/nbbuild/
-/dist/
-/nbdist/
-/.nb-gradle/
-
-### VS Code ###
-.vscode/
-
-### Mac OS ###
-.DS_Store
-
-/certificate/
-/.idea/
+.gradle
+build/
+!gradle/wrapper/gradle-wrapper.jar
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
+
+/certificate/
+/.idea/
diff --git a/LICENSE b/LICENSE
index 05a3ca8..d9d7d03 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1,21 @@
-MIT License
-
-Copyright (c) 2024 Kyren223
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+MIT License
+
+Copyright (c) 2024 Kyren223
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. \ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index d427f07..7aa9b25 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,46 +1,47 @@
-plugins {
- id("java")
- id("org.jetbrains.kotlin.jvm") version "1.9.21"
- id("org.jetbrains.intellij") version "1.17.3"
-}
-group = "me.kyren223"
-version = "2.1.2"
-
-repositories {
- mavenCentral()
-}
-
-// Configure Gradle IntelliJ Plugin
-// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
-intellij {
- version.set("2024.1")
- type.set("IC") // Target IDE Platform
- updateSinceUntilBuild.set(false)
- plugins.set(listOf("IdeaVim:2.11.0"))
-}
-
-tasks {
- // Set the JVM compatibility versions
- withType<JavaCompile> {
- sourceCompatibility = "17"
- targetCompatibility = "17"
- }
- withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
- kotlinOptions.jvmTarget = "17"
- }
-
- patchPluginXml {
- // Supports versions from 2023.2 and up
- sinceBuild.set("232")
- }
-
- signPlugin {
- certificateChainFile.set(file("certificate/chain.crt"))
- privateKeyFile.set(file("certificate/private.pem"))
- password.set(providers.environmentVariable("PRIVATE_KEY_PASSWORD"))
- }
-
- publishPlugin {
- token.set(providers.environmentVariable("PUBLISH_TOKEN"))
- }
-}
+plugins {
+ id("java")
+ id("org.jetbrains.kotlin.jvm") version "1.9.21"
+ id("org.jetbrains.intellij") version "1.17.3"
+}
+
+group = "me.kyren223"
+version = "2.2.0"
+
+repositories {
+ mavenCentral()
+}
+
+// Configure Gradle IntelliJ Plugin
+// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
+intellij {
+ version.set("2024.1.3")
+ type.set("IC") // Target IDE Platform
+ updateSinceUntilBuild.set(false)
+ plugins.set(listOf("IdeaVim:2.16.0"))
+}
+
+tasks {
+ // Set the JVM compatibility versions
+ withType<JavaCompile> {
+ sourceCompatibility = "17"
+ targetCompatibility = "17"
+ }
+ withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
+ kotlinOptions.jvmTarget = "17"
+ }
+
+ patchPluginXml {
+ // Supports versions from 2023.2 and up
+ sinceBuild.set("232")
+ }
+
+ signPlugin {
+ certificateChainFile.set(file("certificate/chain.crt"))
+ privateKeyFile.set(file("certificate/private.pem"))
+ password.set(providers.environmentVariable("PRIVATE_KEY_PASSWORD"))
+ }
+
+ publishPlugin {
+ token.set(providers.environmentVariable("PUBLISH_TOKEN"))
+ }
+}
diff --git a/gradle.properties b/gradle.properties
index 24630b3..c2c3be3 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,6 +1,6 @@
-# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
-kotlin.stdlib.default.dependency=false
-# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
-org.gradle.configuration-cache=true
-# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
-org.gradle.caching=true
+# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
+kotlin.stdlib.default.dependency=false
+# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
+org.gradle.configuration-cache=true
+# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
+org.gradle.caching=true
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 15de902..cf5dd7d 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 40d1eb7..d0cd72a 100644
--- a/gradlew
+++ b/gradlew
@@ -1,234 +1,234 @@
-#!/bin/sh
-
-#
-# Copyright © 2015-2021 the original authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-##############################################################################
-#
-# Gradle start up script for POSIX generated by Gradle.
-#
-# Important for running:
-#
-# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
-# noncompliant, but you have some other compliant shell such as ksh or
-# bash, then to run this script, type that shell name before the whole
-# command line, like:
-#
-# ksh Gradle
-#
-# Busybox and similar reduced shells will NOT work, because this script
-# requires all of these POSIX shell features:
-# * functions;
-# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
-# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
-# * compound commands having a able exit status, especially «case»;
-# * various built-in commands including «command», «set», and «ulimit».
-#
-# Important for patching:
-#
-# (2) This script targets any POSIX shell, so it avoids extensions provided
-# by Bash, Ksh, etc; in particular arrays are avoided.
-#
-# The "traditional" practice of packing multiple parameters into a
-# space-separated string is a well documented source of bugs and security
-# problems, so this is (mostly) avoided, by progressively accumulating
-# options in "$@", and eventually passing that to Java.
-#
-# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
-# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
-# see the in-line comments for details.
-#
-# There are tweaks for specific operating systems such as AIX, CygWin,
-# Darwin, MinGW, and NonStop.
-#
-# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
-# within the Gradle project.
-#
-# You can find Gradle at https://github.com/gradle/gradle/.
-#
-##############################################################################
-
-# Attempt to set APP_HOME
-
-# Resolve links: $0 may be a link
-app_path=$0
-
-# Need this for daisy-chained symlinks.
-while
- APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
- [ -h "$app_path" ]
-do
- ls=$( ls -ld "$app_path" )
- link=${ls#*' -> '}
- case $link in #(
- /*) app_path=$link ;; #(
- *) app_path=$APP_HOME$link ;;
- esac
-done
-
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-
-APP_NAME="Gradle"
-APP_BASE_NAME=${0##*/}
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD=maximum
-
-warn () {
- echo "$*"
-} >&2
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-} >&2
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "$( uname )" in #(
- CYGWIN* ) cygwin=true ;; #(
- Darwin* ) darwin=true ;; #(
- MSYS* | MINGW* ) msys=true ;; #(
- NONSTOP* ) nonstop=true ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD=$JAVA_HOME/jre/sh/java
- else
- JAVACMD=$JAVA_HOME/bin/java
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD=java
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
- case $MAX_FD in #(
- max*)
- MAX_FD=$( ulimit -H -n ) ||
- warn "Could not query maximum file descriptor limit"
- esac
- case $MAX_FD in #(
- '' | soft) :;; #(
- *)
- ulimit -n "$MAX_FD" ||
- warn "Could not set maximum file descriptor limit to $MAX_FD"
- esac
-fi
-
-# Collect all arguments for the java command, stacking in reverse order:
-# * args from the command line
-# * the main class name
-# * -classpath
-# * -D...appname settings
-# * --module-path (only if needed)
-# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if "$cygwin" || "$msys" ; then
- APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
- CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
-
- JAVACMD=$( cygpath --unix "$JAVACMD" )
-
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- for arg do
- if
- case $arg in #(
- -*) false ;; # don't mess with options #(
- /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
- [ -e "$t" ] ;; #(
- *) false ;;
- esac
- then
- arg=$( cygpath --path --ignore --mixed "$arg" )
- fi
- # Roll the args list around exactly as many times as the number of
- # args, so each arg winds up back in the position where it started, but
- # possibly modified.
- #
- # NB: a `for` loop captures its iteration list before it begins, so
- # changing the positional parameters here affects neither the number of
- # iterations, nor the values presented in `arg`.
- shift # remove old arg
- set -- "$@" "$arg" # push replacement arg
- done
-fi
-
-# Collect all arguments for the java command;
-# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
-# shell script including quotes and variable substitutions, so put them in
-# double quotes to make sure that they get re-expanded; and
-# * put everything else in single quotes, so that it's not re-expanded.
-
-set -- \
- "-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- org.gradle.wrapper.GradleWrapperMain \
- "$@"
-
-# Use "xargs" to parse quoted args.
-#
-# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
-#
-# In Bash we could simply go:
-#
-# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
-# set -- "${ARGS[@]}" "$@"
-#
-# but POSIX shell has neither arrays nor command substitution, so instead we
-# post-process each arg (as a line of input to sed) to backslash-escape any
-# character that might be a shell metacharacter, then use eval to reverse
-# that process (while maintaining the separation between arguments), and wrap
-# the whole thing up as a single "set" statement.
-#
-# This will of course break if any of these variables contains a newline or
-# an unmatched quote.
-#
-
-eval "set -- $(
- printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
- xargs -n1 |
- sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
- tr '\n' ' '
- )" '"$@"'
-
-exec "$JAVACMD" "$@"
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a able exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+APP_NAME="Gradle"
+APP_BASE_NAME=${0##*/}
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 107acd3..ac1b06f 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,89 +1,89 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle.kts b/settings.gradle.kts
index c096433..7756d7c 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,9 +1,9 @@
-pluginManagement {
- repositories {
- mavenCentral()
- gradlePluginPortal()
- }
-}
-
-rootProject.name = "Trident"
+pluginManagement {
+ repositories {
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+
+rootProject.name = "Trident"
include("IdeaVIM") \ No newline at end of file
diff --git a/src/main/kotlin/me/kyren223/trident/actions/TridentAppendAction.kt b/src/main/kotlin/me/kyren223/trident/actions/TridentAppendAction.kt
index 1b0d33a..571eb0f 100644
--- a/src/main/kotlin/me/kyren223/trident/actions/TridentAppendAction.kt
+++ b/src/main/kotlin/me/kyren223/trident/actions/TridentAppendAction.kt
@@ -1,16 +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)
- }
-}
+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 0d733f3..f37f0aa 100644
--- a/src/main/kotlin/me/kyren223/trident/actions/TridentListAction.kt
+++ b/src/main/kotlin/me/kyren223/trident/actions/TridentListAction.kt
@@ -1,13 +1,13 @@
-package me.kyren223.trident.actions
-
-import com.intellij.openapi.actionSystem.AnAction
-import com.intellij.openapi.actionSystem.AnActionEvent
-import me.kyren223.trident.ui.TridentListMenu
-
-class TridentListAction : AnAction() {
- override fun actionPerformed(e: AnActionEvent) {
- val project = e.project ?: return
- TridentListMenu.open(project)
- }
-
-}
+package me.kyren223.trident.actions
+
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import me.kyren223.trident.ui.TridentListMenu
+
+class TridentListAction : AnAction() {
+ override fun actionPerformed(e: AnActionEvent) {
+ val project = e.project ?: return
+ TridentListMenu.open(project)
+ }
+
+}
diff --git a/src/main/kotlin/me/kyren223/trident/actions/TridentListSelectAction.kt b/src/main/kotlin/me/kyren223/trident/actions/TridentListSelectAction.kt
index 1b68a59..4161927 100644
--- a/src/main/kotlin/me/kyren223/trident/actions/TridentListSelectAction.kt
+++ b/src/main/kotlin/me/kyren223/trident/actions/TridentListSelectAction.kt
@@ -1,11 +1,11 @@
-package me.kyren223.trident.actions
-
-import com.intellij.openapi.actionSystem.AnAction
-import com.intellij.openapi.actionSystem.AnActionEvent
-import me.kyren223.trident.ui.TridentListMenu
-
-class TridentListSelectAction : AnAction() {
- override fun actionPerformed(e: AnActionEvent) {
- TridentListMenu.instance?.select()
- }
-}
+package me.kyren223.trident.actions
+
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import me.kyren223.trident.ui.TridentListMenu
+
+class TridentListSelectAction : AnAction() {
+ override fun actionPerformed(e: AnActionEvent) {
+ TridentListMenu.instance?.select()
+ }
+}
diff --git a/src/main/kotlin/me/kyren223/trident/actions/TridentMappingsAction.kt b/src/main/kotlin/me/kyren223/trident/actions/TridentMappingsAction.kt
index b303c9e..77e3a11 100644
--- a/src/main/kotlin/me/kyren223/trident/actions/TridentMappingsAction.kt
+++ b/src/main/kotlin/me/kyren223/trident/actions/TridentMappingsAction.kt
@@ -1,12 +1,12 @@
-package me.kyren223.trident.actions
-
-import com.intellij.openapi.actionSystem.AnAction
-import com.intellij.openapi.actionSystem.AnActionEvent
-import me.kyren223.trident.ui.TridentMappingsMenu
-
-class TridentMappingsAction : AnAction() {
- override fun actionPerformed(e: AnActionEvent) {
- val project = e.project ?: return
- TridentMappingsMenu.open(project)
- }
-}
+package me.kyren223.trident.actions
+
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import me.kyren223.trident.ui.TridentMappingsMenu
+
+class TridentMappingsAction : AnAction() {
+ override fun actionPerformed(e: AnActionEvent) {
+ val project = e.project ?: return
+ TridentMappingsMenu.open(project)
+ }
+}
diff --git a/src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt b/src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt
index 60973f2..2eeada3 100644
--- a/src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt
+++ b/src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt
@@ -1,44 +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"
- }
-}
-
+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"
+ }
+}
+
diff --git a/src/main/kotlin/me/kyren223/trident/data/Settings.kt b/src/main/kotlin/me/kyren223/trident/data/Settings.kt
index e97737c..4c9204a 100644
--- a/src/main/kotlin/me/kyren223/trident/data/Settings.kt
+++ b/src/main/kotlin/me/kyren223/trident/data/Settings.kt
@@ -1,33 +1,33 @@
-package me.kyren223.trident.data
-
-import com.intellij.openapi.application.ApplicationManager
-import com.intellij.openapi.components.*
-import com.intellij.util.xmlb.XmlSerializerUtil
-
-// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
-@Service
-@State(name = "me.kyren223.trident.data.SettingsState", storages = [Storage("SdkSettingsPlugin.xml")])
-class SettingsState : PersistentStateComponent<SettingsState?> {
- var width = 800
- var height = 400
- var fontSize = 20
- var enterToSelect = true
- var automaticMapping = AutomaticMapping.Disabled
- var automaticReplacing = AutomaticReplacing.Smart
- var recursiveMapping = false
- var rememberLine = false
- var indexCycling = false
-
- override fun getState(): SettingsState {
- return this
- }
-
- override fun loadState(state: SettingsState) {
- XmlSerializerUtil.copyBean(state, this)
- }
-
- companion object {
- val instance: SettingsState
- get() = ApplicationManager.getApplication().getService(SettingsState::class.java)
- }
-}
+package me.kyren223.trident.data
+
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.components.*
+import com.intellij.util.xmlb.XmlSerializerUtil
+
+// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+@Service
+@State(name = "me.kyren223.trident.data.SettingsState", storages = [Storage("SdkSettingsPlugin.xml")])
+class SettingsState : PersistentStateComponent<SettingsState?> {
+ var width = 800
+ var height = 400
+ var fontSize = 20
+ var enterToSelect = true
+ var automaticMapping = AutomaticMapping.Disabled
+ var automaticReplacing = AutomaticReplacing.Smart
+ var recursiveMapping = false
+ var rememberLine = false
+ var indexCycling = false
+
+ override fun getState(): SettingsState {
+ return this
+ }
+
+ override fun loadState(state: SettingsState) {
+ XmlSerializerUtil.copyBean(state, this)
+ }
+
+ companion object {
+ val instance: SettingsState
+ get() = ApplicationManager.getApplication().getService(SettingsState::class.java)
+ }
+}
diff --git a/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt b/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt
index 26cb1d1..49ca322 100644
--- a/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt
+++ b/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt
@@ -1,175 +1,175 @@
-package me.kyren223.trident.data
-
-import com.intellij.openapi.ui.ComboBox
-import com.intellij.ui.JBColor
-import com.intellij.ui.JBIntSpinner
-import com.intellij.ui.components.JBCheckBox
-import com.intellij.ui.components.JBLabel
-import com.intellij.util.ui.FormBuilder
-import com.intellij.util.ui.JBFont
-import javax.swing.JPanel
-
-class SettingsData {
-
- private val minValue = 1
- private val maxValue = 5000
- private val step = 10
-
- val panel: JPanel
-
- private val width = JBIntSpinner(SettingsState.instance.width, minValue, maxValue, step)
- private val height = JBIntSpinner(SettingsState.instance.height, minValue, maxValue, step)
- private val fontSize = JBIntSpinner(SettingsState.instance.fontSize, minValue, maxValue, step)
-
- private val enterToSelect = JBCheckBox(null, SettingsState.instance.enterToSelect)
- private val rememberLine = JBCheckBox(null, SettingsState.instance.rememberLine)
- private val automaticMapping = ComboBox(AutomaticMapping.entries.toTypedArray())
- private val automaticReplacing = ComboBox(AutomaticReplacing.entries.toTypedArray())
- private val recursiveMapping = JBCheckBox(null, SettingsState.instance.recursiveMapping)
- private val indexCycling = JBCheckBox(null, SettingsState.instance.indexCycling)
-
- init {
- automaticMapping.selectedItem = SettingsState.instance.automaticMapping
- automaticReplacing.selectedItem = SettingsState.instance.automaticReplacing
-
- panel = FormBuilder.createFormBuilder()
- .addComponent(JBLabel("Popup settings").withFont(JBFont.h4()))
- .addLabeledComponent("Popup width", width)
- .addLabeledComponent("Popup height", height)
- .addLabeledComponent("Popup font size", fontSize)
- .addSeparator()
-
- .addComponent(JBLabel("Trident settings").withFont(JBFont.h4()))
- .addLabeledComponent("Enter to select item", enterToSelect)
- .addComponent(desc("If enabled while the TridentList is open, " +
- "pressing enter will select the item in the current line and open the file (if it exists)."))
- .addVerticalGap(step)
-
- .addLabeledComponent("Automatic mapping (when possible)", automaticMapping)
- .addComponent(desc("Disabled - adds the full file path to the Trident Mappings."))
- .addComponent(desc("Filename - Adds the filename (with extension)."))
- .addComponent(desc("Filename (no extension) - Adds the filename (without extension)."))
- .addVerticalGap(step)
-
- .addLabeledComponent("Automatic replacing (when possible)", automaticReplacing)
- .addComponent(desc("Disabled - Keeps the full file path."))
- .addComponent(desc("Exact - Replaces the full path if an exact match is found."))
- .addComponent(desc("Smart - Like exact but if no exact match found, " +
- "it will try to make the path shorter."))
- .addVerticalGap(step)
-
- .addLabeledComponent("Recursive mapping", recursiveMapping)
- .addComponent(desc("If enabled, when expanding a mapping for a path, " +
- "each entry will be expanded recursively."))
- .addComponent(desc("This allows mapping entries to be nested (include other mappings)."))
- .addVerticalGap(step)
-
- .addLabeledComponent("Remember last line", rememberLine)
- .addComponent(desc("If enabled, the current line of the TridentList will be remembered " +
- "and will be selected when the TridentList is opened."))
- .addComponent(desc("Note, this does not persist across restarts, it's run-time only."))
-
- .addLabeledComponent("Index cycling", indexCycling)
- .addComponent(desc("If enabled, indexes will be cyclic, " +
- "For example if you have 3 files and hotkey to 4, it'll cycle to 1."))
-
- .addComponentFillVertically(JPanel(), 0)
- .panel
- }
-
- private fun desc(text: String): JBLabel {
- val label = JBLabel(text).withFont(JBFont.small())
- label.foreground = JBColor.GRAY
- return label
- }
-
- fun getWidth(): Int {
- return width.number
- }
-
- fun getHeight(): Int {
- return height.number
- }
-
- fun getFontSize(): Int {
- return fontSize.number
- }
-
- fun getEnterToSelect(): Boolean {
- return enterToSelect.isSelected
- }
-
- fun setWidth(width: Int) {
- this.width.number = width
- }
-
- fun setHeight(height: Int) {
- this.height.number = height
- }
-
- fun setFontSize(fontSize: Int) {
- this.fontSize.number = fontSize
- }
-
- fun setEnterToSelect(enter: Boolean) {
- this.enterToSelect.isSelected = enter
- }
-
- fun getAutomaticMapping(): AutomaticMapping {
- return automaticMapping.selectedItem as AutomaticMapping
- }
-
- fun setAutomaticMapping(automaticMapping: AutomaticMapping) {
- this.automaticMapping.selectedItem = automaticMapping
- }
-
- fun getAutomaticReplacing(): AutomaticReplacing {
- return automaticReplacing.selectedItem as AutomaticReplacing
- }
-
- fun setAutomaticReplacing(automaticReplacing: AutomaticReplacing) {
- this.automaticReplacing.selectedItem = automaticReplacing
- }
-
- fun getRememberLine(): Boolean {
- return rememberLine.isSelected
- }
-
- fun setRememberLine(rememberLine: Boolean) {
- this.rememberLine.isSelected = rememberLine
- }
-
- fun getRecursiveMapping(): Boolean {
- return recursiveMapping.isSelected
- }
-
- fun setRecursiveMapping(recursiveMapping: Boolean) {
- this.recursiveMapping.isSelected = recursiveMapping
- }
-
- fun getIndexCycling(): Boolean {
- return indexCycling.isSelected
- }
-
- fun setIndexCycling(indexCycling: Boolean) {
- this.indexCycling.isSelected = indexCycling
- }
-}
-
-enum class AutomaticMapping {
- Disabled,
- Filename,
- FilenameNoExtension,
- ;
-
- override fun toString(): String {
- if (this == FilenameNoExtension) return "Filename (without extension)"
- return super.toString()
- }
-}
-
-enum class AutomaticReplacing {
- Disabled,
- Exact,
- Smart,
-}
+package me.kyren223.trident.data
+
+import com.intellij.openapi.ui.ComboBox
+import com.intellij.ui.JBColor
+import com.intellij.ui.JBIntSpinner
+import com.intellij.ui.components.JBCheckBox
+import com.intellij.ui.components.JBLabel
+import com.intellij.util.ui.FormBuilder
+import com.intellij.util.ui.JBFont
+import javax.swing.JPanel
+
+class SettingsData {
+
+ private val minValue = 1
+ private val maxValue = 5000
+ private val step = 10
+
+ val panel: JPanel
+
+ private val width = JBIntSpinner(SettingsState.instance.width, minValue, maxValue, step)
+ private val height = JBIntSpinner(SettingsState.instance.height, minValue, maxValue, step)
+ private val fontSize = JBIntSpinner(SettingsState.instance.fontSize, minValue, maxValue, step)
+
+ private val enterToSelect = JBCheckBox(null, SettingsState.instance.enterToSelect)
+ private val rememberLine = JBCheckBox(null, SettingsState.instance.rememberLine)
+ private val automaticMapping = ComboBox(AutomaticMapping.entries.toTypedArray())
+ private val automaticReplacing = ComboBox(AutomaticReplacing.entries.toTypedArray())
+ private val recursiveMapping = JBCheckBox(null, SettingsState.instance.recursiveMapping)
+ private val indexCycling = JBCheckBox(null, SettingsState.instance.indexCycling)
+
+ init {
+ automaticMapping.selectedItem = SettingsState.instance.automaticMapping
+ automaticReplacing.selectedItem = SettingsState.instance.automaticReplacing
+
+ panel = FormBuilder.createFormBuilder()
+ .addComponent(JBLabel("Popup settings").withFont(JBFont.h4()))
+ .addLabeledComponent("Popup width", width)
+ .addLabeledComponent("Popup height", height)
+ .addLabeledComponent("Popup font size", fontSize)
+ .addSeparator()
+
+ .addComponent(JBLabel("Trident settings").withFont(JBFont.h4()))
+ .addLabeledComponent("Enter to select item", enterToSelect)
+ .addComponent(desc("If enabled while the TridentList is open, " +
+ "pressing enter will select the item in the current line and open the file (if it exists)."))
+ .addVerticalGap(step)
+
+ .addLabeledComponent("Automatic mapping (when possible)", automaticMapping)
+ .addComponent(desc("Disabled - adds the full file path to the Trident Mappings."))
+ .addComponent(desc("Filename - Adds the filename (with extension)."))
+ .addComponent(desc("Filename (no extension) - Adds the filename (without extension)."))
+ .addVerticalGap(step)
+
+ .addLabeledComponent("Automatic replacing (when possible)", automaticReplacing)
+ .addComponent(desc("Disabled - Keeps the full file path."))
+ .addComponent(desc("Exact - Replaces the full path if an exact match is found."))
+ .addComponent(desc("Smart - Like exact but if no exact match found, " +
+ "it will try to make the path shorter."))
+ .addVerticalGap(step)
+
+ .addLabeledComponent("Recursive mapping", recursiveMapping)
+ .addComponent(desc("If enabled, when expanding a mapping for a path, " +
+ "each entry will be expanded recursively."))
+ .addComponent(desc("This allows mapping entries to be nested (include other mappings)."))
+ .addVerticalGap(step)
+
+ .addLabeledComponent("Remember last line", rememberLine)
+ .addComponent(desc("If enabled, the current line of the TridentList will be remembered " +
+ "and will be selected when the TridentList is opened."))
+ .addComponent(desc("Note, this does not persist across restarts, it's run-time only."))
+
+ .addLabeledComponent("Index cycling", indexCycling)
+ .addComponent(desc("If enabled, indexes will be cyclic, " +
+ "For example if you have 3 files and hotkey to 4, it'll cycle to 1."))
+
+ .addComponentFillVertically(JPanel(), 0)
+ .panel
+ }
+
+ private fun desc(text: String): JBLabel {
+ val label = JBLabel(text).withFont(JBFont.small())
+ label.foreground = JBColor.GRAY
+ return label
+ }
+
+ fun getWidth(): Int {
+ return width.number
+ }
+
+ fun getHeight(): Int {
+ return height.number
+ }
+
+ fun getFontSize(): Int {
+ return fontSize.number
+ }
+
+ fun getEnterToSelect(): Boolean {
+ return enterToSelect.isSelected
+ }
+
+ fun setWidth(width: Int) {
+ this.width.number = width
+ }
+
+ fun setHeight(height: Int) {
+ this.height.number = height
+ }
+
+ fun setFontSize(fontSize: Int) {
+ this.fontSize.number = fontSize
+ }
+
+ fun setEnterToSelect(enter: Boolean) {
+ this.enterToSelect.isSelected = enter
+ }
+
+ fun getAutomaticMapping(): AutomaticMapping {
+ return automaticMapping.selectedItem as AutomaticMapping
+ }
+
+ fun setAutomaticMapping(automaticMapping: AutomaticMapping) {
+ this.automaticMapping.selectedItem = automaticMapping
+ }
+
+ fun getAutomaticReplacing(): AutomaticReplacing {
+ return automaticReplacing.selectedItem as AutomaticReplacing
+ }
+
+ fun setAutomaticReplacing(automaticReplacing: AutomaticReplacing) {
+ this.automaticReplacing.selectedItem = automaticReplacing
+ }
+
+ fun getRememberLine(): Boolean {
+ return rememberLine.isSelected
+ }
+
+ fun setRememberLine(rememberLine: Boolean) {
+ this.rememberLine.isSelected = rememberLine
+ }
+
+ fun getRecursiveMapping(): Boolean {
+ return recursiveMapping.isSelected
+ }
+
+ fun setRecursiveMapping(recursiveMapping: Boolean) {
+ this.recursiveMapping.isSelected = recursiveMapping
+ }
+
+ fun getIndexCycling(): Boolean {
+ return indexCycling.isSelected
+ }
+
+ fun setIndexCycling(indexCycling: Boolean) {
+ this.indexCycling.isSelected = indexCycling
+ }
+}
+
+enum class AutomaticMapping {
+ Disabled,
+ Filename,
+ FilenameNoExtension,
+ ;
+
+ override fun toString(): String {
+ if (this == FilenameNoExtension) return "Filename (without extension)"
+ return super.toString()
+ }
+}
+
+enum class AutomaticReplacing {
+ Disabled,
+ Exact,
+ Smart,
+}
diff --git a/src/main/kotlin/me/kyren223/trident/tests/MappingsExpansionTest.kt b/src/main/kotlin/me/kyren223/trident/tests/MappingsExpansionTest.kt
index 0b66c4b..7fe33ad 100644
--- a/src/main/kotlin/me/kyren223/trident/tests/MappingsExpansionTest.kt
+++ b/src/main/kotlin/me/kyren223/trident/tests/MappingsExpansionTest.kt
@@ -1,42 +1,42 @@
-package me.kyren223.trident.tests
-
-import org.junit.Test
-
-class MappingsExpansionTest {
- @Test
- fun testExpand() {
- val mappings = mapOf(
- "\$A" to "A",
- "\$BB" to "B",
- "\$CCC" to "C",
- "\$DDD" to "D",
- "\$EEE" to "E",
- "\$FFFFF" to "F",
- "\$GG" to "G",
- "\$UUU" to "U",
- "\$VVVV" to "V",
- "\$LLLLLL" to "L",
- "\$MM" to "M",
- "\$NN" to "N",
- "\$OOO" to "O",
- "\$PPP" to "P",
- "\$QQQQ" to "Q",
- "\$R" to "R",
- "\$WWW" to "W",
- "\$XX" to "X",
- "\$HI" to "H",
- "\$IJ" to "I",
- "\$JetBrains" to "J",
- "\$Krypton" to "K",
- "\$Soft" to "S",
- "\$Tnt" to "T",
- "\$Ycombinator" to "Y",
- "\$Zig" to "Z",
- ).toList().sortedByDescending { it.first.length }
-
- mappings.forEach { (key, value) ->
- println("$key -> $value")
- }
-
- }
+package me.kyren223.trident.tests
+
+import org.junit.Test
+
+class MappingsExpansionTest {
+ @Test
+ fun testExpand() {
+ val mappings = mapOf(
+ "\$A" to "A",
+ "\$BB" to "B",
+ "\$CCC" to "C",
+ "\$DDD" to "D",
+ "\$EEE" to "E",
+ "\$FFFFF" to "F",
+ "\$GG" to "G",
+ "\$UUU" to "U",
+ "\$VVVV" to "V",
+ "\$LLLLLL" to "L",
+ "\$MM" to "M",
+ "\$NN" to "N",
+ "\$OOO" to "O",
+ "\$PPP" to "P",
+ "\$QQQQ" to "Q",
+ "\$R" to "R",
+ "\$WWW" to "W",
+ "\$XX" to "X",
+ "\$HI" to "H",
+ "\$IJ" to "I",
+ "\$JetBrains" to "J",
+ "\$Krypton" to "K",
+ "\$Soft" to "S",
+ "\$Tnt" to "T",
+ "\$Ycombinator" to "Y",
+ "\$Zig" to "Z",
+ ).toList().sortedByDescending { it.first.length }
+
+ mappings.forEach { (key, value) ->
+ println("$key -> $value")
+ }
+
+ }
} \ No newline at end of file
diff --git a/src/main/kotlin/me/kyren223/trident/tests/SplitTest.kt b/src/main/kotlin/me/kyren223/trident/tests/SplitTest.kt
index e4ea477..586fef1 100644
--- a/src/main/kotlin/me/kyren223/trident/tests/SplitTest.kt
+++ b/src/main/kotlin/me/kyren223/trident/tests/SplitTest.kt
@@ -1,61 +1,61 @@
-package me.kyren223.trident.tests
-
-import org.junit.Test
-
-class SplitTest {
-
- @Test
- fun testSplit() {
- val filenameAndExtension = "SplitTest.kt"
- val filename = "SplitTest"
- val dotfile = ".ideavimrc"
-
- val split = filenameAndExtension.split(".")
- assert(split.size == 2)
- assert(split[0] == filename)
- assert(split[1] == "kt")
-
- val split2 = filename.split(".")
- assert(split2.size == 1)
- assert(split2[0] == filename)
-
- val split3 = dotfile.split(".")
- assert(split3.size == 2)
- assert(split3[0] == "")
- assert(split3[1] == "ideavimrc")
-
-
- }
-
- @Test
- fun testSplit2() {
- val path = "C:/Users/Owner/Projects/Trident/src/main/kotlin/me/kyren223/trident/tests/SplitTest.kt"
- testPath(path, "SplitTest", "kt")
- testPath("SplitTest.kt", "SplitTest", "kt")
- testPath("SplitTest", "SplitTest", null)
- testPath(".ideavimrc", null, "ideavimrc")
- testPath("build.gradle.kts", "build.gradle", "kts")
-
- }
-
- private fun testPath(path: String, filename: String?, extension: String?) {
-
- val fullFilename = path.split("/").last()
- println("fullFilename: $fullFilename")
- val lastDot = fullFilename.lastIndexOf(".")
- val noExtension = lastDot == -1
-
- val filename2 = if (noExtension) fullFilename else {
- fullFilename.substring(0, lastDot).ifEmpty { null }
- }
- val extension2 = if (noExtension) null else fullFilename.substring(lastDot + 1)
-
- println("filename: $filename")
- println("extension: $extension")
- println("filename2: $filename2")
- println("extension2: $extension2")
-
- assert(filename2 == filename)
- assert(extension2 == extension)
- }
+package me.kyren223.trident.tests
+
+import org.junit.Test
+
+class SplitTest {
+
+ @Test
+ fun testSplit() {
+ val filenameAndExtension = "SplitTest.kt"
+ val filename = "SplitTest"
+ val dotfile = ".ideavimrc"
+
+ val split = filenameAndExtension.split(".")
+ assert(split.size == 2)
+ assert(split[0] == filename)
+ assert(split[1] == "kt")
+
+ val split2 = filename.split(".")
+ assert(split2.size == 1)
+ assert(split2[0] == filename)
+
+ val split3 = dotfile.split(".")
+ assert(split3.size == 2)
+ assert(split3[0] == "")
+ assert(split3[1] == "ideavimrc")
+
+
+ }
+
+ @Test
+ fun testSplit2() {
+ val path = "C:/Users/Owner/Projects/Trident/src/main/kotlin/me/kyren223/trident/tests/SplitTest.kt"
+ testPath(path, "SplitTest", "kt")
+ testPath("SplitTest.kt", "SplitTest", "kt")
+ testPath("SplitTest", "SplitTest", null)
+ testPath(".ideavimrc", null, "ideavimrc")
+ testPath("build.gradle.kts", "build.gradle", "kts")
+
+ }
+
+ private fun testPath(path: String, filename: String?, extension: String?) {
+
+ val fullFilename = path.split("/").last()
+ println("fullFilename: $fullFilename")
+ val lastDot = fullFilename.lastIndexOf(".")
+ val noExtension = lastDot == -1
+
+ val filename2 = if (noExtension) fullFilename else {
+ fullFilename.substring(0, lastDot).ifEmpty { null }
+ }
+ val extension2 = if (noExtension) null else fullFilename.substring(lastDot + 1)
+
+ println("filename: $filename")
+ println("extension: $extension")
+ println("filename2: $filename2")
+ println("extension2: $extension2")
+
+ assert(filename2 == filename)
+ assert(extension2 == extension)
+ }
} \ No newline at end of file
diff --git a/src/main/kotlin/me/kyren223/trident/ui/SettingsConfigurable.kt b/src/main/kotlin/me/kyren223/trident/ui/SettingsConfigurable.kt
index f6979b1..085c6f2 100644
--- a/src/main/kotlin/me/kyren223/trident/ui/SettingsConfigurable.kt
+++ b/src/main/kotlin/me/kyren223/trident/ui/SettingsConfigurable.kt
@@ -1,67 +1,67 @@
-// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
-package me.kyren223.trident.ui
-
-import com.intellij.openapi.options.Configurable
-import com.intellij.openapi.util.NlsContexts.ConfigurableName
-import me.kyren223.trident.data.SettingsData
-import me.kyren223.trident.data.SettingsState
-import javax.swing.JComponent
-
-class SettingsConfigurable : Configurable {
-
- private var settings: SettingsData? = null
-
- override fun getDisplayName(): @ConfigurableName String {
- return "Trident Settings"
- }
-
- override fun createComponent(): JComponent {
- settings = SettingsData()
- return settings!!.panel
- }
-
- override fun isModified(): Boolean {
- val settings = SettingsState.instance
- if (settings.width != this.settings!!.getWidth()) return true
- if (settings.height != this.settings!!.getHeight()) return true
- if (settings.fontSize != this.settings!!.getFontSize()) return true
- if (settings.enterToSelect != this.settings!!.getEnterToSelect()) return true
- if (settings.automaticMapping != this.settings!!.getAutomaticMapping()) return true
- if (settings.automaticReplacing != this.settings!!.getAutomaticReplacing()) return true
- if (settings.recursiveMapping != this.settings!!.getRecursiveMapping()) return true
- if (settings.rememberLine != this.settings!!.getRememberLine()) return true
- if (settings.indexCycling != this.settings!!.getIndexCycling()) return true
- return false
- }
-
- override fun apply() {
- val settings = SettingsState.instance
- settings.width = this.settings!!.getWidth()
- settings.height = this.settings!!.getHeight()
- settings.fontSize = this.settings!!.getFontSize()
- settings.enterToSelect = this.settings!!.getEnterToSelect()
- settings.automaticMapping = this.settings!!.getAutomaticMapping()
- settings.automaticReplacing = this.settings!!.getAutomaticReplacing()
- settings.recursiveMapping = this.settings!!.getRecursiveMapping()
- settings.rememberLine = this.settings!!.getRememberLine()
- settings.indexCycling = this.settings!!.getIndexCycling()
- }
-
- override fun reset() {
- val settings = SettingsState.instance
- if (this.settings == null) this.settings = SettingsData()
- this.settings!!.setWidth(settings.width)
- this.settings!!.setHeight(settings.height)
- this.settings!!.setFontSize(settings.fontSize)
- this.settings!!.setEnterToSelect(settings.enterToSelect)
- this.settings!!.setAutomaticMapping(settings.automaticMapping)
- this.settings!!.setAutomaticReplacing(settings.automaticReplacing)
- this.settings!!.setRecursiveMapping(settings.recursiveMapping)
- this.settings!!.setRememberLine(settings.rememberLine)
- this.settings!!.setIndexCycling(settings.indexCycling)
- }
-
- override fun disposeUIResources() {
- settings = null
- }
-}
+// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package me.kyren223.trident.ui
+
+import com.intellij.openapi.options.Configurable
+import com.intellij.openapi.util.NlsContexts.ConfigurableName
+import me.kyren223.trident.data.SettingsData
+import me.kyren223.trident.data.SettingsState
+import javax.swing.JComponent
+
+class SettingsConfigurable : Configurable {
+
+ private var settings: SettingsData? = null
+
+ override fun getDisplayName(): @ConfigurableName String {
+ return "Trident Settings"
+ }
+
+ override fun createComponent(): JComponent {
+ settings = SettingsData()
+ return settings!!.panel
+ }
+
+ override fun isModified(): Boolean {
+ val settings = SettingsState.instance
+ if (settings.width != this.settings!!.getWidth()) return true
+ if (settings.height != this.settings!!.getHeight()) return true
+ if (settings.fontSize != this.settings!!.getFontSize()) return true
+ if (settings.enterToSelect != this.settings!!.getEnterToSelect()) return true
+ if (settings.automaticMapping != this.settings!!.getAutomaticMapping()) return true
+ if (settings.automaticReplacing != this.settings!!.getAutomaticReplacing()) return true
+ if (settings.recursiveMapping != this.settings!!.getRecursiveMapping()) return true
+ if (settings.rememberLine != this.settings!!.getRememberLine()) return true
+ if (settings.indexCycling != this.settings!!.getIndexCycling()) return true
+ return false
+ }
+
+ override fun apply() {
+ val settings = SettingsState.instance
+ settings.width = this.settings!!.getWidth()
+ settings.height = this.settings!!.getHeight()
+ settings.fontSize = this.settings!!.getFontSize()
+ settings.enterToSelect = this.settings!!.getEnterToSelect()
+ settings.automaticMapping = this.settings!!.getAutomaticMapping()
+ settings.automaticReplacing = this.settings!!.getAutomaticReplacing()
+ settings.recursiveMapping = this.settings!!.getRecursiveMapping()
+ settings.rememberLine = this.settings!!.getRememberLine()
+ settings.indexCycling = this.settings!!.getIndexCycling()
+ }
+
+ override fun reset() {
+ val settings = SettingsState.instance
+ if (this.settings == null) this.settings = SettingsData()
+ this.settings!!.setWidth(settings.width)
+ this.settings!!.setHeight(settings.height)
+ this.settings!!.setFontSize(settings.fontSize)
+ this.settings!!.setEnterToSelect(settings.enterToSelect)
+ this.settings!!.setAutomaticMapping(settings.automaticMapping)
+ this.settings!!.setAutomaticReplacing(settings.automaticReplacing)
+ this.settings!!.setRecursiveMapping(settings.recursiveMapping)
+ this.settings!!.setRememberLine(settings.rememberLine)
+ this.settings!!.setIndexCycling(settings.indexCycling)
+ }
+
+ override fun disposeUIResources() {
+ settings = null
+ }
+}
diff --git a/src/main/kotlin/me/kyren223/trident/ui/TridentListMenu.kt b/src/main/kotlin/me/kyren223/trident/ui/TridentListMenu.kt
index 75e059a..45eaf76 100644
--- a/src/main/kotlin/me/kyren223/trident/ui/TridentListMenu.kt
+++ b/src/main/kotlin/me/kyren223/trident/ui/TridentListMenu.kt
@@ -1,102 +1,102 @@
-package me.kyren223.trident.ui
-
-import com.intellij.openapi.editor.EditorSettings
-import com.intellij.openapi.editor.LogicalPosition
-import com.intellij.openapi.fileEditor.FileEditorManager
-import com.intellij.openapi.project.Project
-import com.intellij.openapi.ui.DialogWrapper
-import com.intellij.ui.EditorTextField
-import com.maddyhome.idea.vim.newapi.vim
-import com.maddyhome.idea.vim.state.mode.Mode
-import me.kyren223.trident.data.SettingsState
-import me.kyren223.trident.utils.TridentList
-import me.kyren223.trident.utils.injectEnterToSelectMapping
-import me.kyren223.trident.utils.setEditorMode
-import java.awt.event.FocusEvent
-import java.awt.event.FocusListener
-import javax.swing.JComponent
-
-class TridentListMenu(private val content: String) : DialogWrapper(true) {
-
- private lateinit var editor: EditorTextField
-
- init {
- this.title = "Trident List"
- val settings = SettingsState.instance
- setSize(settings.width, settings.height)
- super.init()
- }
-
- override fun createCenterPanel(): JComponent {
- editor = EditorTextField(this.content)
- editor.setOneLineMode(false)
- editor.addSettingsProvider {
- it.setFontSize(SettingsState.instance.fontSize)
- it.isInsertMode = false
- val lineNumber = if (SettingsState.instance.rememberLine) line else 0
- it.caretModel.moveToLogicalPosition(LogicalPosition(lineNumber, 0))
- it.settings.isLineNumbersShown = true
- it.settings.lineNumerationType = EditorSettings.LineNumerationType.ABSOLUTE
- }
-
- editor.addFocusListener(object : FocusListener {
- override fun focusGained(e: FocusEvent?) {
- val editor = editor.editor!!.vim
- setEditorMode(editor, Mode.NORMAL())
- }
-
- override fun focusLost(e: FocusEvent?) { /* Do nothing */
- }
- })
-
- return editor
- }
-
-
- override fun getPreferredFocusedComponent(): JComponent {
- return this.editor
- }
-
- fun select() {
- doOKAction()
- }
-
- override fun doOKAction() {
- save()
- super.doOKAction()
- }
-
- override fun doCancelAction() {
- save()
- super.doCancelAction()
- }
-
- private fun save() {
- instance = null
- files = editor.text.split("\n")
- line = editor.editor?.caretModel?.logicalPosition?.line ?: 0
- }
-
- override fun createSouthPanel(): JComponent? {
- return null
- }
-
- companion object {
- var instance: TridentListMenu? = null
- var files: List<String>? = null
- var line = 0
- fun open(project: Project) {
- val content = TridentList.get(project).joinToString("\n")
- instance = TridentListMenu(content)
- injectEnterToSelectMapping()
- val selected = instance!!.showAndGet()
-
- files?.let { TridentList.set(project, it) }
- files = null
-
- if (!selected) return
- val file = TridentList.select(project, line) ?: return
- FileEditorManager.getInstance(project).openFile(file, true)
- }
- }
-}
+package me.kyren223.trident.ui
+
+import com.intellij.openapi.editor.EditorSettings
+import com.intellij.openapi.editor.LogicalPosition
+import com.intellij.openapi.fileEditor.FileEditorManager
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.ui.DialogWrapper
+import com.intellij.ui.EditorTextField
+import com.maddyhome.idea.vim.newapi.vim
+import com.maddyhome.idea.vim.state.mode.Mode
+import me.kyren223.trident.data.SettingsState
+import me.kyren223.trident.utils.TridentList
+import me.kyren223.trident.utils.injectEnterToSelectMapping
+import java.awt.event.FocusEvent
+import java.awt.event.FocusListener
+import javax.swing.JComponent
+
+class TridentListMenu(private val content: String) : DialogWrapper(true) {
+
+ private lateinit var editor: EditorTextField
+
+ init {
+ this.title = "Trident List"
+ val settings = SettingsState.instance
+ setSize(settings.width, settings.height)
+ super.init()
+ }
+
+ override fun createCenterPanel(): JComponent {
+ editor = EditorTextField(this.content)
+ editor.setOneLineMode(false)
+ editor.addSettingsProvider {
+ it.setFontSize(SettingsState.instance.fontSize)
+ it.isInsertMode = false
+ val lineNumber = if (SettingsState.instance.rememberLine) line else 0
+ it.caretModel.moveToLogicalPosition(LogicalPosition(lineNumber, 0))
+ it.settings.isLineNumbersShown = true
+ it.settings.lineNumerationType = EditorSettings.LineNumerationType.ABSOLUTE
+ }
+
+ editor.addFocusListener(object : FocusListener {
+ override fun focusGained(e: FocusEvent?) {
+ val editor = editor.editor!!.vim
+ editor.mode = Mode.NORMAL()
+// setEditorMode(editor, Mode.NORMAL())
+ }
+
+ override fun focusLost(e: FocusEvent?) { /* Do nothing */
+ }
+ })
+
+ return editor
+ }
+
+
+ override fun getPreferredFocusedComponent(): JComponent {
+ return this.editor
+ }
+
+ fun select() {
+ doOKAction()
+ }
+
+ override fun doOKAction() {
+ save()
+ super.doOKAction()
+ }
+
+ override fun doCancelAction() {
+ save()
+ super.doCancelAction()
+ }
+
+ private fun save() {
+ instance = null
+ files = editor.text.split("\n")
+ line = editor.editor?.caretModel?.logicalPosition?.line ?: 0
+ }
+
+ override fun createSouthPanel(): JComponent? {
+ return null
+ }
+
+ companion object {
+ var instance: TridentListMenu? = null
+ var files: List<String>? = null
+ var line = 0
+ fun open(project: Project) {
+ val content = TridentList.get(project).joinToString("\n")
+ instance = TridentListMenu(content)
+ injectEnterToSelectMapping()
+ val selected = instance!!.showAndGet()
+
+ files?.let { TridentList.set(project, it) }
+ files = null
+
+ if (!selected) return
+ val file = TridentList.select(project, line) ?: return
+ FileEditorManager.getInstance(project).openFile(file, true)
+ }
+ }
+}
diff --git a/src/main/kotlin/me/kyren223/trident/ui/TridentMappingsMenu.kt b/src/main/kotlin/me/kyren223/trident/ui/TridentMappingsMenu.kt
index 79f1df8..062c618 100644
--- a/src/main/kotlin/me/kyren223/trident/ui/TridentMappingsMenu.kt
+++ b/src/main/kotlin/me/kyren223/trident/ui/TridentMappingsMenu.kt
@@ -1,86 +1,85 @@
-package me.kyren223.trident.ui
-
-import com.intellij.openapi.editor.EditorSettings
-import com.intellij.openapi.editor.LogicalPosition
-import com.intellij.openapi.project.Project
-import com.intellij.openapi.ui.DialogWrapper
-import com.intellij.ui.EditorTextField
-import com.maddyhome.idea.vim.newapi.vim
-import com.maddyhome.idea.vim.state.mode.Mode
-import me.kyren223.trident.data.SettingsState
-import me.kyren223.trident.utils.TridentMappings
-import me.kyren223.trident.utils.setEditorMode
-import java.awt.event.FocusEvent
-import java.awt.event.FocusListener
-import javax.swing.JComponent
-
-class TridentMappingsMenu(private val content: String) : DialogWrapper(true) {
- private lateinit var editor: EditorTextField
-
- init {
- val settings = SettingsState.instance.state
- this.title = "Trident Mappings"
- setSize(settings.width, settings.height)
- super.init()
- }
-
- override fun createCenterPanel(): JComponent {
- editor = EditorTextField(this.content)
- editor.setOneLineMode(false)
- editor.addSettingsProvider {
- it.setFontSize(SettingsState.instance.fontSize)
- it.isInsertMode = false
- it.caretModel.moveToLogicalPosition(LogicalPosition(0, 0))
- it.settings.isLineNumbersShown = true
- it.settings.lineNumerationType = EditorSettings.LineNumerationType.ABSOLUTE
- }
-
- editor.addFocusListener(object : FocusListener {
- override fun focusGained(e: FocusEvent?) {
- val editor = editor.editor!!.vim
- setEditorMode(editor, Mode.NORMAL())
- }
-
- override fun focusLost(e: FocusEvent?) { /* Do nothing */ }
- })
-
- return editor
- }
-
- override fun getPreferredFocusedComponent(): JComponent {
- return this.editor
- }
-
- override fun doOKAction() {
- save()
- super.doOKAction()
- }
-
- override fun doCancelAction() {
- save()
- super.doCancelAction()
- }
-
- private fun save() {
- map = editor.text.split("\n")
- .map { entry -> entry.split("=") }
- .filter { entry -> entry.size == 2 }
- .associate { it[0] to it[1] }
- }
-
- override fun createSouthPanel(): JComponent? {
- return null
- }
-
- companion object {
- var map: Map<String, String>? = null
- fun open(project: Project) {
- val content = TridentMappings.get(project).entries
- .joinToString("\n") { "${it.key}=${it.value}" }
- val menu = TridentMappingsMenu(content)
- menu.show()
- map?.let { TridentMappings.set(project, it) }
- map = null
- }
- }
-}
+package me.kyren223.trident.ui
+
+import com.intellij.openapi.editor.EditorSettings
+import com.intellij.openapi.editor.LogicalPosition
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.ui.DialogWrapper
+import com.intellij.ui.EditorTextField
+import com.maddyhome.idea.vim.newapi.vim
+import com.maddyhome.idea.vim.state.mode.Mode
+import me.kyren223.trident.data.SettingsState
+import me.kyren223.trident.utils.TridentMappings
+import java.awt.event.FocusEvent
+import java.awt.event.FocusListener
+import javax.swing.JComponent
+
+class TridentMappingsMenu(private val content: String) : DialogWrapper(true) {
+ private lateinit var editor: EditorTextField
+
+ init {
+ val settings = SettingsState.instance.state
+ this.title = "Trident Mappings"
+ setSize(settings.width, settings.height)
+ super.init()
+ }
+
+ override fun createCenterPanel(): JComponent {
+ editor = EditorTextField(this.content)
+ editor.setOneLineMode(false)
+ editor.addSettingsProvider {
+ it.setFontSize(SettingsState.instance.fontSize)
+ it.isInsertMode = false
+ it.caretModel.moveToLogicalPosition(LogicalPosition(0, 0))
+ it.settings.isLineNumbersShown = true
+ it.settings.lineNumerationType = EditorSettings.LineNumerationType.ABSOLUTE
+ }
+
+ editor.addFocusListener(object : FocusListener {
+ override fun focusGained(e: FocusEvent?) {
+ val editor = editor.editor!!.vim
+ editor.mode = Mode.NORMAL()
+ }
+
+ override fun focusLost(e: FocusEvent?) { /* Do nothing */ }
+ })
+
+ return editor
+ }
+
+ override fun getPreferredFocusedComponent(): JComponent {
+ return this.editor
+ }
+
+ override fun doOKAction() {
+ save()
+ super.doOKAction()
+ }
+
+ override fun doCancelAction() {
+ save()
+ super.doCancelAction()
+ }
+
+ private fun save() {
+ map = editor.text.split("\n")
+ .map { entry -> entry.split("=") }
+ .filter { entry -> entry.size == 2 }
+ .associate { it[0] to it[1] }
+ }
+
+ override fun createSouthPanel(): JComponent? {
+ return null
+ }
+
+ companion object {
+ var map: Map<String, String>? = null
+ fun open(project: Project) {
+ val content = TridentMappings.get(project).entries
+ .joinToString("\n") { "${it.key}=${it.value}" }
+ val menu = TridentMappingsMenu(content)
+ menu.show()
+ map?.let { TridentMappings.set(project, it) }
+ map = null
+ }
+ }
+}
diff --git a/src/main/kotlin/me/kyren223/trident/utils/TridentUtils.kt b/src/main/kotlin/me/kyren223/trident/utils/TridentUtils.kt
index 96ab454..5f96bd3 100644
--- a/src/main/kotlin/me/kyren223/trident/utils/TridentUtils.kt
+++ b/src/main/kotlin/me/kyren223/trident/utils/TridentUtils.kt
@@ -1,196 +1,196 @@
-package me.kyren223.trident.utils
-
-import com.intellij.ide.util.PropertiesComponent
-import com.intellij.openapi.project.Project
-import com.intellij.openapi.project.guessProjectDir
-import com.intellij.openapi.vfs.LocalFileSystem
-import com.intellij.openapi.vfs.VirtualFile
-import me.kyren223.trident.data.AutomaticMapping
-import me.kyren223.trident.data.AutomaticReplacing
-import me.kyren223.trident.data.SettingsState
-
-object TridentList {
- private const val PROPERTIES_KEY = "TridentList"
-
- private fun isValidFile(project: Project, path: String): Boolean {
- // Requirements:
- // - File must exist on disk after expansion
- val expandedPath = TridentMappings.expand(project, path)
- return expandedPath.isNotBlank() && LocalFileSystem.getInstance().findFileByPath(expandedPath) != null
- }
-
- private fun getModifiedPath(project: Project, path: String): String {
- val automaticMapping = SettingsState.instance.automaticMapping
- val automaticReplacing = SettingsState.instance.automaticReplacing
- val mappings = TridentMappings.get(project)
-
- val hasReplacement = automaticReplacing != AutomaticReplacing.Disabled
- && mappings.containsValue(path)
-
- if (hasReplacement) {
- return mappings.filterValues { it == path }.keys.firstOrNull()!!
- }
-
- if (automaticMapping == AutomaticMapping.Disabled) {
- return if (automaticReplacing == AutomaticReplacing.Smart) {
- return smartReplacement(path, mappings)
- } else path
- }
-
- return path.split("/")
- .lastOrNull()
- ?.let {
- if (automaticMapping == AutomaticMapping.Filename) {
- return@let it
- }
- val dotIndex = it.lastIndexOf(".")
- val filename = if (dotIndex == -1) it else it.substring(0, dotIndex).ifBlank { null }
- val extension = if (dotIndex == -1) null else it.substring(dotIndex + 1)
- return@let (filename ?: extension)!!
- }?.let {
- val key = "\$$it"
- if (TridentMappings.exists(project, key)) {
- return@let null
- }
- TridentMappings.append(project, key, path)
- return@let key
- } ?: (if (automaticReplacing == AutomaticReplacing.Smart) smartReplacement(path, mappings) else path)
- }
-
- private fun smartReplacement(path: String, mappings: Map<String, String>): String {
- // This is technically redundant,
- // The smart path is sorted based on length, so the longest path will be the first
- // And the longest path will be the first path that exactly matches
- val exactPath = mappings.filter { it.value == path }.keys.firstOrNull()
- exactPath?.let { return it }
-
- var smartPath = path
- for ((key, value) in mappings
- .toList()
- .sortedByDescending { it.second.length }
- .associate { it.first to it.second }) {
- smartPath = smartPath.replace(value, key)
- }
- return smartPath
- }
-
- fun append(project: Project, file: VirtualFile) {
- println("TridentList.append - file: ${file.path}")
- val files = get(project).toMutableList()
- val path = getModifiedPath(project, file.path)
- println("TridentList.append - path: $path")
- files.add(path)
- println("TridentList.append - add: " + files.joinToString(", "))
- set(project, files)
- println("TridentList.append - set")
-
- println("TridentList.append - TridentList: " + get(project).joinToString(", "))
- println("TridentList.append - TridentMappings: " + TridentMappings.get(project)
- .map { "${it.key}=${it.value}" }
- .joinToString(", "))
- }
-
- fun set(project: Project, files: List<String>) {
- val properties = PropertiesComponent.getInstance(project)
- val list = files.filter { isValidFile(project, it) }
- properties.setList(PROPERTIES_KEY, list)
- }
-
- fun get(project: Project): List<String> {
- val properties = PropertiesComponent.getInstance(project)
- return properties.getList(PROPERTIES_KEY) ?: emptyList()
- }
-
- private fun getFiles(project: Project): List<VirtualFile> {
- return get(project)
- .map { TridentMappings.expand(project, it) }
- .mapNotNull { LocalFileSystem.getInstance().findFileByPath(it) }
- }
-
- fun getIndexOfFile(project: Project, file: VirtualFile): Int? {
- val files = getFiles(project)
- return files.indexOfFirst { it.path == file.path }.takeUnless { it == -1 }
- }
-
- fun select(project: Project, index: Int): VirtualFile? {
- val cycle = SettingsState.instance.indexCycling
- val count = getFiles(project).size
- val i = if (cycle) ((index % count) + count) % count else index
- val files = getFiles(project)
- return files.getOrNull(i)
- }
-}
-
-object TridentMappings {
- private const val PROPERTIES_KEY = "TridentMappings"
-
- private fun isValidEntry(key: String, value: String): Boolean {
- // Requirements:
- // - Key and value must not be blank
- // - key must start with $
- // - key must only contain alphanumeric characters, underscores, hyphens, and dots
- // - value must not contain =
- return key.isNotBlank() && value.isNotBlank() &&
- key.matches(Regex("""^\$[a-zA-Z0-9_.\-]+$""")) &&
- value.matches(Regex("""^[^=]+$"""))
- }
-
- fun append(project: Project, key: String, value: String, overwrite: Boolean = false) {
- println("TridentMappings.append - key: $key, value: $value")
- val map = get(project).toMutableMap()
- if (map.containsKey(key) && !overwrite) return
- println("TridentMappings.append - map: $map")
- map[key] = value
- println("TridentMappings.append - map after: $map")
- set(project, map)
- println("TridentMappings.append - set: ${get(project).map { "${it.key}=${it.value}" }.joinToString(", ")}")
- }
-
- fun set(project: Project, mappings: Map<String, String>) {
- val properties = PropertiesComponent.getInstance(project)
-
- val list = mappings
- .filter { isValidEntry(it.key, it.value) }
- .map { "${it.key}=${it.value}" }
- .toMutableList()
-
- properties.setList(PROPERTIES_KEY, list)
- }
-
- fun get(project: Project): Map<String, String> {
- val properties = PropertiesComponent.getInstance(project)
- val list = properties.getList(PROPERTIES_KEY) ?: return emptyMap()
- val map = list
- .map { it.split("=") }
- .associate { it[0] to it[1] }
- .toMutableMap()
- project.guessProjectDir()?.let {
- map["..."] = it.path
- map["\$project"] = it.path
- }
- return map
- }
-
- fun expand(project: Project, path: String): String {
- val recursive = SettingsState.instance.recursiveMapping
- val mappings = get(project).toList().sortedByDescending { it.first.length }
- var expandedPath = path
- while (true) {
- var expanded = false
- mappings.forEach { (key, value) ->
- val expansion = expandedPath.replace(key, value)
- if (expansion != expandedPath) {
- expandedPath = expansion
- expanded = true
- }
- }
- if (!recursive || !expanded) break
- }
-
- return expandedPath
- }
-
- fun exists(project: Project, key: String): Boolean {
- return get(project).containsKey(key)
- }
+package me.kyren223.trident.utils
+
+import com.intellij.ide.util.PropertiesComponent
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.project.guessProjectDir
+import com.intellij.openapi.vfs.LocalFileSystem
+import com.intellij.openapi.vfs.VirtualFile
+import me.kyren223.trident.data.AutomaticMapping
+import me.kyren223.trident.data.AutomaticReplacing
+import me.kyren223.trident.data.SettingsState
+
+object TridentList {
+ private const val PROPERTIES_KEY = "TridentList"
+
+ private fun isValidFile(project: Project, path: String): Boolean {
+ // Requirements:
+ // - File must exist on disk after expansion
+ val expandedPath = TridentMappings.expand(project, path)
+ return expandedPath.isNotBlank() && LocalFileSystem.getInstance().findFileByPath(expandedPath) != null
+ }
+
+ private fun getModifiedPath(project: Project, path: String): String {
+ val automaticMapping = SettingsState.instance.automaticMapping
+ val automaticReplacing = SettingsState.instance.automaticReplacing
+ val mappings = TridentMappings.get(project)
+
+ val hasReplacement = automaticReplacing != AutomaticReplacing.Disabled
+ && mappings.containsValue(path)
+
+ if (hasReplacement) {
+ return mappings.filterValues { it == path }.keys.firstOrNull()!!
+ }
+
+ if (automaticMapping == AutomaticMapping.Disabled) {
+ return if (automaticReplacing == AutomaticReplacing.Smart) {
+ return smartReplacement(path, mappings)
+ } else path
+ }
+
+ return path.split("/")
+ .lastOrNull()
+ ?.let {
+ if (automaticMapping == AutomaticMapping.Filename) {
+ return@let it
+ }
+ val dotIndex = it.lastIndexOf(".")
+ val filename = if (dotIndex == -1) it else it.substring(0, dotIndex).ifBlank { null }
+ val extension = if (dotIndex == -1) null else it.substring(dotIndex + 1)
+ return@let (filename ?: extension)!!
+ }?.let {
+ val key = "\$$it"
+ if (TridentMappings.exists(project, key)) {
+ return@let null
+ }
+ TridentMappings.append(project, key, path)
+ return@let key
+ } ?: (if (automaticReplacing == AutomaticReplacing.Smart) smartReplacement(path, mappings) else path)
+ }
+
+ private fun smartReplacement(path: String, mappings: Map<String, String>): String {
+ // This is technically redundant,
+ // The smart path is sorted based on length, so the longest path will be the first
+ // And the longest path will be the first path that exactly matches
+ val exactPath = mappings.filter { it.value == path }.keys.firstOrNull()
+ exactPath?.let { return it }
+
+ var smartPath = path
+ for ((key, value) in mappings
+ .toList()
+ .sortedByDescending { it.second.length }
+ .associate { it.first to it.second }) {
+ smartPath = smartPath.replace(value, key)
+ }
+ return smartPath
+ }
+
+ fun append(project: Project, file: VirtualFile) {
+ println("TridentList.append - file: ${file.path}")
+ val files = get(project).toMutableList()
+ val path = getModifiedPath(project, file.path)
+ println("TridentList.append - path: $path")
+ files.add(path)
+ println("TridentList.append - add: " + files.joinToString(", "))
+ set(project, files)
+ println("TridentList.append - set")
+
+ println("TridentList.append - TridentList: " + get(project).joinToString(", "))
+ println("TridentList.append - TridentMappings: " + TridentMappings.get(project)
+ .map { "${it.key}=${it.value}" }
+ .joinToString(", "))
+ }
+
+ fun set(project: Project, files: List<String>) {
+ val properties = PropertiesComponent.getInstance(project)
+ val list = files.filter { isValidFile(project, it) }
+ properties.setList(PROPERTIES_KEY, list)
+ }
+
+ fun get(project: Project): List<String> {
+ val properties = PropertiesComponent.getInstance(project)
+ return properties.getList(PROPERTIES_KEY) ?: emptyList()
+ }
+
+ private fun getFiles(project: Project): List<VirtualFile> {
+ return get(project)
+ .map { TridentMappings.expand(project, it) }
+ .mapNotNull { LocalFileSystem.getInstance().findFileByPath(it) }
+ }
+
+ fun getIndexOfFile(project: Project, file: VirtualFile): Int? {
+ val files = getFiles(project)
+ return files.indexOfFirst { it.path == file.path }.takeUnless { it == -1 }
+ }
+
+ fun select(project: Project, index: Int): VirtualFile? {
+ val cycle = SettingsState.instance.indexCycling
+ val count = getFiles(project).size
+ val i = if (cycle) ((index % count) + count) % count else index
+ val files = getFiles(project)
+ return files.getOrNull(i)
+ }
+}
+
+object TridentMappings {
+ private const val PROPERTIES_KEY = "TridentMappings"
+
+ private fun isValidEntry(key: String, value: String): Boolean {
+ // Requirements:
+ // - Key and value must not be blank
+ // - key must start with $
+ // - key must only contain alphanumeric characters, underscores, hyphens, and dots
+ // - value must not contain =
+ return key.isNotBlank() && value.isNotBlank() &&
+ key.matches(Regex("""^\$[a-zA-Z0-9_.\-]+$""")) &&
+ value.matches(Regex("""^[^=]+$"""))
+ }
+
+ fun append(project: Project, key: String, value: String, overwrite: Boolean = false) {
+ println("TridentMappings.append - key: $key, value: $value")
+ val map = get(project).toMutableMap()
+ if (map.containsKey(key) && !overwrite) return
+ println("TridentMappings.append - map: $map")
+ map[key] = value
+ println("TridentMappings.append - map after: $map")
+ set(project, map)
+ println("TridentMappings.append - set: ${get(project).map { "${it.key}=${it.value}" }.joinToString(", ")}")
+ }
+
+ fun set(project: Project, mappings: Map<String, String>) {
+ val properties = PropertiesComponent.getInstance(project)
+
+ val list = mappings
+ .filter { isValidEntry(it.key, it.value) }
+ .map { "${it.key}=${it.value}" }
+ .toMutableList()
+
+ properties.setList(PROPERTIES_KEY, list)
+ }
+
+ fun get(project: Project): Map<String, String> {
+ val properties = PropertiesComponent.getInstance(project)
+ val list = properties.getList(PROPERTIES_KEY) ?: return emptyMap()
+ val map = list
+ .map { it.split("=") }
+ .associate { it[0] to it[1] }
+ .toMutableMap()
+ project.guessProjectDir()?.let {
+ map["..."] = it.path
+ map["\$project"] = it.path
+ }
+ return map
+ }
+
+ fun expand(project: Project, path: String): String {
+ val recursive = SettingsState.instance.recursiveMapping
+ val mappings = get(project).toList().sortedByDescending { it.first.length }
+ var expandedPath = path
+ while (true) {
+ var expanded = false
+ mappings.forEach { (key, value) ->
+ val expansion = expandedPath.replace(key, value)
+ if (expansion != expandedPath) {
+ expandedPath = expansion
+ expanded = true
+ }
+ }
+ if (!recursive || !expanded) break
+ }
+
+ return expandedPath
+ }
+
+ fun exists(project: Project, key: String): Boolean {
+ return get(project).containsKey(key)
+ }
} \ No newline at end of file
diff --git a/src/main/kotlin/me/kyren223/trident/utils/Utils.kt b/src/main/kotlin/me/kyren223/trident/utils/Utils.kt
index e688dd8..d9b4f34 100644
--- a/src/main/kotlin/me/kyren223/trident/utils/Utils.kt
+++ b/src/main/kotlin/me/kyren223/trident/utils/Utils.kt
@@ -1,26 +1,16 @@
-package me.kyren223.trident.utils
-
-import com.maddyhome.idea.vim.api.VimEditor
-import com.maddyhome.idea.vim.api.injector
-import com.maddyhome.idea.vim.command.MappingMode
-import com.maddyhome.idea.vim.command.OperatorArguments
-import com.maddyhome.idea.vim.key.MappingOwner
-import com.maddyhome.idea.vim.state.mode.Mode
-
-fun setEditorMode(editor: VimEditor, mode: Mode) {
- val context = injector.executionContextManager.onEditor(editor, null)
- val operatorArguments = OperatorArguments(false, 0, mode)
- editor.exitInsertMode(context, operatorArguments)
- editor.vimChangeActionSwitchMode = Mode.NORMAL()
-}
-
-fun injectEnterToSelectMapping() {
- injector.keyGroup.putKeyMapping(
- MappingMode.NV,
- injector.parser.parseKeys("<cr>"),
- MappingOwner.Plugin.get("Trident"),
- injector.parser.parseKeys(":action TridentListSelect<cr>"),
- false
- )
-}
-
+package me.kyren223.trident.utils
+
+import com.maddyhome.idea.vim.api.injector
+import com.maddyhome.idea.vim.command.MappingMode
+import com.maddyhome.idea.vim.key.MappingOwner
+
+fun injectEnterToSelectMapping() {
+ injector.keyGroup.putKeyMapping(
+ MappingMode.NV,
+ injector.parser.parseKeys("<cr>"),
+ MappingOwner.Plugin.get("Trident"),
+ injector.parser.parseKeys(":action TridentListSelect<cr>"),
+ false
+ )
+}
+
diff --git a/src/main/resources/META-INF/Trident-IdeaVim.xml b/src/main/resources/META-INF/Trident-IdeaVim.xml
index 164f46c..b72ce85 100644
--- a/src/main/resources/META-INF/Trident-IdeaVim.xml
+++ b/src/main/resources/META-INF/Trident-IdeaVim.xml
@@ -1,2 +1,2 @@
-<idea-plugin>
-</idea-plugin>
+<idea-plugin>
+</idea-plugin>
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index e52e798..60095a7 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -1,133 +1,133 @@
-<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
-<idea-plugin>
- <!-- Unique identifier of the plugin. It should be FQN. It cannot be changed between the plugin versions. -->
- <id>me.kyren223.trident</id>
-
- <!-- Public plugin name should be written in Title Case.
- Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-name -->
- <name>Trident</name>
-
- <!-- A displayed Vendor name or Organization ID displayed on the Plugins Page. -->
- <vendor email="ulmliad223@gmail.com" url="https://discord.gg/7vpTv7m3QR">Kyren223</vendor>
-
- <!-- Description of the plugin displayed on the Plugin Page and IDE Plugin Manager.
- Simple HTML elements (text formatting, paragraphs, and lists) can be added inside of <![CDATA[ ]]> tag.
- Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-description -->
- <description><![CDATA[
- <h3>Trident</h3>
- Trident is a plugin for JetBrains IDEs that provides a fast and intuitive<br>
- way to navigate between files effortlessly.<br>
- <br>
- The plugin is inspired by the "Harpoon" plugin made<br>
- by ThePrimeagen for Neovim.<br>
- <br>
- Trident aims to bring the same experience to JetBrains IDEs.<br>
- but with additional features and proper integration with the IDE.<br>
- <br>
- Want to help contribute to the project?<br>
- Source code: <a href="https://github.com/Kyren223/Trident">GitHub Repo</a><br>
- ]]></description>
-
- <!-- Product and plugin compatibility requirements.
- Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
- <depends>com.intellij.modules.platform</depends>
- <depends optional="true" config-file="Trident-IdeaVim.xml">IdeaVIM</depends>
- <!-- Extension points defined by the plugin.
- Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
- <extensions defaultExtensionNs="com.intellij">
- <applicationConfigurable
- parentId="tools"
- instance="me.kyren223.trident.ui.SettingsConfigurable"
- id="me.kyren223.trident.ui.SettingsConfigurable"
- displayName="Trident Settings"/>
- <applicationService serviceImplementation="me.kyren223.trident.data.SettingsState"/>
- </extensions>
-
- <actions>
- <group id="me.kyren223.trident.mainGroup"
- text="Trident" description="Trident"
- popup="true">
- </group>
-
- <!-- Trident Select Buffer -->
- <action id="TridentSelect1" class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Buffer 1">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
- <action id="TridentSelect2" class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Buffer 2">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
- <action id="TridentSelect3" class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Buffer 3">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
- <action id="TridentSelect4" class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Buffer 4">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
- <action id="TridentSelect5" class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Buffer 5">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
- <action id="TridentSelect6" class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Buffer 6">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
- <action id="TridentSelect7" class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Buffer 7">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
- <action id="TridentSelect8" class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Buffer 8">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
- <action id="TridentSelect9" class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Buffer 9">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
- <action id="TridentSelect10" class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Buffer 10">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
-
- <!-- Select Previous & Next Buffer -->
- <action id="TridentSelectPrev"
- class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Previous Buffer">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
- <action id="TridentSelectNext"
- class="me.kyren223.trident.actions.TridentSelectAction"
- text="Select Next Buffer">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
-
- <!-- Append -->
- <action id="TridentAppend"
- class="me.kyren223.trident.actions.TridentAppendAction"
- text="Append File">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
-
- <!-- UI Actions -->
- <action id="TridentList"
- class="me.kyren223.trident.actions.TridentListAction"
- text="Toggle Quick Menu">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
-
- <action id="TridentListSelect"
- class="me.kyren223.trident.actions.TridentListSelectAction"
- text="Quick Menu Select">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
-
- <action id="TridentMappings"
- class="me.kyren223.trident.actions.TridentMappingsAction"
- text="Toggle Path Mappings Menu">
- <add-to-group group-id="me.kyren223.trident.mainGroup"/>
- </action>
- </actions>
-
+<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
+<idea-plugin>
+ <!-- Unique identifier of the plugin. It should be FQN. It cannot be changed between the plugin versions. -->
+ <id>me.kyren223.trident</id>
+
+ <!-- Public plugin name should be written in Title Case.
+ Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-name -->
+ <name>Trident</name>
+
+ <!-- A displayed Vendor name or Organization ID displayed on the Plugins Page. -->
+ <vendor email="ulmliad223@gmail.com" url="https://discord.gg/7vpTv7m3QR">Kyren223</vendor>
+
+ <!-- Description of the plugin displayed on the Plugin Page and IDE Plugin Manager.
+ Simple HTML elements (text formatting, paragraphs, and lists) can be added inside of <![CDATA[ ]]> tag.
+ Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-description -->
+ <description><![CDATA[
+ <h3>Trident</h3>
+ Trident is a plugin for JetBrains IDEs that provides a fast and intuitive<br>
+ way to navigate between files effortlessly.<br>
+ <br>
+ The plugin is inspired by the "Harpoon" plugin made<br>
+ by ThePrimeagen for Neovim.<br>
+ <br>
+ Trident aims to bring the same experience to JetBrains IDEs.<br>
+ but with additional features and proper integration with the IDE.<br>
+ <br>
+ Want to help contribute to the project?<br>
+ Source code: <a href="https://github.com/Kyren223/Trident">GitHub Repo</a><br>
+ ]]></description>
+
+ <!-- Product and plugin compatibility requirements.
+ Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
+ <depends>com.intellij.modules.platform</depends>
+ <depends optional="true" config-file="Trident-IdeaVim.xml">IdeaVIM</depends>
+ <!-- Extension points defined by the plugin.
+ Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
+ <extensions defaultExtensionNs="com.intellij">
+ <applicationConfigurable
+ parentId="tools"
+ instance="me.kyren223.trident.ui.SettingsConfigurable"
+ id="me.kyren223.trident.ui.SettingsConfigurable"
+ displayName="Trident Settings"/>
+ <applicationService serviceImplementation="me.kyren223.trident.data.SettingsState"/>
+ </extensions>
+
+ <actions>
+ <group id="me.kyren223.trident.mainGroup"
+ text="Trident" description="Trident"
+ popup="true">
+ </group>
+
+ <!-- Trident Select Buffer -->
+ <action id="TridentSelect1" class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Buffer 1">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+ <action id="TridentSelect2" class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Buffer 2">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+ <action id="TridentSelect3" class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Buffer 3">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+ <action id="TridentSelect4" class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Buffer 4">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+ <action id="TridentSelect5" class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Buffer 5">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+ <action id="TridentSelect6" class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Buffer 6">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+ <action id="TridentSelect7" class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Buffer 7">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+ <action id="TridentSelect8" class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Buffer 8">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+ <action id="TridentSelect9" class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Buffer 9">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+ <action id="TridentSelect10" class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Buffer 10">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+
+ <!-- Select Previous & Next Buffer -->
+ <action id="TridentSelectPrev"
+ class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Previous Buffer">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+ <action id="TridentSelectNext"
+ class="me.kyren223.trident.actions.TridentSelectAction"
+ text="Select Next Buffer">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+
+ <!-- Append -->
+ <action id="TridentAppend"
+ class="me.kyren223.trident.actions.TridentAppendAction"
+ text="Append File">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+
+ <!-- UI Actions -->
+ <action id="TridentList"
+ class="me.kyren223.trident.actions.TridentListAction"
+ text="Toggle Quick Menu">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+
+ <action id="TridentListSelect"
+ class="me.kyren223.trident.actions.TridentListSelectAction"
+ text="Quick Menu Select">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+
+ <action id="TridentMappings"
+ class="me.kyren223.trident.actions.TridentMappingsAction"
+ text="Toggle Path Mappings Menu">
+ <add-to-group group-id="me.kyren223.trident.mainGroup"/>
+ </action>
+ </actions>
+
</idea-plugin> \ No newline at end of file
diff --git a/src/main/resources/META-INF/pluginIcon.svg b/src/main/resources/META-INF/pluginIcon.svg
index e79cf98..1bcfd45 100644
--- a/src/main/resources/META-INF/pluginIcon.svg
+++ b/src/main/resources/META-INF/pluginIcon.svg
@@ -1,26 +1,26 @@
-<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
-<path d="M19.4431 20.5569V23.4283H16.5717V20.5569H19.4431Z" fill="#2B3339"/>
-<path d="M18.022 21.9781V24.8495H15.1506V21.9781H18.022Z" fill="#2B3339"/>
-<path d="M16.6008 23.3994V26.2708H13.7295V23.3994H16.6008Z" fill="#2B3339"/>
-<path d="M15.1797 24.8207V27.6921H12.3083V24.8207H15.1797Z" fill="#2B3339"/>
-<path d="M13.7581 26.2419V29.1133H10.8867V26.2419H13.7581Z" fill="#2B3339"/>
-<path d="M12.3372 27.6631V30.5345H9.46578V27.6631H12.3372Z" fill="#2B3339"/>
-<path d="M10.9155 29.0844V31.9557H8.04415V29.0844H10.9155Z" fill="#2B3339"/>
-<path d="M9.49463 30.5059V33.3772H6.62326V30.5059H9.49463Z" fill="#2B3339"/>
-<path d="M8.07324 31.9271V34.7985H5.20187V31.9271H8.07324Z" fill="#2B3339"/>
-<path d="M6.6521 33.3483V36.2196H3.78073V33.3483H6.6521Z" fill="#2B3339"/>
-<path d="M5.23071 34.7695V37.6409H2.35934V34.7695H5.23071Z" fill="#2B3339"/>
-<path d="M27.7678 12.2323V15.1037H24.8964V12.2323H27.7678Z" fill="#487494"/>
-<path d="M37.5647 12.2831V15.1545H34.6933V12.2831H37.5647Z" fill="#487494"/>
-<path d="M32.6411 7.3595V10.2309H29.7697V7.3595H32.6411Z" fill="#487494"/>
-<path d="M32.6917 17.1559V20.0273H29.8203V17.1559H32.6917Z" fill="#487494"/>
-<path d="M22.8953 17.1055V19.9768H20.0239V17.1055H22.8953Z" fill="#487494"/>
-<path d="M22.8442 7.30872V10.1801H19.9729V7.30872H22.8442Z" fill="#487494"/>
-<path d="M27.7173 2.43579V5.30716H24.8459V2.43579H27.7173Z" fill="#487494"/>
-<path d="M17.9717 12.1818V15.0531H15.1003V12.1818H17.9717Z" fill="#487494"/>
-<path d="M27.8188 22.0291V24.9004H24.9475V22.0291H27.8188Z" fill="#487494"/>
-<path d="M25.5708 3.1322L26.9921 4.55346L15.2667 16.2788L13.8454 14.8576L25.5708 3.1322Z" fill="#487494"/>
-<path d="M35.4182 12.9795L36.8395 14.4007L25.1141 26.1261L23.6928 24.7049L35.4182 12.9795Z" fill="#487494"/>
-<path d="M30.4944 8.05591L31.9156 9.47717L20.1903 21.2025L18.769 19.7813L30.4944 8.05591Z" fill="#487494"/>
-<path d="M13.8452 14.8575L25.1138 26.1261L23.6417 27.5981L12.3732 16.3296L13.8452 14.8575Z" fill="#487494"/>
-</svg>
+<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M19.4431 20.5569V23.4283H16.5717V20.5569H19.4431Z" fill="#2B3339"/>
+<path d="M18.022 21.9781V24.8495H15.1506V21.9781H18.022Z" fill="#2B3339"/>
+<path d="M16.6008 23.3994V26.2708H13.7295V23.3994H16.6008Z" fill="#2B3339"/>
+<path d="M15.1797 24.8207V27.6921H12.3083V24.8207H15.1797Z" fill="#2B3339"/>
+<path d="M13.7581 26.2419V29.1133H10.8867V26.2419H13.7581Z" fill="#2B3339"/>
+<path d="M12.3372 27.6631V30.5345H9.46578V27.6631H12.3372Z" fill="#2B3339"/>
+<path d="M10.9155 29.0844V31.9557H8.04415V29.0844H10.9155Z" fill="#2B3339"/>
+<path d="M9.49463 30.5059V33.3772H6.62326V30.5059H9.49463Z" fill="#2B3339"/>
+<path d="M8.07324 31.9271V34.7985H5.20187V31.9271H8.07324Z" fill="#2B3339"/>
+<path d="M6.6521 33.3483V36.2196H3.78073V33.3483H6.6521Z" fill="#2B3339"/>
+<path d="M5.23071 34.7695V37.6409H2.35934V34.7695H5.23071Z" fill="#2B3339"/>
+<path d="M27.7678 12.2323V15.1037H24.8964V12.2323H27.7678Z" fill="#487494"/>
+<path d="M37.5647 12.2831V15.1545H34.6933V12.2831H37.5647Z" fill="#487494"/>
+<path d="M32.6411 7.3595V10.2309H29.7697V7.3595H32.6411Z" fill="#487494"/>
+<path d="M32.6917 17.1559V20.0273H29.8203V17.1559H32.6917Z" fill="#487494"/>
+<path d="M22.8953 17.1055V19.9768H20.0239V17.1055H22.8953Z" fill="#487494"/>
+<path d="M22.8442 7.30872V10.1801H19.9729V7.30872H22.8442Z" fill="#487494"/>
+<path d="M27.7173 2.43579V5.30716H24.8459V2.43579H27.7173Z" fill="#487494"/>
+<path d="M17.9717 12.1818V15.0531H15.1003V12.1818H17.9717Z" fill="#487494"/>
+<path d="M27.8188 22.0291V24.9004H24.9475V22.0291H27.8188Z" fill="#487494"/>
+<path d="M25.5708 3.1322L26.9921 4.55346L15.2667 16.2788L13.8454 14.8576L25.5708 3.1322Z" fill="#487494"/>
+<path d="M35.4182 12.9795L36.8395 14.4007L25.1141 26.1261L23.6928 24.7049L35.4182 12.9795Z" fill="#487494"/>
+<path d="M30.4944 8.05591L31.9156 9.47717L20.1903 21.2025L18.769 19.7813L30.4944 8.05591Z" fill="#487494"/>
+<path d="M13.8452 14.8575L25.1138 26.1261L23.6417 27.5981L12.3732 16.3296L13.8452 14.8575Z" fill="#487494"/>
+</svg>