diff -r ed5a6478e710 -r 9006e158a81f hedgewars/uChat.pas --- 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);