From c3a97a14382fa5b11ea0db866ae1d69c19bcd263 Mon Sep 17 00:00:00 2001 From: xiaoming <2014500726@smail.xtu.edu.cn> Date: Tue, 24 Oct 2023 02:03:02 +0800 Subject: [PATCH] src:add Key_Home and Key_End Signed-off-by: xiaoming <2014500726@smail.xtu.edu.cn> --- lib/qtermwidget/Vt102Emulation.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/qtermwidget/Vt102Emulation.cpp b/lib/qtermwidget/Vt102Emulation.cpp index 1dbded0c..cf11261b 100644 --- a/lib/qtermwidget/Vt102Emulation.cpp +++ b/lib/qtermwidget/Vt102Emulation.cpp @@ -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) {