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.
568128f474
...
cb814e0999
@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "org.acejump"
|
group = "org.acejump"
|
||||||
version = "chylex-26"
|
version = "chylex-25"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -20,7 +20,6 @@ class AceConfig : PersistentStateComponent<AceSettings> {
|
|||||||
|
|
||||||
val layout get() = settings.layout
|
val layout get() = settings.layout
|
||||||
val minQueryLength get() = settings.minQueryLength
|
val minQueryLength get() = settings.minQueryLength
|
||||||
val invertUppercaseMode get() = settings.invertUppercaseMode
|
|
||||||
val editorFadeOpacity get() = settings.editorFadeOpacity
|
val editorFadeOpacity get() = settings.editorFadeOpacity
|
||||||
val jumpModeColor get() = settings.jumpModeColor
|
val jumpModeColor get() = settings.jumpModeColor
|
||||||
val tagForegroundColor1 get() = settings.tagForegroundColor1
|
val tagForegroundColor1 get() = settings.tagForegroundColor1
|
||||||
|
@ -15,7 +15,6 @@ class AceConfigurable : Configurable {
|
|||||||
panel.allowedChars != settings.allowedChars ||
|
panel.allowedChars != settings.allowedChars ||
|
||||||
panel.keyboardLayout != settings.layout ||
|
panel.keyboardLayout != settings.layout ||
|
||||||
panel.minQueryLengthInt != settings.minQueryLength ||
|
panel.minQueryLengthInt != settings.minQueryLength ||
|
||||||
panel.invertUppercaseMode != settings.invertUppercaseMode ||
|
|
||||||
panel.editorFadeOpacityPercent != settings.editorFadeOpacity ||
|
panel.editorFadeOpacityPercent != settings.editorFadeOpacity ||
|
||||||
panel.jumpModeColor != settings.jumpModeColor ||
|
panel.jumpModeColor != settings.jumpModeColor ||
|
||||||
panel.tagForegroundColor1 != settings.tagForegroundColor1 ||
|
panel.tagForegroundColor1 != settings.tagForegroundColor1 ||
|
||||||
@ -26,7 +25,6 @@ class AceConfigurable : Configurable {
|
|||||||
settings.allowedChars = panel.allowedChars
|
settings.allowedChars = panel.allowedChars
|
||||||
settings.layout = panel.keyboardLayout
|
settings.layout = panel.keyboardLayout
|
||||||
settings.minQueryLength = panel.minQueryLengthInt ?: settings.minQueryLength
|
settings.minQueryLength = panel.minQueryLengthInt ?: settings.minQueryLength
|
||||||
settings.invertUppercaseMode = panel.invertUppercaseMode
|
|
||||||
settings.editorFadeOpacity = panel.editorFadeOpacityPercent
|
settings.editorFadeOpacity = panel.editorFadeOpacityPercent
|
||||||
panel.jumpModeColor?.let { settings.jumpModeColor = it }
|
panel.jumpModeColor?.let { settings.jumpModeColor = it }
|
||||||
panel.tagForegroundColor1?.let { settings.tagForegroundColor1 = it }
|
panel.tagForegroundColor1?.let { settings.tagForegroundColor1 = it }
|
||||||
|
@ -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 invertUppercaseMode: Boolean = false,
|
|
||||||
var minQueryLength: Int = 1,
|
var minQueryLength: Int = 1,
|
||||||
var editorFadeOpacity: Int = 70,
|
var editorFadeOpacity: Int = 70,
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package org.acejump.config
|
|||||||
|
|
||||||
import com.intellij.openapi.ui.ComboBox
|
import com.intellij.openapi.ui.ComboBox
|
||||||
import com.intellij.ui.ColorPanel
|
import com.intellij.ui.ColorPanel
|
||||||
import com.intellij.ui.components.JBCheckBox
|
|
||||||
import com.intellij.ui.components.JBSlider
|
import com.intellij.ui.components.JBSlider
|
||||||
import com.intellij.ui.components.JBTextArea
|
import com.intellij.ui.components.JBTextArea
|
||||||
import com.intellij.ui.components.JBTextField
|
import com.intellij.ui.components.JBTextField
|
||||||
@ -31,7 +30,6 @@ internal class AceSettingsPanel {
|
|||||||
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()
|
||||||
private val invertUppercaseModeCheckBox = JBCheckBox("Invert uppercase mode")
|
|
||||||
private val editorFadeOpacitySlider = JBSlider(0, 10).apply {
|
private val editorFadeOpacitySlider = JBSlider(0, 10).apply {
|
||||||
labelTable = Hashtable((0..10).associateWith { JLabel("${it * 10}") })
|
labelTable = Hashtable((0..10).associateWith { JLabel("${it * 10}") })
|
||||||
paintTrack = true
|
paintTrack = true
|
||||||
@ -61,7 +59,6 @@ internal class AceSettingsPanel {
|
|||||||
|
|
||||||
group("Behavior") {
|
group("Behavior") {
|
||||||
row("Minimum typed characters (1-10):") { cell(minQueryLengthField).columns(COLUMNS_SHORT) }
|
row("Minimum typed characters (1-10):") { cell(minQueryLengthField).columns(COLUMNS_SHORT) }
|
||||||
row { cell(invertUppercaseModeCheckBox) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group("Colors") {
|
group("Colors") {
|
||||||
@ -86,7 +83,6 @@ internal class AceSettingsPanel {
|
|||||||
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
|
||||||
internal var invertUppercaseMode by invertUppercaseModeCheckBox
|
|
||||||
internal var editorFadeOpacity by editorFadeOpacitySlider
|
internal var editorFadeOpacity by editorFadeOpacitySlider
|
||||||
internal var jumpModeColor by jumpModeColorWheel
|
internal var jumpModeColor by jumpModeColorWheel
|
||||||
internal var tagForegroundColor1 by tagForeground1ColorWheel
|
internal var tagForegroundColor1 by tagForeground1ColorWheel
|
||||||
@ -105,7 +101,6 @@ internal class AceSettingsPanel {
|
|||||||
allowedChars = settings.allowedChars
|
allowedChars = settings.allowedChars
|
||||||
keyboardLayout = settings.layout
|
keyboardLayout = settings.layout
|
||||||
minQueryLength = settings.minQueryLength.toString()
|
minQueryLength = settings.minQueryLength.toString()
|
||||||
invertUppercaseMode = settings.invertUppercaseMode
|
|
||||||
editorFadeOpacityPercent = settings.editorFadeOpacity
|
editorFadeOpacityPercent = settings.editorFadeOpacity
|
||||||
jumpModeColor = settings.jumpModeColor
|
jumpModeColor = settings.jumpModeColor
|
||||||
tagForegroundColor1 = settings.tagForegroundColor1
|
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.
|
* 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>) {
|
class SearchProcessor private constructor(query: SearchQuery, val boundaries: Boundaries, private val results: MutableMap<Editor, IntArrayList>) {
|
||||||
internal constructor(editors: List<Editor>, query: SearchQuery, boundaries: Boundaries, invertUppercaseMode: Boolean) : this(query, boundaries, invertUppercaseMode, mutableMapOf()) {
|
internal constructor(editors: List<Editor>, query: SearchQuery, boundaries: Boundaries) : this(query, boundaries, mutableMapOf()) {
|
||||||
val regex = query.toRegex(invertUppercaseMode)
|
val regex = query.toRegex()
|
||||||
|
|
||||||
if (regex != null) {
|
if (regex != null) {
|
||||||
for (editor in editors) {
|
for (editor in editors) {
|
||||||
|
@ -21,7 +21,7 @@ internal sealed class SearchQuery {
|
|||||||
/**
|
/**
|
||||||
* Converts the query into a regular expression to find the initial matches.
|
* 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.
|
* Searches for all occurrences of a literal text query.
|
||||||
@ -41,14 +41,14 @@ internal sealed class SearchQuery {
|
|||||||
return text.countMatchingCharacters(offset, rawText)
|
return text.countMatchingCharacters(offset, rawText)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toRegex(invertUppercaseMode: Boolean): Regex {
|
override fun toRegex(): Regex {
|
||||||
val firstChar = rawText.first()
|
val firstChar = rawText.first()
|
||||||
val pattern = if (firstChar.isLowerCase() xor invertUppercaseMode) {
|
val pattern = if (firstChar.isLowerCase()) {
|
||||||
val fullPattern = Regex.escape(rawText)
|
val fullPattern = Regex.escape(rawText)
|
||||||
"(?i)$fullPattern"
|
"(?i)$fullPattern"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val firstCharUppercasePattern = Regex.escape(firstChar.uppercase())
|
val firstCharUppercasePattern = Regex.escape(firstChar.toString())
|
||||||
val firstCharLowercasePattern = Regex.escape(firstChar.lowercase())
|
val firstCharLowercasePattern = Regex.escape(firstChar.lowercase())
|
||||||
val remainingPattern = if (rawText.length > 1) Regex.escape(rawText.drop(1)) else ""
|
val remainingPattern = if (rawText.length > 1) Regex.escape(rawText.drop(1)) else ""
|
||||||
"(?:$firstCharUppercasePattern|(?<![a-zA-Z])$firstCharLowercasePattern)$remainingPattern"
|
"(?:$firstCharUppercasePattern|(?<![a-zA-Z])$firstCharLowercasePattern)$remainingPattern"
|
||||||
@ -72,7 +72,7 @@ internal sealed class SearchQuery {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toRegex(invertUppercaseMode: Boolean): Regex {
|
override fun toRegex(): Regex {
|
||||||
return Regex(pattern, setOf(RegexOption.MULTILINE, RegexOption.IGNORE_CASE))
|
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())
|
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())
|
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)
|
textHighlighter.renderOccurrences(processor.resultsCopy, processor.query)
|
||||||
|
|
||||||
state = SessionState.SelectTag(actions, jumpEditors, processor)
|
state = SessionState.SelectTag(actions, jumpEditors, processor)
|
||||||
|
@ -16,10 +16,9 @@ sealed interface SessionState {
|
|||||||
private val actions: SessionActions,
|
private val actions: SessionActions,
|
||||||
private val jumpEditors: List<Editor>,
|
private val jumpEditors: List<Editor>,
|
||||||
private val defaultBoundary: Boundaries,
|
private val defaultBoundary: Boundaries,
|
||||||
private val invertUppercaseMode: Boolean,
|
|
||||||
) : SessionState {
|
) : SessionState {
|
||||||
override fun type(char: Char): TypeResult {
|
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) {
|
return if (searchProcessor.isQueryFinished) {
|
||||||
TypeResult.ChangeState(SelectTag(actions, jumpEditors, searchProcessor))
|
TypeResult.ChangeState(SelectTag(actions, jumpEditors, searchProcessor))
|
||||||
@ -73,14 +72,10 @@ sealed interface SessionState {
|
|||||||
else -> searchProcessor.boundaries
|
else -> searchProcessor.boundaries
|
||||||
}
|
}
|
||||||
|
|
||||||
val newSearchProcessor = SearchProcessor(jumpEditors, query, newBoundaries, searchProcessor.invertUppercaseMode)
|
val newSearchProcessor = SearchProcessor(jumpEditors, query, newBoundaries)
|
||||||
return TypeResult.ChangeState(SelectTag(actions, jumpEditors, newSearchProcessor))
|
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))) {
|
return when (val result = tagger.type(AceConfig.layout.characterRemapping.getOrDefault(char, char))) {
|
||||||
is TaggingResult.Nothing -> TypeResult.Nothing
|
is TaggingResult.Nothing -> TypeResult.Nothing
|
||||||
|
Loading…
Reference in New Issue
Block a user