--- a/QTfrontend/game.cpp Tue Nov 10 20:43:13 2015 +0100
+++ b/QTfrontend/game.cpp Tue Nov 10 22:18:06 2015 +0100
@@ -267,12 +267,6 @@
QApplication::clipboard()->setText(QString::fromUtf8(msg.mid(2)));
break;
}
- case 'Y':
- {
- // paste clipboard to game
- SendIPC(QString("Y").toAscii() + QApplication::clipboard()->text().toUtf8().left(250).replace('\n', ' '));
- break;
- }
case 'i':
{
emit GameStats(msg.at(2), QString::fromUtf8(msg.mid(3)));
--- a/hedgewars/SDLh.pas Tue Nov 10 20:43:13 2015 +0100
+++ b/hedgewars/SDLh.pas Tue Nov 10 22:18:06 2015 +0100
@@ -780,6 +780,8 @@
function SDL_InitSubSystem(flags: LongWord): LongInt; cdecl; external SDLLibName;
procedure SDL_Quit; cdecl; external SDLLibName;
+procedure SDL_free(mem: Pointer); cdecl; external SDLLibName;
+
procedure SDL_Delay(msec: LongWord); cdecl; external SDLLibName;
function SDL_GetTicks: LongWord; cdecl; external SDLLibName;
@@ -986,6 +988,9 @@
function SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName;
function SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName;
+// SDL 2 clipboard functions
+function SDL_HasClipboardText(): Boolean; cdecl; external SDLLibName;
+function SDL_GetClipboardText(): PChar; cdecl; external SDLLibName;
procedure SDLNet_Write16(value: Word; buf: Pointer);
procedure SDLNet_Write32(value: LongWord; buf: Pointer);
@@ -1060,5 +1065,6 @@
(PByteArray(buf)^[0] shl 24)
end;
+
end.
--- a/hedgewars/uChat.pas Tue Nov 10 20:43:13 2015 +0100
+++ b/hedgewars/uChat.pas Tue Nov 10 22:18:06 2015 +0100
@@ -270,8 +270,6 @@
inc(visibleCount)
end;
-procedure CheckPasteBuffer(); forward;
-
procedure UpdateInputLinePrefix();
begin
if liveLua then
@@ -305,7 +303,6 @@
// draw chat input line first and under all other lines
if (GameState = gsChat) and (InputStr.Tex <> nil) then
begin
- CheckPasteBuffer();
if InputLinePrefix.Tex = nil then
RenderChatLineTex(InputLinePrefix, InputLinePrefix.s);
@@ -802,16 +799,18 @@
end;
procedure PasteFromClipboard();
+var clip: PChar;
begin
- SendIPC(_S'Y');
-end;
-
-procedure CheckPasteBuffer();
-begin
- if Length(ChatPasteBuffer) > 0 then
+ // use SDL2 clipboard functions
+ if SDL_HasClipboardText() then
begin
- InsertIntoInputStr(ChatPasteBuffer);
- ChatPasteBuffer:= '';
+ clip:= SDL_GetClipboardText();
+ // returns NULL if not enough memory for a copy of clipboard content
+ if clip <> nil then
+ begin
+ InsertIntoInputStr(shortstring(clip));
+ SDL_free(Pointer(clip));
+ end;
end;
end;
@@ -826,8 +825,6 @@
LastKeyPressTick:= RealTicks;
action:= true;
- CheckPasteBuffer();
-
selMode:= (modifier and (KMOD_LSHIFT or KMOD_RSHIFT)) <> 0;
ctrl:= (modifier and (KMOD_LCTRL or KMOD_RCTRL)) <> 0;
ctrlonly:= ctrl and ((modifier and nonStateMask and (not (KMOD_LCTRL or KMOD_RCTRL))) = 0);
--- a/hedgewars/uIO.pas Tue Nov 10 20:43:13 2015 +0100
+++ b/hedgewars/uIO.pas Tue Nov 10 22:18:06 2015 +0100
@@ -163,7 +163,6 @@
ParseChatCommand('chatmsg ' + #4, s, 2)
else
isProcessed:= false;
- 'Y': ChatPasteBuffer:= copy(s, 2, Length(s) - 1);
else
isProcessed:= false;
end;
--- a/hedgewars/uVariables.pas Tue Nov 10 20:43:13 2015 +0100
+++ b/hedgewars/uVariables.pas Tue Nov 10 22:18:06 2015 +0100
@@ -244,8 +244,6 @@
MaxTextureSize: LongInt;
- ChatPasteBuffer: shortstring;
-
/////////////////////////////////////
//Buttons
{$IFDEF USE_TOUCH_INTERFACE}
@@ -2739,8 +2737,6 @@
cViewLimitsDebug:= false;
AprilOne := false;
- ChatPasteBuffer:= '';
-
// initialize pointers to nil
// (don't rely on implicit init of fpc, because that one only happens ONCE when used as lib)
CurAmmoGear:= nil;