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

Compare commits

..

3 Commits

7 changed files with 27 additions and 21 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

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) } } .flatMap { (editor, sites) -> sites.map { site -> Tag(editor, site) } }
.sortedWith(siteOrder(editors, caches)) .sortedWith(siteOrder(editors, caches))
tagMap = KeyLayoutCache.allPossibleTags.zip(tagSites).toMap() tagMap = KeyLayoutCache.allPossibleTagsLowercase.zip(tagSites).toMap()
} }
internal fun type(char: Char): TaggingResult { internal fun type(char: Char): TaggingResult {
val newTypedTag = typedTag + char val newTypedTag = typedTag + char.lowercaseChar()
val matchingTag = tagMap[newTypedTag] val matchingTag = tagMap[newTypedTag]
if (matchingTag != null) { if (matchingTag != null) {
return TaggingResult.Accept(matchingTag) return TaggingResult.Accept(matchingTag)
} }
val newTagMap = tagMap.filter { it.key.startsWith(newTypedTag, ignoreCase = true) } val newTagMap = tagMap.filter { it.key.startsWith(newTypedTag) }
if (newTagMap.isEmpty()) { if (newTagMap.isEmpty()) {
return TaggingResult.Nothing return TaggingResult.Nothing
} }

View File

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