Skip to content

Commit

Permalink
feat: init text attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Jul 19, 2023
1 parent c505638 commit 042806e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Expand Up @@ -27,6 +27,13 @@ class CodeCompletionIntention : AbstractChatIntention() {
return "Complete code from prompt"
}

/**
* Invokes the method and performs auto-completion based on the current caret position in the editor.
*
* @param project the current project
* @param editor the editor in which the completion is performed
* @param file the PSI file in the editor
*/
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
if (editor == null || file == null) return

Expand Down
@@ -0,0 +1,38 @@
package cc.unitmesh.devti.presentation

import com.intellij.codeInsight.hints.presentation.BasePresentation
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.markup.TextAttributes
import com.intellij.ui.JBColor
import java.awt.Color
import java.awt.Graphics2D

class AutoDevTextPresentation : BasePresentation() {
override val height: Int
get() = TODO("Not yet implemented")
override val width: Int
get() = TODO("Not yet implemented")

override fun paint(g: Graphics2D, attributes: TextAttributes) {
TODO("Not yet implemented")
}

override fun toString(): String {
TODO("Not yet implemented")
}
}

private fun getTextAttributes(editor: Editor): TextAttributes {
val scheme = editor.colorsScheme
val themeAttributes = scheme.getAttributes(DefaultLanguageHighlighterColors.INLAY_TEXT_WITHOUT_BACKGROUND)
if (themeAttributes != null && themeAttributes.foregroundColor != null) {
return themeAttributes
}
val customAttributes = themeAttributes?.clone() ?: TextAttributes()
if (customAttributes.foregroundColor == null) {
customAttributes.foregroundColor = JBColor.GRAY as Color
}

return customAttributes
}

0 comments on commit 042806e

Please sign in to comment.