Fix copying html from the terminal

wilder
Jonah Brüchert 5 years ago committed by Ahmad Samir
parent 9cf7a59f66
commit 8b38d5875e
  1. 6
      src/terminalDisplay/TerminalClipboard.cpp
  2. 2
      src/terminalDisplay/TerminalClipboard.h
  3. 7
      src/terminalDisplay/TerminalDisplay.cpp

@ -141,7 +141,7 @@ bool isUnsafe(const QChar c) {
return (c.category() == QChar::Category::Other_Control && std::find(ALLOWLIST.begin(), ALLOWLIST.end(), c.unicode()) != ALLOWLIST.end());
}
void copyToX11Selection(const QString &textToCopy, bool isHtml, bool autoCopySelectedText)
void copyToX11Selection(const QString &textToCopy, const QString &htmlToCopy, bool autoCopySelectedText)
{
if (textToCopy.isEmpty()) {
return;
@ -150,8 +150,8 @@ void copyToX11Selection(const QString &textToCopy, bool isHtml, bool autoCopySel
auto mimeData = new QMimeData;
mimeData->setText(textToCopy);
if (isHtml) {
mimeData->setHtml(textToCopy);
if (!htmlToCopy.isEmpty()) {
mimeData->setHtml(htmlToCopy);
}
if (QApplication::clipboard()->supportsSelection()) {

@ -47,6 +47,6 @@ QStringList checkForUnsafeCharacters(const QString &text);
*/
bool isUnsafe(const QChar c);
void copyToX11Selection(const QString &textToCopy, bool copyAsHtml, bool autoCopySelectedText);
void copyToX11Selection(const QString &textToCopy, const QString &htmlToCopy, bool autoCopySelectedText);
}

@ -2181,11 +2181,10 @@ void TerminalDisplay::copyToX11Selection()
return;
}
const auto &text = _copyTextAsHTML ?
_screenWindow->selectedText(currentDecodingOptions() | Screen::ConvertToHtml)
: _screenWindow->selectedText(currentDecodingOptions());
const auto text = _screenWindow->selectedText(currentDecodingOptions());
const auto html = _screenWindow->selectedText(currentDecodingOptions() | Screen::ConvertToHtml);
terminalClipboard::copyToX11Selection(text, _copyTextAsHTML, _autoCopySelectedText);
terminalClipboard::copyToX11Selection(text, html, _autoCopySelectedText);
}
void TerminalDisplay::copyToClipboard()

Loading…
Cancel
Save