mirror of
https://github.com/chylex/IntelliJ-AceJump.git
synced 2024-11-25 17:42:46 +01:00
Compare commits
No commits in common. "b13d6290466a46122bcb75454b77e19d48f64619" and "fa3505b8500f31adda3bf5087f1cdefa1c21aff1" have entirely different histories.
b13d629046
...
fa3505b850
@ -21,8 +21,7 @@ class AceConfig : PersistentStateComponent<AceSettings> {
|
||||
val layout get() = settings.layout
|
||||
val minQueryLength get() = settings.minQueryLength
|
||||
val jumpModeColor get() = settings.jumpModeColor
|
||||
val tagForegroundColor1 get() = settings.tagForegroundColor1
|
||||
val tagForegroundColor2 get() = settings.tagForegroundColor2
|
||||
val tagForegroundColor get() = settings.tagForegroundColor
|
||||
val searchHighlightColor get() = settings.searchHighlightColor
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,7 @@ class AceConfigurable : Configurable {
|
||||
panel.keyboardLayout != settings.layout ||
|
||||
panel.minQueryLengthInt != settings.minQueryLength ||
|
||||
panel.jumpModeColor != settings.jumpModeColor ||
|
||||
panel.tagForegroundColor1 != settings.tagForegroundColor1 ||
|
||||
panel.tagForegroundColor2 != settings.tagForegroundColor2 ||
|
||||
panel.tagForegroundColor != settings.tagForegroundColor ||
|
||||
panel.searchHighlightColor != settings.searchHighlightColor
|
||||
|
||||
override fun apply() {
|
||||
@ -27,8 +26,7 @@ class AceConfigurable : Configurable {
|
||||
settings.layout = panel.keyboardLayout
|
||||
settings.minQueryLength = panel.minQueryLengthInt ?: settings.minQueryLength
|
||||
panel.jumpModeColor?.let { settings.jumpModeColor = it }
|
||||
panel.tagForegroundColor1?.let { settings.tagForegroundColor1 = it }
|
||||
panel.tagForegroundColor2?.let { settings.tagForegroundColor2 = it }
|
||||
panel.tagForegroundColor?.let { settings.tagForegroundColor = it }
|
||||
panel.searchHighlightColor?.let { settings.searchHighlightColor = it }
|
||||
KeyLayoutCache.reset(settings)
|
||||
}
|
||||
|
@ -15,10 +15,7 @@ data class AceSettings(
|
||||
var jumpModeColor: Color = Color(0xFFFFFF),
|
||||
|
||||
@OptionTag("tagForegroundRGB", converter = ColorConverter::class)
|
||||
var tagForegroundColor1: Color = Color(0xFFFFFF),
|
||||
|
||||
@OptionTag("tagForeground2RGB", converter = ColorConverter::class)
|
||||
var tagForegroundColor2: Color = Color(0xFFFFFF),
|
||||
var tagForegroundColor: Color = Color(0xFFFFFF),
|
||||
|
||||
@OptionTag("searchHighlightRGB", converter = ColorConverter::class)
|
||||
var searchHighlightColor: Color = Color(0x008299),
|
||||
|
@ -28,8 +28,7 @@ internal class AceSettingsPanel {
|
||||
private val keyboardLayoutArea = JBTextArea().apply { isEditable = false }
|
||||
private val minQueryLengthField = JBTextField()
|
||||
private val jumpModeColorWheel = ColorPanel()
|
||||
private val tagForeground1ColorWheel = ColorPanel()
|
||||
private val tagForeground2ColorWheel = ColorPanel()
|
||||
private val tagForegroundColorWheel = ColorPanel()
|
||||
private val searchHighlightColorWheel = ColorPanel()
|
||||
|
||||
init {
|
||||
@ -55,22 +54,9 @@ internal class AceSettingsPanel {
|
||||
}
|
||||
|
||||
titledRow("Colors") {
|
||||
row("Caret background:") {
|
||||
cell {
|
||||
component(jumpModeColorWheel)
|
||||
}
|
||||
}
|
||||
row("Tag foreground:") {
|
||||
cell {
|
||||
component(tagForeground1ColorWheel)
|
||||
component(tagForeground2ColorWheel)
|
||||
}
|
||||
}
|
||||
row("Search highlight:") {
|
||||
cell {
|
||||
component(searchHighlightColorWheel)
|
||||
}
|
||||
}
|
||||
row("Caret background:") { short(jumpModeColorWheel) }
|
||||
row("Tag foreground:") { short(tagForegroundColorWheel) }
|
||||
row("Search highlight:") { short(searchHighlightColorWheel) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,8 +67,7 @@ internal class AceSettingsPanel {
|
||||
internal var keyChars by keyboardLayoutArea
|
||||
internal var minQueryLength by minQueryLengthField
|
||||
internal var jumpModeColor by jumpModeColorWheel
|
||||
internal var tagForegroundColor1 by tagForeground1ColorWheel
|
||||
internal var tagForegroundColor2 by tagForeground2ColorWheel
|
||||
internal var tagForegroundColor by tagForegroundColorWheel
|
||||
internal var searchHighlightColor by searchHighlightColorWheel
|
||||
|
||||
internal var minQueryLengthInt
|
||||
@ -95,8 +80,7 @@ internal class AceSettingsPanel {
|
||||
keyboardLayout = settings.layout
|
||||
minQueryLength = settings.minQueryLength.toString()
|
||||
jumpModeColor = settings.jumpModeColor
|
||||
tagForegroundColor1 = settings.tagForegroundColor1
|
||||
tagForegroundColor2 = settings.tagForegroundColor2
|
||||
tagForegroundColor = settings.tagForegroundColor
|
||||
searchHighlightColor = settings.searchHighlightColor
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ enum class KeyLayout(internal val rows: Array<String>, priority: String) {
|
||||
internal val allChars = rows.joinToString("").toCharArray().apply(CharArray::sort).joinToString("")
|
||||
internal val allPriorities = priority.mapIndexed { index, char -> char to index }.toMap()
|
||||
|
||||
internal inline fun priority(crossinline tagToChar: (String) -> Char): (String) -> Int {
|
||||
return { allPriorities.getOrDefault(tagToChar(it), Int.MAX_VALUE) }
|
||||
internal inline fun priority(crossinline tagToChar: (String) -> Char): (String) -> Int? {
|
||||
return { allPriorities[tagToChar(it)] }
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,7 @@ internal class TagFont(editor: Editor) {
|
||||
val tagFont: Font = editor.colorsScheme.getFont(EditorFontType.PLAIN)
|
||||
val tagCharWidth = editor.component.getFontMetrics(tagFont).charWidth('W')
|
||||
|
||||
val foregroundColor1 = AceConfig.tagForegroundColor1
|
||||
val foregroundColor2 = AceConfig.tagForegroundColor2
|
||||
val foregroundColor = AceConfig.tagForegroundColor
|
||||
|
||||
val lineHeight = editor.lineHeight
|
||||
val baselineDistance = editor.ascent
|
||||
|
@ -12,10 +12,10 @@ import java.awt.Rectangle
|
||||
* Describes a 1 or 2 character shortcut that points to a specific character in the editor.
|
||||
*/
|
||||
internal class TagMarker(
|
||||
private val tag: CharArray,
|
||||
private val tag: String,
|
||||
val offset: Int
|
||||
) {
|
||||
private val length = tag.size
|
||||
private val length = tag.length
|
||||
|
||||
companion object {
|
||||
/**
|
||||
@ -28,7 +28,26 @@ internal class TagMarker(
|
||||
* character ([typedTag]) matches the first [tag] character, only the second [tag] character is displayed.
|
||||
*/
|
||||
fun create(tag: String, offset: Int, typedTag: String): TagMarker {
|
||||
return TagMarker(tag.drop(typedTag.length).toCharArray(), offset)
|
||||
return TagMarker(tag.drop(typedTag.length), offset)
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the tag background.
|
||||
*/
|
||||
private fun drawHighlight(g: Graphics2D, rect: Rectangle, color: Color) {
|
||||
g.color = color
|
||||
g.translate(0.0, HIGHLIGHT_OFFSET)
|
||||
g.fillRect(rect.x, rect.y, rect.width, rect.height + 1)
|
||||
g.translate(0.0, -HIGHLIGHT_OFFSET)
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the tag text.
|
||||
*/
|
||||
private fun drawForeground(g: Graphics2D, font: TagFont, point: Point, text: String) {
|
||||
g.color = font.foregroundColor
|
||||
g.font = font.tagFont
|
||||
g.drawString(text, point.x, point.y + font.baselineDistance)
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,39 +59,12 @@ internal class TagMarker(
|
||||
val rect = alignTag(editor, cache, font, occupied) ?: return null
|
||||
|
||||
drawHighlight(g, rect, editor.colorsScheme.defaultBackground)
|
||||
drawForeground(g, font, rect.location)
|
||||
drawForeground(g, font, rect.location, tag)
|
||||
|
||||
occupied.add(rect)
|
||||
return rect
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the tag background.
|
||||
*/
|
||||
private fun drawHighlight(g: Graphics2D, rect: Rectangle, color: Color) {
|
||||
g.color = color
|
||||
g.translate(0.0, HIGHLIGHT_OFFSET)
|
||||
g.fillRect(rect.x, rect.y, rect.width, rect.height + 1)
|
||||
g.translate(0.0, -HIGHLIGHT_OFFSET)
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the tag text.
|
||||
*/
|
||||
private fun drawForeground(g: Graphics2D, font: TagFont, point: Point) {
|
||||
val x = point.x
|
||||
val y = point.y + font.baselineDistance
|
||||
|
||||
g.font = font.tagFont
|
||||
g.color = font.foregroundColor1
|
||||
g.drawChars(tag, 0, 1, x, y)
|
||||
|
||||
if (tag.size > 1) {
|
||||
g.color = font.foregroundColor2
|
||||
g.drawChars(tag, 1, length - 1, x + font.tagCharWidth, y)
|
||||
}
|
||||
}
|
||||
|
||||
private fun alignTag(editor: Editor, cache: EditorOffsetCache, font: TagFont, occupied: List<Rectangle>): Rectangle? {
|
||||
val pos = cache.offsetToXY(editor, offset)
|
||||
val rect = Rectangle(pos.x, pos.y, font.tagCharWidth * length, font.lineHeight)
|
||||
|
Loading…
Reference in New Issue
Block a user