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" group = "org.acejump"
version = "chylex-16" version = "chylex-15"
repositories { repositories {
mavenCentral() mavenCentral()

View File

@ -13,7 +13,6 @@ 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 ||
@ -22,7 +21,6 @@ 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,7 +8,6 @@ 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,8 +22,7 @@ import kotlin.reflect.KProperty
*/ */
@Suppress("UsePropertyAccessSyntax") @Suppress("UsePropertyAccessSyntax")
internal class AceSettingsPanel { internal class AceSettingsPanel {
private val tagAllowedCharsField = JBTextField() private val tagCharsField = 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()
@ -32,8 +31,7 @@ internal class AceSettingsPanel {
private val searchHighlightColorWheel = ColorPanel() private val searchHighlightColorWheel = ColorPanel()
init { init {
tagAllowedCharsField.apply { font = Font("monospaced", font.style, font.size) } tagCharsField.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") }
} }
@ -43,8 +41,7 @@ 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(tagAllowedCharsField) } row("Allowed characters in tags:") { medium(tagCharsField) }
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) }
} }
@ -61,8 +58,7 @@ 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 tagAllowedCharsField internal var allowedChars by tagCharsField
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
@ -76,7 +72,6 @@ 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 allPossibleTagsLowercase: List<String> lateinit var allPossibleTags: List<String>
private set private set
/** /**
@ -39,15 +39,12 @@ internal object KeyLayoutCache {
) )
@Suppress("ConvertLambdaToReference") @Suppress("ConvertLambdaToReference")
val allSuffixChars = processCharList(settings.allowedChars).ifEmpty { processCharList(settings.layout.allChars).toList() } val allPossibleChars = settings.allowedChars
val allPrefixChars = processCharList(settings.prefixChars).filterNot(allSuffixChars::contains).plus("") .toCharArray()
.filter(Char::isLetterOrDigit)
.distinct()
.ifEmpty { settings.layout.allChars.toCharArray().toList() }
allPossibleTagsLowercase = allSuffixChars allPossibleTags = allPossibleChars.flatMap { listOf("$it", ";$it") }.sortedWith(tagOrder)
.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.allPossibleTagsLowercase.zip(tagSites).toMap() tagMap = KeyLayoutCache.allPossibleTags.zip(tagSites).toMap()
} }
internal fun type(char: Char): TaggingResult { internal fun type(char: Char): TaggingResult {
val newTypedTag = typedTag + char.lowercaseChar() val newTypedTag = typedTag + char
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) } val newTagMap = tagMap.filter { it.key.startsWith(newTypedTag, ignoreCase = true) }
if (newTagMap.isEmpty()) { if (newTagMap.isEmpty()) {
return TaggingResult.Nothing 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. * 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 {
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)
} }
/** /**