diff --git a/src/Screen.h b/src/Screen.h index 9f5e6b2a..ba991452 100644 --- a/src/Screen.h +++ b/src/Screen.h @@ -44,6 +44,7 @@ namespace Konsole { class TerminalCharacterDecoder; +class TerminalDisplay; /** \brief An image of characters with associated attributes. @@ -545,6 +546,16 @@ public: */ static void fillWithDefaultChar(Character* dest, int count); + void setCurrentTerminalDisplay(TerminalDisplay *terminal_display) + { + _currentTerminalDisplay = terminal_display; + } + + TerminalDisplay *currentTerminalDisplay() + { + return _currentTerminalDisplay; + } + private: //copies a line of text from the screen or history into a stream using a @@ -581,6 +592,9 @@ private: // scroll down 'i' lines in current region, clearing the top 'i' lines void scrollDown(int from, int i); + //when we handle scroll commands, we need to know which screenwindow will scroll + TerminalDisplay *_currentTerminalDisplay; + void addHistLine(); void initTabStops(); diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index 1e226ef4..eb909aa5 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "ScreenWindow.h" // Own #include "TerminalDisplay.h" @@ -57,8 +58,9 @@ //#include #include "Filter.h" #include "konsole_wcwidth.h" -#include "ScreenWindow.h" #include "TerminalCharacterDecoder.h" +#include "Screen.h" +#include "ScreenWindow.h" using namespace Konsole; @@ -2480,46 +2482,20 @@ void TerminalDisplay::setFlowControlWarningEnabled( bool enable ) outputSuspended(false); } +void TerminalDisplay::scrollScreenWindow( enum ScreenWindow::RelativeScrollMode mode, int amount ) +{ + _screenWindow->scrollBy( mode, amount); + _screenWindow->setTrackOutput( _screenWindow->atEndOfOutput() ); + + updateLineProperties(); + updateImage(); +} + void TerminalDisplay::keyPressEvent( QKeyEvent* event ) { bool emitKeyPressSignal = true; - // Keyboard-based navigation - if ( event->modifiers() == Qt::ShiftModifier ) - { - bool update = true; - - if ( event->key() == Qt::Key_PageUp ) - { - _screenWindow->scrollBy( ScreenWindow::ScrollPages , -1 ); - } - else if ( event->key() == Qt::Key_PageDown ) - { - _screenWindow->scrollBy( ScreenWindow::ScrollPages , 1 ); - } - else if ( event->key() == Qt::Key_Up ) - { - _screenWindow->scrollBy( ScreenWindow::ScrollLines , -1 ); - } - else if ( event->key() == Qt::Key_Down ) - { - _screenWindow->scrollBy( ScreenWindow::ScrollLines , 1 ); - } - else - update = false; - - if ( update ) - { - _screenWindow->setTrackOutput( _screenWindow->atEndOfOutput() ); - - updateLineProperties(); - updateImage(); - - // do not send key press to terminal - emitKeyPressSignal = false; - } - } - + _screenWindow->screen()->setCurrentTerminalDisplay(this); _actSel=0; // Key stroke implies a screen update, so TerminalDisplay won't // know where the current selection is. diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h index 0b611709..38e3e94b 100644 --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -30,6 +30,7 @@ #include "Filter.h" #include "Character.h" #include "konsole_export.h" +#include "ScreenWindow.h" class QDrag; class QDragEnterEvent; @@ -52,7 +53,6 @@ namespace Konsole extern unsigned short vt100_graphics[32]; -class ScreenWindow; /** * A widget which displays output from a terminal emulation and sends input keypresses and mouse activity @@ -410,6 +410,12 @@ public: static bool HAVE_TRANSPARENCY; public slots: + /** + * Scrolls current ScreenWindow + * + * it's needed for proper handling scroll commands in the Vt102Emulation class + */ + void scrollScreenWindow( enum ScreenWindow::RelativeScrollMode mode , int amount ); /** * Causes the terminal display to fetch the latest character image from the associated diff --git a/src/Vt102Emulation.cpp b/src/Vt102Emulation.cpp index caaa6e6e..66ee684e 100644 --- a/src/Vt102Emulation.cpp +++ b/src/Vt102Emulation.cpp @@ -54,6 +54,7 @@ // Konsole #include "KeyboardTranslator.h" #include "Screen.h" +#include "TerminalDisplay.h" using namespace Konsole; @@ -943,10 +944,18 @@ void Vt102Emulation::sendKeyEvent( QKeyEvent* event ) if ( entry.command() != KeyboardTranslator::NoCommand ) { - if (entry.command() & KeyboardTranslator::EraseCommand) + bool update = true; + if (entry.command() & KeyboardTranslator::EraseCommand) { textToSend += eraseChar(); - - // TODO command handling + update = false; + } else if ( entry.command() & KeyboardTranslator::ScrollPageUpCommand ) + _currentScreen->currentTerminalDisplay()->scrollScreenWindow( ScreenWindow::ScrollPages , -1 ); + else if ( entry.command() & KeyboardTranslator::ScrollPageDownCommand ) + _currentScreen->currentTerminalDisplay()->scrollScreenWindow( ScreenWindow::ScrollPages , 1 ); + else if ( entry.command() & KeyboardTranslator::ScrollLineUpCommand ) + _currentScreen->currentTerminalDisplay()->scrollScreenWindow( ScreenWindow::ScrollLines , -1 ); + else if ( entry.command() & KeyboardTranslator::ScrollLineDownCommand ) + _currentScreen->currentTerminalDisplay()->scrollScreenWindow( ScreenWindow::ScrollLines , 1 ); } else if ( !entry.text().isEmpty() ) {