mirror of
https://github.com/chylex/IntelliJ-Inspection-Lens.git
synced 2025-05-20 02:34:09 +02:00
Add option to use UI font for lenses
This commit is contained in:
parent
66abf6b349
commit
ec9c5c4c9b
src/main/kotlin/com/chylex/intellij/inspectionlens
@ -1,6 +1,8 @@
|
|||||||
package com.chylex.intellij.inspectionlens.editor
|
package com.chylex.intellij.inspectionlens.editor
|
||||||
|
|
||||||
|
import com.chylex.intellij.inspectionlens.settings.LensSettingsState
|
||||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo
|
import com.intellij.codeInsight.daemon.impl.HighlightInfo
|
||||||
|
import com.intellij.openapi.components.service
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.openapi.editor.Inlay
|
import com.intellij.openapi.editor.Inlay
|
||||||
import com.intellij.openapi.editor.InlayProperties
|
import com.intellij.openapi.editor.InlayProperties
|
||||||
@ -29,7 +31,7 @@ internal value class EditorLensInlay(private val inlay: Inlay<LensRenderer>) {
|
|||||||
val offset = getInlayHintOffset(info)
|
val offset = getInlayHintOffset(info)
|
||||||
val priority = getInlayHintPriority(editor, info)
|
val priority = getInlayHintPriority(editor, info)
|
||||||
|
|
||||||
val renderer = LensRenderer(info)
|
val renderer = LensRenderer(info, !service<LensSettingsState>().useUiFont)
|
||||||
val properties = InlayProperties().relatesToPrecedingText(true).disableSoftWrapping(true).priority(priority)
|
val properties = InlayProperties().relatesToPrecedingText(true).disableSoftWrapping(true).priority(priority)
|
||||||
|
|
||||||
return editor.inlayModel.addAfterLineEndElement(offset, properties, renderer)
|
return editor.inlayModel.addAfterLineEndElement(offset, properties, renderer)
|
||||||
|
@ -24,7 +24,7 @@ import javax.swing.SwingUtilities
|
|||||||
/**
|
/**
|
||||||
* Renders the text of an inspection lens.
|
* Renders the text of an inspection lens.
|
||||||
*/
|
*/
|
||||||
class LensRenderer(private var info: HighlightInfo) : HintRenderer(null), InputHandler {
|
class LensRenderer(private var info: HighlightInfo, private val useEditorFont: Boolean) : HintRenderer(null), InputHandler {
|
||||||
private lateinit var severity: LensSeverity
|
private lateinit var severity: LensSeverity
|
||||||
private lateinit var inlay: Inlay<*>
|
private lateinit var inlay: Inlay<*>
|
||||||
private var hovered = false
|
private var hovered = false
|
||||||
@ -63,7 +63,7 @@ class LensRenderer(private var info: HighlightInfo) : HintRenderer(null), InputH
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun useEditorFont(): Boolean {
|
override fun useEditorFont(): Boolean {
|
||||||
return true
|
return useEditorFont
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseMoved(event: MouseEvent, translated: Point) {
|
override fun mouseMoved(event: MouseEvent, translated: Point) {
|
||||||
|
@ -89,6 +89,12 @@ class LensApplicationConfigurable : BoundConfigurable("Inspection Lens"), Config
|
|||||||
checkBox("Other").bindSelected(settings::showUnknownSeverities)
|
checkBox("Other").bindSelected(settings::showUnknownSeverities)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
group("Appearance") {
|
||||||
|
row {
|
||||||
|
checkBox("Use UI Font").bindSelected(settings::useUiFont)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ class LensSettingsState : SimplePersistentStateComponent<LensSettingsState.State
|
|||||||
val hiddenSeverities by map<String, StoredSeverity>()
|
val hiddenSeverities by map<String, StoredSeverity>()
|
||||||
|
|
||||||
var showUnknownSeverities by property(true)
|
var showUnknownSeverities by property(true)
|
||||||
|
var useUiFont by property(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@get:Synchronized
|
@get:Synchronized
|
||||||
@ -27,6 +28,9 @@ class LensSettingsState : SimplePersistentStateComponent<LensSettingsState.State
|
|||||||
var severityFilter = createSeverityFilter()
|
var severityFilter = createSeverityFilter()
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
val useUiFont
|
||||||
|
get() = state.useUiFont
|
||||||
|
|
||||||
override fun loadState(state: State) {
|
override fun loadState(state: State) {
|
||||||
super.loadState(state)
|
super.loadState(state)
|
||||||
update()
|
update()
|
||||||
|
Loading…
Reference in New Issue
Block a user