1
0
mirror of https://github.com/chylex/IntelliJ-AceJump.git synced 2024-11-25 17:42:46 +01:00

Compare commits

..

No commits in common. "fa3505b8500f31adda3bf5087f1cdefa1c21aff1" and "084d729baa27a4e15fb37b57be8d868de3d896c8" have entirely different histories.

7 changed files with 21 additions and 27 deletions

View File

@ -8,7 +8,7 @@ plugins {
}
group = "org.acejump"
version = "chylex-16"
version = "chylex-15"
repositories {
mavenCentral()

View File

@ -13,7 +13,6 @@ class AceConfigurable : Configurable {
override fun isModified() =
panel.allowedChars != settings.allowedChars ||
panel.prefixChars != settings.prefixChars ||
panel.keyboardLayout != settings.layout ||
panel.minQueryLengthInt != settings.minQueryLength ||
panel.jumpModeColor != settings.jumpModeColor ||
@ -22,7 +21,6 @@ class AceConfigurable : Configurable {
override fun apply() {
settings.allowedChars = panel.allowedChars
settings.prefixChars = panel.prefixChars
settings.layout = panel.keyboardLayout
settings.minQueryLength = panel.minQueryLengthInt ?: settings.minQueryLength
panel.jumpModeColor?.let { settings.jumpModeColor = it }

View File

@ -8,7 +8,6 @@ import java.awt.Color
data class AceSettings(
var layout: KeyLayout = QWERTY,
var allowedChars: String = layout.allChars,
var prefixChars: String = ";",
var minQueryLength: Int = 1,
@OptionTag("jumpModeRGB", converter = ColorConverter::class)

View File

@ -22,8 +22,7 @@ import kotlin.reflect.KProperty
*/
@Suppress("UsePropertyAccessSyntax")
internal class AceSettingsPanel {
private val tagAllowedCharsField = JBTextField()
private val tagPrefixCharsField = JBTextField()
private val tagCharsField = JBTextField()
private val keyboardLayoutCombo = ComboBox<KeyLayout>()
private val keyboardLayoutArea = JBTextArea().apply { isEditable = false }
private val minQueryLengthField = JBTextField()
@ -32,8 +31,7 @@ internal class AceSettingsPanel {
private val searchHighlightColorWheel = ColorPanel()
init {
tagAllowedCharsField.apply { font = Font("monospaced", font.style, font.size) }
tagPrefixCharsField.apply { font = Font("monospaced", font.style, font.size) }
tagCharsField.apply { font = Font("monospaced", font.style, font.size) }
keyboardLayoutArea.apply { font = Font("monospaced", font.style, font.size) }
keyboardLayoutCombo.setupEnumItems { keyChars = it.rows.joinToString("\n") }
}
@ -43,8 +41,7 @@ internal class AceSettingsPanel {
fun Cell.medium(component: JComponent) = component(growPolicy = MEDIUM_TEXT)
titledRow("Characters and Layout") {
row("Allowed characters in tags:") { medium(tagAllowedCharsField) }
row("Allowed prefix characters in tags:") { medium(tagPrefixCharsField) }
row("Allowed characters in tags:") { medium(tagCharsField) }
row("Keyboard layout:") { short(keyboardLayoutCombo) }
row("Keyboard design:") { short(keyboardLayoutArea) }
}
@ -61,8 +58,7 @@ internal class AceSettingsPanel {
}
// Property-to-property delegation: https://stackoverflow.com/q/45074596/1772342
internal var allowedChars by tagAllowedCharsField
internal var prefixChars by tagPrefixCharsField
internal var allowedChars by tagCharsField
internal var keyboardLayout by keyboardLayoutCombo
internal var keyChars by keyboardLayoutArea
internal var minQueryLength by minQueryLengthField
@ -76,7 +72,6 @@ internal class AceSettingsPanel {
fun reset(settings: AceSettings) {
allowedChars = settings.allowedChars
prefixChars = settings.prefixChars
keyboardLayout = settings.layout
minQueryLength = settings.minQueryLength.toString()
jumpModeColor = settings.jumpModeColor

View File

@ -17,7 +17,7 @@ internal object KeyLayoutCache {
/**
* Returns all possible two key tags, pre-sorted according to [tagOrder].
*/
lateinit var allPossibleTagsLowercase: List<String>
lateinit var allPossibleTags: List<String>
private set
/**
@ -39,15 +39,12 @@ internal object KeyLayoutCache {
)
@Suppress("ConvertLambdaToReference")
val allSuffixChars = processCharList(settings.allowedChars).ifEmpty { processCharList(settings.layout.allChars).toList() }
val allPrefixChars = processCharList(settings.prefixChars).filterNot(allSuffixChars::contains).plus("")
val allPossibleChars = settings.allowedChars
.toCharArray()
.filter(Char::isLetterOrDigit)
.distinct()
.ifEmpty { settings.layout.allChars.toCharArray().toList() }
allPossibleTagsLowercase = allSuffixChars
.flatMap { suffix -> allPrefixChars.map { prefix -> "$prefix$suffix" } }
.sortedWith(tagOrder)
}
private fun processCharList(charList: String): Set<String> {
return charList.toCharArray().map(Char::lowercase).toSet()
allPossibleTags = allPossibleChars.flatMap { listOf("$it", ";$it") }.sortedWith(tagOrder)
}
}

View File

@ -43,17 +43,17 @@ class Tagger(private val editors: List<Editor>, results: Map<Editor, IntList>) {
.flatMap { (editor, sites) -> sites.map { site -> Tag(editor, site) } }
.sortedWith(siteOrder(editors, caches))
tagMap = KeyLayoutCache.allPossibleTagsLowercase.zip(tagSites).toMap()
tagMap = KeyLayoutCache.allPossibleTags.zip(tagSites).toMap()
}
internal fun type(char: Char): TaggingResult {
val newTypedTag = typedTag + char.lowercaseChar()
val newTypedTag = typedTag + char
val matchingTag = tagMap[newTypedTag]
if (matchingTag != null) {
return TaggingResult.Accept(matchingTag)
}
val newTagMap = tagMap.filter { it.key.startsWith(newTypedTag) }
val newTagMap = tagMap.filter { it.key.startsWith(newTypedTag, ignoreCase = true) }
if (newTagMap.isEmpty()) {
return TaggingResult.Nothing
}

View File

@ -28,7 +28,12 @@ internal class TagMarker(
* character ([typedTag]) matches the first [tag] character, only the second [tag] character is displayed.
*/
fun create(tag: String, offset: Int, typedTag: String): TagMarker {
return TagMarker(tag.drop(typedTag.length), offset)
val displayedTag = if (typedTag.isNotEmpty() && typedTag.last().equals(tag.first(), ignoreCase = true))
tag.drop(1).uppercase()
else
tag.uppercase()
return TagMarker(displayedTag, offset)
}
/**