summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Hindenburg <kurt.hindenburg@gmail.com>2016-09-25 03:39:05 (GMT)
committerKurt Hindenburg <kurt.hindenburg@gmail.com>2016-09-25 03:39:05 (GMT)
commit191b1ce83d6d030a59fbdb912af33c260e530053 (patch)
tree7c2bf8c5aa8a9d1b43d77360974d6d5f6ca4b2f8
parent0d5df7689f0f47de4db367578fcaffe64641a730 (diff)
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.
-rw-r--r--src/Character.h16
-rw-r--r--src/CharacterColor.h37
-rw-r--r--src/TerminalCharacterDecoder.cpp8
-rw-r--r--src/TerminalDisplay.cpp7
-rw-r--r--src/autotests/CharacterColorTest.cpp35
-rw-r--r--src/autotests/TerminalTest.cpp10
6 files changed, 9 insertions, 104 deletions
diff --git a/src/Character.h b/src/Character.h
index 68d0563..15c677e 100644
--- a/src/Character.h
+++ b/src/Character.h
@@ -123,13 +123,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
*/
bool equalsFormat(const Character& other) const;
@@ -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);
diff --git a/src/CharacterColor.h b/src/CharacterColor.h
index b55a510..efa99fd 100644
--- a/src/CharacterColor.h
+++ b/src/CharacterColor.h
@@ -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)
diff --git a/src/TerminalCharacterDecoder.cpp b/src/TerminalCharacterDecoder.cpp
index b470be5..fbfb467 100644
--- a/src/TerminalCharacterDecoder.cpp
+++ b/src/TerminalCharacterDecoder.cpp
@@ -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;");
diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index edbdc43..39a8b84 100644
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -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();
diff --git a/src/autotests/CharacterColorTest.cpp b/src/autotests/CharacterColorTest.cpp
index 1d52adc..b9a8668 100644
--- a/src/autotests/CharacterColorTest.cpp
+++ b/src/autotests/CharacterColorTest.cpp
@@ -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);
}
diff --git a/src/autotests/TerminalTest.cpp b/src/autotests/TerminalTest.cpp
index db37e4d..cd728fb 100644
--- a/src/autotests/TerminalTest.cpp
+++ b/src/autotests/TerminalTest.cpp
@@ -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;
}