diff --git a/data/keyboard-layouts/default.keytab b/data/keyboard-layouts/default.keytab index 68e90559..68b40394 100644 --- a/data/keyboard-layouts/default.keytab +++ b/data/keyboard-layouts/default.keytab @@ -185,10 +185,12 @@ key Space +Control : "\x00" # The scroll* operations refer to the history buffer. key Up +Shift-AppScreen : scrollLineUp -key PgUp +Shift-AppScreen : scrollPageUp +key PgUp +Shift-Ctrl-AppScreen : scrollPageUp key Home +Shift-AppScreen : scrollUpToTop key Down +Shift-AppScreen : scrollLineDown -key PgDown +Shift-AppScreen : scrollPageDown +key PgDown +Shift-Ctrl-AppScreen : scrollPageDown key End +Shift-AppScreen : scrollDownToBottom +key PgUp +Shift+Ctrl-AppScreen : scrollPromptUp +key PgDown +Shift+Ctrl-AppScreen : scrollDownPrompt diff --git a/data/keyboard-layouts/linux.keytab b/data/keyboard-layouts/linux.keytab index c93c3009..f6cd5ffe 100644 --- a/data/keyboard-layouts/linux.keytab +++ b/data/keyboard-layouts/linux.keytab @@ -117,9 +117,11 @@ key Space +Control : "\x00" # some of keys are used by konsole. key Up +Shift : scrollLineUp -key PgUp +Shift : scrollPageUp +key PgUp +Shift-Ctrl : scrollPageUp key Down +Shift : scrollLineDown -key PgDown +Shift : scrollPageDown +key PgDown +Shift-Ctrl : scrollPageDown +key PgUp +Shift+Ctrl : scrollPromptUp +key PgDown +Shift+Ctrl : scrollPromptDown #---------------------------------------------------------- diff --git a/data/keyboard-layouts/macos.keytab b/data/keyboard-layouts/macos.keytab index dfd42b9d..c37378ae 100644 --- a/data/keyboard-layouts/macos.keytab +++ b/data/keyboard-layouts/macos.keytab @@ -188,10 +188,12 @@ key Space +Control : "\x00" # The scroll* operations refer to the history buffer. key Up +Shift-AppScreen : scrollLineUp -key PgUp +Shift-AppScreen : scrollPageUp +key PgUp +Shift-Ctrl-AppScreen : scrollPageUp key Home +Shift-AppScreen : scrollUpToTop -key Down +Shift-AppScreen : scrollLineDown +key Down +Shift-Ctrl-AppScreen : scrollLineDown key PgDown +Shift-AppScreen : scrollPageDown key End +Shift-AppScreen : scrollDownToBottom +key PgUp +Shift+Ctrl-AppScreen : scrollPromptUp +key Down +Shift+Ctrl-AppScreen : scrollPromptDown diff --git a/data/keyboard-layouts/solaris.keytab b/data/keyboard-layouts/solaris.keytab index fe77e85b..01905d9e 100644 --- a/data/keyboard-layouts/solaris.keytab +++ b/data/keyboard-layouts/solaris.keytab @@ -100,9 +100,11 @@ key Space +Control : "\x00" #key Left +Shift : prevSession #key Right +Shift : nextSession key Up +Shift : scrollLineUp -key PgUp +Shift : scrollPageUp +key PgUp +Shift-Ctrl : scrollPageUp key Down +Shift : scrollLineDown -key PgDown +Shift : scrollPageDown +key PgDown +Shift-Ctrl : scrollPageDown #key Insert+Shift : emitSelection +key PgUp +Shift+Ctrl : scrollPromptUp +key PgDown +Shift+Ctrl : scrollPromptDown # keypad characters are not offered differently by Qt. diff --git a/src/Screen.cpp b/src/Screen.cpp index 99e11e99..1e0f3bde 100644 --- a/src/Screen.cpp +++ b/src/Screen.cpp @@ -1232,8 +1232,6 @@ void Screen::clearImage(int loca, int loce, char c, bool resetLineRendition) const bool isDefaultCh = (clearCh == Screen::DefaultChar); for (int y = topLine; y <= bottomLine; ++y) { - _lineProperties[y] = 0; - const int endCol = (y == bottomLine) ? loce % _columns : _columns - 1; const int startCol = (y == topLine) ? loca % _columns : 0; diff --git a/src/ScreenWindow.cpp b/src/ScreenWindow.cpp index 0321ff06..ca779000 100644 --- a/src/ScreenWindow.cpp +++ b/src/ScreenWindow.cpp @@ -231,12 +231,36 @@ void ScreenWindow::scrollBy(RelativeScrollMode mode, int amount, bool fullPage) { if (mode == ScrollLines) { scrollTo(currentLine() + amount); - } else if (mode == ScrollPages) { + } else if (mode == ScrollPages || (mode == ScrollPrompts && !_screen->hasRepl())) { if (fullPage) { scrollTo(currentLine() + amount * (windowLines())); } else { scrollTo(currentLine() + amount * (windowLines() / 2)); } + } else if (mode == ScrollPrompts) { + int i = currentLine(); + if (amount < 0) { + QVector properties = _screen->getLineProperties(0, currentLine()); + while (i > 0 && amount < 0) { + i--; + if ((properties[i] & LINE_PROMPT_START) != 0) { + if (++amount == 0) { + break; + } + } + } + } else if (amount > 0) { + QVector properties = _screen->getLineProperties(currentLine(), _screen->getHistLines()); + while (i < _screen->getHistLines() && amount > 0) { + i++; + if ((properties[i - currentLine()] & LINE_PROMPT_START) != 0) { + if (--amount == 0) { + break; + } + } + } + } + scrollTo(i); } } diff --git a/src/ScreenWindow.h b/src/ScreenWindow.h index 4da07cd0..78d0ba6d 100644 --- a/src/ScreenWindow.h +++ b/src/ScreenWindow.h @@ -183,6 +183,10 @@ public: * one page is windowLines() lines */ ScrollPages, + /** Scroll by prompt (when using semantic shell integration) + * scrolls up/down until the given number of new prompts appear. + */ + ScrollPrompts, }; /** diff --git a/src/Vt102Emulation.cpp b/src/Vt102Emulation.cpp index b32a8926..1ab19069 100644 --- a/src/Vt102Emulation.cpp +++ b/src/Vt102Emulation.cpp @@ -2157,7 +2157,6 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent *event) // look up key binding if (_keyTranslator != nullptr) { KeyboardTranslator::Entry entry = _keyTranslator->findEntry(event->key(), modifiers, states); - // send result to terminal QByteArray textToSend; @@ -2193,6 +2192,10 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent *event) currentView->scrollScreenWindow(ScreenWindow::ScrollLines, -currentView->screenWindow()->currentLine()); } else if ((entry.command() & KeyboardTranslator::ScrollDownToBottomCommand) != 0) { currentView->scrollScreenWindow(ScreenWindow::ScrollLines, lineCount()); + } else if ((entry.command() & KeyboardTranslator::ScrollPromptUpCommand) != 0) { + currentView->scrollScreenWindow(ScreenWindow::ScrollPrompts, -1); + } else if ((entry.command() & KeyboardTranslator::ScrollPromptDownCommand) != 0) { + currentView->scrollScreenWindow(ScreenWindow::ScrollPrompts, 1); } } } else if (!entry.text().isEmpty()) { diff --git a/src/keyboardtranslator/KeyboardTranslator.cpp b/src/keyboardtranslator/KeyboardTranslator.cpp index e0614b98..9f1ff0fe 100644 --- a/src/keyboardtranslator/KeyboardTranslator.cpp +++ b/src/keyboardtranslator/KeyboardTranslator.cpp @@ -262,6 +262,10 @@ QString KeyboardTranslator::Entry::resultToString(bool expandWildCards, Qt::Keyb return QStringLiteral("ScrollUpToTop"); } else if (_command == ScrollDownToBottomCommand) { return QStringLiteral("ScrollDownToBottom"); + } else if (_command == ScrollPromptUpCommand) { + return QStringLiteral("ScrollPromptUp"); + } else if (_command == ScrollPromptDownCommand) { + return QStringLiteral("ScrollPromptDown"); } return QString(); diff --git a/src/keyboardtranslator/KeyboardTranslator.h b/src/keyboardtranslator/KeyboardTranslator.h index 192eb15d..243f42fa 100644 --- a/src/keyboardtranslator/KeyboardTranslator.h +++ b/src/keyboardtranslator/KeyboardTranslator.h @@ -95,8 +95,12 @@ public: ScrollUpToTopCommand = 32, /** Scroll the terminal display down to the end of history */ ScrollDownToBottomCommand = 64, + /** Scroll the terminal display up to the next prompt */ + ScrollPromptUpCommand = 128, + /** Scroll the terminal display down to the next prompt */ + ScrollPromptDownCommand = 256, /** Echos the operating system specific erase character. */ - EraseCommand = 256, + EraseCommand = 512, }; Q_DECLARE_FLAGS(Commands, Command) diff --git a/src/keyboardtranslator/KeyboardTranslatorReader.cpp b/src/keyboardtranslator/KeyboardTranslatorReader.cpp index 140ff7fb..d542ac6e 100644 --- a/src/keyboardtranslator/KeyboardTranslatorReader.cpp +++ b/src/keyboardtranslator/KeyboardTranslatorReader.cpp @@ -122,6 +122,10 @@ bool KeyboardTranslatorReader::parseAsCommand(const QString &text, KeyboardTrans command = KeyboardTranslator::ScrollUpToTopCommand; } else if (text.compare(QLatin1String("scrolldowntobottom"), Qt::CaseInsensitive) == 0) { command = KeyboardTranslator::ScrollDownToBottomCommand; + } else if (text.compare(QLatin1String("scrollpromptup"), Qt::CaseInsensitive) == 0) { + command = KeyboardTranslator::ScrollPromptUpCommand; + } else if (text.compare(QLatin1String("scrollpromptdown"), Qt::CaseInsensitive) == 0) { + command = KeyboardTranslator::ScrollPromptDownCommand; } else { return false; }