From 0f84f38c0aa3c7bc9929fedf8b5aedcc937995dc Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Wed, 12 Feb 2014 14:22:35 -0500 Subject: [PATCH] All 'select line' for use with shortcut Select entire line from a shortcut. Patch by Christian Couder chriscool@tuxfamily.org BUG: 327395 FIXED-IN: 2.13 (cherry picked from commit 7cf548bea8a7c3c5da4a0dd00c3a7e677f0481c8) --- src/SessionController.cpp | 9 +++++++++ src/SessionController.h | 1 + src/TerminalDisplay.cpp | 7 +++++++ src/TerminalDisplay.h | 3 +++ 4 files changed, 20 insertions(+) diff --git a/src/SessionController.cpp b/src/SessionController.cpp index 0410ae4e2..5621eab31 100644 --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -368,11 +368,13 @@ void SessionController::setupPrimaryScreenSpecificActions(bool use) QAction* clearAction = collection->action("clear-history"); QAction* resetAction = collection->action("clear-history-and-reset"); QAction* selectAllAction = collection->action("select-all"); + QAction* selectLineAction = collection->action("select-line"); // these actions are meaningful only when primary screen is used. clearAction->setEnabled(use); resetAction->setEnabled(use); selectAllAction->setEnabled(use); + selectLineAction->setEnabled(use); } void SessionController::selectionChanged(const QString& selectedText) @@ -601,6 +603,9 @@ void SessionController::setupCommonActions() action->setText(i18n("&Select All")); action->setIcon(KIcon("edit-select-all")); + action = collection->addAction("select-line", this, SLOT(selectLine())); + action->setText(i18n("Select &Line")); + action = KStandardAction::saveAs(this, SLOT(saveHistory()), collection); action->setText(i18n("Save Output &As...")); @@ -954,6 +959,10 @@ void SessionController::selectAll() screenWindow->setSelectionByLineRange(0, _session->emulation()->lineCount()); _view->copyToX11Selection(); } +void SessionController::selectLine() +{ + _view->selectCurrentLine(); +} 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 a6de868a5..847c2a491 100644 --- a/src/SessionController.h +++ b/src/SessionController.h @@ -225,6 +225,7 @@ private slots: void copy(); void paste(); void selectAll(); + void selectLine(); void pasteFromX11Selection(); // shortcut only void copyInputActionsTriggered(QAction* action); void copyInputToAllTabs(); diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index 72888c53c..ddf816aa7 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -2647,6 +2647,13 @@ void TerminalDisplay::selectLine(QPoint pos, bool entireLine) _iPntSel.ry() += _scrollBar->value(); } +void TerminalDisplay::selectCurrentLine() +{ + if (!_screenWindow) return; + + selectLine(cursorPosition(), true); +} + bool TerminalDisplay::focusNextPrevChild(bool next) { // for 'Tab', always disable focus switching among widgets diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h index e6dc09961..95fc0a051 100644 --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -450,6 +450,9 @@ public: /** Returns the terminal screen section which is displayed in this widget. See setScreenWindow() */ ScreenWindow* screenWindow() const; + // Select the current line. + void selectCurrentLine(); + void printContent(QPainter& painter, bool friendly); public slots: