diff --git a/src/EditProfileDialog.h b/src/EditProfileDialog.h
--- a/src/EditProfileDialog.h
+++ b/src/EditProfileDialog.h
@@ -170,6 +170,7 @@
void toggleCtrlRequiredForDrag(bool);
void toggleDropUrlsAsText(bool);
void toggleCopyTextToClipboard(bool);
+ void toggleCopyTextAsHTML(bool);
void toggleTrimLeadingSpacesInSelectedText(bool);
void toggleTrimTrailingSpacesInSelectedText(bool);
void pasteFromX11Selection();
diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp
--- a/src/EditProfileDialog.cpp
+++ b/src/EditProfileDialog.cpp
@@ -1269,6 +1269,10 @@
_ui->ctrlRequiredForDragButton, Profile::CtrlRequiredForDrag,
SLOT(toggleCtrlRequiredForDrag(bool))
},
+ {
+ _ui->copyTextAsHTMLButton, Profile::CopyTextAsHTML,
+ SLOT(toggleCopyTextAsHTML(bool))
+ },
{
_ui->copyTextToClipboardButton, Profile::AutoCopySelectedText,
SLOT(toggleCopyTextToClipboard(bool))
@@ -1467,6 +1471,11 @@
updateTempProfileProperty(Profile::OpenLinksByDirectClickEnabled, enable);
}
+void EditProfileDialog::toggleCopyTextAsHTML(bool enable)
+{
+ updateTempProfileProperty(Profile::CopyTextAsHTML, enable);
+}
+
void EditProfileDialog::toggleCopyTextToClipboard(bool enable)
{
updateTempProfileProperty(Profile::AutoCopySelectedText, enable);
diff --git a/src/EditProfileDialog.ui b/src/EditProfileDialog.ui
--- a/src/EditProfileDialog.ui
+++ b/src/EditProfileDialog.ui
@@ -952,18 +952,8 @@
true
- -
+
-
-
-
-
-
- Automatically copy selected text into clipboard
-
-
- Copy on select
-
-
-
-
@@ -986,7 +976,7 @@
- -
+
-
-
@@ -1011,6 +1001,30 @@
+ -
+
+
-
+
+
+ Automatically copy selected text into clipboard
+
+
+ Copy on select
+
+
+
+ -
+
+
+ Copy text as HTML (including formatting, font faces, colors... etc)
+
+
+ Copy text as HTML
+
+
+
+
+
@@ -1109,19 +1123,6 @@
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 328
-
-
-
-
diff --git a/src/Profile.h b/src/Profile.h
--- a/src/Profile.h
+++ b/src/Profile.h
@@ -205,6 +205,14 @@
CtrlRequiredForDrag,
/** (bool) If true, automatically copy selected text into the clipboard */
AutoCopySelectedText,
+ /** (bool) The QMimeData object used when copying text always
+ * has the plain/text MIME set and if this is @c true then the
+ * text/html MIME is set too in that object i.e. the copied
+ * text will include formatting, font faces, colors... etc; users
+ * can paste the text as HTML (default) or as plain/text by using
+ * e.g. the "Paste Special" functionality in LibreOffice.
+ */
+ CopyTextAsHTML,
/** (bool) If true, leading spaces are trimmed in selected text */
TrimLeadingSpacesInSelectedText,
/** (bool) If true, trailing spaces are trimmed in selected text */
diff --git a/src/Profile.cpp b/src/Profile.cpp
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -114,6 +114,7 @@
, { CtrlRequiredForDrag, "CtrlRequiredForDrag" , INTERACTION_GROUP , QVariant::Bool }
, { DropUrlsAsText , "DropUrlsAsText" , INTERACTION_GROUP , QVariant::Bool }
, { AutoCopySelectedText , "AutoCopySelectedText" , INTERACTION_GROUP , QVariant::Bool }
+ , { CopyTextAsHTML , "CopyTextAsHTML" , INTERACTION_GROUP , QVariant::Bool }
, { TrimLeadingSpacesInSelectedText , "TrimLeadingSpacesInSelectedText" , INTERACTION_GROUP , QVariant::Bool }
, { TrimTrailingSpacesInSelectedText , "TrimTrailingSpacesInSelectedText" , INTERACTION_GROUP , QVariant::Bool }
, { PasteFromSelectionEnabled , "PasteFromSelectionEnabled" , INTERACTION_GROUP , QVariant::Bool }
@@ -189,6 +190,7 @@
setProperty(OpenLinksByDirectClickEnabled, false);
setProperty(CtrlRequiredForDrag, true);
setProperty(AutoCopySelectedText, false);
+ setProperty(CopyTextAsHTML, true);
setProperty(TrimLeadingSpacesInSelectedText, false);
setProperty(TrimTrailingSpacesInSelectedText, false);
setProperty(DropUrlsAsText, false);
diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h
--- a/src/TerminalDisplay.h
+++ b/src/TerminalDisplay.h
@@ -569,6 +569,8 @@
void setAutoCopySelectedText(bool enabled);
+ void setCopyTextAsHTML(bool enabled);
+
void setMiddleClickPasteMode(Enum::MiddleClickPasteModeEnum mode);
/** Copies the selected text to the X11 Selection. */
@@ -915,6 +917,7 @@
bool _columnSelectionMode;
bool _autoCopySelectedText;
+ bool _copyTextAsHTML;
Enum::MiddleClickPasteModeEnum _middleClickPasteMode;
QScrollBar *_scrollBar;
diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -354,6 +354,7 @@
, _preserveLineBreaks(false)
, _columnSelectionMode(false)
, _autoCopySelectedText(false)
+ , _copyTextAsHTML(true)
, _middleClickPasteMode(Enum::PasteFromX11Selection)
, _scrollbarLocation(Enum::ScrollBarRight)
, _scrollFullPage(false)
@@ -3108,22 +3109,29 @@
_middleClickPasteMode = mode;
}
+void TerminalDisplay::setCopyTextAsHTML(bool enabled)
+{
+ _copyTextAsHTML = enabled;
+}
+
void TerminalDisplay::copyToX11Selection()
{
if (_screenWindow == nullptr) {
return;
}
- QString text = _screenWindow->selectedText(currentDecodingOptions());
+ const QString &text = _screenWindow->selectedText(currentDecodingOptions());
if (text.isEmpty()) {
return;
}
- QString html = _screenWindow->selectedText(currentDecodingOptions() | Screen::ConvertToHtml);
auto mimeData = new QMimeData;
mimeData->setText(text);
- mimeData->setHtml(html);
+
+ if (_copyTextAsHTML) {
+ mimeData->setHtml(_screenWindow->selectedText(currentDecodingOptions() | Screen::ConvertToHtml));
+ }
if (QApplication::clipboard()->supportsSelection()) {
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Selection);
@@ -3140,15 +3148,17 @@
return;
}
- QString text = _screenWindow->selectedText(currentDecodingOptions());
+ const QString &text = _screenWindow->selectedText(currentDecodingOptions());
if (text.isEmpty()) {
return;
}
- QString html = _screenWindow->selectedText(currentDecodingOptions() | Screen::ConvertToHtml);
auto mimeData = new QMimeData;
mimeData->setText(text);
- mimeData->setHtml(html);
+
+ if (_copyTextAsHTML) {
+ mimeData->setHtml(_screenWindow->selectedText(currentDecodingOptions() | Screen::ConvertToHtml));
+ }
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
}
diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp
--- a/src/ViewManager.cpp
+++ b/src/ViewManager.cpp
@@ -930,6 +930,8 @@
view->setMiddleClickPasteMode(Enum::PasteFromClipboard);
}
+ view->setCopyTextAsHTML(profile->property(Profile::CopyTextAsHTML));
+
// margin/center
view->setMargin(profile->property(Profile::TerminalMargin));
view->setCenterContents(profile->property(Profile::TerminalCenter));