mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-06-01 12:15:27 -06:00
UI: ANSI colors, further fix-ups
This commit is contained in:
parent
484d97caf1
commit
6eeca69c56
@ -295,13 +295,13 @@ void log_frame::CreateAndConnectActions()
|
|||||||
m_gui_settings->SetValue(gui::l_ansi_code, checked);
|
m_gui_settings->SetValue(gui::l_ansi_code, checked);
|
||||||
m_ansi_tty = checked;
|
m_ansi_tty = checked;
|
||||||
|
|
||||||
if (!m_tty_ansi_highlighter)
|
if (m_ansi_tty)
|
||||||
{
|
{
|
||||||
m_tty_ansi_highlighter = new AnsiHighlighter(m_tty->document());
|
m_tty_ansi_highlighter = new AnsiHighlighter(m_tty->document());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete m_tty_ansi_highlighter;
|
m_tty_ansi_highlighter->deleteLater();
|
||||||
m_tty_ansi_highlighter = nullptr;
|
m_tty_ansi_highlighter = nullptr;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Utilities/File.h"
|
#include "Utilities/File.h"
|
||||||
#include "rpcs3qt/syntax_highlighter.h"
|
|
||||||
#include "util/logs.hpp"
|
#include "util/logs.hpp"
|
||||||
|
|
||||||
#include "custom_dock_widget.h"
|
#include "custom_dock_widget.h"
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class LogHighlighter;
|
class LogHighlighter;
|
||||||
class AnsiHighlighter;
|
|
||||||
class gui_settings;
|
class gui_settings;
|
||||||
|
|
||||||
class log_viewer : public QWidget
|
class log_viewer : public QWidget
|
||||||
|
|||||||
@ -186,20 +186,15 @@ GlslHighlighter::GlslHighlighter(QTextDocument* parent) : Highlighter(parent)
|
|||||||
|
|
||||||
AnsiHighlighter::AnsiHighlighter(QTextDocument* parent) : Highlighter(parent)
|
AnsiHighlighter::AnsiHighlighter(QTextDocument* parent) : Highlighter(parent)
|
||||||
{
|
{
|
||||||
|
m_escape_format.setForeground(Qt::darkGray);
|
||||||
|
m_escape_format.setFontItalic(true);
|
||||||
|
|
||||||
m_foreground_color = gui::utils::get_foreground_color();
|
m_foreground_color = gui::utils::get_foreground_color();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnsiHighlighter::highlightBlock(const QString& text)
|
void AnsiHighlighter::highlightBlock(const QString& text)
|
||||||
{
|
{
|
||||||
// Match ANSI SGR sequences, e.g. "\x1b[31m" or "\x1b[1;32m"
|
QTextCharFormat current_format;
|
||||||
static const QRegularExpression ansi_re("\x1b\\[[0-9;]*m");
|
|
||||||
static const QRegularExpression param_re("\x1b\\[([0-9;]*)m");
|
|
||||||
|
|
||||||
static QTextCharFormat escape_format;
|
|
||||||
escape_format.setForeground(Qt::darkGray);
|
|
||||||
escape_format.setFontItalic(true);
|
|
||||||
|
|
||||||
static QTextCharFormat current_format;
|
|
||||||
current_format.setForeground(m_foreground_color);
|
current_format.setForeground(m_foreground_color);
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
@ -217,7 +212,7 @@ void AnsiHighlighter::highlightBlock(const QString& text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Highlight the escape sequence itself
|
// Highlight the escape sequence itself
|
||||||
setFormat(start, length, escape_format);
|
setFormat(start, length, m_escape_format);
|
||||||
|
|
||||||
// Parse SGR parameters and update currentFormat
|
// Parse SGR parameters and update currentFormat
|
||||||
const QRegularExpressionMatch pm = param_re.match(match.captured());
|
const QRegularExpressionMatch pm = param_re.match(match.captured());
|
||||||
|
|||||||
@ -62,6 +62,10 @@ public:
|
|||||||
explicit AnsiHighlighter(QTextDocument* parent = nullptr);
|
explicit AnsiHighlighter(QTextDocument* parent = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
const QRegularExpression ansi_re = QRegularExpression("\x1b\\[[0-9;]*m");
|
||||||
|
const QRegularExpression param_re = QRegularExpression("\x1b\\[([0-9;]*)m");
|
||||||
|
|
||||||
|
QTextCharFormat m_escape_format;
|
||||||
QColor m_foreground_color;
|
QColor m_foreground_color;
|
||||||
|
|
||||||
void highlightBlock(const QString& text) override;
|
void highlightBlock(const QString& text) override;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user