diff --git a/qmltermwidget/lib/Screen.cpp b/qmltermwidget/lib/Screen.cpp index ea635e5..5fc700d 100644 --- a/qmltermwidget/lib/Screen.cpp +++ b/qmltermwidget/lib/Screen.cpp @@ -1110,6 +1110,14 @@ void Screen::setSelectionEnd( const int x, const int y) } } +void Screen::selectAll() +{ + selBegin = 0; + selTopLeft = 0; + int endPos = (getHistLines() + getCursorY() + 1) * columns - 1; + selBottomRight = endPos; +} + bool Screen::isSelected( const int x,const int y) const { bool columnInSelection = true; diff --git a/qmltermwidget/lib/Screen.h b/qmltermwidget/lib/Screen.h index c4baf0e..0ca56ae 100644 --- a/qmltermwidget/lib/Screen.h +++ b/qmltermwidget/lib/Screen.h @@ -423,6 +423,8 @@ public: */ void setSelectionEnd(const int column, const int line); + void selectAll(); + /** * Retrieves the start of the selection or the cursor position if there * is no selection. diff --git a/qmltermwidget/lib/ScreenWindow.cpp b/qmltermwidget/lib/ScreenWindow.cpp index 640465f..96b9a3f 100644 --- a/qmltermwidget/lib/ScreenWindow.cpp +++ b/qmltermwidget/lib/ScreenWindow.cpp @@ -262,6 +262,14 @@ QRect ScreenWindow::scrollRegion() const return QRect(0,0,windowColumns(),windowLines()); } +void ScreenWindow::selectAll() +{ + _screen->selectAll(); + + _bufferNeedsUpdate = true; + emit selectionChanged(); +} + void ScreenWindow::notifyOutputChanged() { // move window to the bottom of the screen and update scroll count diff --git a/qmltermwidget/lib/ScreenWindow.h b/qmltermwidget/lib/ScreenWindow.h index 87d0840..475796f 100644 --- a/qmltermwidget/lib/ScreenWindow.h +++ b/qmltermwidget/lib/ScreenWindow.h @@ -114,6 +114,8 @@ public: */ QRect scrollRegion() const; + void selectAll(); + /** * Sets the start of the selection to the given @p line and @p column within * the window. diff --git a/qmltermwidget/lib/TerminalDisplay.cpp b/qmltermwidget/lib/TerminalDisplay.cpp index e5afa67..a18a290 100644 --- a/qmltermwidget/lib/TerminalDisplay.cpp +++ b/qmltermwidget/lib/TerminalDisplay.cpp @@ -2616,6 +2616,15 @@ bool TerminalDisplay::selectedText() return !m_screenWindow->selectedText(false).isEmpty(); } +void TerminalDisplay::selectAll() +{ + if (!m_screenWindow) + return; + + m_screenWindow->selectAll(); + setSelection(m_screenWindow->selectedText(_preserveLineBreaks)); +} + void TerminalDisplay::copyClipboard() { if ( !m_screenWindow ) diff --git a/qmltermwidget/lib/TerminalDisplay.h b/qmltermwidget/lib/TerminalDisplay.h index be8c040..013e874 100644 --- a/qmltermwidget/lib/TerminalDisplay.h +++ b/qmltermwidget/lib/TerminalDisplay.h @@ -355,6 +355,8 @@ public: void setSelection(const QString &t); bool selectedText(); + Q_INVOKABLE void selectAll(); + /** * Reimplemented. Has no effect. Use setVTFont() to change the font * used to draw characters in the display. diff --git a/src/qml/Terminal.qml b/src/qml/Terminal.qml index 2f5635e..f3264e6 100644 --- a/src/qml/Terminal.qml +++ b/src/qml/Terminal.qml @@ -51,6 +51,13 @@ Page { } onKeyPressed: { + if ((event.key === Qt.Key_A) + && (event.modifiers & Qt.ControlModifier) + && (event.modifiers & Qt.ShiftModifier)) { + _terminal.selectAll() + event.accepted = true + } + if ((event.key === Qt.Key_C) && (event.modifiers & Qt.ControlModifier) && (event.modifiers & Qt.ShiftModifier)) { @@ -185,6 +192,12 @@ Page { action: _pasteAction } + MenuItem { + id: selectAllItem + text: qsTr("Select All") + onTriggered: _terminal.selectAll() + } + MenuItem { text: qsTr("Open File Manager") onTriggered: Process.openFileManager(_session.currentDir)