mirror of
https://github.com/chylex/IntelliJ-AceJump.git
synced 2025-04-09 17:15:43 +02:00
initial implementation of #314
This commit is contained in:
parent
e5de0fa9ea
commit
9e65193c7e
@ -1,5 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
### 3.6.0
|
||||
|
||||
Adds support for Chinese [#314](https://github.com/acejump/AceJump/issues/314).
|
||||
|
||||
### 3.5.9
|
||||
|
||||
Fix a build configuration error affecting plugins which depend on AceJump. Fixes [#305](https://github.com/acejump/AceJump/issues/305).
|
||||
|
@ -42,6 +42,7 @@ tasks {
|
||||
dependencies {
|
||||
// gradle-intellij-plugin doesn't attach sources properly for Kotlin :(
|
||||
compileOnly(kotlin("stdlib-jdk8"))
|
||||
implementation("net.duguying.pinyin:pinyin:0.0.1")
|
||||
}
|
||||
|
||||
repositories.mavenCentral()
|
||||
|
@ -28,6 +28,7 @@ object AceConfig: Configurable, PersistentStateComponent<AceSettings> {
|
||||
val definitionModeColor: Color get() = settings.definitionModeColor
|
||||
val tagForegroundColor: Color get() = settings.tagForegroundColor
|
||||
val tagBackgroundColor: Color get() = settings.tagBackgroundColor
|
||||
val supportPinyin: Boolean get() = settings.supportPinyin
|
||||
|
||||
private var allPossibleTags: Set<String> = settings.allowedChars.bigrams()
|
||||
|
||||
@ -57,7 +58,8 @@ object AceConfig: Configurable, PersistentStateComponent<AceSettings> {
|
||||
panel.targetModeColor != settings.targetModeColor ||
|
||||
panel.textHighlightColor != settings.textHighlightColor ||
|
||||
panel.tagForegroundColor != settings.tagForegroundColor ||
|
||||
panel.tagBackgroundColor != settings.tagBackgroundColor
|
||||
panel.tagBackgroundColor != settings.tagBackgroundColor ||
|
||||
panel.supportPinyin != settings.supportPinyin
|
||||
|
||||
private fun String.distinctAlphanumerics() =
|
||||
if (isEmpty()) settings.layout.text
|
||||
@ -75,6 +77,7 @@ object AceConfig: Configurable, PersistentStateComponent<AceSettings> {
|
||||
panel.textHighlightColor?.let { settings.textHighlightRGB = it.rgb }
|
||||
panel.tagForegroundColor?.let { settings.tagForegroundRGB = it.rgb }
|
||||
panel.tagBackgroundColor?.let { settings.tagBackgroundRGB = it.rgb }
|
||||
panel.supportPinyin.let { settings.supportPinyin = it }
|
||||
logger.info("User applied new settings: $settings")
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,8 @@ data class AceSettings(var layout: KeyLayout = QWERTY,
|
||||
internal var textHighlightRGB: Int = GREEN.rgb,
|
||||
internal var tagForegroundRGB: Int = BLACK.rgb,
|
||||
internal var tagBackgroundRGB: Int = YELLOW.rgb,
|
||||
internal var displayQuery: Boolean = false) {
|
||||
internal var displayQuery: Boolean = false,
|
||||
internal var supportPinyin: Boolean = true) {
|
||||
|
||||
// ...but we expose them to the world as Color
|
||||
val jumpModeColor: Color by { jumpModeRGB }
|
||||
|
@ -30,6 +30,7 @@ internal class AceSettingsPanel {
|
||||
private val tagForegroundColorWheel = ColorPanel()
|
||||
private val tagBackgroundColorWheel = ColorPanel()
|
||||
private val displayQueryCheckBox = JBCheckBox()
|
||||
private val supportPinyinCheckBox = JBCheckBox()
|
||||
|
||||
init {
|
||||
tagCharsField.apply { font = Font("monospaced", font.style, font.size) }
|
||||
@ -61,6 +62,8 @@ internal class AceSettingsPanel {
|
||||
row(aceString("textHighlightColorLabel")) { short(textHighlightColorWheel) }
|
||||
row(aceString("appearanceHeading")) { SeparatorComponent() }
|
||||
row(aceString("displayQueryLabel")) { short(displayQueryCheckBox) }
|
||||
row(aceString("languagesHeading")) { SeparatorComponent() }
|
||||
row(aceString("supportPinyin")) { short(supportPinyinCheckBox) }
|
||||
}
|
||||
|
||||
internal var keyboardLayout: KeyLayout
|
||||
@ -76,6 +79,7 @@ internal class AceSettingsPanel {
|
||||
internal var tagForegroundColor by tagForegroundColorWheel
|
||||
internal var tagBackgroundColor by tagBackgroundColorWheel
|
||||
internal var displayQuery by displayQueryCheckBox
|
||||
internal var supportPinyin by supportPinyinCheckBox
|
||||
|
||||
fun reset(settings: AceSettings) {
|
||||
allowedChars = settings.allowedChars
|
||||
@ -86,6 +90,7 @@ internal class AceSettingsPanel {
|
||||
tagForegroundColor = settings.tagForegroundColor
|
||||
tagBackgroundColor = settings.tagBackgroundColor
|
||||
displayQuery = settings.displayQuery
|
||||
supportPinyin = settings.supportPinyin
|
||||
}
|
||||
|
||||
// Removal pending support for https://youtrack.jetbrains.com/issue/KT-8575
|
||||
|
@ -4,6 +4,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.colors.EditorColors.CARET_COLOR
|
||||
import com.intellij.openapi.editor.impl.EditorImpl
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import net.duguying.pinyin.Pinyin
|
||||
import org.acejump.config.AceConfig
|
||||
import org.acejump.search.defaultEditor
|
||||
import org.acejump.view.Boundary.FULL_FILE_BOUNDARY
|
||||
@ -11,6 +12,7 @@ import java.awt.Color.BLACK
|
||||
import java.awt.Color.YELLOW
|
||||
import java.awt.Font
|
||||
import java.awt.Font.BOLD
|
||||
import java.lang.Character.UnicodeScript
|
||||
|
||||
/**
|
||||
* Data holder for all settings and IDE components needed by AceJump.
|
||||
@ -27,8 +29,17 @@ object Model {
|
||||
get() = editor.project ?: ProjectManager.getInstance().defaultProject
|
||||
val caretOffset
|
||||
get() = editor.caretModel.offset
|
||||
val editorText
|
||||
val editorText: String
|
||||
get() = editor.document.text
|
||||
.let { if (AceConfig.supportPinyin) mapToPinyin(it) else it }
|
||||
|
||||
private fun mapToPinyin(it: String) =
|
||||
it.mapNotNull {
|
||||
if (UnicodeScript.of(it.toInt()) == UnicodeScript.HAN)
|
||||
pinyin.translateFirstChar(it.toString()).first() else it
|
||||
}.joinToString("")
|
||||
|
||||
val pinyin = Pinyin()
|
||||
|
||||
var naturalBlock = false
|
||||
var naturalBlink = true
|
||||
|
@ -7,4 +7,6 @@ tagForegroundColorLabel=Tag foreground color:
|
||||
targetModeColorLabel=Target mode color:
|
||||
textHighlightColorLabel=Text highlight color:
|
||||
appearanceHeading=Other appearance settings
|
||||
displayQueryLabel=Display search query
|
||||
displayQueryLabel=Display search query
|
||||
langaugesHeading=Language settings
|
||||
supportPinyin=Support Pinyin selection
|
||||
|
Loading…
Reference in New Issue
Block a user