Created
December 20, 2017 12:11
-
-
Save dploeger/cfaca3d6b81b4c3590b5bb97faccc199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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