Commit ed84b89a authored by Matan Ziv-Av's avatar Matan Ziv-Av Committed by Kurt Hindenburg
Browse files

Add four semantic integration visual hints:

- Error bars: show red bars at the left of lines when the command fails.
- Error background: show dark red background for failed commands.
- Alternating bars: show gray bars for every odd command.
- Alternating background: show dark gray background for every odd command.

Each of those is configurable in the profile individually. The bars are
enabled by default. The backgrounds show when visual hints keys are pressed
by default.
parent 29bff837
Pipeline #253530 passed with stage
in 6 minutes and 51 seconds
......@@ -77,6 +77,10 @@ const std::vector<Profile::PropertyInfo> Profile::DefaultProperties = {
{TerminalRows, "TerminalRows", GENERAL_GROUP, 28},
{TerminalMargin, "TerminalMargin", GENERAL_GROUP, 1},
{TerminalCenter, "TerminalCenter", GENERAL_GROUP, false},
{ErrorBars, "ErrorBars", GENERAL_GROUP, 2},
{ErrorBackground, "ErrorBackground", GENERAL_GROUP, 1},
{AlternatingBars, "AlternatingBars", GENERAL_GROUP, 2},
{AlternatingBackground, "AlternatingBackground", GENERAL_GROUP, 1},
// Appearance
{Font, "Font", APPEARANCE_GROUP, QFont()},
......
......@@ -378,6 +378,18 @@ public:
* 0 for Never, 1 when showing URL hints, 2 for always
*/
LineNumbers,
/** When to show Red error bars
*/
ErrorBars,
/** When to show Red error background
*/
ErrorBackground,
/** When to show alternating gray bars
*/
AlternatingBars,
/** When to show alternating background
*/
AlternatingBackground,
};
Q_ENUM(Property)
......
......@@ -79,6 +79,11 @@ void TerminalPainter::drawContents(Character *image,
const bool invertedRendition = currentProfile ? currentProfile->property<bool>(Profile::InvertSelectionColors) : false;
const Enum::Hints semanticHints = currentProfile ? static_cast<Enum::Hints>(currentProfile->semanticHints()) : Enum::HintsNever;
const Enum::Hints lineNumbers = currentProfile ? static_cast<Enum::Hints>(currentProfile->lineNumbers()) : Enum::HintsNever;
const Enum::Hints errorBars = currentProfile ? static_cast<Enum::Hints>(currentProfile->property<int>(Profile::ErrorBars)) : Enum::HintsNever;
const Enum::Hints errorBackground = currentProfile ? static_cast<Enum::Hints>(currentProfile->property<int>(Profile::ErrorBackground)) : Enum::HintsNever;
const Enum::Hints alternatingBars = currentProfile ? static_cast<Enum::Hints>(currentProfile->property<int>(Profile::AlternatingBars)) : Enum::HintsNever;
const Enum::Hints alternatingBackground =
currentProfile ? static_cast<Enum::Hints>(currentProfile->property<int>(Profile::AlternatingBackground)) : Enum::HintsNever;
QVector<uint> univec;
univec.reserve(m_parentDisplay->usedColumns());
......@@ -169,6 +174,15 @@ void TerminalPainter::drawContents(Character *image,
int lastNonSpace = m_parentDisplay->bidiMap(image + pos, line, log2line, line2log, shapemap, vis2line, shaped, bidiEnabled, bidiEnabled);
const QRect textArea(textScale.inverted().map(QPoint(textX, textY)), QSize(textWidth, textHeight));
if (!printerFriendly) {
QColor background = m_parentDisplay->terminalColor()->backgroundColor();
if (lineProperty.flags.f.error
&& ((errorBackground == Enum::HintsURL && m_parentDisplay->filterChain()->showUrlHint()) || errorBackground == Enum::HintsAlways)) {
background = QColor(48, 0, 0);
} else if ((lineProperty.counter & 1)
&& ((alternatingBackground == Enum::HintsURL && m_parentDisplay->filterChain()->showUrlHint())
|| alternatingBackground == Enum::HintsAlways)) {
background = QColor(40, 40, 40);
}
drawBelowText(paint,
textArea,
image + pos,
......@@ -179,7 +193,8 @@ void TerminalPainter::drawContents(Character *image,
invertedRendition,
vis2line,
line2log,
bidiEnabled);
bidiEnabled,
background);
}
RenditionFlags oldRendition = -1;
......@@ -251,6 +266,19 @@ void TerminalPainter::drawContents(Character *image,
paint.setPen(pen);
paint.drawLine(leftPadding, textY, m_parentDisplay->contentRect().right(), textY);
}
if ((lineProperty.counter & 1)
&& ((alternatingBars == Enum::HintsURL && m_parentDisplay->filterChain()->showUrlHint()) || alternatingBars == Enum::HintsAlways)) {
QPen pen(QColor("dark gray"));
pen.setWidth(2);
paint.setPen(pen);
paint.drawLine(leftPadding, textY, leftPadding, textY + fontHeight);
}
if (lineProperty.flags.f.error && ((errorBars == Enum::HintsURL && m_parentDisplay->filterChain()->showUrlHint()) || errorBars == Enum::HintsAlways)) {
QPen pen(QColor("red"));
pen.setWidth(4);
paint.setPen(pen);
paint.drawLine(leftPadding, textY, leftPadding, textY + fontHeight);
}
if ((lineNumbers == Enum::HintsURL && m_parentDisplay->filterChain()->showUrlHint()) || lineNumbers == Enum::HintsAlways) {
QRect rect(m_parentDisplay->contentRect().right() - 4 * fontWidth, textY, m_parentDisplay->contentRect().right(), textY + fontHeight);
QPen pen(QColor(0xC00000));
......@@ -622,7 +650,8 @@ void TerminalPainter::drawBelowText(QPainter &painter,
const bool invertedRendition,
int *vis2line,
int *line2log,
bool bidiEnabled)
bool bidiEnabled,
QColor background)
{
// setup painter
......@@ -673,6 +702,9 @@ void TerminalPainter::drawBelowText(QPainter &painter,
}
}
}
if (backgroundColor == colorTable[DEFAULT_BACK_COLOR]) {
backgroundColor = background;
}
drawBG = backgroundColor != colorTable[DEFAULT_BACK_COLOR];
if (style[x].rendition.f.transparent) {
drawBG = false;
......
......@@ -98,7 +98,8 @@ private:
const bool invertedRendition,
int *vis2line,
int *line2log,
bool bidiEnabled);
bool bidiEnabled,
QColor background);
void drawAboveText(QPainter &painter,
const QRect &rect,
Character *style,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment