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 layout get() = settings.layout
|
||||||
val minQueryLength get() = settings.minQueryLength
|
val minQueryLength get() = settings.minQueryLength
|
||||||
val jumpModeColor get() = settings.jumpModeColor
|
val jumpModeColor get() = settings.jumpModeColor
|
||||||
val tagForegroundColor1 get() = settings.tagForegroundColor1
|
val tagForegroundColor get() = settings.tagForegroundColor
|
||||||
val tagForegroundColor2 get() = settings.tagForegroundColor2
|
|
||||||
val searchHighlightColor get() = settings.searchHighlightColor
|
val searchHighlightColor get() = settings.searchHighlightColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,7 @@ class AceConfigurable : Configurable {
|
|||||||
panel.keyboardLayout != settings.layout ||
|
panel.keyboardLayout != settings.layout ||
|
||||||
panel.minQueryLengthInt != settings.minQueryLength ||
|
panel.minQueryLengthInt != settings.minQueryLength ||
|
||||||
panel.jumpModeColor != settings.jumpModeColor ||
|
panel.jumpModeColor != settings.jumpModeColor ||
|
||||||
panel.tagForegroundColor1 != settings.tagForegroundColor1 ||
|
panel.tagForegroundColor != settings.tagForegroundColor ||
|
||||||
panel.tagForegroundColor2 != settings.tagForegroundColor2 ||
|
|
||||||
panel.searchHighlightColor != settings.searchHighlightColor
|
panel.searchHighlightColor != settings.searchHighlightColor
|
||||||
|
|
||||||
override fun apply() {
|
override fun apply() {
|
||||||
@ -27,8 +26,7 @@ class AceConfigurable : Configurable {
|
|||||||
settings.layout = panel.keyboardLayout
|
settings.layout = panel.keyboardLayout
|
||||||
settings.minQueryLength = panel.minQueryLengthInt ?: settings.minQueryLength
|
settings.minQueryLength = panel.minQueryLengthInt ?: settings.minQueryLength
|
||||||
panel.jumpModeColor?.let { settings.jumpModeColor = it }
|
panel.jumpModeColor?.let { settings.jumpModeColor = it }
|
||||||
panel.tagForegroundColor1?.let { settings.tagForegroundColor1 = it }
|
panel.tagForegroundColor?.let { settings.tagForegroundColor = it }
|
||||||
panel.tagForegroundColor2?.let { settings.tagForegroundColor2 = it }
|
|
||||||
panel.searchHighlightColor?.let { settings.searchHighlightColor = it }
|
panel.searchHighlightColor?.let { settings.searchHighlightColor = it }
|
||||||
KeyLayoutCache.reset(settings)
|
KeyLayoutCache.reset(settings)
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,7 @@ data class AceSettings(
|
|||||||
var jumpModeColor: Color = Color(0xFFFFFF),
|
var jumpModeColor: Color = Color(0xFFFFFF),
|
||||||
|
|
||||||
@OptionTag("tagForegroundRGB", converter = ColorConverter::class)
|
@OptionTag("tagForegroundRGB", converter = ColorConverter::class)
|
||||||
var tagForegroundColor1: Color = Color(0xFFFFFF),
|
var tagForegroundColor: Color = Color(0xFFFFFF),
|
||||||
|
|
||||||
@OptionTag("tagForeground2RGB", converter = ColorConverter::class)
|
|
||||||
var tagForegroundColor2: Color = Color(0xFFFFFF),
|
|
||||||
|
|
||||||
@OptionTag("searchHighlightRGB", converter = ColorConverter::class)
|
@OptionTag("searchHighlightRGB", converter = ColorConverter::class)
|
||||||
var searchHighlightColor: Color = Color(0x008299),
|
var searchHighlightColor: Color = Color(0x008299),
|
||||||
|
@ -28,8 +28,7 @@ internal class AceSettingsPanel {
|
|||||||
private val keyboardLayoutArea = JBTextArea().apply { isEditable = false }
|
private val keyboardLayoutArea = JBTextArea().apply { isEditable = false }
|
||||||
private val minQueryLengthField = JBTextField()
|
private val minQueryLengthField = JBTextField()
|
||||||
private val jumpModeColorWheel = ColorPanel()
|
private val jumpModeColorWheel = ColorPanel()
|
||||||
private val tagForeground1ColorWheel = ColorPanel()
|
private val tagForegroundColorWheel = ColorPanel()
|
||||||
private val tagForeground2ColorWheel = ColorPanel()
|
|
||||||
private val searchHighlightColorWheel = ColorPanel()
|
private val searchHighlightColorWheel = ColorPanel()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -55,22 +54,9 @@ internal class AceSettingsPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
titledRow("Colors") {
|
titledRow("Colors") {
|
||||||
row("Caret background:") {
|
row("Caret background:") { short(jumpModeColorWheel) }
|
||||||
cell {
|
row("Tag foreground:") { short(tagForegroundColorWheel) }
|
||||||
component(jumpModeColorWheel)
|
row("Search highlight:") { short(searchHighlightColorWheel) }
|
||||||
}
|
|
||||||
}
|
|
||||||
row("Tag foreground:") {
|
|
||||||
cell {
|
|
||||||
component(tagForeground1ColorWheel)
|
|
||||||
component(tagForeground2ColorWheel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
row("Search highlight:") {
|
|
||||||
cell {
|
|
||||||
component(searchHighlightColorWheel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,8 +67,7 @@ internal class AceSettingsPanel {
|
|||||||
internal var keyChars by keyboardLayoutArea
|
internal var keyChars by keyboardLayoutArea
|
||||||
internal var minQueryLength by minQueryLengthField
|
internal var minQueryLength by minQueryLengthField
|
||||||
internal var jumpModeColor by jumpModeColorWheel
|
internal var jumpModeColor by jumpModeColorWheel
|
||||||
internal var tagForegroundColor1 by tagForeground1ColorWheel
|
internal var tagForegroundColor by tagForegroundColorWheel
|
||||||
internal var tagForegroundColor2 by tagForeground2ColorWheel
|
|
||||||
internal var searchHighlightColor by searchHighlightColorWheel
|
internal var searchHighlightColor by searchHighlightColorWheel
|
||||||
|
|
||||||
internal var minQueryLengthInt
|
internal var minQueryLengthInt
|
||||||
@ -95,8 +80,7 @@ internal class AceSettingsPanel {
|
|||||||
keyboardLayout = settings.layout
|
keyboardLayout = settings.layout
|
||||||
minQueryLength = settings.minQueryLength.toString()
|
minQueryLength = settings.minQueryLength.toString()
|
||||||
jumpModeColor = settings.jumpModeColor
|
jumpModeColor = settings.jumpModeColor
|
||||||
tagForegroundColor1 = settings.tagForegroundColor1
|
tagForegroundColor = settings.tagForegroundColor
|
||||||
tagForegroundColor2 = settings.tagForegroundColor2
|
|
||||||
searchHighlightColor = settings.searchHighlightColor
|
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 allChars = rows.joinToString("").toCharArray().apply(CharArray::sort).joinToString("")
|
||||||
internal val allPriorities = priority.mapIndexed { index, char -> char to index }.toMap()
|
internal val allPriorities = priority.mapIndexed { index, char -> char to index }.toMap()
|
||||||
|
|
||||||
internal inline fun priority(crossinline tagToChar: (String) -> Char): (String) -> Int {
|
internal inline fun priority(crossinline tagToChar: (String) -> Char): (String) -> Int? {
|
||||||
return { allPriorities.getOrDefault(tagToChar(it), Int.MAX_VALUE) }
|
return { allPriorities[tagToChar(it)] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,7 @@ internal class TagFont(editor: Editor) {
|
|||||||
val tagFont: Font = editor.colorsScheme.getFont(EditorFontType.PLAIN)
|
val tagFont: Font = editor.colorsScheme.getFont(EditorFontType.PLAIN)
|
||||||
val tagCharWidth = editor.component.getFontMetrics(tagFont).charWidth('W')
|
val tagCharWidth = editor.component.getFontMetrics(tagFont).charWidth('W')
|
||||||
|
|
||||||
val foregroundColor1 = AceConfig.tagForegroundColor1
|
val foregroundColor = AceConfig.tagForegroundColor
|
||||||
val foregroundColor2 = AceConfig.tagForegroundColor2
|
|
||||||
|
|
||||||
val lineHeight = editor.lineHeight
|
val lineHeight = editor.lineHeight
|
||||||
val baselineDistance = editor.ascent
|
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.
|
* Describes a 1 or 2 character shortcut that points to a specific character in the editor.
|
||||||
*/
|
*/
|
||||||
internal class TagMarker(
|
internal class TagMarker(
|
||||||
private val tag: CharArray,
|
private val tag: String,
|
||||||
val offset: Int
|
val offset: Int
|
||||||
) {
|
) {
|
||||||
private val length = tag.size
|
private val length = tag.length
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/**
|
/**
|
||||||
@ -28,22 +28,7 @@ internal class TagMarker(
|
|||||||
* character ([typedTag]) matches the first [tag] character, only the second [tag] character is displayed.
|
* character ([typedTag]) matches the first [tag] character, only the second [tag] character is displayed.
|
||||||
*/
|
*/
|
||||||
fun create(tag: String, offset: Int, typedTag: String): TagMarker {
|
fun create(tag: String, offset: Int, typedTag: String): TagMarker {
|
||||||
return TagMarker(tag.drop(typedTag.length).toCharArray(), offset)
|
return TagMarker(tag.drop(typedTag.length), offset)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Paints the tag, taking into consideration visual space around characters in the editor, as well as all other previously painted tags.
|
|
||||||
* Returns a rectangle indicating the area where the tag was rendered, or null if the tag could not be rendered due to overlap.
|
|
||||||
*/
|
|
||||||
fun paint(g: Graphics2D, editor: Editor, cache: EditorOffsetCache, font: TagFont, occupied: MutableList<Rectangle>): Rectangle? {
|
|
||||||
val rect = alignTag(editor, cache, font, occupied) ?: return null
|
|
||||||
|
|
||||||
drawHighlight(g, rect, editor.colorsScheme.defaultBackground)
|
|
||||||
drawForeground(g, font, rect.location)
|
|
||||||
|
|
||||||
occupied.add(rect)
|
|
||||||
return rect
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,20 +44,27 @@ internal class TagMarker(
|
|||||||
/**
|
/**
|
||||||
* Renders the tag text.
|
* Renders the tag text.
|
||||||
*/
|
*/
|
||||||
private fun drawForeground(g: Graphics2D, font: TagFont, point: Point) {
|
private fun drawForeground(g: Graphics2D, font: TagFont, point: Point, text: String) {
|
||||||
val x = point.x
|
g.color = font.foregroundColor
|
||||||
val y = point.y + font.baselineDistance
|
|
||||||
|
|
||||||
g.font = font.tagFont
|
g.font = font.tagFont
|
||||||
g.color = font.foregroundColor1
|
g.drawString(text, point.x, point.y + font.baselineDistance)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paints the tag, taking into consideration visual space around characters in the editor, as well as all other previously painted tags.
|
||||||
|
* Returns a rectangle indicating the area where the tag was rendered, or null if the tag could not be rendered due to overlap.
|
||||||
|
*/
|
||||||
|
fun paint(g: Graphics2D, editor: Editor, cache: EditorOffsetCache, font: TagFont, occupied: MutableList<Rectangle>): Rectangle? {
|
||||||
|
val rect = alignTag(editor, cache, font, occupied) ?: return null
|
||||||
|
|
||||||
|
drawHighlight(g, rect, editor.colorsScheme.defaultBackground)
|
||||||
|
drawForeground(g, font, rect.location, tag)
|
||||||
|
|
||||||
|
occupied.add(rect)
|
||||||
|
return rect
|
||||||
|
}
|
||||||
|
|
||||||
private fun alignTag(editor: Editor, cache: EditorOffsetCache, font: TagFont, occupied: List<Rectangle>): Rectangle? {
|
private fun alignTag(editor: Editor, cache: EditorOffsetCache, font: TagFont, occupied: List<Rectangle>): Rectangle? {
|
||||||
val pos = cache.offsetToXY(editor, offset)
|
val pos = cache.offsetToXY(editor, offset)
|
||||||
val rect = Rectangle(pos.x, pos.y, font.tagCharWidth * length, font.lineHeight)
|
val rect = Rectangle(pos.x, pos.y, font.tagCharWidth * length, font.lineHeight)
|
||||||
|
Loading…
Reference in New Issue
Block a user