mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 15:06:56 +07:00
[dotnet, inlays] adjust inlay width to next text-equal width
GitOrigin-RevId: 9d3e207ef07df6671ebb4bb1f278fc1915622b6b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5b2556c776
commit
01a0db3047
@@ -15,6 +15,7 @@ import com.intellij.openapi.editor.colors.CodeInsightColors
|
||||
import com.intellij.openapi.editor.colors.EditorColors
|
||||
import com.intellij.openapi.editor.colors.EditorColors.REFERENCE_HYPERLINK_COLOR
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
import com.intellij.openapi.vfs.JarFileSystem
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
@@ -118,6 +119,30 @@ class PresentationFactory(private val editor: Editor) : InlayPresentationFactory
|
||||
return DynamicInsetPresentation(rounding, offsetFromTopProvider)
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
fun roundWithBackgroundAndNoInset(base: InlayPresentation): InlayPresentation {
|
||||
val rounding = withInlayAttributes(RoundWithBackgroundPresentation(base, 8, 8))
|
||||
return DynamicInsetPresentation(rounding, offsetFromTopProvider)
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
fun adjustToNextTextEqualWidth(base: InlayPresentation): InlayPresentation {
|
||||
return DynamicInsetPresentation(base, object : InsetValueProvider {
|
||||
|
||||
fun getInset(roundUp: Boolean): Int {
|
||||
val spaceWidth = EditorUtil.getPlainSpaceWidth(editor)
|
||||
val additionalWidth = spaceWidth - base.width % spaceWidth
|
||||
return if (roundUp) (additionalWidth + 1) / 2 else additionalWidth / 2
|
||||
}
|
||||
|
||||
override val left: Int
|
||||
get() = getInset(true)
|
||||
|
||||
override val right: Int
|
||||
get() = getInset(false)
|
||||
})
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
override fun icon(icon: Icon): IconPresentation = IconPresentation(icon, editor.component)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user