Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
3baa2aa8
Verified
Commit
3baa2aa8
authored
Jul 06, 2021
by
Jonah Brüchert
🍪
Browse files
Revert "TerminalDisplay: Extract copying related functions"
This reverts commit
1a2867c8
.
parent
dfda7d53
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/CMakeLists.txt
View file @
3baa2aa8
...
...
@@ -184,8 +184,8 @@ set(konsoleprivate_SRCS ${windowadaptors_SRCS}
terminalDisplay/TerminalScrollBar.cpp
terminalDisplay/TerminalColor.cpp
terminalDisplay/TerminalFonts.cpp
terminalDisplay/TerminalClipboard.cpp
terminalDisplay/TerminalBell.cpp
terminalDisplay/TerminalPasting.cpp
widgets/TerminalDisplayAccessible.cpp
widgets/TerminalHeaderBar.cpp
...
...
src/terminalDisplay/TerminalDisplay.cpp
View file @
3baa2aa8
...
...
@@ -75,7 +75,7 @@
#include "TerminalScrollBar.h"
#include "TerminalColor.h"
#include "TerminalFonts.h"
#include "Terminal
Clipboard
.h"
#include "Terminal
Pasting
.h"
using
namespace
Konsole
;
...
...
@@ -1568,7 +1568,7 @@ void TerminalDisplay::processMidButtonClick(QMouseEvent* ev)
if
(
_middleClickPasteMode
==
Enum
::
PasteFromX11Selection
)
{
pasteFromX11Selection
(
appendEnter
);
}
else
if
(
_middleClickPasteMode
==
Enum
::
PasteFromClipboard
)
{
doPaste
(
terminal
Clipboard
::
pasteFromClipboard
(),
appendEnter
);
doPaste
(
terminal
Pasting
::
pasteFromClipboard
(),
appendEnter
);
}
else
{
Q_ASSERT
(
false
);
}
...
...
@@ -2120,7 +2120,7 @@ void TerminalDisplay::doPaste(QString text, bool appendReturn)
}
}
auto
unsafeCharacters
=
terminal
Clipboard
::
checkForUnsafeCharacters
(
text
);
auto
unsafeCharacters
=
terminal
Pasting
::
checkForUnsafeCharacters
(
text
);
if
(
!
unsafeCharacters
.
isEmpty
())
{
int
result
=
KMessageBox
::
warningYesNoCancelList
(
window
(),
...
...
@@ -2143,7 +2143,7 @@ void TerminalDisplay::doPaste(QString text, bool appendReturn)
case
KMessageBox
::
Cancel
:
return
;
case
KMessageBox
::
Yes
:
{
text
=
terminal
Clipboard
::
sanitizeString
(
text
);
text
=
terminal
Pasting
::
sanitizeString
(
text
);
}
case
KMessageBox
::
No
:
break
;
...
...
@@ -2152,7 +2152,7 @@ void TerminalDisplay::doPaste(QString text, bool appendReturn)
}
}
auto
pasteString
=
terminal
Clipboard
::
prepareStringForPasting
(
text
,
appendReturn
,
bracketedPasteMode
());
auto
pasteString
=
terminal
Pasting
::
prepareStringForPasting
(
text
,
appendReturn
,
bracketedPasteMode
());
if
(
pasteString
.
has_value
())
{
// perform paste by simulating keypress events
QKeyEvent
e
(
QEvent
::
KeyPress
,
0
,
Qt
::
NoModifier
,
text
);
...
...
@@ -2181,11 +2181,26 @@ void TerminalDisplay::copyToX11Selection()
return
;
}
const
auto
&
text
=
_copyTextAsHTML
?
_screenWindow
->
selectedText
(
currentDecodingOptions
()
|
Screen
::
ConvertToHtml
)
:
_screenWindow
->
selectedText
(
currentDecodingOptions
());
terminalClipboard
::
copyToX11Selection
(
text
,
_copyTextAsHTML
,
_autoCopySelectedText
);
const
QString
&
text
=
_screenWindow
->
selectedText
(
currentDecodingOptions
());
if
(
text
.
isEmpty
())
{
return
;
}
auto
mimeData
=
new
QMimeData
;
mimeData
->
setText
(
text
);
if
(
_copyTextAsHTML
)
{
mimeData
->
setHtml
(
_screenWindow
->
selectedText
(
currentDecodingOptions
()
|
Screen
::
ConvertToHtml
));
}
if
(
QApplication
::
clipboard
()
->
supportsSelection
())
{
QApplication
::
clipboard
()
->
setMimeData
(
mimeData
,
QClipboard
::
Selection
);
}
if
(
_autoCopySelectedText
)
{
QApplication
::
clipboard
()
->
setMimeData
(
mimeData
,
QClipboard
::
Clipboard
);
}
}
void
TerminalDisplay
::
copyToClipboard
()
...
...
@@ -2650,7 +2665,7 @@ void TerminalDisplay::setSessionController(SessionController* controller)
{
_sessionController
=
controller
;
connect
(
_sessionController
,
&
Konsole
::
SessionController
::
pasteFromClipboardRequested
,
[
this
]
{
doPaste
(
terminal
Clipboard
::
pasteFromClipboard
(),
false
);
doPaste
(
terminal
Pasting
::
pasteFromClipboard
(),
false
);
});
_headerBar
->
finishHeaderSetup
(
controller
);
}
...
...
src/terminalDisplay/Terminal
Clipboard
.cpp
→
src/terminalDisplay/Terminal
Pasting
.cpp
View file @
3baa2aa8
...
...
@@ -17,9 +17,10 @@
#include <KShell>
#include <KLocalizedString>
#include "Terminal
Clipboard
.h"
#include "Terminal
Pasting
.h"
namespace
Konsole
::
terminalClipboard
{
namespace
Konsole
{
namespace
terminalPasting
{
// Most code in Konsole uses UTF-32. We're filtering
// UTF-16 here, as all control characters can be represented
...
...
@@ -141,26 +142,5 @@ 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
)
{
if
(
textToCopy
.
isEmpty
())
{
return
;
}
auto
mimeData
=
new
QMimeData
;
mimeData
->
setText
(
textToCopy
);
if
(
isHtml
)
{
mimeData
->
setHtml
(
textToCopy
);
}
if
(
QApplication
::
clipboard
()
->
supportsSelection
())
{
QApplication
::
clipboard
()
->
setMimeData
(
mimeData
,
QClipboard
::
Selection
);
}
if
(
autoCopySelectedText
)
{
QApplication
::
clipboard
()
->
setMimeData
(
mimeData
,
QClipboard
::
Clipboard
);
}
}
}
src/terminalDisplay/Terminal
Clipboard
.h
→
src/terminalDisplay/Terminal
Pasting
.h
View file @
3baa2aa8
...
...
@@ -15,7 +15,8 @@ class QStringList;
#include <optional>
namespace
Konsole
::
terminalClipboard
{
namespace
Konsole
{
namespace
terminalPasting
{
/**
* Retrieves the content of the clipboard and preprocesses it for pasting
...
...
@@ -47,6 +48,5 @@ QStringList checkForUnsafeCharacters(const QString &text);
*/
bool
isUnsafe
(
const
QChar
c
);
void
copyToX11Selection
(
const
QString
&
textToCopy
,
bool
copyAsHtml
,
bool
autoCopySelectedText
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment