Skip to content

Instantly share code, notes, and snippets.

@dploeger
Created December 20, 2017 12:11
Show Gist options
  • Save dploeger/cfaca3d6b81b4c3590b5bb97faccc199 to your computer and use it in GitHub Desktop.
Save dploeger/cfaca3d6b81b4c3590b5bb97faccc199 to your computer and use it in GitHub Desktop.
package de.dieploegers.develop.idea.custommark
import com.intellij.openapi.editor.EditorLinePainter
import com.intellij.openapi.editor.LineExtensionInfo
import com.intellij.openapi.editor.markup.EffectType
import com.intellij.openapi.editor.markup.TextAttributes
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import java.awt.Color
class CustomMarkEditorLinePainter : EditorLinePainter() {
override fun getLineExtensions(project: Project, file: VirtualFile, lineNumber: Int): MutableCollection<LineExtensionInfo> {
val content = file.contentsToByteArray().toString(file.charset).lines()[lineNumber]
val returnInfos = ArrayList<LineExtensionInfo>()
val textAttributes = TextAttributes()
textAttributes.effectType = EffectType.LINE_UNDERSCORE
textAttributes.backgroundColor = Color(255,0,0)
textAttributes.foregroundColor = Color(255,255,255)
if (content.matches(Regex(".*abab.*"))) {
returnInfos.add(
LineExtensionInfo("MARK", textAttributes)
)
}
return returnInfos
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment