Commit 191b1ce8 authored by Kurt Hindenburg's avatar Kurt Hindenburg

Remove ColorEntry::FontWeight as it hasn't been used for a long time

The ColorEntry::FontWeight has always been set to the default
ColorEntry::UseCurrentFormat.
This greatly simplifies ColorEntry to just a QColor.
parent 0d5df768
......@@ -122,13 +122,6 @@ public:
*/
bool isRealCharacter;
/**
* Returns true if this character should always be drawn in bold when
* it is drawn with the specified @p palette, independent of whether
* or not the character has the RE_BOLD rendition flag.
*/
ColorEntry::FontWeight fontWeight(const ColorEntry* base) const;
/**
* returns true if the format (color, rendition flag) of the compared characters is equal
*/
......@@ -180,15 +173,6 @@ inline bool Character::equalsFormat(const Character& other) const
rendition == other.rendition;
}
inline ColorEntry::FontWeight Character::fontWeight(const ColorEntry* base) const
{
if (foregroundColor._colorSpace == COLOR_SPACE_DEFAULT)
return base[foregroundColor._u + 0 + (foregroundColor._v ? BASE_COLORS : 0)].fontWeight;
else if (foregroundColor._colorSpace == COLOR_SPACE_SYSTEM)
return base[foregroundColor._u + 2 + (foregroundColor._v ? BASE_COLORS : 0)].fontWeight;
else
return ColorEntry::UseCurrentFormat;
}
}
Q_DECLARE_TYPEINFO(Konsole::Character, Q_MOVABLE_TYPE);
......
......@@ -40,67 +40,44 @@ namespace Konsole
class ColorEntry
{
public:
/** Specifies the weight to use when drawing text with this color. */
enum FontWeight {
/** Always draw text in this color with a bold weight. */
Bold,
/** Always draw text in this color with a normal weight. */
Normal,
/**
* Use the current font weight set by the terminal application.
* This is the default behavior.
*/
UseCurrentFormat
};
/**
* Constructs a new color palette entry.
*
* @param c The color value for this entry.
* @param weight Specifies the font weight to use when drawing text with this color.
*/
explicit ColorEntry(QColor c, FontWeight weight = UseCurrentFormat)
: color(c), fontWeight(weight) {}
explicit ColorEntry(QColor c)
: color(c) {}
/**
* Constructs a new color palette entry using black color and font weight set to
* use current format.
* Constructs a new color palette entry using black color.
*/
ColorEntry() : color(QColor(0x00, 0x00, 0x00)), fontWeight(UseCurrentFormat) {}
ColorEntry() : color(QColor(0x00, 0x00, 0x00)) {}
/**
* Sets the color and boldness of this color to those of @p rhs.
*/
void operator=(const ColorEntry& rhs) {
color = rhs.color;
fontWeight = rhs.fontWeight;
}
/** The color value of this entry for display. */
QColor color;
/**
* Specifies the font weight to use when drawing text with this color.
* This is not applicable when the color is used to draw a character's background.
*/
FontWeight fontWeight;
/**
* Compares two color entries and returns true if they represent the same
* color and font weight.
* color.
*/
friend bool operator == (const ColorEntry& a, const ColorEntry& b);
/**
* Compares two color entries and returns true if they represent different
* color and font weight.
* color.
*/
friend bool operator != (const ColorEntry& a, const ColorEntry& b);
};
inline bool operator == (const ColorEntry& a, const ColorEntry& b)
{
return a.color == b.color &&
a.fontWeight == b.fontWeight;
return a.color == b.color;
}
inline bool operator != (const ColorEntry& a, const ColorEntry& b)
......
......@@ -199,13 +199,7 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP
//colors - a color table must have been defined first
if (_colorTable) {
bool useBold;
ColorEntry::FontWeight weight = characters[i].fontWeight(_colorTable);
if (weight == ColorEntry::UseCurrentFormat)
useBold = _lastRendition & RE_BOLD;
else
useBold = weight == ColorEntry::Bold;
bool useBold = _lastRendition & RE_BOLD;
if (useBold)
style.append("font-weight:bold;");
......
......@@ -817,12 +817,7 @@ void TerminalDisplay::drawCharacters(QPainter& painter,
return;
// setup bold and underline
bool useBold;
ColorEntry::FontWeight weight = style->fontWeight(_colorTable);
if (weight == ColorEntry::UseCurrentFormat)
useBold = ((style->rendition & RE_BOLD) && _boldIntense) || font().bold();
else
useBold = (weight == ColorEntry::Bold) ? true : false;
bool useBold = ((style->rendition & RE_BOLD) && _boldIntense) || font().bold();
const bool useUnderline = style->rendition & RE_UNDERLINE || font().underline();
const bool useItalic = style->rendition & RE_ITALIC || font().italic();
const bool useStrikeOut = style->rendition & RE_STRIKEOUT || font().strikeOut();
......
......@@ -86,55 +86,20 @@ void CharacterColorTest::testColorEntry()
QCOMPARE(red == green, false);
QCOMPARE(red != green, true);
ColorEntry blackBold = ColorEntry(QColor(0x00, 0x00, 0x00), ColorEntry::FontWeight::Bold);
ColorEntry blackNormal = ColorEntry(QColor(0x00, 0x00, 0x00), ColorEntry::FontWeight::Normal);
ColorEntry blackUseCurrentFormat = ColorEntry(QColor(0x00, 0x00, 0x00), ColorEntry::FontWeight::UseCurrentFormat);
QCOMPARE(blackBold == white, false);
QCOMPARE(blackBold != white, true);
QCOMPARE(blackBold == black, false);
QCOMPARE(blackBold != black, true);
QCOMPARE(blackNormal == white, false);
QCOMPARE(blackNormal != white, true);
QCOMPARE(blackNormal == black, false);
QCOMPARE(blackNormal != black, true);
QCOMPARE(blackUseCurrentFormat == white, false);
QCOMPARE(blackUseCurrentFormat != white, true);
QCOMPARE(blackUseCurrentFormat == black, true); // UseCurrentFormat is default
QCOMPARE(blackUseCurrentFormat != black, false);
QCOMPARE(blackUseCurrentFormat == blackBold, false);
QCOMPARE(blackUseCurrentFormat != blackBold, true);
QCOMPARE(blackUseCurrentFormat == blackNormal, false);
QCOMPARE(blackUseCurrentFormat != blackNormal, true);
QCOMPARE(blackBold == blackNormal, false);
QCOMPARE(blackBold != blackNormal, true);
QCOMPARE(red == green, false);
QCOMPARE(red != green, true);
// Test operator=
ColorEntry tmpColorEntry;
ColorEntry redBold = ColorEntry(QColor(0xB2, 0x18, 0x18), ColorEntry::FontWeight::Bold);
tmpColorEntry = red;
QCOMPARE(tmpColorEntry == red, true);
QCOMPARE(red == tmpColorEntry, true);
tmpColorEntry = redBold;
QCOMPARE(tmpColorEntry == red, false);
QCOMPARE(red == tmpColorEntry, false);
QCOMPARE(tmpColorEntry != red, true);
QCOMPARE(red != tmpColorEntry, true);
// Test ColorEntry()
ColorEntry defaultColorEntry = ColorEntry();
QCOMPARE(defaultColorEntry != green, true);
QCOMPARE(defaultColorEntry == black, true);
QCOMPARE(defaultColorEntry != black, false);
QCOMPARE(defaultColorEntry == blackUseCurrentFormat, true);
}
......
......@@ -73,16 +73,6 @@ void TerminalTest::testColorTable()
ColorEntry colorEntry = ColorEntry(QColor(0x00, 0x00, 0x00));
QVERIFY(colorTable[1] != colorEntry);
// UseCurrentFormat is the default FontWeight
colorEntry = ColorEntry(QColor(0x00, 0x00, 0x00), ColorEntry::Bold);
QVERIFY(colorTable[0] != colorEntry);
colorEntry = ColorEntry(QColor(0x00, 0x00, 0x00), ColorEntry::Normal);
QVERIFY(colorTable[0] != colorEntry);
colorEntry = ColorEntry(QColor(0x00, 0x00, 0x00), ColorEntry::UseCurrentFormat);
QVERIFY(colorTable[0] == colorEntry);
delete display;
}
......
Markdown is supported
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