summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJekyll Wu <adaptee@gmail.com>2012-04-25 04:08:40 (GMT)
committerJekyll Wu <adaptee@gmail.com>2012-04-25 04:55:38 (GMT)
commitbb818010b42a3d6fcdc4a057f0afd2e7b7a85b9f (patch)
treee2c7a63c04453330a0f91d511f74e39eb39aedad
parent11814cbf942070f19c5547e00852bddb310276b7 (diff)
Add two profile options for the copy & paste behavior of mouse
* support "automatially copy selected text into clipboard" * mouse middle button can be customized to paste from selectio or clipboard The first feature might look like a unnecessary duplicate of the "synchronize selection and clipboard" feature of Klipper. However, that klipper feature is generally problematic, while doing it only in Konsole is generally useful and harmless. FEATURE: 183490 FIXED-IN: 4.9.0 REVIEW: 103861 DIGEST:
-rw-r--r--src/EditProfileDialog.cpp63
-rw-r--r--src/EditProfileDialog.h13
-rw-r--r--src/EditProfileDialog.ui244
-rw-r--r--src/Enumeration.h8
-rw-r--r--src/Profile.cpp8
-rw-r--r--src/Profile.h16
-rw-r--r--src/SessionController.cpp8
-rw-r--r--src/SessionController.h2
-rw-r--r--src/TerminalDisplay.cpp74
-rw-r--r--src/TerminalDisplay.h23
-rw-r--r--src/ViewManager.cpp7
11 files changed, 333 insertions, 133 deletions
diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp
index 1c0a462..21aa097 100644
--- a/src/EditProfileDialog.cpp
+++ b/src/EditProfileDialog.cpp
@@ -213,6 +213,8 @@ void EditProfileDialog::preparePage(int page)
setupScrollingPage(profile);
else if (pageWidget == _ui->keyboardTab)
setupKeyboardPage(profile);
+ else if (pageWidget == _ui->mouseTab)
+ setupMousePage(profile);
else if (pageWidget == _ui->advancedTab)
setupAdvancedPage(profile);
else
@@ -978,32 +980,29 @@ void EditProfileDialog::showScrollBarRight()
{
updateTempProfileProperty(Profile::ScrollBarPosition, Enum::ScrollBarRight);
}
-void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
+void EditProfileDialog::setupMousePage(const Profile::Ptr profile)
{
BooleanOption options[] = { {
- _ui->enableBlinkingTextButton , Profile::BlinkingTextEnabled ,
- SLOT(toggleBlinkingText(bool))
- },
- {
- _ui->enableFlowControlButton , Profile::FlowControlEnabled ,
- SLOT(toggleFlowControl(bool))
- },
- {
- _ui->enableBlinkingCursorButton , Profile::BlinkingCursorEnabled ,
- SLOT(toggleBlinkingCursor(bool))
- },
- {
_ui->underlineLinksButton , Profile::UnderlineLinksEnabled,
SLOT(toggleUnderlineLinks(bool))
},
{
- _ui->enableBidiRenderingButton , Profile::BidiRenderingEnabled ,
- SLOT(togglebidiRendering(bool))
+ _ui->copyTextToClipboardButton , Profile::AutoCopySelectedText,
+ SLOT(toggleCopyTextToClipboard(bool))
},
{ 0 , Profile::Property(0) , 0 }
};
setupCheckBoxes(options , profile);
+ // setup middle click paste mode
+ const int middleClickPasteMode = profile->property<int>(Profile::MiddleClickPasteMode);
+ RadioOption pasteModes[] = {
+ {_ui->pasteFromX11SelectionButton, Enum::PasteFromX11Selection, SLOT(pasteFromX11Selection())},
+ {_ui->pasteFromClipboardButton, Enum::PasteFromClipboard, SLOT(pasteFromClipboard())},
+ {0, 0, 0}
+ };
+ setupRadio(pasteModes , middleClickPasteMode);
+
// interaction options
_ui->wordCharacterEdit->setText(profile->wordCharacters());
@@ -1015,6 +1014,28 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
connect(_ui->tripleClickModeCombo, SIGNAL(activated(int)), this,
SLOT(TripleClickModeChanged(int)));
+}
+void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
+{
+ BooleanOption options[] = { {
+ _ui->enableBlinkingTextButton , Profile::BlinkingTextEnabled ,
+ SLOT(toggleBlinkingText(bool))
+ },
+ {
+ _ui->enableFlowControlButton , Profile::FlowControlEnabled ,
+ SLOT(toggleFlowControl(bool))
+ },
+ {
+ _ui->enableBlinkingCursorButton , Profile::BlinkingCursorEnabled ,
+ SLOT(toggleBlinkingCursor(bool))
+ },
+ {
+ _ui->enableBidiRenderingButton , Profile::BidiRenderingEnabled ,
+ SLOT(togglebidiRendering(bool))
+ },
+ { 0 , Profile::Property(0) , 0 }
+ };
+ setupCheckBoxes(options , profile);
// cursor options
if (profile->useCustomCursorColor())
@@ -1084,6 +1105,18 @@ void EditProfileDialog::toggleUnderlineLinks(bool enable)
{
updateTempProfileProperty(Profile::UnderlineLinksEnabled, enable);
}
+void EditProfileDialog::toggleCopyTextToClipboard(bool enable)
+{
+ updateTempProfileProperty(Profile::AutoCopySelectedText, enable);
+}
+void EditProfileDialog::pasteFromX11Selection()
+{
+ updateTempProfileProperty(Profile::MiddleClickPasteMode, Enum::PasteFromX11Selection);
+}
+void EditProfileDialog::pasteFromClipboard()
+{
+ updateTempProfileProperty(Profile::MiddleClickPasteMode, Enum::PasteFromClipboard);
+}
void EditProfileDialog::TripleClickModeChanged(int newValue)
{
updateTempProfileProperty(Profile::TripleClickMode, newValue);
diff --git a/src/EditProfileDialog.h b/src/EditProfileDialog.h
index c330fc6..682db91 100644
--- a/src/EditProfileDialog.h
+++ b/src/EditProfileDialog.h
@@ -149,19 +149,25 @@ private slots:
void keyBindingSelected();
void removeKeyBinding();
+ // mouse page
+ void toggleUnderlineLinks(bool);
+ void toggleCopyTextToClipboard(bool);
+ void pasteFromX11Selection();
+ void pasteFromClipboard();
+
+ void TripleClickModeChanged(int);
+ void wordCharactersChanged(const QString&);
+
// advanced page
void toggleBlinkingText(bool);
void toggleFlowControl(bool);
void togglebidiRendering(bool);
void toggleBlinkingCursor(bool);
- void TripleClickModeChanged(int);
- void toggleUnderlineLinks(bool);
void setCursorShape(int);
void autoCursorColor();
void customCursorColor();
void customCursorColorChanged(const QColor&);
- void wordCharactersChanged(const QString&);
void setDefaultCodec(QTextCodec*);
// apply the first previewed changes stored up by delayedPreview()
@@ -175,6 +181,7 @@ private:
void setupKeyboardPage(const Profile::Ptr profile);
void setupScrollingPage(const Profile::Ptr profile);
void setupAdvancedPage(const Profile::Ptr profile);
+ void setupMousePage(const Profile::Ptr info);
void updateColorSchemeList(bool selectCurrentScheme = false);
void updateColorSchemeButtons();
diff --git a/src/EditProfileDialog.ui b/src/EditProfileDialog.ui
index 707c20a..29c0828 100644
--- a/src/EditProfileDialog.ui
+++ b/src/EditProfileDialog.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>441</width>
+ <width>594</width>
<height>551</height>
</rect>
</property>
@@ -267,7 +267,7 @@
</property>
<layout class="QGridLayout">
<item row="0" column="0">
- <widget class="Konsole::RenameTabWidget" name="renameTabWidget"/>
+ <widget class="Konsole::RenameTabWidget" name="renameTabWidget" native="true"/>
</item>
</layout>
</widget>
@@ -532,8 +532,7 @@
</property>
<layout class="QVBoxLayout">
<item>
- <widget class="Konsole::HistorySizeWidget" name="historySizeWidget">
- </widget>
+ <widget class="Konsole::HistorySizeWidget" name="historySizeWidget" native="true"/>
</item>
</layout>
</widget>
@@ -615,7 +614,7 @@
</widget>
<widget class="QWidget" name="keyboardTab">
<attribute name="title">
- <string>Input</string>
+ <string>Keyboard</string>
</attribute>
<layout class="QVBoxLayout">
<item>
@@ -695,82 +694,22 @@
</item>
</layout>
</widget>
- <widget class="QWidget" name="advancedTab">
+ <widget class="QWidget" name="mouseTab">
<attribute name="title">
- <string comment="@title:tab Complex options">Advanced</string>
+ <string>Mouse</string>
</attribute>
- <layout class="QVBoxLayout">
- <item>
- <widget class="QGroupBox" name="groupBox_4">
- <property name="title">
- <string>Terminal Features</string>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout">
- <item>
- <widget class="QCheckBox" name="enableBlinkingTextButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Allow terminal programs to create blinking sections of text</string>
- </property>
- <property name="text">
- <string>Allow blinking text</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="enableFlowControlButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Allow the output to be suspended by pressing Ctrl+S</string>
- </property>
- <property name="text">
- <string>Enable flow control using Ctrl+S, Ctrl+Q</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="enableBidiRenderingButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Enable Bi-Directional display on terminals (valid for Arabic, Farsi or Hebrew only)</string>
- </property>
- <property name="text">
- <string>Enable Bi-Directional text rendering</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
+ <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
- <string>Mouse Interaction</string>
+ <string>Select Text</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
- <layout class="QVBoxLayout">
+ <layout class="QVBoxLayout" name="_2">
<item>
- <layout class="QHBoxLayout">
+ <layout class="QHBoxLayout" name="_3">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
@@ -794,7 +733,7 @@
</layout>
</item>
<item>
- <layout class="QHBoxLayout">
+ <layout class="QHBoxLayout" name="_4">
<item>
<widget class="QLabel" name="label_17">
<property name="text">
@@ -819,21 +758,76 @@
</item>
</widget>
</item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_14">
+ <property name="title">
+ <string>Copy &amp;&amp; Paste</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QCheckBox" name="copyTextToClipboardButton">
+ <property name="toolTip">
+ <string>Automatically copy selected text into clipboard</string>
+ </property>
+ <property name="text">
+ <string>Copy on select</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>561</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_13">
+ <property name="text">
+ <string>Mouse middle button:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="pasteFromX11SelectionButton">
+ <property name="text">
+ <string>Paste from selection</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="pasteFromClipboardButton">
+ <property name="text">
+ <string>Paste from clipboard</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Miscellaneous</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="underlineLinksButton">
<property name="toolTip">
@@ -848,6 +842,86 @@
</widget>
</item>
<item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>328</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="advancedTab">
+ <attribute name="title">
+ <string comment="@title:tab Complex options">Advanced</string>
+ </attribute>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox_4">
+ <property name="title">
+ <string>Terminal Features</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QCheckBox" name="enableBlinkingTextButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Allow terminal programs to create blinking sections of text</string>
+ </property>
+ <property name="text">
+ <string>Allow blinking text</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="enableFlowControlButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Allow the output to be suspended by pressing Ctrl+S</string>
+ </property>
+ <property name="text">
+ <string>Enable flow control using Ctrl+S, Ctrl+Q</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="enableBidiRenderingButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Enable Bi-Directional display on terminals (valid for Arabic, Farsi or Hebrew only)</string>
+ </property>
+ <property name="text">
+ <string>Enable Bi-Directional text rendering</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>Cursor</string>
diff --git a/src/Enumeration.h b/src/Enumeration.h
index 8fe2277..99919f1 100644
--- a/src/Enumeration.h
+++ b/src/Enumeration.h
@@ -88,6 +88,14 @@ public:
SelectForwardsFromCursor = 1
};
+ /** This enum describes the source from which mouse middle click pastes data . */
+ enum MiddleClickPasteModeEnum {
+ /** Paste from X11 Selection. */
+ PasteFromX11Selection = 0,
+ /** Paste from Clipboard. */
+ PasteFromClipboard = 1
+ };
+
/**
* This enum describes the different types of sounds and visual effects which
* can be used to alert the user when a 'bell' occurs in the terminal
diff --git a/src/Profile.cpp b/src/Profile.cpp
index 198640e..dfea342 100644
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -102,6 +102,10 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
, { WordCharacters , "WordCharacters" , INTERACTION_GROUP , QVariant::String }
, { TripleClickMode , "TripleClickMode" , INTERACTION_GROUP , QVariant::Int }
, { UnderlineLinksEnabled , "UnderlineLinksEnabled" , INTERACTION_GROUP , QVariant::Bool }
+ , { AutoCopySelectedText , "AutoCopySelectedText" , INTERACTION_GROUP , QVariant::Bool }
+ , { PasteFromSelectionEnabled , "PasteFromSelectionEnabled" , INTERACTION_GROUP , QVariant::Bool }
+ , { PasteFromClipboardEnabled , "PasteFromClipboardEnabled" , INTERACTION_GROUP , QVariant::Bool }
+ , { MiddleClickPasteMode, "MiddleClickPasteMode" , INTERACTION_GROUP , QVariant::Int }
// Encoding
, { DefaultEncoding , "DefaultEncoding" , ENCODING_GROUP , QVariant::String }
@@ -161,6 +165,10 @@ FallbackProfile::FallbackProfile()
setProperty(FlowControlEnabled, true);
setProperty(BlinkingTextEnabled, true);
setProperty(UnderlineLinksEnabled, true);
+ setProperty(AutoCopySelectedText, false);
+ setProperty(PasteFromSelectionEnabled, true);
+ setProperty(PasteFromClipboardEnabled, false);
+ setProperty(MiddleClickPasteMode, Enum::PasteFromX11Selection);
setProperty(TripleClickMode, Enum::SelectWholeLine);
setProperty(BlinkingCursorEnabled, false);
diff --git a/src/Profile.h b/src/Profile.h
index 78e95cf..acc3446 100644
--- a/src/Profile.h
+++ b/src/Profile.h
@@ -196,6 +196,18 @@ public:
* underlined when hovered by the mouse pointer.
*/
UnderlineLinksEnabled,
+ /** (bool) If true, automatically copy selected text into the clipboard */
+ AutoCopySelectedText,
+ /** (bool) If true, middle mouse button pastes from X Selection */
+ PasteFromSelectionEnabled,
+ /** (bool) If true, middle mouse button pastes from Clipboard */
+ PasteFromClipboardEnabled,
+ /** (MiddleClickPasteModeEnum) Specifies the source from which mouse
+ * middle click pastes data.
+ *
+ * See Enum::MiddleClickPasteModeEnum
+ */
+ MiddleClickPasteMode,
/** (String) Default text codec */
DefaultEncoding,
/** (bool) Whether fonts should be aliased or not */
@@ -421,6 +433,10 @@ public:
return property<bool>(Profile::UnderlineLinksEnabled);
}
+ bool autoCopySelectedText() const {
+ return property<bool>(Profile::AutoCopySelectedText);
+ }
+
/** Convenience method for property<QString>(Profile::DefaultEncoding) */
QString defaultEncoding() const {
return property<QString>(Profile::DefaultEncoding);
diff --git a/src/SessionController.cpp b/src/SessionController.cpp
index 0404f1f..0c91295 100644
--- a/src/SessionController.cpp
+++ b/src/SessionController.cpp
@@ -543,7 +543,7 @@ void SessionController::setupCommonActions()
pasteShortcut.setAlternate(QKeySequence(Qt::SHIFT + Qt::Key_Insert));
action->setShortcut(pasteShortcut);
- action = collection->addAction("paste-selection", this, SLOT(pasteFromXSelection()));
+ action = collection->addAction("paste-selection", this, SLOT(pasteFromX11Selection()));
action->setText(i18n("Paste Selection"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Insert));
@@ -833,15 +833,15 @@ void SessionController::paste()
{
_view->pasteFromClipboard();
}
-void SessionController::pasteFromXSelection()
+void SessionController::pasteFromX11Selection()
{
- _view->pasteFromXSelection();
+ _view->pasteFromX11Selection();
}
void SessionController::selectAll()
{
ScreenWindow * screenWindow = _view->screenWindow();
screenWindow->setSelectionByLineRange(0, _session->emulation()->lineCount());
- TerminalDisplay::setXSelection(screenWindow->selectedText(true));
+ _view->copyToX11Selection();
}
static const KXmlGuiWindow* findWindow(const QObject* object)
{
diff --git a/src/SessionController.h b/src/SessionController.h
index 85dbdbb..cd5a9ff 100644
--- a/src/SessionController.h
+++ b/src/SessionController.h
@@ -218,7 +218,7 @@ private slots:
void copy();
void paste();
void selectAll();
- void pasteFromXSelection(); // shortcut only
+ void pasteFromX11Selection(); // shortcut only
void copyInputActionsTriggered(QAction* action);
void copyInputToAllTabs();
void copyInputToSelectedTabs();
diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index 195942b..32e09d9 100644
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -63,6 +63,8 @@
#include "WindowSystemInfo.h"
#include "ExtendedCharTable.h"
#include "TerminalDisplayAccessible.h"
+#include "SessionManager.h"
+#include "Session.h"
using namespace Konsole;
@@ -304,6 +306,8 @@ TerminalDisplay::TerminalDisplay(QWidget* parent)
, _lineSelectionMode(false)
, _preserveLineBreaks(false)
, _columnSelectionMode(false)
+ , _autoCopySelectedText(false)
+ , _middleClickPasteMode(Enum::PasteFromX11Selection)
, _scrollbarLocation(Enum::ScrollBarRight)
, _wordCharacters(":@-./_~")
, _bellMode(Enum::NotifyBell)
@@ -1793,10 +1797,21 @@ void TerminalDisplay::mousePressEvent(QMouseEvent* ev)
}
}
} else if (ev->button() == Qt::MidButton) {
- if (_mouseMarks || (ev->modifiers() & Qt::ShiftModifier))
- doPaste(true, ev->modifiers() & Qt::ControlModifier);
- else
+ if (_mouseMarks || (ev->modifiers() & Qt::ShiftModifier)) {
+
+ const bool appendEnter = ev->modifiers() & Qt::ControlModifier;
+
+ if ( _middleClickPasteMode == Enum::PasteFromX11Selection ) {
+ pasteFromX11Selection(appendEnter);
+ } else if ( _middleClickPasteMode == Enum::PasteFromClipboard ) {
+ pasteFromClipboard(appendEnter);
+ } else {
+ Q_ASSERT(false);
+ }
+
+ } else {
emit mouseSignal(1, charColumn + 1, charLine + 1 + _scrollBar->value() - _scrollBar->maximum() , 0);
+ }
} else if (ev->button() == Qt::RightButton) {
if (_mouseMarks || (ev->modifiers() & Qt::ShiftModifier))
emit configureRequest(ev->pos());
@@ -2134,7 +2149,7 @@ void TerminalDisplay::mouseReleaseEvent(QMouseEvent* ev)
_screenWindow->clearSelection();
} else {
if (_actSel > 1) {
- setXSelection(_screenWindow->selectedText(_preserveLineBreaks));
+ copyToX11Selection();
}
_actSel = 0;
@@ -2269,7 +2284,7 @@ void TerminalDisplay::mouseDoubleClickEvent(QMouseEvent* ev)
_screenWindow->setSelectionEnd(endSel.x() , endSel.y());
- setXSelection(_screenWindow->selectedText(_preserveLineBreaks));
+ copyToX11Selection();
}
_possibleTripleClick = true;
@@ -2390,7 +2405,7 @@ void TerminalDisplay::mouseTripleClickEvent(QMouseEvent* ev)
_screenWindow->setSelectionEnd(_columns - 1 , _iPntSel.y());
- setXSelection(_screenWindow->selectedText(_preserveLineBreaks));
+ copyToX11Selection();
_iPntSel.ry() += _scrollBar->value();
}
@@ -2455,28 +2470,47 @@ bool TerminalDisplay::usesMouse() const
/* */
/* ------------------------------------------------------------------------- */
-void TerminalDisplay::doPaste(bool useXselection, bool appendReturn)
+void TerminalDisplay::doPaste(QString text, bool appendReturn)
{
if (!_screenWindow)
return;
- // Paste Clipboard by simulating keypress events
- QString text = QApplication::clipboard()->text(useXselection ? QClipboard::Selection :
- QClipboard::Clipboard);
if (appendReturn)
text.append("\r");
+
if (! text.isEmpty()) {
text.replace('\n', '\r');
+ // perform paste by simulating keypress events
QKeyEvent e(QEvent::KeyPress, 0, Qt::NoModifier, text);
- emit keyPressedSignal(&e); // expose as a big fat keypress event
+ emit keyPressedSignal(&e);
_screenWindow->clearSelection();
}
}
-void TerminalDisplay::setXSelection(const QString& text)
+void TerminalDisplay::setAutoCopySelectedText(bool enabled)
+{
+ _autoCopySelectedText = enabled;
+}
+
+void TerminalDisplay::setMiddleClickPasteMode(Enum::MiddleClickPasteModeEnum mode)
{
+ _middleClickPasteMode = mode;
+}
+
+void TerminalDisplay::copyToX11Selection()
+{
+ if (!_screenWindow)
+ return;
+
+ QString text = _screenWindow->selectedText(_preserveLineBreaks);
+ if (text.isEmpty())
+ return;
+
QApplication::clipboard()->setText(text, QClipboard::Selection);
+
+ if (_autoCopySelectedText)
+ QApplication::clipboard()->setText(text, QClipboard::Clipboard);
}
void TerminalDisplay::copyToClipboard()
@@ -2485,18 +2519,22 @@ void TerminalDisplay::copyToClipboard()
return;
QString text = _screenWindow->selectedText(_preserveLineBreaks);
- if (!text.isEmpty())
- QApplication::clipboard()->setText(text);
+ if (text.isEmpty())
+ return;
+
+ QApplication::clipboard()->setText(text, QClipboard::Clipboard);
}
-void TerminalDisplay::pasteFromClipboard()
+void TerminalDisplay::pasteFromClipboard(bool appendEnter)
{
- doPaste(false, false);
+ QString text = QApplication::clipboard()->text(QClipboard::Clipboard);
+ doPaste(text, appendEnter);
}
-void TerminalDisplay::pasteFromXSelection()
+void TerminalDisplay::pasteFromX11Selection(bool appendEnter)
{
- doPaste(true, false);
+ QString text = QApplication::clipboard()->text(QClipboard::Selection);
+ doPaste(text, appendEnter);
}
/* ------------------------------------------------------------------------- */
diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h
index 5b067cd..40168be 100644
--- a/src/TerminalDisplay.h
+++ b/src/TerminalDisplay.h
@@ -404,8 +404,6 @@ public:
/** Returns the terminal screen section which is displayed in this widget. See setScreenWindow() */
ScreenWindow* screenWindow() const;
- static void setXSelection(const QString& text);
-
public slots:
/**
* Scrolls current ScreenWindow
@@ -425,18 +423,26 @@ public slots:
*/
void updateLineProperties();
- /** Copies the selected text to the clipboard. */
+ void setAutoCopySelectedText(bool enabled);
+
+ void setMiddleClickPasteMode(Enum::MiddleClickPasteModeEnum mode);
+
+ /** Copies the selected text to the X11 Selection. */
+ void copyToX11Selection();
+
+ /** Copies the selected text to the system clipboard. */
void copyToClipboard();
+
/**
* Pastes the content of the clipboard into the
* display.
*/
- void pasteFromClipboard();
+ void pasteFromClipboard(bool appendEnter=false);
/**
- * Pastes the content of the X selection into the
+ * Pastes the content of the X11 selection into the
* display.
*/
- void pasteFromXSelection();
+ void pasteFromX11Selection(bool appendEnter=false);
/**
* Changes whether the flow control warning box should be shown when the flow control
@@ -685,7 +691,7 @@ private:
bool handleShortcutOverrideEvent(QKeyEvent* event);
- void doPaste(bool useXselection, bool appendReturn);
+ void doPaste(QString text, bool appendReturn);
// the window onto the terminal screen which this display
// is currently showing.
@@ -740,6 +746,9 @@ private:
bool _preserveLineBreaks;
bool _columnSelectionMode;
+ bool _autoCopySelectedText;
+ Enum::MiddleClickPasteModeEnum _middleClickPasteMode;
+
QScrollBar* _scrollBar;
Enum::ScrollBarPositionEnum _scrollbarLocation;
QString _wordCharacters;
diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp
index c654ace..4885c86 100644
--- a/src/ViewManager.cpp
+++ b/src/ViewManager.cpp
@@ -804,9 +804,16 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr
int tripleClickMode = profile->property<int>(Profile::TripleClickMode);
view->setTripleClickMode(Enum::TripleClickModeEnum(tripleClickMode));
+ view->setAutoCopySelectedText(profile->autoCopySelectedText());
view->setUnderlineLinks(profile->underlineLinksEnabled());
view->setBidiEnabled(profile->bidiRenderingEnabled());
+ int middleClickPasteMode = profile->property<int>(Profile::MiddleClickPasteMode);
+ if (middleClickPasteMode == Enum::PasteFromX11Selection)
+ view->setMiddleClickPasteMode(Enum::PasteFromX11Selection);
+ else if (middleClickPasteMode == Enum::PasteFromClipboard)
+ view->setMiddleClickPasteMode(Enum::PasteFromClipboard);
+
// cursor shape
int cursorShape = profile->property<int>(Profile::CursorShape);