mirror of
https://github.com/KDE/konsole.git
synced 2025-12-23 23:38:08 -05:00
Session: support resetting bg and fg colors through OSC 110 and 111
This adds support for OSC 110 and OSC 111 for resetting the default fg and bg colors of the profile. Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
This commit is contained in:
committed by
Christoph Cullmann
parent
a6416f816c
commit
3389c39c9d
@@ -691,6 +691,15 @@ void Session::setSessionAttribute(int what, const QString &caption)
|
||||
return;
|
||||
}
|
||||
|
||||
if (what == ResetTextColor || what == ResetBackgroundColor) {
|
||||
QColor color;
|
||||
if (what == ResetTextColor) {
|
||||
Q_EMIT changeForegroundColorRequest(color);
|
||||
} else {
|
||||
Q_EMIT changeBackgroundColorRequest(color);
|
||||
}
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
Q_EMIT sessionAttributeChanged();
|
||||
}
|
||||
|
||||
@@ -401,6 +401,8 @@ public:
|
||||
SessionIcon = 32, // Non-standard
|
||||
SessionColor = 34, // Non-standard
|
||||
ProfileChange = 50, // this clashes with Xterm's font change command
|
||||
ResetTextColor = 110,
|
||||
ResetBackgroundColor = 111,
|
||||
};
|
||||
|
||||
// session management
|
||||
|
||||
@@ -34,6 +34,8 @@ void TerminalColor::applyProfile(const Profile::Ptr &profile, const std::shared_
|
||||
|
||||
m_cursorColor = profile->useCustomCursorColor() ? profile->customCursorColor() : QColor();
|
||||
m_cursorTextColor = profile->useCustomCursorColor() ? profile->customCursorTextColor() : QColor();
|
||||
m_defaultForeColor = colorScheme->foregroundColor();
|
||||
m_defaultBackColor = colorScheme->backgroundColor();
|
||||
}
|
||||
|
||||
QColor TerminalColor::backgroundColor() const
|
||||
@@ -92,13 +94,21 @@ void TerminalColor::setCursorColor(const QColor &color)
|
||||
|
||||
void TerminalColor::setBackgroundColor(const QColor &color)
|
||||
{
|
||||
m_colorTable[DEFAULT_BACK_COLOR] = color;
|
||||
if (color == QColor()) {
|
||||
m_colorTable[DEFAULT_BACK_COLOR] = m_defaultBackColor;
|
||||
} else {
|
||||
m_colorTable[DEFAULT_BACK_COLOR] = color;
|
||||
}
|
||||
onColorsChanged();
|
||||
}
|
||||
|
||||
void TerminalColor::setForegroundColor(const QColor &color)
|
||||
{
|
||||
m_colorTable[DEFAULT_FORE_COLOR] = color;
|
||||
if (color == QColor()) {
|
||||
m_colorTable[DEFAULT_FORE_COLOR] = m_defaultForeColor;
|
||||
} else {
|
||||
m_colorTable[DEFAULT_FORE_COLOR] = color;
|
||||
}
|
||||
onColorsChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ private:
|
||||
|
||||
QColor m_cursorColor;
|
||||
QColor m_cursorTextColor;
|
||||
QColor m_defaultForeColor;
|
||||
QColor m_defaultBackColor;
|
||||
|
||||
QColor m_colorTable[TABLE_COLORS];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user