hedgewars/uChat.pas
changeset 10850 c76ea22ea249
parent 10849 a772d342066a
child 10851 f25dad9c3136
--- 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;