Add ANSI color rendering and terminal themes

This commit is contained in:
Keith Smith
2026-03-01 10:08:04 -07:00
parent 2b4f498259
commit 20ee48db32
4 changed files with 444 additions and 11 deletions

View File

@@ -4,6 +4,7 @@
#include "terminal_view.h"
#include <QClipboard>
#include <QComboBox>
#include <QDateTime>
#include <QFileDialog>
#include <QFileInfo>
@@ -16,7 +17,6 @@
#include <QMessageBox>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QTextCursor>
#include <QThread>
#include <QToolButton>
#include <QVBoxLayout>
@@ -38,6 +38,7 @@ SessionTab::SessionTab(const Profile& profile, QWidget* parent)
m_reconnectButton(nullptr),
m_copyErrorButton(nullptr),
m_clearTerminalButton(nullptr),
m_themeSelector(nullptr),
m_toggleDetailsButton(nullptr),
m_toggleEventsButton(nullptr),
m_detailsPanel(nullptr),
@@ -196,11 +197,7 @@ void SessionTab::onBackendOutputReceived(const QString& text)
return;
}
QTextCursor cursor = m_terminalOutput->textCursor();
cursor.movePosition(QTextCursor::End);
cursor.insertText(text);
m_terminalOutput->setTextCursor(cursor);
m_terminalOutput->ensureCursorVisible();
m_terminalOutput->appendTerminalData(text);
}
void SessionTab::onBackendHostKeyConfirmationRequested(const QString& prompt)
@@ -268,13 +265,17 @@ void SessionTab::setupUi()
auto* terminalHeader = new QHBoxLayout();
auto* terminalLabel = new QLabel(QStringLiteral("SSH Terminal"), this);
m_themeSelector = new QComboBox(this);
m_themeSelector->addItems(TerminalView::themeNames());
m_themeSelector->setCurrentText(QStringLiteral("Dark"));
m_clearTerminalButton = new QPushButton(QStringLiteral("Clear"), this);
terminalHeader->addWidget(terminalLabel);
terminalHeader->addStretch();
terminalHeader->addWidget(new QLabel(QStringLiteral("Theme"), this));
terminalHeader->addWidget(m_themeSelector);
terminalHeader->addWidget(m_clearTerminalButton);
m_terminalOutput = new TerminalView(this);
m_terminalOutput->setMaximumBlockCount(4000);
QFont terminalFont(QStringLiteral("Monospace"));
terminalFont.setStyleHint(QFont::TypeWriter);
m_terminalOutput->setFont(terminalFont);
@@ -338,6 +339,10 @@ void SessionTab::setupUi()
&TerminalView::inputGenerated,
this,
[this](const QString& input) { emit requestInput(input); });
connect(m_themeSelector,
&QComboBox::currentTextChanged,
m_terminalOutput,
&TerminalView::setThemeName);
}
std::optional<SessionConnectOptions> SessionTab::buildConnectOptions()