Handle keyboard commands properly

It was hard-coded in TerminalDisplay.cpp - Shift+Up always results in
ScrollLineUpCommand regardless of settings in *.keytab. Now those
commands are correctly parsed by KeyboardTranslator.

Fixes lxde/qterminal#348

This fix is similar to KDE/konsole@b88dfb402a
while I use signals and slots instead of introducing new pointers. That
sounds more reliable :)
This commit is contained in:
Yen Chi Hsuan
2017-08-29 23:34:12 +08:00
committed by Chih-Hsuan Yen
parent 2df79b77bf
commit c797ccf97d
7 changed files with 65 additions and 46 deletions
+47
View File
@@ -292,4 +292,51 @@ void ScreenWindow::notifyOutputChanged()
emit outputChanged();
}
void ScreenWindow::handleCommandFromKeyboard(KeyboardTranslator::Command command)
{
// Keyboard-based navigation
bool update = false;
// EraseCommand is handled in Vt102Emulation
if ( command & KeyboardTranslator::ScrollPageUpCommand )
{
scrollBy( ScreenWindow::ScrollPages , -1 );
update = true;
}
if ( command & KeyboardTranslator::ScrollPageDownCommand )
{
scrollBy( ScreenWindow::ScrollPages , 1 );
update = true;
}
if ( command & KeyboardTranslator::ScrollLineUpCommand )
{
scrollBy( ScreenWindow::ScrollLines , -1 );
update = true;
}
if ( command & KeyboardTranslator::ScrollLineDownCommand )
{
scrollBy( ScreenWindow::ScrollLines , 1 );
update = true;
}
if ( command & KeyboardTranslator::ScrollDownToBottomCommand )
{
Q_EMIT scrollToEnd();
update = true;
}
if ( command & KeyboardTranslator::ScrollUpToTopCommand)
{
scrollTo(0);
update = true;
}
// TODO: KeyboardTranslator::ScrollLockCommand
// TODO: KeyboardTranslator::SendCommand
if ( update )
{
setTrackOutput( atEndOfOutput() );
Q_EMIT outputChanged();
}
}
//#include "ScreenWindow.moc"