mirror of
https://github.com/KDE/konsole.git
synced 2025-12-23 23:38:08 -05:00
KonsoleDecoders: Remove konsolecolorscheme dependency
This commit is contained in:
committed by
Kurt Hindenburg
parent
ae1b05e629
commit
d7706fab23
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "../decoders/HTMLDecoder.h"
|
||||
#include "../decoders/PlainTextDecoder.h"
|
||||
#include "colorscheme/ColorScheme.h"
|
||||
#include "colorscheme/ColorSchemeManager.h"
|
||||
|
||||
namespace Konsole
|
||||
{
|
||||
@@ -110,7 +112,16 @@ void SaveHistoryTask::execute()
|
||||
if (((dialog->selectedNameFilter()).contains(QLatin1String("html"), Qt::CaseInsensitive))
|
||||
|| ((dialog->selectedFiles()).at(0).endsWith(QLatin1String("html"), Qt::CaseInsensitive))) {
|
||||
Profile::Ptr profile = SessionManager::instance()->sessionProfile(session);
|
||||
jobInfo.decoder = new HTMLDecoder(profile->colorScheme(), profile->font());
|
||||
const auto schemeName = profile->colorScheme();
|
||||
const auto scheme = ColorSchemeManager::instance()->findColorScheme(schemeName);
|
||||
QColor colorTable[TABLE_COLORS];
|
||||
if (scheme) {
|
||||
scheme->getColorTable(colorTable);
|
||||
} else {
|
||||
std::copy_n(ColorScheme::defaultTable, TABLE_COLORS, colorTable);
|
||||
}
|
||||
|
||||
jobInfo.decoder = new HTMLDecoder(colorTable, profile->font());
|
||||
} else {
|
||||
jobInfo.decoder = new PlainTextDecoder();
|
||||
}
|
||||
|
||||
@@ -1962,7 +1962,7 @@ QString Screen::text(int startIndex, int endIndex, const DecodingOptions options
|
||||
QString result;
|
||||
QTextStream stream(&result, QIODevice::ReadWrite);
|
||||
|
||||
HTMLDecoder htmlDecoder;
|
||||
HTMLDecoder htmlDecoder(ColorScheme::defaultTable);
|
||||
PlainTextDecoder plainTextDecoder;
|
||||
|
||||
TerminalCharacterDecoder *decoder;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
// Konsole
|
||||
#include "../decoders/HTMLDecoder.h"
|
||||
#include "../decoders/PlainTextDecoder.h"
|
||||
#include "colorscheme/ColorScheme.h"
|
||||
|
||||
// Qt
|
||||
#include <QTextStream>
|
||||
@@ -101,7 +102,7 @@ void TerminalCharacterDecoderTest::testHTMLDecoder()
|
||||
QFETCH(QVector<RenditionFlags>, renditions);
|
||||
QFETCH(QString, result);
|
||||
|
||||
TerminalCharacterDecoder *decoder = new HTMLDecoder();
|
||||
TerminalCharacterDecoder *decoder = new HTMLDecoder(ColorScheme::defaultTable);
|
||||
auto testCharacters = new Character[text.size()];
|
||||
convertToCharacter(testCharacters, text, renditions);
|
||||
QString outputString;
|
||||
|
||||
@@ -12,4 +12,4 @@ target_include_directories(konsoledecoders
|
||||
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# TODO: remove the konsolecolorscheme dependencies
|
||||
target_link_libraries(konsoledecoders konsolecharacters konsolecolorscheme)
|
||||
target_link_libraries(konsoledecoders konsolecharacters)
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
// Own
|
||||
#include "HTMLDecoder.h"
|
||||
|
||||
// Konsole colorScheme
|
||||
#include <ColorSchemeManager.h>
|
||||
|
||||
// Konsole characters
|
||||
#include <ExtendedCharTable.h>
|
||||
|
||||
@@ -18,9 +15,8 @@
|
||||
|
||||
using namespace Konsole;
|
||||
|
||||
HTMLDecoder::HTMLDecoder(const QString &colorSchemeName, const QFont &profileFont)
|
||||
HTMLDecoder::HTMLDecoder(const QColor *colorTable, const QFont &profileFont)
|
||||
: _output(nullptr)
|
||||
, _colorSchemeName(colorSchemeName)
|
||||
, _profileFont(profileFont)
|
||||
, _innerSpanOpen(false)
|
||||
, _lastRendition(DEFAULT_RENDITION)
|
||||
@@ -28,23 +24,8 @@ HTMLDecoder::HTMLDecoder(const QString &colorSchemeName, const QFont &profileFon
|
||||
, _lastBackColor(CharacterColor())
|
||||
, _validProfile(false)
|
||||
{
|
||||
std::shared_ptr<const ColorScheme> colorScheme = nullptr;
|
||||
|
||||
if (!colorSchemeName.isEmpty()) {
|
||||
colorScheme = ColorSchemeManager::instance()->findColorScheme(colorSchemeName);
|
||||
|
||||
if (colorScheme == nullptr) {
|
||||
colorScheme = ColorSchemeManager::instance()->defaultColorScheme();
|
||||
}
|
||||
|
||||
_validProfile = true;
|
||||
}
|
||||
|
||||
if (colorScheme != nullptr) {
|
||||
colorScheme->getColorTable(_colorTable);
|
||||
} else {
|
||||
std::copy_n(ColorScheme::defaultTable, TABLE_COLORS, _colorTable);
|
||||
}
|
||||
Q_ASSERT(colorTable);
|
||||
std::copy_n(colorTable, TABLE_COLORS, _colorTable);
|
||||
}
|
||||
|
||||
void HTMLDecoder::begin(QTextStream *output)
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
/**
|
||||
* Constructs an HTML decoder using a default black-on-white color scheme.
|
||||
*/
|
||||
explicit HTMLDecoder(const QString &colorSchemeName = QString(), const QFont &profileFont = QFont());
|
||||
explicit HTMLDecoder(const QColor *colorTable, const QFont &profileFont = QFont());
|
||||
|
||||
void decodeLine(const Character *const characters, int count, LineProperty properties) override;
|
||||
|
||||
@@ -36,7 +36,6 @@ private:
|
||||
void closeSpan(QString &text);
|
||||
|
||||
QTextStream *_output;
|
||||
QString _colorSchemeName;
|
||||
QFont _profileFont;
|
||||
QColor _colorTable[TABLE_COLORS];
|
||||
bool _innerSpanOpen;
|
||||
|
||||
Reference in New Issue
Block a user