Skip to content

Commit

Permalink
Vt102Emulation: improve QKeyPress event management
Browse files Browse the repository at this point in the history
If the QKeyEvent as no text and only a key code, the text should contain
that character.

Signed-off-by: Christophe Chapuis <chris.chapuis@gmail.com>
  • Loading branch information
Tofee committed Apr 29, 2023
1 parent 1e7ab36 commit 32da270
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/Vt102Emulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,9 +1143,18 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent* origEvent, bool fromPaste)
else if (event->key() == Qt::Key_PageDown) {
textToSend += "\033[6~";
}
else {
else if (event->text().length() > 0) {
textToSend += _codec->fromUnicode(event->text());
}
else if (event->key() <= 0xFFFF) {
QChar c(event->key());

if (c.isLetter()) {
c = ((modifiers & Qt::ShiftModifier) != 0) ? c.toUpper() : c.toLower();
}

textToSend += _codec->fromUnicode(QString(c));
}

if (!fromPaste && textToSend.length()) {
Q_EMIT outputFromKeypressEvent();
Expand Down

0 comments on commit 32da270

Please sign in to comment.