--- a/QTfrontend/game.cpp Fri Mar 06 21:24:21 2015 +0100
+++ b/QTfrontend/game.cpp Sun Mar 08 01:04:41 2015 +0100
@@ -16,6 +16,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <QApplication>
+#include <QClipboard>
+
#include <QString>
#include <QCheckBox>
#include <QByteArray>
@@ -210,6 +213,18 @@
SendIPC("!");
break;
}
+ case 'Y':
+ {
+ // copy string to clipboard
+ QApplication::clipboard()->setText(QString::fromUtf8(msg.mid(2)));
+ break;
+ }
+ case 'P':
+ {
+ // paste clipboard to game
+ SendIPC(QString("P").toAscii() + QApplication::clipboard()->text().toUtf8().left(254).replace('\n', ' '));
+ break;
+ }
case 'C':
{
switch (gameType)
--- a/hedgewars/uChat.pas Fri Mar 06 21:24:21 2015 +0100
+++ b/hedgewars/uChat.pas Sun Mar 08 01:04:41 2015 +0100
@@ -249,6 +249,8 @@
inc(visibleCount)
end;
+procedure CheckPasteBuffer(); forward;
+
procedure DrawChat;
var i, t, left, top, cnt: LongInt;
selRect: TSDL_Rect;
@@ -265,6 +267,8 @@
// draw chat input line first and under all other lines
if (GameState = gsChat) and (InputStr.Tex <> nil) then
begin
+ CheckPasteBuffer();
+
if firstDraw then
begin
UpdateCursorCoords();
@@ -662,11 +666,9 @@
end;
end;
-var clipboardBuffer: shortstring;
-
procedure CopyToClipboard(var newContent: shortstring);
begin
- clipboardBuffer:= newContent;
+ SendIPC(_S'Y' + copy(newContent, 1, 253) + #0);
end;
procedure CopySelectionToClipboard();
@@ -710,8 +712,16 @@
procedure PasteFromClipboard();
begin
- DeleteSelected();
- InsertIntoInputStr(clipboardBuffer);
+ SendIPC(_S'P');
+end;
+
+procedure CheckPasteBuffer();
+begin
+ if Length(ChatPasteBuffer) > 0 then
+ begin
+ InsertIntoInputStr(ChatPasteBuffer);
+ ChatPasteBuffer:= '';
+ end;
end;
procedure KeyPressChat(Key, Sym: Longword; Modifier: Word);
@@ -724,6 +734,8 @@
LastKeyPressTick:= RealTicks;
action:= true;
+ CheckPasteBuffer();
+
selMode:= (modifier and (KMOD_LSHIFT or KMOD_RSHIFT)) <> 0;
ctrl:= (modifier and (KMOD_LCTRL or KMOD_RCTRL)) <> 0;
skip:= none;
@@ -1069,8 +1081,6 @@
LastKeyPressTick:= 0;
ResetCursor();
-
- clipboardBuffer:= '';
end;
procedure freeModule;
--- a/hedgewars/uIO.pas Fri Mar 06 21:24:21 2015 +0100
+++ b/hedgewars/uIO.pas Sun Mar 08 01:04:41 2015 +0100
@@ -138,6 +138,7 @@
case s[1] of
'!': begin AddFileLog('Ping? Pong!'); isPonged:= true; end;
'?': SendIPC(_S'!');
+ 'P': ChatPasteBuffer:= copy(s, 2, Length(s) - 1);
'e': ParseCommand(copy(s, 2, Length(s) - 1), true);
'E': OutError(copy(s, 2, Length(s) - 1), true);
'W': OutError(copy(s, 2, Length(s) - 1), false);
--- a/hedgewars/uVariables.pas Fri Mar 06 21:24:21 2015 +0100
+++ b/hedgewars/uVariables.pas Sun Mar 08 01:04:41 2015 +0100
@@ -237,6 +237,8 @@
MaxTextureSize: LongInt;
+ ChatPasteBuffer: shortstring;
+
/////////////////////////////////////
//Buttons
{$IFDEF USE_TOUCH_INTERFACE}
@@ -2685,6 +2687,8 @@
cStereoDepth:= 0;
cViewLimitsDebug:= false;
AprilOne := false;
+
+ ChatPasteBuffer:= '';
end;
procedure freeModule;