mirror of
https://github.com/chylex/IntelliJ-AceJump.git
synced 2024-11-24 23:42:46 +01:00
Compare commits
2 Commits
cb814e0999
...
568128f474
Author | SHA1 | Date | |
---|---|---|---|
568128f474 | |||
018d29007c |
@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "org.acejump"
|
||||
version = "chylex-25"
|
||||
version = "chylex-26"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -20,6 +20,7 @@ class AceConfig : PersistentStateComponent<AceSettings> {
|
||||
|
||||
val layout get() = settings.layout
|
||||
val minQueryLength get() = settings.minQueryLength
|
||||
val invertUppercaseMode get() = settings.invertUppercaseMode
|
||||
val editorFadeOpacity get() = settings.editorFadeOpacity
|
||||
val jumpModeColor get() = settings.jumpModeColor
|
||||
val tagForegroundColor1 get() = settings.tagForegroundColor1
|
||||
|
@ -15,6 +15,7 @@ class AceConfigurable : Configurable {
|
||||
panel.allowedChars != settings.allowedChars ||
|
||||
panel.keyboardLayout != settings.layout ||
|
||||
panel.minQueryLengthInt != settings.minQueryLength ||
|
||||
panel.invertUppercaseMode != settings.invertUppercaseMode ||
|
||||
panel.editorFadeOpacityPercent != settings.editorFadeOpacity ||
|
||||
panel.jumpModeColor != settings.jumpModeColor ||
|
||||
panel.tagForegroundColor1 != settings.tagForegroundColor1 ||
|
||||
@ -25,6 +26,7 @@ class AceConfigurable : Configurable {
|
||||
settings.allowedChars = panel.allowedChars
|
||||
settings.layout = panel.keyboardLayout
|
||||
settings.minQueryLength = panel.minQueryLengthInt ?: settings.minQueryLength
|
||||
settings.invertUppercaseMode = panel.invertUppercaseMode
|
||||
settings.editorFadeOpacity = panel.editorFadeOpacityPercent
|
||||
panel.jumpModeColor?.let { settings.jumpModeColor = it }
|
||||
panel.tagForegroundColor1?.let { settings.tagForegroundColor1 = it }
|
||||
|
@ -8,6 +8,7 @@ import java.awt.Color
|
||||
data class AceSettings(
|
||||
var layout: KeyLayout = QWERTY,
|
||||
var allowedChars: String = layout.allChars,
|
||||
var invertUppercaseMode: Boolean = false,
|
||||
var minQueryLength: Int = 1,
|
||||
var editorFadeOpacity: Int = 70,
|
||||
|
||||
|
@ -2,6 +2,7 @@ package org.acejump.config
|
||||
|
||||
import com.intellij.openapi.ui.ComboBox
|
||||
import com.intellij.ui.ColorPanel
|
||||
import com.intellij.ui.components.JBCheckBox
|
||||
import com.intellij.ui.components.JBSlider
|
||||
import com.intellij.ui.components.JBTextArea
|
||||
import com.intellij.ui.components.JBTextField
|
||||
@ -30,6 +31,7 @@ internal class AceSettingsPanel {
|
||||
private val keyboardLayoutCombo = ComboBox<KeyLayout>()
|
||||
private val keyboardLayoutArea = JBTextArea().apply { isEditable = false }
|
||||
private val minQueryLengthField = JBTextField()
|
||||
private val invertUppercaseModeCheckBox = JBCheckBox("Invert uppercase mode")
|
||||
private val editorFadeOpacitySlider = JBSlider(0, 10).apply {
|
||||
labelTable = Hashtable((0..10).associateWith { JLabel("${it * 10}") })
|
||||
paintTrack = true
|
||||
@ -59,6 +61,7 @@ internal class AceSettingsPanel {
|
||||
|
||||
group("Behavior") {
|
||||
row("Minimum typed characters (1-10):") { cell(minQueryLengthField).columns(COLUMNS_SHORT) }
|
||||
row { cell(invertUppercaseModeCheckBox) }
|
||||
}
|
||||
|
||||
group("Colors") {
|
||||
@ -83,6 +86,7 @@ internal class AceSettingsPanel {
|
||||
internal var keyboardLayout by keyboardLayoutCombo
|
||||
internal var keyChars by keyboardLayoutArea
|
||||
internal var minQueryLength by minQueryLengthField
|
||||
internal var invertUppercaseMode by invertUppercaseModeCheckBox
|
||||
internal var editorFadeOpacity by editorFadeOpacitySlider
|
||||
internal var jumpModeColor by jumpModeColorWheel
|
||||
internal var tagForegroundColor1 by tagForeground1ColorWheel
|
||||
@ -101,6 +105,7 @@ internal class AceSettingsPanel {
|
||||
allowedChars = settings.allowedChars
|
||||
keyboardLayout = settings.layout
|
||||
minQueryLength = settings.minQueryLength.toString()
|
||||
invertUppercaseMode = settings.invertUppercaseMode
|
||||
editorFadeOpacityPercent = settings.editorFadeOpacity
|
||||
jumpModeColor = settings.jumpModeColor
|
||||
tagForegroundColor1 = settings.tagForegroundColor1
|
||||
|
@ -12,9 +12,9 @@ import org.acejump.matchesAt
|
||||
/**
|
||||
* Searches editor text for matches of a [SearchQuery], and updates previous results when the user [refineQuery]s a character.
|
||||
*/
|
||||
class SearchProcessor private constructor(query: SearchQuery, val boundaries: Boundaries, private val results: MutableMap<Editor, IntArrayList>) {
|
||||
internal constructor(editors: List<Editor>, query: SearchQuery, boundaries: Boundaries) : this(query, boundaries, mutableMapOf()) {
|
||||
val regex = query.toRegex()
|
||||
class SearchProcessor private constructor(query: SearchQuery, val boundaries: Boundaries, val invertUppercaseMode: Boolean, private val results: MutableMap<Editor, IntArrayList>) {
|
||||
internal constructor(editors: List<Editor>, query: SearchQuery, boundaries: Boundaries, invertUppercaseMode: Boolean) : this(query, boundaries, invertUppercaseMode, mutableMapOf()) {
|
||||
val regex = query.toRegex(invertUppercaseMode)
|
||||
|
||||
if (regex != null) {
|
||||
for (editor in editors) {
|
||||
|
@ -21,7 +21,7 @@ internal sealed class SearchQuery {
|
||||
/**
|
||||
* Converts the query into a regular expression to find the initial matches.
|
||||
*/
|
||||
abstract fun toRegex(): Regex?
|
||||
abstract fun toRegex(invertUppercaseMode: Boolean): Regex?
|
||||
|
||||
/**
|
||||
* Searches for all occurrences of a literal text query.
|
||||
@ -41,14 +41,14 @@ internal sealed class SearchQuery {
|
||||
return text.countMatchingCharacters(offset, rawText)
|
||||
}
|
||||
|
||||
override fun toRegex(): Regex {
|
||||
override fun toRegex(invertUppercaseMode: Boolean): Regex {
|
||||
val firstChar = rawText.first()
|
||||
val pattern = if (firstChar.isLowerCase()) {
|
||||
val pattern = if (firstChar.isLowerCase() xor invertUppercaseMode) {
|
||||
val fullPattern = Regex.escape(rawText)
|
||||
"(?i)$fullPattern"
|
||||
}
|
||||
else {
|
||||
val firstCharUppercasePattern = Regex.escape(firstChar.toString())
|
||||
val firstCharUppercasePattern = Regex.escape(firstChar.uppercase())
|
||||
val firstCharLowercasePattern = Regex.escape(firstChar.lowercase())
|
||||
val remainingPattern = if (rawText.length > 1) Regex.escape(rawText.drop(1)) else ""
|
||||
"(?:$firstCharUppercasePattern|(?<![a-zA-Z])$firstCharLowercasePattern)$remainingPattern"
|
||||
@ -72,7 +72,7 @@ internal sealed class SearchQuery {
|
||||
return 1
|
||||
}
|
||||
|
||||
override fun toRegex(): Regex {
|
||||
override fun toRegex(invertUppercaseMode: Boolean): Regex {
|
||||
return Regex(pattern, setOf(RegexOption.MULTILINE, RegexOption.IGNORE_CASE))
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ class Session(private val mainEditor: Editor, private val jumpEditors: List<Edit
|
||||
}
|
||||
|
||||
setMode(mode())
|
||||
state = SessionState.WaitForKey(actions, jumpEditors, defaultBoundary)
|
||||
state = SessionState.WaitForKey(actions, jumpEditors, defaultBoundary, AceConfig.invertUppercaseMode)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +128,7 @@ class Session(private val mainEditor: Editor, private val jumpEditors: List<Edit
|
||||
canvas.setMarkers(emptyList())
|
||||
}
|
||||
|
||||
val processor = SearchProcessor(jumpEditors, SearchQuery.RegularExpression(pattern.regex), defaultBoundary)
|
||||
val processor = SearchProcessor(jumpEditors, SearchQuery.RegularExpression(pattern.regex), defaultBoundary, AceConfig.invertUppercaseMode)
|
||||
textHighlighter.renderOccurrences(processor.resultsCopy, processor.query)
|
||||
|
||||
state = SessionState.SelectTag(actions, jumpEditors, processor)
|
||||
|
@ -16,9 +16,10 @@ sealed interface SessionState {
|
||||
private val actions: SessionActions,
|
||||
private val jumpEditors: List<Editor>,
|
||||
private val defaultBoundary: Boundaries,
|
||||
private val invertUppercaseMode: Boolean,
|
||||
) : SessionState {
|
||||
override fun type(char: Char): TypeResult {
|
||||
val searchProcessor = SearchProcessor(jumpEditors, SearchQuery.Literal(char.toString()), defaultBoundary)
|
||||
val searchProcessor = SearchProcessor(jumpEditors, SearchQuery.Literal(char.toString()), defaultBoundary, invertUppercaseMode)
|
||||
|
||||
return if (searchProcessor.isQueryFinished) {
|
||||
TypeResult.ChangeState(SelectTag(actions, jumpEditors, searchProcessor))
|
||||
@ -72,10 +73,14 @@ sealed interface SessionState {
|
||||
else -> searchProcessor.boundaries
|
||||
}
|
||||
|
||||
val newSearchProcessor = SearchProcessor(jumpEditors, query, newBoundaries)
|
||||
val newSearchProcessor = SearchProcessor(jumpEditors, query, newBoundaries, searchProcessor.invertUppercaseMode)
|
||||
return TypeResult.ChangeState(SelectTag(actions, jumpEditors, newSearchProcessor))
|
||||
}
|
||||
}
|
||||
else if (char == '\n') {
|
||||
val newSearchProcessor = SearchProcessor(jumpEditors, searchProcessor.query, searchProcessor.boundaries, !searchProcessor.invertUppercaseMode)
|
||||
return TypeResult.ChangeState(SelectTag(actions, jumpEditors, newSearchProcessor))
|
||||
}
|
||||
|
||||
return when (val result = tagger.type(AceConfig.layout.characterRemapping.getOrDefault(char, char))) {
|
||||
is TaggingResult.Nothing -> TypeResult.Nothing
|
||||
|
Loading…
Reference in New Issue
Block a user