summarylogtreecommitdiffstats
path: root/osc52.patch
blob: 934313c0311b625fbbc38078692956996a95670a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
diff --git a/src/Vt102Emulation.cpp b/src/Vt102Emulation.cpp
index bebd5e399..a434ee4ab 100644
--- a/src/Vt102Emulation.cpp
+++ b/src/Vt102Emulation.cpp
@@ -12,7 +12,9 @@
 #include <cstdio>
 
 // Qt
+#include <QApplication>
 #include <QBuffer>
+#include <QClipboard>
 #include <QEvent>
 #include <QKeyEvent>
 #include <QTimer>
@@ -1147,6 +1149,29 @@ void Vt102Emulation::processSessionAttributeRequest(const int tokenSize, const u
         connect(notification, &KNotification::defaultActivated, this, [this, notification]() {
             _currentScreen->currentTerminalDisplay()->notificationClicked(notification->xdgActivationToken());
         });
+    }
+    if (attribute == 52) {
+        // Clipboard
+        QStringList params = value.split(QLatin1Char(';'));
+        if (params.length() == 0) {
+            return;
+        }
+
+        QClipboard::Mode mode;
+        if (params[0] == QLatin1Char('c')) {
+            mode = QClipboard::Clipboard;
+        } else if (params[0] == QLatin1Char('p')) {
+            mode = QClipboard::Selection;
+        } else {
+            return;
+        }
+
+        if (params.length() == 2) {
+            // Copy to clipboard
+            QApplication::clipboard()->setText(QString::fromUtf8(QByteArray::fromBase64(params[1].toUtf8())), mode);
+        } else {
+            QApplication::clipboard()->clear(mode);
+        }
 
         return;
     }
diff --git a/src/Vt102Emulation.h b/src/Vt102Emulation.h
index 3e067549a..a34bfc590 100644
--- a/src/Vt102Emulation.h
+++ b/src/Vt102Emulation.h
@@ -124,7 +124,7 @@ private:
     void resetModes();
 
     void resetTokenizer();
-#define MAX_TOKEN_LENGTH 256 // Max length of tokens (e.g. window title)
+#define MAX_TOKEN_LENGTH 65536 // Max length of tokens (e.g. window title)
     void addToCurrentToken(uint cc);
     int tokenBufferPos;