1
0
mirror of https://github.com/chylex/IntelliJ-AceJump.git synced 2024-10-17 06:42:47 +02:00

Compare commits

..

No commits in common. "01c38df82af60b4197daefed1a5e063b741ff43d" and "59fbd4e19c8071dd15e6a8e93b6aac8e1e1d5593" have entirely different histories.

5 changed files with 49 additions and 49 deletions

View File

@ -15,15 +15,12 @@ repositories {
}
intellij {
version.set("2024.2")
version.set("2024.1.4")
updateSinceUntilBuild.set(false)
plugins.add("IdeaVIM:chylex-40")
plugins.add("com.intellij.classic.ui:242.20224.159")
plugins.add("IdeaVIM:chylex-37")
pluginsRepositories {
custom("https://intellij.chylex.com")
marketplace()
}
}
@ -36,7 +33,7 @@ dependencies {
}
tasks.patchPluginXml {
sinceBuild.set("242")
sinceBuild.set("241")
}
tasks.buildSearchableOptions {

View File

@ -1,6 +1,5 @@
package org.acejump.action
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.application.ApplicationManager
@ -168,10 +167,6 @@ sealed class AceVimAction : DumbAwareAction() {
action.presentation.isEnabled = action.getData(CommonDataKeys.EDITOR) != null
}
override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}
override fun actionPerformed(e: AnActionEvent) {
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
val session = SessionManager.start(editor, AceVimMode.JumpAllEditors.getJumpEditors(editor))

View File

@ -5,15 +5,16 @@ import com.intellij.ui.ColorPanel
import com.intellij.ui.components.JBSlider
import com.intellij.ui.components.JBTextArea
import com.intellij.ui.components.JBTextField
import com.intellij.ui.dsl.builder.COLUMNS_LARGE
import com.intellij.ui.dsl.builder.COLUMNS_SHORT
import com.intellij.ui.dsl.builder.columns
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.layout.Cell
import com.intellij.ui.layout.GrowPolicy.MEDIUM_TEXT
import com.intellij.ui.layout.GrowPolicy.SHORT_TEXT
import com.intellij.ui.layout.panel
import org.acejump.input.KeyLayout
import java.awt.Color
import java.awt.Font
import java.util.Hashtable
import javax.swing.JCheckBox
import javax.swing.JComponent
import javax.swing.JLabel
import javax.swing.JPanel
import javax.swing.JSlider
@ -51,30 +52,39 @@ internal class AceSettingsPanel {
}
internal val rootPanel: JPanel = panel {
group("Characters and Layout") {
row("Allowed characters in tags:") { cell(tagAllowedCharsField).columns(COLUMNS_LARGE) }
row("Allowed prefix characters in tags:") { cell(tagPrefixCharsField).columns(COLUMNS_MEDIUM) }
row("Keyboard layout:") { cell(keyboardLayoutCombo).columns(COLUMNS_SHORT) }
row("Keyboard design:") { cell(keyboardLayoutArea).columns(COLUMNS_SHORT) }
fun Cell.short(component: JComponent) = component(growPolicy = SHORT_TEXT)
fun Cell.medium(component: JComponent) = component(growPolicy = MEDIUM_TEXT)
titledRow("Characters and Layout") {
row("Allowed characters in tags:") { medium(tagAllowedCharsField) }
row("Allowed prefix characters in tags:") { medium(tagPrefixCharsField) }
row("Keyboard layout:") { short(keyboardLayoutCombo) }
row("Keyboard design:") { short(keyboardLayoutArea) }
}
group("Behavior") {
row("Minimum typed characters (1-10):") { cell(minQueryLengthField).columns(COLUMNS_SHORT) }
titledRow("Behavior") {
row("Minimum typed characters (1-10):") { short(minQueryLengthField) }
}
group("Colors") {
titledRow("Colors") {
row("Caret background:") {
cell(jumpModeColorWheel)
cell {
component(jumpModeColorWheel)
}
}
row("Tag foreground:") {
cell(tagForeground1ColorWheel)
cell(tagForeground2ColorWheel)
cell {
component(tagForeground1ColorWheel)
component(tagForeground2ColorWheel)
}
}
row("Search highlight:") {
cell(searchHighlightColorWheel)
cell {
component(searchHighlightColorWheel)
}
}
row("Editor fade opacity (%):") {
cell(editorFadeOpacitySlider)
medium(editorFadeOpacitySlider)
}
}
}
@ -113,7 +123,7 @@ internal class AceSettingsPanel {
// Removal pending support for https://youtrack.jetbrains.com/issue/KT-8575
private operator fun JTextComponent.getValue(a: AceSettingsPanel, p: KProperty<*>) = text.lowercase()
private operator fun JTextComponent.getValue(a: AceSettingsPanel, p: KProperty<*>) = text.toLowerCase()
private operator fun JTextComponent.setValue(a: AceSettingsPanel, p: KProperty<*>, s: String) = setText(s)
private operator fun ColorPanel.getValue(a: AceSettingsPanel, p: KProperty<*>) = selectedColor

View File

@ -28,13 +28,13 @@ internal sealed class SearchQuery {
* If the first character of the query is lowercase, then the entire query will be case-insensitive,
* and only beginnings of words and camel humps will be matched.
*/
class Literal(override val rawText: String) : SearchQuery() {
class Literal(override val rawText: String, val excludeMiddlesOfWords: Boolean) : SearchQuery() {
init {
require(rawText.isNotEmpty())
}
override fun refine(char: Char): SearchQuery {
return Literal(rawText + char)
return Literal(rawText + char, excludeMiddlesOfWords)
}
override fun getHighlightLength(text: CharSequence, offset: Int): Int {
@ -44,14 +44,19 @@ internal sealed class SearchQuery {
override fun toRegex(): Regex {
val firstChar = rawText.first()
val pattern = if (firstChar.isLowerCase()) {
val fullPattern = Regex.escape(rawText)
"(?i)$fullPattern"
if (excludeMiddlesOfWords) {
val firstCharUppercasePattern = Regex.escape(firstChar.uppercaseChar().toString())
val firstCharPattern = Regex.escape(firstChar.toString())
val remainingPattern = if (rawText.length > 1) Regex.escape(rawText.drop(1)) else ""
"(?:$firstCharUppercasePattern|(?<![a-zA-Z])$firstCharPattern)$remainingPattern"
}
else {
val fullPattern = Regex.escape(rawText)
"(?i)$fullPattern"
}
}
else {
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"
Regex.escape(rawText)
}
return Regex(pattern, setOf(RegexOption.MULTILINE))
@ -65,7 +70,7 @@ internal sealed class SearchQuery {
override val rawText = ""
override fun refine(char: Char): SearchQuery {
return Literal(char.toString())
return Literal(char.toString(), excludeMiddlesOfWords = false)
}
override fun getHighlightLength(text: CharSequence, offset: Int): Int {

View File

@ -2,7 +2,6 @@ package org.acejump.session
import com.intellij.openapi.editor.Editor
import org.acejump.boundaries.Boundaries
import org.acejump.boundaries.StandardBoundaries
import org.acejump.config.AceConfig
import org.acejump.search.SearchProcessor
import org.acejump.search.SearchQuery
@ -18,7 +17,7 @@ sealed interface SessionState {
private val defaultBoundary: Boundaries,
) : SessionState {
override fun type(char: Char): TypeResult {
val searchProcessor = SearchProcessor(jumpEditors, SearchQuery.Literal(char.toString()), defaultBoundary)
val searchProcessor = SearchProcessor(jumpEditors, SearchQuery.Literal(char.toString(), excludeMiddlesOfWords = true), defaultBoundary)
return if (searchProcessor.isQueryFinished) {
TypeResult.ChangeState(SelectTag(actions, jumpEditors, searchProcessor))
@ -64,15 +63,9 @@ sealed interface SessionState {
override fun type(char: Char): TypeResult {
if (char == ' ') {
val query = searchProcessor.query
if (query is SearchQuery.Literal) {
val newBoundaries = when (searchProcessor.boundaries) {
StandardBoundaries.VISIBLE_ON_SCREEN -> StandardBoundaries.AFTER_CARET
StandardBoundaries.AFTER_CARET -> StandardBoundaries.BEFORE_CARET
StandardBoundaries.BEFORE_CARET -> StandardBoundaries.VISIBLE_ON_SCREEN
else -> searchProcessor.boundaries
}
val newSearchProcessor = SearchProcessor(jumpEditors, query, newBoundaries)
if (query is SearchQuery.Literal && query.excludeMiddlesOfWords) {
val newQuery = SearchQuery.Literal(query.rawText, excludeMiddlesOfWords = false)
val newSearchProcessor = SearchProcessor(jumpEditors, newQuery, searchProcessor.boundaries)
return TypeResult.ChangeState(SelectTag(actions, jumpEditors, newSearchProcessor))
}
}