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

Compare commits

..

No commits in common. "568128f474bc3b359401f65e8d94c103cda0d2f2" and "cb814e099917fab86ad5d182a34fb47a997cbda3" have entirely different histories.

9 changed files with 13 additions and 27 deletions

View File

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

View File

@ -20,7 +20,6 @@ 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

View File

@ -15,7 +15,6 @@ 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 ||
@ -26,7 +25,6 @@ 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 }

View File

@ -8,7 +8,6 @@ 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,

View File

@ -2,7 +2,6 @@ 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
@ -31,7 +30,6 @@ 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
@ -61,7 +59,6 @@ internal class AceSettingsPanel {
group("Behavior") {
row("Minimum typed characters (1-10):") { cell(minQueryLengthField).columns(COLUMNS_SHORT) }
row { cell(invertUppercaseModeCheckBox) }
}
group("Colors") {
@ -86,7 +83,6 @@ 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
@ -105,7 +101,6 @@ 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

View File

@ -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, 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)
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()
if (regex != null) {
for (editor in editors) {

View File

@ -21,7 +21,7 @@ internal sealed class SearchQuery {
/**
* Converts the query into a regular expression to find the initial matches.
*/
abstract fun toRegex(invertUppercaseMode: Boolean): Regex?
abstract fun toRegex(): 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(invertUppercaseMode: Boolean): Regex {
override fun toRegex(): Regex {
val firstChar = rawText.first()
val pattern = if (firstChar.isLowerCase() xor invertUppercaseMode) {
val pattern = if (firstChar.isLowerCase()) {
val fullPattern = Regex.escape(rawText)
"(?i)$fullPattern"
}
else {
val firstCharUppercasePattern = Regex.escape(firstChar.uppercase())
val firstCharUppercasePattern = Regex.escape(firstChar.toString())
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(invertUppercaseMode: Boolean): Regex {
override fun toRegex(): Regex {
return Regex(pattern, setOf(RegexOption.MULTILINE, RegexOption.IGNORE_CASE))
}
}

View File

@ -113,7 +113,7 @@ class Session(private val mainEditor: Editor, private val jumpEditors: List<Edit
}
setMode(mode())
state = SessionState.WaitForKey(actions, jumpEditors, defaultBoundary, AceConfig.invertUppercaseMode)
state = SessionState.WaitForKey(actions, jumpEditors, defaultBoundary)
}
/**
@ -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, AceConfig.invertUppercaseMode)
val processor = SearchProcessor(jumpEditors, SearchQuery.RegularExpression(pattern.regex), defaultBoundary)
textHighlighter.renderOccurrences(processor.resultsCopy, processor.query)
state = SessionState.SelectTag(actions, jumpEditors, processor)

View File

@ -16,10 +16,9 @@ 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, invertUppercaseMode)
val searchProcessor = SearchProcessor(jumpEditors, SearchQuery.Literal(char.toString()), defaultBoundary)
return if (searchProcessor.isQueryFinished) {
TypeResult.ChangeState(SelectTag(actions, jumpEditors, searchProcessor))
@ -73,14 +72,10 @@ sealed interface SessionState {
else -> searchProcessor.boundaries
}
val newSearchProcessor = SearchProcessor(jumpEditors, query, newBoundaries, searchProcessor.invertUppercaseMode)
val newSearchProcessor = SearchProcessor(jumpEditors, query, newBoundaries)
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