[terminal] IDEA-330183 Refactor: rename TerminalUI

GitOrigin-RevId: f397936c6929768c98428364e823e96a6e88cf41
This commit is contained in:
Konstantin Hudyakov
2023-08-22 19:30:28 +03:00
committed by intellij-monorepo-bot
parent 4639926a33
commit e1ab0116db
6 changed files with 30 additions and 30 deletions

View File

@@ -87,7 +87,7 @@ class BlockTerminalView(
}
})
component.background = TerminalUI.terminalBackground
component.background = TerminalUi.terminalBackground
installPromptAndOutput()
}

View File

@@ -54,8 +54,8 @@ class SimpleTerminalView(
}
})
component.background = TerminalUI.terminalBackground
component.border = JBUI.Borders.emptyLeft(TerminalUI.alternateBufferLeftInset)
component.background = TerminalUi.terminalBackground
component.border = JBUI.Borders.emptyLeft(TerminalUi.alternateBufferLeftInset)
component.layout = BorderLayout()
component.add(editor.component, BorderLayout.CENTER)
}

View File

@@ -30,13 +30,13 @@ class TerminalBlocksDecorator(private val editor: EditorEx) {
@RequiresEdt
fun installDecoration(block: CommandBlock, isFirstBlock: Boolean = false): BlockDecoration {
// add additional empty space on top of the block, if it is the first block
val topInset = TerminalUI.blockTopInset + if (isFirstBlock) TerminalUI.blocksGap else 0
val topInset = TerminalUi.blockTopInset + if (isFirstBlock) TerminalUi.blocksGap else 0
val topRenderer = EmptyWidthInlayRenderer(topInset)
val topInlay = editor.inlayModel.addBlockElement(block.startOffset, false, true, 1, topRenderer)!!
val bottomRenderer = EmptyWidthInlayRenderer(TerminalUI.blockBottomInset + TerminalUI.blocksGap)
val bottomRenderer = EmptyWidthInlayRenderer(TerminalUi.blockBottomInset + TerminalUi.blocksGap)
val bottomInlay = editor.inlayModel.addBlockElement(block.endOffset, true, false, 0, bottomRenderer)!!
val attributes = TextAttributes(TerminalUI.outputForeground, TerminalUI.blockBackground, null, null, Font.PLAIN)
val attributes = TextAttributes(TerminalUi.outputForeground, TerminalUi.blockBackground, null, null, Font.PLAIN)
val highlighter = editor.markupModel.addRangeHighlighter(block.startOffset, block.endOffset, HighlighterLayer.FIRST - 100,
attributes, HighlighterTargetArea.LINES_IN_RANGE)
highlighter.isGreedyToRight = true
@@ -60,10 +60,10 @@ class TerminalBlocksDecorator(private val editor: EditorEx) {
private class TerminalRightAreaRenderer : CustomHighlighterRenderer {
override fun paint(editor: Editor, highlighter: RangeHighlighter, g: Graphics) {
val visibleArea = editor.scrollingModel.visibleArea
val width = JBUI.scale(TerminalUI.cornerToBlockInset)
val width = JBUI.scale(TerminalUi.cornerToBlockInset)
val oldColor = g.color
try {
g.color = TerminalUI.terminalBackground
g.color = TerminalUi.terminalBackground
g.fillRect(visibleArea.width - width, visibleArea.y, width, visibleArea.height)
}
finally {
@@ -75,10 +75,10 @@ class TerminalBlocksDecorator(private val editor: EditorEx) {
/** Paints the left part of the rounded block frame in the gutter area. */
private class TerminalBlockLeftAreaRenderer : LineMarkerRenderer {
override fun paint(editor: Editor, g: Graphics, r: Rectangle) {
val topIns = toFloatAndScale(TerminalUI.blockTopInset)
val bottomIns = toFloatAndScale(TerminalUI.blockBottomInset)
val width = toFloatAndScale(TerminalUI.blockLeftInset)
val arc = toFloatAndScale(TerminalUI.blockArc)
val topIns = toFloatAndScale(TerminalUi.blockTopInset)
val bottomIns = toFloatAndScale(TerminalUi.blockBottomInset)
val width = toFloatAndScale(TerminalUi.blockLeftInset)
val arc = toFloatAndScale(TerminalUi.blockArc)
val gutterWidth = (editor as EditorEx).gutterComponentEx.width
val rect = Rectangle2D.Float(gutterWidth - width, r.y - topIns, width, r.height + topIns + bottomIns)
@@ -96,7 +96,7 @@ class TerminalBlocksDecorator(private val editor: EditorEx) {
val g2d = g.create() as Graphics2D
try {
GraphicsUtil.setupAntialiasing(g2d)
g2d.color = TerminalUI.blockBackground
g2d.color = TerminalUi.blockBackground
g2d.fill(path)
}
finally {
@@ -113,11 +113,11 @@ class TerminalBlocksDecorator(private val editor: EditorEx) {
*/
private class TerminalBlockRenderer : CustomHighlighterRenderer {
override fun paint(editor: Editor, highlighter: RangeHighlighter, g: Graphics) {
val topIns = toFloatAndScale(TerminalUI.blockTopInset)
val bottomIns = toFloatAndScale(TerminalUI.blockBottomInset)
val cornerToBlock = toFloatAndScale(TerminalUI.cornerToBlockInset)
val gap = toFloatAndScale(TerminalUI.blocksGap)
val arc = toFloatAndScale(TerminalUI.blockArc)
val topIns = toFloatAndScale(TerminalUi.blockTopInset)
val bottomIns = toFloatAndScale(TerminalUi.blockBottomInset)
val cornerToBlock = toFloatAndScale(TerminalUi.cornerToBlockInset)
val gap = toFloatAndScale(TerminalUi.blocksGap)
val arc = toFloatAndScale(TerminalUi.blockArc)
val visibleArea = editor.scrollingModel.visibleArea
val width = visibleArea.width - cornerToBlock
@@ -145,10 +145,10 @@ class TerminalBlocksDecorator(private val editor: EditorEx) {
val g2d = g.create() as Graphics2D
try {
GraphicsUtil.setupAntialiasing(g2d)
g2d.color = TerminalUI.blockBackground
g2d.color = TerminalUi.blockBackground
g2d.fill(topRect)
g2d.fill(bottomRect)
g2d.color = TerminalUI.terminalBackground
g2d.color = TerminalUi.terminalBackground
g2d.fill(gapRect)
// override the right corners to make them rounded
g2d.fill(topCornerPath)

View File

@@ -47,15 +47,15 @@ class TerminalPromptView(
commandHistoryPresenter = CommandHistoryPresenter(project, editor, commandExecutor)
val innerBorder = JBUI.Borders.empty(TerminalUI.promptTopInset,
TerminalUI.blockLeftInset + TerminalUI.cornerToBlockInset,
TerminalUI.promptBottomInset,
TerminalUI.blockRightInset + TerminalUI.cornerToBlockInset)
val innerBorder = JBUI.Borders.empty(TerminalUi.promptTopInset,
TerminalUi.blockLeftInset + TerminalUi.cornerToBlockInset,
TerminalUi.promptBottomInset,
TerminalUi.blockRightInset + TerminalUi.cornerToBlockInset)
val outerBorder = JBUI.Borders.customLineTop(JBUI.CurrentTheme.CustomFrameDecorations.separatorForeground())
component.border = JBUI.Borders.compound(outerBorder, innerBorder)
component.background = TerminalUI.terminalBackground
component.layout = ListLayout.vertical(TerminalUI.promptToCommandInset)
component.background = TerminalUi.terminalBackground
component.layout = ListLayout.vertical(TerminalUi.promptToCommandInset)
component.add(promptLabel)
component.add(editorTextField)
}
@@ -98,7 +98,7 @@ class TerminalPromptView(
val editor = textField.getEditor(true) as EditorImpl
editor.scrollPane.border = JBUI.Borders.empty()
editor.gutterComponentEx.isPaintBackground = false
editor.backgroundColor = TerminalUI.terminalBackground
editor.backgroundColor = TerminalUi.terminalBackground
editor.colorsScheme.apply {
editorFontName = settings.terminalFont.fontName
editorFontSize = settings.terminalFont.size
@@ -116,7 +116,7 @@ class TerminalPromptView(
font = EditorUtil.getEditorFont()
}
}
label.foreground = TerminalUI.promptForeground
label.foreground = TerminalUi.promptForeground
label.alignmentX = JComponent.LEFT_ALIGNMENT
return label
}

View File

@@ -5,7 +5,7 @@ import com.intellij.ui.JBColor
import java.awt.Color
@Suppress("ConstPropertyName")
object TerminalUI {
object TerminalUi {
const val blockTopInset = 8
const val blockBottomInset = 12
const val blockLeftInset = 12

View File

@@ -101,7 +101,7 @@ class TerminalWidgetImpl(private val project: Project,
private class TerminalPlaceholder : TerminalContentView {
override val component: JComponent = object : JPanel() {
override fun getBackground(): Color {
return TerminalUI.terminalBackground
return TerminalUi.terminalBackground
}
}