Skip to content

Commit

Permalink
src:add Key_Home and Key_End
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoming <2014500726@smail.xtu.edu.cn>
  • Loading branch information
QQxiaoming committed Oct 23, 2023
1 parent 7cd555c commit c3a97a1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/qtermwidget/Vt102Emulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,30 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent* event, bool fromPaste)
textToSend.prepend("\030@s");
}

#if defined(Q_OS_MACOS)
if ((modifiers & Qt::AltModifier) && (event->key() == Qt::Key_Left)) {
for(int i = 0; i < _currentScreen->getCursorX(); ++i) {
textToSend += "\033[D";
}
}
else if ((modifiers & Qt::AltModifier) && (event->key() == Qt::Key_Right)) {
for(int i = 0; i < _currentScreen->getColumns() - _currentScreen->getCursorX() - 1; ++i) {
textToSend += "\033[C";
}
} else
#else
if (event->key() == Qt::Key_Home) {
for(int i = 0; i < _currentScreen->getCursorX(); ++i) {
textToSend += "\033[D";
}
}
else if (event->key() == Qt::Key_End) {
for(int i = 0; i < _currentScreen->getColumns() - _currentScreen->getCursorX() - 1; ++i) {
textToSend += "\033[C";
}
} else
#endif

if ( entry.command() != KeyboardTranslator::NoCommand )
{
if (entry.command() & KeyboardTranslator::EraseCommand) {
Expand Down

0 comments on commit c3a97a1

Please sign in to comment.