diff --git a/libtheterminal/com/vicr123/theterminal/libtheterminal/impl/qmlterminalscreencontroller.cpp b/libtheterminal/com/vicr123/theterminal/libtheterminal/impl/qmlterminalscreencontroller.cpp index 8bf4ae5..c1c54ad 100644 --- a/libtheterminal/com/vicr123/theterminal/libtheterminal/impl/qmlterminalscreencontroller.cpp +++ b/libtheterminal/com/vicr123/theterminal/libtheterminal/impl/qmlterminalscreencontroller.cpp @@ -214,7 +214,7 @@ void QmlTerminalScreenController::paste() { QVariantList QmlTerminalScreenController::calculateRuns(int start, int cols, std::function getCharacter) { QVariantList runs; QVariantMap currentMap = initFormat({}); - QByteArray currentText; + QString currentText; TerminalScreen::CharacterSpace::CharacterFormat previousFormat; for (auto i = start; i < cols; i++) { auto character = getCharacter(i); @@ -229,7 +229,7 @@ QVariantList QmlTerminalScreenController::calculateRuns(int start, int cols, std currentMap = initFormat(character.format); } - currentText.append(character.character.unicode()); + currentText.append(character.character); previousFormat = character.format; } diff --git a/libtheterminal/common/Emulation/vt100emulation.cpp b/libtheterminal/common/Emulation/vt100emulation.cpp index e72fc27..321d695 100644 --- a/libtheterminal/common/Emulation/vt100emulation.cpp +++ b/libtheterminal/common/Emulation/vt100emulation.cpp @@ -8,6 +8,7 @@ struct VT100EmulationPrivate { QIODevice* device; + QTextStream reader; TerminalScreen* screen; bool echo = false; @@ -44,10 +45,14 @@ VT100Emulation::VT100Emulation(QIODevice* device, TerminalScreen* screen, QObjec setupStateMachine(); setupCsiStateMachine(); + d->reader.setAutoDetectUnicode(false); + d->reader.setDevice(device); + connect(device, &QIODevice::readyRead, this, [this] { - auto buf = d->device->readAll(); - for (auto character : buf) { - processCharacter(character); + while (!d->reader.atEnd()) { + QChar ch; + d->reader >> ch; + processCharacter(ch); } }); } @@ -77,7 +82,7 @@ void VT100Emulation::pressKey(Qt::KeyboardModifiers modifiers, Qt::Key key, QStr this->write("\x1B[B"); return; } else if (key == Qt::Key_Up) { - this->write("\x1B[A"); + this->write("\x1B[A"); return; } @@ -589,7 +594,7 @@ void VT100Emulation::invokeCsi(QString csi) { switch (lastResult) { case TerminalStateMachine::Result::Accepted: - return; + return; case TerminalStateMachine::Result::Pending: break; case TerminalStateMachine::Result::Rejected: diff --git a/libtheterminal/common/PtyImpl/winpty.cpp b/libtheterminal/common/PtyImpl/winpty.cpp index c29a0a1..ec79ae2 100644 --- a/libtheterminal/common/PtyImpl/winpty.cpp +++ b/libtheterminal/common/PtyImpl/winpty.cpp @@ -13,7 +13,7 @@ struct ReadFileWorker : public QThread ReadFileWorker(HANDLE hnd, QObject* parent) : QThread(parent), hnd(hnd) {} void run() override { - std::byte buf[1024]; + char buf[1024]; while (true) { DWORD readBytes; if (!ReadFile(hnd, buf, sizeof(buf), &readBytes, nullptr)) { @@ -21,7 +21,6 @@ struct ReadFileWorker : public QThread return; } - emit dataRead(QByteArrayView(buf, readBytes)); emit dataRead(QByteArray(buf, readBytes)); } } @@ -173,7 +172,7 @@ bool WinPty::setWindowSize(qint16 cols, qint16 rows) { if (d->hPC != nullptr) { auto hr = ResizePseudoConsole(d->hPC, { cols, rows }); return SUCCEEDED(hr); - } + } return false; } @@ -189,6 +188,10 @@ qint64 WinPty::writeData(const char* data, qint64 len) { return len; } +qint64 WinPty::bytesAvailable() const { + return d->readBuffer.length(); +} + QStringList WinPty::runningProcesses() { return {}; } diff --git a/libtheterminal/common/PtyImpl/winpty.h b/libtheterminal/common/PtyImpl/winpty.h index b46d142..fa22d84 100644 --- a/libtheterminal/common/PtyImpl/winpty.h +++ b/libtheterminal/common/PtyImpl/winpty.h @@ -28,6 +28,7 @@ class WinPty : public AbstractPty { protected: qint64 readData(char *data, qint64 maxlen) override; qint64 writeData(const char *data, qint64 len) override; + qint64 bytesAvailable() const override; }; #endif // WINPTY_H