From 7451f83d6685073d10df9bae5c957fdb55dcdc53 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Fri, 23 Aug 2024 00:31:20 +0300 Subject: fix: issues with IdeaVim version 2.16.0, everything should work now --- .../kotlin/me/kyren223/trident/data/Settings.kt | 66 ++-- .../me/kyren223/trident/data/SettingsData.kt | 350 ++++++++++----------- 2 files changed, 208 insertions(+), 208 deletions(-) (limited to 'src/main/kotlin/me/kyren223/trident/data') 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 { - 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 { + 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, +} -- cgit v1.3.1