Skip to content

Commit

Permalink
Increases search highlight usability for light themes (fixes #485)
Browse files Browse the repository at this point in the history
  • Loading branch information
Unthrottled committed Jan 30, 2022
1 parent 7fe2823 commit 8403648
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main/kotlin/io/unthrottled/doki/hax/HackComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ object HackComponent : Disposable {

private fun enableSelectionConsistency() {
hackWelcomeScreen()
hackSearchHighlight()
}

private fun enableHoverConsistency() {
Expand Down Expand Up @@ -155,6 +156,33 @@ object HackComponent : Disposable {
}
}

private fun hackSearchHighlight() {
runSafely({
val cp = ClassPool(true)
cp.insertClassPath(
ClassClassPath(
Class.forName("com.intellij.ui.SideBorder")
)
)
val ctClass = cp.get("com.intellij.ui.SimpleColoredComponent")
val doPaintText = ctClass.getDeclaredMethods("doPaintText")[0]
doPaintText.instrument(
object : ExprEditor() {
override fun edit(e: NewExpr?) {
if (e?.className == "com.intellij.ui.JBColor") {
e.replace(
"{ \$_ = com.intellij.ui.JBColor.namedColor(\"Panel.background\", com.intellij.ui.JBColor.BLACK); }"
)
}
}
}
)
ctClass.toClass()
}) {
log.warn("Unable to hackSearchHighlight for reasons.")
}
}

private fun hackWelcomeScreen() {
runSafely({
val cp = ClassPool(true)
Expand Down

0 comments on commit 8403648

Please sign in to comment.