Improve terminal theming, cursor UX, and size negotiation
This commit is contained in:
@@ -25,7 +25,9 @@ SshSessionBackend::SshSessionBackend(const Profile& profile, QObject* parent)
|
||||
m_reconnectPending(false),
|
||||
m_waitingForPasswordPrompt(false),
|
||||
m_waitingForHostKeyConfirmation(false),
|
||||
m_passwordSubmitted(false)
|
||||
m_passwordSubmitted(false),
|
||||
m_terminalColumns(0),
|
||||
m_terminalRows(0)
|
||||
{
|
||||
m_connectedProbeTimer->setSingleShot(true);
|
||||
|
||||
@@ -152,6 +154,16 @@ void SshSessionBackend::confirmHostKey(bool trustHost)
|
||||
: QStringLiteral("Host key rejected by user."));
|
||||
}
|
||||
|
||||
void SshSessionBackend::updateTerminalSize(int columns, int rows)
|
||||
{
|
||||
m_terminalColumns = columns;
|
||||
m_terminalRows = rows;
|
||||
|
||||
if (m_state == SessionState::Connected) {
|
||||
applyTerminalSizeIfAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
void SshSessionBackend::onProcessStarted()
|
||||
{
|
||||
emit eventLogged(QStringLiteral("ssh process started."));
|
||||
@@ -284,6 +296,10 @@ void SshSessionBackend::setState(SessionState state, const QString& message)
|
||||
m_state = state;
|
||||
emit stateChanged(state, message);
|
||||
emit eventLogged(message);
|
||||
|
||||
if (m_state == SessionState::Connected) {
|
||||
applyTerminalSizeIfAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
bool SshSessionBackend::startSshProcess(const SessionConnectOptions& options)
|
||||
@@ -502,3 +518,21 @@ QString SshSessionBackend::knownHostsFileForNullDevice() const
|
||||
return QStringLiteral("/dev/null");
|
||||
#endif
|
||||
}
|
||||
|
||||
void SshSessionBackend::applyTerminalSizeIfAvailable()
|
||||
{
|
||||
if (m_process->state() != QProcess::Running) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_terminalColumns <= 0 || m_terminalRows <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QString command = QStringLiteral("stty cols %1 rows %2\\n")
|
||||
.arg(m_terminalColumns)
|
||||
.arg(m_terminalRows);
|
||||
m_process->write(command.toUtf8());
|
||||
emit eventLogged(
|
||||
QStringLiteral("Applied terminal size: %1x%2").arg(m_terminalColumns).arg(m_terminalRows));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user