diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index e13b085..1c7bec3 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -2662,11 +2662,7 @@ void TerminalDisplay::emitSelection(bool useXselection,bool appendReturn) if ( ! text.isEmpty() ) { text.replace('\n', '\r'); - if ( bracketedPasteMode() ) - { - text.prepend("\e[200~"); - text.append("\e[201~"); - } + bracketText(text); QKeyEvent e(QEvent::KeyPress, 0, Qt::NoModifier, text); emit keyPressedSignal(&e); // expose as a big fat keypress event @@ -2674,6 +2670,15 @@ void TerminalDisplay::emitSelection(bool useXselection,bool appendReturn) } } +void TerminalDisplay::bracketText(QString& text) +{ + if (bracketedPasteMode()) + { + text.prepend("\033[200~"); + text.append("\033[201~"); + } +} + void TerminalDisplay::setSelection(const QString& t) { QApplication::clipboard()->setText(t, QClipboard::Selection); diff --git a/lib/TerminalDisplay.h b/lib/TerminalDisplay.h index ea0dc27..aa707bd 100644 --- a/lib/TerminalDisplay.h +++ b/lib/TerminalDisplay.h @@ -192,6 +192,9 @@ public: void emitSelection(bool useXselection,bool appendReturn); + /** change and wrap text corresponding to paste mode **/ + void bracketText(QString& text); + /** * Sets the shape of the keyboard cursor. This is the cursor drawn * at the position in the terminal where keyboard input will appear. diff --git a/lib/qtermwidget.cpp b/lib/qtermwidget.cpp index 1136459..c389acc 100644 --- a/lib/qtermwidget.cpp +++ b/lib/qtermwidget.cpp @@ -531,6 +531,11 @@ void QTermWidget::sessionFinished() emit finished(); } +void QTermWidget::bracketText(QString& text) +{ + m_impl->m_terminalDisplay->bracketText(text); +} + void QTermWidget::copyClipboard() { m_impl->m_terminalDisplay->copyClipboard(); diff --git a/lib/qtermwidget.h b/lib/qtermwidget.h index 46e54cf..04c84b4 100644 --- a/lib/qtermwidget.h +++ b/lib/qtermwidget.h @@ -219,6 +219,8 @@ public: /** True if the title() or icon() was (ever) changed by the session. */ bool isTitleChanged() const; + /** change and wrap text corresponding to paste mode **/ + void bracketText(QString& text); signals: void finished(); void copyAvailable(bool);