diff --git a/desktop/sessionui.rc b/desktop/sessionui.rc index e9894daac..8d07d999e 100644 --- a/desktop/sessionui.rc +++ b/desktop/sessionui.rc @@ -1,6 +1,6 @@ - + @@ -12,6 +12,8 @@ + + Copy Input To diff --git a/src/ScreenWindow.cpp b/src/ScreenWindow.cpp index 553b4e2b8..495f1e145 100644 --- a/src/ScreenWindow.cpp +++ b/src/ScreenWindow.cpp @@ -146,6 +146,17 @@ void ScreenWindow::setSelectionEnd( int column , int line ) emit selectionChanged(); } +void ScreenWindow::setSelectionByLineRange(int start, int end) +{ + clearSelection(); + + _screen->setSelectionStart( 0 , start , false); + _screen->setSelectionEnd( windowColumns() , end ); + + _bufferNeedsUpdate = true; + emit selectionChanged(); +} + bool ScreenWindow::isSelected( int column , int line ) { return _screen->isSelected( column , qMin(line + currentLine(),endWindowLine()) ); diff --git a/src/ScreenWindow.h b/src/ScreenWindow.h index 51adb4242..d048998a4 100644 --- a/src/ScreenWindow.h +++ b/src/ScreenWindow.h @@ -124,6 +124,18 @@ public: * the window. */ void setSelectionEnd( int column , int line ); + + /** + * Sets the selection as the range specified by line @p start and line @p + * end in the whole history. + * + * Both @p start and @p end are absolute line number in the whole history, + * not relative line number in the window. This make it possible to select + * range larger than the window . A good use case is selecting the whole + * history. + */ + void setSelectionByLineRange(int start, int end); + /** * Retrieves the start of the selection within the window. */ diff --git a/src/SessionController.cpp b/src/SessionController.cpp index b357172ec..19e27506a 100644 --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -297,10 +297,12 @@ void SessionController::setupPrimaryScreenSpecificActions( bool use) KActionCollection * collection = actionCollection() ; QAction * clearAction = collection->action("clear-history"); QAction * resetAction = collection->action("clear-history-and-reset"); + QAction * selectAllAction = collection->action("select-all"); // these actions are meaningful only when primary screen is used. clearAction->setEnabled(use); resetAction->setEnabled(use); + selectAllAction->setEnabled(use); } void SessionController::updateCopyAction( const QString & text ) @@ -443,6 +445,10 @@ void SessionController::setupActions() pasteShortcut.setAlternate(QKeySequence(Qt::SHIFT + Qt::Key_Insert)); action->setShortcut(pasteShortcut); + action = collection->addAction("select-all", this, SLOT(selectAll())); + action->setText(i18n("&Select All")); + action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S)); + action = collection->addAction("paste-selection", this, SLOT(pasteSelection())); action->setText(i18n("Paste Selection")); action->setShortcut(QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_Insert)); @@ -674,6 +680,11 @@ void SessionController::pasteSelection() { _view->pasteSelection(); } +void SessionController::selectAll() +{ + ScreenWindow * screenWindow = _view->screenWindow(); + screenWindow->setSelectionByLineRange(0, _session->emulation()->lineCount() ); +} static const KXmlGuiWindow* findWindow(const QObject* object) { // Walk up the QObject hierarchy to find a KXmlGuiWindow. diff --git a/src/SessionController.h b/src/SessionController.h index 0de39d40e..796b57943 100644 --- a/src/SessionController.h +++ b/src/SessionController.h @@ -176,6 +176,7 @@ private slots: void openBrowser(); void copy(); void paste(); + void selectAll(); void pasteSelection(); // shortcut only void copyInputToAllTabs(); void copyInputToSelectedTabs(); @@ -230,6 +231,7 @@ private slots: /* Returns true if called within a KPart; false if called within Konsole. */ bool isKonsolePart() const; + private: // begins the search // text - pattern to search for