1
0
mirror of https://github.com/chylex/IntelliJ-AceJump.git synced 2025-04-09 17:15:43 +02:00

progress on fixing ,

This commit is contained in:
breandan 2018-10-08 09:50:12 -04:00
parent 48d96b294b
commit 76908c67cf
9 changed files with 42 additions and 37 deletions
.idea/runConfigurations
src/main

View File

@ -5,7 +5,7 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--build-cache" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
@ -16,6 +16,7 @@
</option>
<option name="vmOptions" value="" />
</ExternalSystemSettings>
<method />
<GradleScriptDebugEnabled>true</GradleScriptDebugEnabled>
<method v="2" />
</configuration>
</component>

View File

@ -5,16 +5,18 @@ import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.options.Configurable
import org.acejump.view.Model.Settings
import com.intellij.openapi.diagnostic.Logger
import javax.swing.JComponent
@State(name = "AceConfig", storages = [(Storage("AceJump.xml"))])
class AceConfig : Configurable, PersistentStateComponent<Settings> {
companion object {
var settings = Settings()
}
object AceConfig : Configurable, PersistentStateComponent<Settings> {
private val logger = Logger.getInstance(AceConfig::class.java)
var settings: Settings = Settings()
override fun getState() = settings
override fun loadState(state: Settings) {
logger.info("Loaded AceConfig settings: $settings")
settings = state
}
@ -23,7 +25,7 @@ class AceConfig : Configurable, PersistentStateComponent<Settings> {
override fun getDisplayName() = "AceJump"
override fun createComponent(): JComponent =
AceSettingsPanel().apply { gui = this }.rootPanel
AceSettingsPanel().apply { gui = this }.rootPanel
override fun isModified() =
gui.allowedChars != settings.allowedChars ||
@ -40,7 +42,11 @@ class AceConfig : Configurable, PersistentStateComponent<Settings> {
gui.textHighlightColor?.let { settings.textHighlightColor = it }
gui.tagForegroundColor?.let { settings.tagForegroundColor = it }
gui.tagBackgroundColor?.let { settings.tagBackgroundColor = it }
logger.info("User applied new settings: $settings")
}
override fun reset() = gui.reset(settings)
override fun reset() {
logger.info("Resetting settings")
gui.reset(settings)
}
}

View File

@ -99,9 +99,9 @@ class AceSettingsPanel {
}
}
var allowedChars: List<Char>
get() = tagCharacters.text.toLowerCase().toList().distinct()
set(value) = tagCharacters.setText(value.joinToString(""))
var allowedChars: String
get() = tagCharacters.text.toLowerCase().toList().distinct().joinToString("")
set(value) = tagCharacters.setText(value)
var jumpModeColor by jumpModeColorChooser
var targetModeColor by targetModeColorChooser
@ -118,7 +118,7 @@ class AceSettingsPanel {
tagBackgroundColor = settings.tagBackgroundColor
}
// Removal pending support for https://youtrack.jetbrains.com/issue/KT-8658
// Removal pending support for https://youtrack.jetbrains.com/issue/KT-8575
private operator fun ColorPanel.getValue(a: AceSettingsPanel, p: KProperty<*>) = selectedColor
private operator fun ColorPanel.setValue(a: AceSettingsPanel, p: KProperty<*>, c: Color?) {

View File

@ -22,7 +22,7 @@ import java.awt.event.KeyEvent
*/
open class AceAction : DumbAwareAction() {
val logger = Logger.getInstance(AceAction::class.java)
open val logger = Logger.getInstance(javaClass)
override fun update(action: AnActionEvent) {
action.presentation.isEnabled = action.getData(EDITOR) != null
}

View File

@ -96,7 +96,6 @@ object Handler : TypedActionHandler, Resettable {
// Investigate replacing this with `IDEEventQueue.*Dispatcher(...)`
private fun JComponent.installCustomShortcutHandler() {
logger.info("Installing custom shortcuts")
defaultAction = getClientProperty(ACTIONS_KEY) as List<*>?
putClientProperty(ACTIONS_KEY, SmartList<AnAction>(AceKeyAction))
val css = CustomShortcutSet(*keyMap.keys.toTypedArray())
@ -104,7 +103,6 @@ object Handler : TypedActionHandler, Resettable {
}
private fun JComponent.uninstallCustomShortCutHandler() {
logger.info("Uninstalling custom shortcuts")
putClientProperty(ACTIONS_KEY, defaultAction)
AceKeyAction.unregisterCustomShortcutSet(this)
editorTypeAction.setupRawHandler(handler)

View File

@ -1,6 +1,6 @@
package org.acejump.label
import org.acejump.config.AceConfig.Companion.settings
import org.acejump.config.AceConfig
/**
* Patterns related to key priority, separation, and regexps for line mode.
@ -20,11 +20,11 @@ enum class Pattern(val string: String) {
fun priority(char: Char) = priority[char]
private var _allowedChars = settings.allowedChars
private var _allowedChars = AceConfig.settings.allowedChars
private var allBigrams = emptyList<String>()
get() {
if (settings.allowedChars != _allowedChars || field.isEmpty()) {
_allowedChars = settings.allowedChars
if (AceConfig.settings.allowedChars != _allowedChars || field.isEmpty()) {
_allowedChars = AceConfig.settings.allowedChars
field = _allowedChars.run { flatMap { e -> map { c -> "$e$c" } } }
}
@ -35,7 +35,7 @@ enum class Pattern(val string: String) {
get() = NUM_CHARS * NUM_CHARS
var NUM_CHARS: Int = 36
get() = settings.allowedChars.size
get() = AceConfig.settings.allowedChars.length
val defaultOrder: Comparator<String> = compareBy(
{ it[0].isDigit() || it[1].isDigit() },

View File

@ -3,7 +3,7 @@ package org.acejump.view
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.markup.CustomHighlighterRenderer
import com.intellij.openapi.editor.markup.RangeHighlighter
import org.acejump.config.AceConfig.Companion.settings
import org.acejump.config.AceConfig
import org.acejump.label.Tagger.regex
import org.acejump.search.*
import org.acejump.search.JumpMode.TARGET
@ -86,7 +86,7 @@ class Marker(val query: String, val tag: String?, val index: Int)
setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON)
color = settings.textHighlightColor
color = AceConfig.settings.textHighlightColor
if (regex) highlightRegex()
else {
fillRoundRect(start.x, startY, searchWidth, rectHeight, arcD, arcD)
@ -95,7 +95,7 @@ class Marker(val query: String, val tag: String?, val index: Int)
}
private fun Graphics2D.surroundTargetWord() {
color = settings.targetModeColor
color = AceConfig.settings.targetModeColor
val (wordStart, wordEnd) = text.wordBounds(index)
val xPos = editor.getPoint(wordStart).x
@ -107,7 +107,7 @@ class Marker(val query: String, val tag: String?, val index: Int)
private fun Graphics2D.drawTagForeground(tagPosition: Point?) {
font = Model.font
color = settings.tagForegroundColor
color = AceConfig.settings.tagForegroundColor
composite = getInstance(SRC_OVER, 1.toFloat())
drawString(tag!!.toUpperCase(), tagPosition!!.x, tagPosition.y + fontHeight)
@ -156,7 +156,7 @@ class Marker(val query: String, val tag: String?, val index: Int)
fun highlightFirst() {
composite = getInstance(SRC_OVER, 0.40.toFloat())
color = settings.textHighlightColor
color = AceConfig.settings.textHighlightColor
if (tag != null && lastQueryChar == tag.first() && lastQueryChar != textChar) {
fillRoundRect(tagX, yPos, fontWidth, rectHeight, arcD, arcD)
@ -166,7 +166,7 @@ class Marker(val query: String, val tag: String?, val index: Int)
}
fun highlightLast() {
color = settings.tagBackgroundColor
color = AceConfig.settings.tagBackgroundColor
if (alignment != RIGHT || text.hasSpaceRight(index) || regex)
composite = getInstance(SRC_OVER, 1.toFloat())

View File

@ -11,7 +11,7 @@ import com.intellij.openapi.editor.markup.EffectType.ROUNDED_BOX
import com.intellij.openapi.editor.markup.TextAttributes
import com.intellij.openapi.project.ProjectManager
import org.acejump.config.AceConfig
import org.acejump.config.AceConfig.Companion.settings
import org.acejump.config.AceConfig.settings
import org.acejump.search.defaultEditor
import org.acejump.view.Boundary.FullFileBoundary
import java.awt.Color
@ -61,9 +61,9 @@ object Model {
.getAttributes(TEXT_SEARCH_RESULT_ATTRIBUTES)?.backgroundColor ?: YELLOW
val targetModeHighlightStyle =
TextAttributes(null, null, settings.targetModeColor, ROUNDED_BOX, PLAIN)
TextAttributes(null, null, AceConfig.settings.targetModeColor, ROUNDED_BOX, PLAIN)
val textHighlightStyle =
TextAttributes(null, GREEN, settings.textHighlightColor, BOXED, PLAIN)
TextAttributes(null, GREEN, AceConfig.settings.textHighlightColor, BOXED, PLAIN)
val scheme
get() = editor.colorsScheme
@ -89,8 +89,8 @@ object Model {
val DEFAULT_BOUNDARY = FullFileBoundary
var boundaries: Boundary = DEFAULT_BOUNDARY
data class Settings(var allowedChars: List<Char> =
('a'..'z').plus('0'..'9').toList(),
data class Settings(var allowedChars: String =
('a'..'z').plus('0'..'9').joinToString(""),
var jumpModeColor: Color = BLUE,
var targetModeColor: Color = RED,
var definitionModeColor: Color = MAGENTA,

View File

@ -22,14 +22,14 @@ Pressing [Enter] during a search will now jump to the next visible match (or clo
<vendor url="https://github.com/acejump/AceJump">AceJump</vendor>
<idea-version since-build="143.379"/>
<!--<application-components>-->
<!--<component>-->
<!--<implementation-class>org.acejump.config.AceConfig</implementation-class>-->
<!--</component>-->
<!--</application-components>-->
<application-components>
<component>
<implementation-class>org.acejump.config.AceConfig</implementation-class>
</component>
</application-components>
<extensions defaultExtensionNs="com.intellij">
<applicationService serviceInterface="org.acejump.config.AceConfig" serviceImplementation="org.acejump.config.AceConfig"/>
<applicationService serviceInterface="org.acejump.config.AceConfig" serviceImplementation="org.acejump.config.AceConfig" overrides="true"/>
<applicationConfigurable groupId="tools" displayName="AceJump" id="preferences.AceConfigurable" instance="org.acejump.config.AceConfig"/>
</extensions>