1
|
=== modified file 'src/com/goldencode/p2j/ui/client/driver/web/res/p2j.clipboard.js'
|
2
|
--- src/com/goldencode/p2j/ui/client/driver/web/res/p2j.clipboard.js 2015-08-12 18:07:06 +0000
|
3
|
+++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.clipboard.js 2015-10-13 22:04:19 +0000
|
4
|
@@ -140,12 +140,12 @@
|
5
|
p2j.clipboard_helpers.init(cfg);
|
6
|
|
7
|
// the event handlers must have been defined above the init() function
|
8
|
- window.addEventListener("copy", copyHandler);
|
9
|
- window.addEventListener("paste", pasteHandler);
|
10
|
+ document.addEventListener("copy", copyHandler);
|
11
|
+ document.addEventListener("paste", pasteHandler);
|
12
|
|
13
|
// ChUI doesn't use CUT for system clipboard integration
|
14
|
if (p2j.isGui)
|
15
|
- window.addEventListener("cut", copyHandler);
|
16
|
+ document.addEventListener("cut", copyHandler);
|
17
|
};
|
18
|
|
19
|
/**
|
20
|
@@ -232,12 +232,17 @@
|
21
|
*/
|
22
|
me.writeClipboard = function(text)
|
23
|
{
|
24
|
- // TODO: find a way to arbitrarily write the contents of the clipboard on non-IE
|
25
|
- if (window.clipboardData)
|
26
|
- {
|
27
|
- window.clipboardData.clearData();
|
28
|
- window.clipboardData.setData("Text", text);
|
29
|
- }
|
30
|
+ // copy selection to clipboard
|
31
|
+ inputText.value = encodeURIComponent(text); // to escape "\n"
|
32
|
+ inputText.focus();
|
33
|
+ inputText.select();
|
34
|
+// TODO: find a way to arbitrarily write the contents of the clipboard on non-IE
|
35
|
+// if (window.clipboardData)
|
36
|
+// {
|
37
|
+// console.log("window.clipboardData");
|
38
|
+// window.clipboardData.clearData();
|
39
|
+// window.clipboardData.setData("Text", text);
|
40
|
+// }
|
41
|
};
|
42
|
|
43
|
/**
|
44
|
|
45
|
=== modified file 'src/com/goldencode/p2j/ui/client/driver/web/res/p2j.keyboard.js'
|
46
|
--- src/com/goldencode/p2j/ui/client/driver/web/res/p2j.keyboard.js 2015-10-09 19:15:11 +0000
|
47
|
+++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.keyboard.js 2015-10-13 22:49:10 +0000
|
48
|
@@ -161,28 +161,39 @@
|
49
|
// if have clipboard
|
50
|
if (p2j.clipboard.enabled)
|
51
|
{
|
52
|
- // TODO: in GUI, alternate cut (shift-del), copy (ctrl-ins) and paste (shift-ins) keys
|
53
|
- // will generate the clipboard events; we need processing here for those events
|
54
|
- // when we generate them properly (shift-ins == 1022, shift-del == 639 and
|
55
|
- // ctrl-ins == 2558)
|
56
|
-
|
57
|
- // CTRL-C (copy) or CTRL-X (cut), CUT to system clipboard is not supported for ChUI
|
58
|
- if ((key === 3 && (!p2j.clipboard.needsSelection() || p2j.clipboard.haveSelection())) ||
|
59
|
- (key === 24 && !p2j.clipboard.needsSelection()))
|
60
|
+ // in GUI, alternate cut (shift-del), copy (ctrl-ins) and paste (shift-ins) keys
|
61
|
+ // will generate the clipboard events; we need processing here for those events
|
62
|
+ // when we generate them properly (shift-ins == 1022, shift-del == 639 and
|
63
|
+ // ctrl-ins == 2558)
|
64
|
+ if (p2j.isGui)
|
65
|
{
|
66
|
- // prepare clipboard operations on CTRL key down (copies selected text into a
|
67
|
- // hidden input field, focuses that field and selects the text)
|
68
|
- p2j.clipboard.prepareCopy();
|
69
|
+ if (((key === 3 || key === 2558) && (!p2j.clipboard.needsSelection() || p2j.clipboard.haveSelection())) ||
|
70
|
+ ((key === 24 || key === 639) && !p2j.clipboard.needsSelection()))
|
71
|
+ {
|
72
|
+ sendKeyCode(key);
|
73
|
+ return;
|
74
|
+ }
|
75
|
+ }
|
76
|
+ else
|
77
|
+ {
|
78
|
+ // CTRL-C (copy) or CTRL-X (cut), CUT to system clipboard is not supported for ChUI
|
79
|
+ if ((key === 3 && (!p2j.clipboard.needsSelection() || p2j.clipboard.haveSelection())) ||
|
80
|
+ (key === 24 && !p2j.clipboard.needsSelection()))
|
81
|
+ {
|
82
|
+ // prepare clipboard operations on CTRL key down (copies selected text into a
|
83
|
+ // hidden input field, focuses that field and selects the text)
|
84
|
+ p2j.clipboard.prepareCopy();
|
85
|
+
|
86
|
+ // let the browser generate the corresponding clipboard event by not suppressing the
|
87
|
+ // default processing
|
88
|
+ // TODO: GUI needs to see these keys regardless and the code below would disable the
|
89
|
+ // default processing
|
90
|
+ return;
|
91
|
+ }
|
92
|
+ }
|
93
|
|
94
|
- // let the browser generate the corresponding clipboard event by not suppressing the
|
95
|
- // default processing
|
96
|
- // TODO: GUI needs to see these keys regardless and the code below would disable the
|
97
|
- // default processing
|
98
|
- return;
|
99
|
- }
|
100
|
-
|
101
|
// CTRL-V (paste)
|
102
|
- if (key === 22)
|
103
|
+ if (key === 22 || (p2j.isGui && (key === 1022)))
|
104
|
{
|
105
|
// use a not-visible input field and select all contents of that field
|
106
|
p2j.clipboard.preparePaste();
|
107
|
@@ -195,20 +206,30 @@
|
108
|
return;
|
109
|
}
|
110
|
}
|
111
|
+ sendKeyCode(key);
|
112
|
|
113
|
+ evt.preventDefault();
|
114
|
+ evt.stopImmediatePropagation();
|
115
|
+ };
|
116
|
+
|
117
|
+ /**
|
118
|
+ * Sends a compatible Progress 4GL key code message.
|
119
|
+ *
|
120
|
+ * @param {number} keyCode
|
121
|
+ * The key code
|
122
|
+ */
|
123
|
+ function sendKeyCode(keyCode)
|
124
|
+ {
|
125
|
var data = new Uint8Array(3);
|
126
|
data[0] = 0x01;
|
127
|
- var c = key;
|
128
|
+ var c = keyCode;
|
129
|
data[2] = c & 0xff;
|
130
|
c = c >> 8;
|
131
|
data[1] = c & 0xff;
|
132
|
|
133
|
p2j.socket.send(data);
|
134
|
-
|
135
|
- evt.preventDefault();
|
136
|
- evt.stopImmediatePropagation();
|
137
|
- };
|
138
|
-
|
139
|
+ }
|
140
|
+
|
141
|
/**
|
142
|
* Send key code and character code.
|
143
|
*
|
144
|
|
145
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/EditorGuiImpl.java'
|
146
|
--- src/com/goldencode/p2j/ui/client/gui/EditorGuiImpl.java 2015-10-08 19:17:34 +0000
|
147
|
+++ src/com/goldencode/p2j/ui/client/gui/EditorGuiImpl.java 2015-10-13 21:41:47 +0000
|
148
|
@@ -2462,6 +2462,7 @@
|
149
|
config.selectionEnd = parsedText.get(selectionEnd.y).getOffset() +
|
150
|
selectionEnd.x + 1;
|
151
|
config.selectionText = getSelectedText(false);
|
152
|
+ gd.setCurrentSelection(config.selectionText);
|
153
|
}
|
154
|
}
|
155
|
|
156
|
|
157
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/FillInGuiImpl.java'
|
158
|
--- src/com/goldencode/p2j/ui/client/gui/FillInGuiImpl.java 2015-10-08 17:42:19 +0000
|
159
|
+++ src/com/goldencode/p2j/ui/client/gui/FillInGuiImpl.java 2015-10-13 21:56:42 +0000
|
160
|
@@ -472,6 +472,8 @@
|
161
|
{
|
162
|
config.selectionEnd = Math.min(config.selectionEnd + 1, lastOffset + 1);
|
163
|
}
|
164
|
+ // notify about the current selection
|
165
|
+ gd.setCurrentSelection(getSelectedText());
|
166
|
|
167
|
ke.setKeyCode(Keyboard.KA_CURSOR_RIGHT);
|
168
|
ke.setActionCode(Keyboard.KA_CURSOR_RIGHT);
|
169
|
@@ -504,6 +506,8 @@
|
170
|
{
|
171
|
config.selectionStart = Math.max(config.selectionStart - 1, 0);
|
172
|
}
|
173
|
+ // notify about the current selection
|
174
|
+ gd.setCurrentSelection(getSelectedText());
|
175
|
|
176
|
ke.setKeyCode(Keyboard.KA_CURSOR_LEFT);
|
177
|
ke.setActionCode(Keyboard.KA_CURSOR_LEFT);
|
178
|
@@ -521,6 +525,8 @@
|
179
|
config.selectionEnd = config.selectionStart;
|
180
|
}
|
181
|
config.selectionStart = 0;
|
182
|
+ // notify about the current selection
|
183
|
+ gd.setCurrentSelection(getSelectedText());
|
184
|
|
185
|
ke.setKeyCode(Keyboard.KA_HOME);
|
186
|
ke.setActionCode(Keyboard.KA_HOME);
|
187
|
@@ -539,6 +545,8 @@
|
188
|
}
|
189
|
|
190
|
config.selectionEnd = lastOffset + 1;
|
191
|
+ // notify about the current selection
|
192
|
+ gd.setCurrentSelection(getSelectedText());
|
193
|
|
194
|
ke.setKeyCode(Keyboard.KA_END);
|
195
|
ke.setActionCode(Keyboard.KA_END);
|
196
|
@@ -554,6 +562,9 @@
|
197
|
{
|
198
|
config.selectionStart = 0;
|
199
|
config.selectionEnd = lastOffset + 1;
|
200
|
+ // notify about the current selection
|
201
|
+ gd.setCurrentSelection(getSelectedText());
|
202
|
+
|
203
|
repaint();
|
204
|
}
|
205
|
|
206
|
|
207
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java'
|
208
|
--- src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java 2015-10-13 17:07:58 +0000
|
209
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java 2015-10-13 21:36:25 +0000
|
210
|
@@ -1031,6 +1031,14 @@
|
211
|
public String clipboardContents();
|
212
|
|
213
|
/**
|
214
|
+ * Sets the current selection.
|
215
|
+ *
|
216
|
+ * @param txt
|
217
|
+ * The current selection.
|
218
|
+ */
|
219
|
+ public void setCurrentSelection(String txt);
|
220
|
+
|
221
|
+ /**
|
222
|
* Register all the mouse-aware widgets (in all Windows) with the driver.
|
223
|
*/
|
224
|
public void registerMouseWidgets();
|
225
|
|
226
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java'
|
227
|
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java 2015-10-13 17:07:58 +0000
|
228
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java 2015-10-13 21:41:00 +0000
|
229
|
@@ -459,4 +459,15 @@
|
230
|
sew.restoreFocusListeners();
|
231
|
}
|
232
|
}
|
233
|
+
|
234
|
+ /**
|
235
|
+ * Sets the current selection.
|
236
|
+ *
|
237
|
+ * @param txt
|
238
|
+ * The current selection.
|
239
|
+ */
|
240
|
+ @Override
|
241
|
+ public void setCurrentSelection(String txt)
|
242
|
+ {
|
243
|
+ }
|
244
|
}
|
245
|
|
246
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java'
|
247
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java 2015-10-13 17:07:58 +0000
|
248
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java 2015-10-13 22:22:58 +0000
|
249
|
@@ -520,7 +520,7 @@
|
250
|
@Override
|
251
|
public void copyToCliboard(String txt)
|
252
|
{
|
253
|
- // TODO
|
254
|
+ websock.writeClipboard(txt);
|
255
|
}
|
256
|
|
257
|
/**
|
258
|
@@ -1214,4 +1214,16 @@
|
259
|
}
|
260
|
}
|
261
|
}
|
262
|
+
|
263
|
+ /**
|
264
|
+ * Sets the current selection.
|
265
|
+ *
|
266
|
+ * @param txt
|
267
|
+ * The current selection.
|
268
|
+ */
|
269
|
+ @Override
|
270
|
+ public void setCurrentSelection(String txt)
|
271
|
+ {
|
272
|
+ copyToCliboard(txt);
|
273
|
+ }
|
274
|
}
|
275
|
|
276
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java'
|
277
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2015-10-13 17:07:58 +0000
|
278
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2015-10-13 22:28:59 +0000
|
279
|
@@ -913,6 +913,23 @@
|
280
|
}
|
281
|
|
282
|
/**
|
283
|
+ * Writes to the current selection to the application clipboard and notify the JS client
|
284
|
+ * about the current selection.
|
285
|
+ *
|
286
|
+ * @param text
|
287
|
+ * The current selection.
|
288
|
+ */
|
289
|
+ public void writeClipboard(String text)
|
290
|
+ {
|
291
|
+ synchronized (clipboardLock)
|
292
|
+ {
|
293
|
+ clipboardContents = text;
|
294
|
+ clipboardLock.notify();
|
295
|
+ }
|
296
|
+ sendBinaryMessage(MSG_WRITE_CLIPBOARD, (text == null) ? "" : text);
|
297
|
+ }
|
298
|
+
|
299
|
+ /**
|
300
|
* This is the worker method which is called when a binary message is received.
|
301
|
*
|
302
|
* @param message
|
303
|
|