mirror of
				https://github.com/chylex/IntelliJ-AceJump.git
				synced 2025-10-31 18:17:17 +01:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			fa3505b850
			...
			b13d629046
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| b13d629046 | |||
| 92dcd033fb | 
| @@ -21,7 +21,8 @@ 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 tagForegroundColor get() = settings.tagForegroundColor |     val tagForegroundColor1 get() = settings.tagForegroundColor1 | ||||||
|  |     val tagForegroundColor2 get() = settings.tagForegroundColor2 | ||||||
|     val searchHighlightColor get() = settings.searchHighlightColor |     val searchHighlightColor get() = settings.searchHighlightColor | ||||||
|   } |   } | ||||||
|    |    | ||||||
|   | |||||||
| @@ -17,7 +17,8 @@ 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.tagForegroundColor != settings.tagForegroundColor || |       panel.tagForegroundColor1 != settings.tagForegroundColor1 || | ||||||
|  |       panel.tagForegroundColor2 != settings.tagForegroundColor2 || | ||||||
|       panel.searchHighlightColor != settings.searchHighlightColor |       panel.searchHighlightColor != settings.searchHighlightColor | ||||||
|    |    | ||||||
|   override fun apply() { |   override fun apply() { | ||||||
| @@ -26,7 +27,8 @@ 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.tagForegroundColor?.let { settings.tagForegroundColor = it } |     panel.tagForegroundColor1?.let { settings.tagForegroundColor1 = 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,7 +15,10 @@ data class AceSettings( | |||||||
|   var jumpModeColor: Color = Color(0xFFFFFF), |   var jumpModeColor: Color = Color(0xFFFFFF), | ||||||
|    |    | ||||||
|   @OptionTag("tagForegroundRGB", converter = ColorConverter::class) |   @OptionTag("tagForegroundRGB", converter = ColorConverter::class) | ||||||
|   var tagForegroundColor: Color = Color(0xFFFFFF), |   var tagForegroundColor1: 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,7 +28,8 @@ 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 tagForegroundColorWheel = ColorPanel() |   private val tagForeground1ColorWheel = ColorPanel() | ||||||
|  |   private val tagForeground2ColorWheel = ColorPanel() | ||||||
|   private val searchHighlightColorWheel = ColorPanel() |   private val searchHighlightColorWheel = ColorPanel() | ||||||
|    |    | ||||||
|   init { |   init { | ||||||
| @@ -54,9 +55,22 @@ internal class AceSettingsPanel { | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     titledRow("Colors") { |     titledRow("Colors") { | ||||||
|       row("Caret background:") { short(jumpModeColorWheel) } |       row("Caret background:") { | ||||||
|       row("Tag foreground:") { short(tagForegroundColorWheel) } |         cell { | ||||||
|       row("Search highlight:") { short(searchHighlightColorWheel) } |           component(jumpModeColorWheel) | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |       row("Tag foreground:") { | ||||||
|  |         cell { | ||||||
|  |           component(tagForeground1ColorWheel) | ||||||
|  |           component(tagForeground2ColorWheel) | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |       row("Search highlight:") { | ||||||
|  |         cell { | ||||||
|  |           component(searchHighlightColorWheel) | ||||||
|  |         } | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|    |    | ||||||
| @@ -67,7 +81,8 @@ 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 tagForegroundColor by tagForegroundColorWheel |   internal var tagForegroundColor1 by tagForeground1ColorWheel | ||||||
|  |   internal var tagForegroundColor2 by tagForeground2ColorWheel | ||||||
|   internal var searchHighlightColor by searchHighlightColorWheel |   internal var searchHighlightColor by searchHighlightColorWheel | ||||||
|    |    | ||||||
|   internal var minQueryLengthInt |   internal var minQueryLengthInt | ||||||
| @@ -80,7 +95,8 @@ internal class AceSettingsPanel { | |||||||
|     keyboardLayout = settings.layout |     keyboardLayout = settings.layout | ||||||
|     minQueryLength = settings.minQueryLength.toString() |     minQueryLength = settings.minQueryLength.toString() | ||||||
|     jumpModeColor = settings.jumpModeColor |     jumpModeColor = settings.jumpModeColor | ||||||
|     tagForegroundColor = settings.tagForegroundColor |     tagForegroundColor1 = settings.tagForegroundColor1 | ||||||
|  |     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[tagToChar(it)] } |     return { allPriorities.getOrDefault(tagToChar(it), Int.MAX_VALUE) } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -12,7 +12,8 @@ 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 foregroundColor = AceConfig.tagForegroundColor |   val foregroundColor1 = AceConfig.tagForegroundColor1 | ||||||
|  |   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: String, |   private val tag: CharArray, | ||||||
|   val offset: Int |   val offset: Int | ||||||
| ) { | ) { | ||||||
|   private val length = tag.length |   private val length = tag.size | ||||||
|    |    | ||||||
|   companion object { |   companion object { | ||||||
|     /** |     /** | ||||||
| @@ -28,7 +28,22 @@ 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), offset) |       return TagMarker(tag.drop(typedTag.length).toCharArray(), 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 | ||||||
|   } |   } | ||||||
|    |    | ||||||
|   /** |   /** | ||||||
| @@ -44,27 +59,20 @@ internal class TagMarker( | |||||||
|   /** |   /** | ||||||
|    * Renders the tag text. |    * Renders the tag text. | ||||||
|    */ |    */ | ||||||
|     private fun drawForeground(g: Graphics2D, font: TagFont, point: Point, text: String) { |   private fun drawForeground(g: Graphics2D, font: TagFont, point: Point) { | ||||||
|       g.color = font.foregroundColor |     val x = point.x | ||||||
|  |     val y = point.y + font.baselineDistance | ||||||
|  |      | ||||||
|     g.font = font.tagFont |     g.font = font.tagFont | ||||||
|       g.drawString(text, point.x, point.y + font.baselineDistance) |     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) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|    |    | ||||||
|   /** |  | ||||||
|    * 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) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user