Skip to content

Commit e057ae9

Browse files
Fix issue: Clipboard usage on WebAssembly (#389)
* Add CLI input handling and documentation * Fix clang-format * Fix Issue #386: Clipboard usage on WebAssembly
1 parent 973d34a commit e057ae9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/console.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
#include <QScrollBar>
77

8+
#include <QClipboard>
9+
#include <QGuiApplication>
10+
811
namespace Ripes {
912

1013
Console::Console(QWidget *parent) : QPlainTextEdit(parent) {
@@ -70,6 +73,27 @@ void Console::backspace() {
7073
}
7174

7275
void Console::keyPressEvent(QKeyEvent *e) {
76+
QClipboard *clipboard = QGuiApplication::clipboard();
77+
78+
if (e->modifiers() & Qt::ControlModifier) {
79+
switch (e->key()) {
80+
case Qt::Key_C:
81+
if (textCursor().hasSelection()) {
82+
clipboard->setText(textCursor().selectedText());
83+
}
84+
return;
85+
86+
case Qt::Key_V:
87+
QString clipboardText = clipboard->text();
88+
if (!clipboardText.isEmpty()) {
89+
m_buffer += clipboardText;
90+
if (m_localEchoEnabled)
91+
putData(clipboardText.toUtf8());
92+
}
93+
return;
94+
}
95+
}
96+
7397
switch (e->key()) {
7498
case Qt::Key_Left:
7599
case Qt::Key_Right:

0 commit comments

Comments
 (0)