# HG changeset patch # User sheepluva # Date 1461530484 -7200 # Node ID 446ce60700dd5763fc4bd92537f4d3d8b905ec9e # Parent fa4bc078e509ee940670fda9957320989858adce some more dark magic regarding hog speech input diff -r fa4bc078e509 -r 446ce60700dd hedgewars/uChat.pas --- a/hedgewars/uChat.pas Sun Apr 24 22:10:37 2016 +0200 +++ b/hedgewars/uChat.pas Sun Apr 24 22:41:24 2016 +0200 @@ -1011,10 +1011,12 @@ procedure TextInput(var event: TSDL_TextInputEvent); var s: shortstring; l: byte; + isl: integer; begin DeleteSelected(); l:= 0; + // fetch all bytes of character/input while event.text[l] <> #0 do begin s[l + 1]:= event.text[l]; @@ -1023,16 +1025,28 @@ if l > 0 then begin - if byte(InputStr.s[0]) + l > 240 then exit; - s[0]:= char(l); - InsertIntoInputStr(s); + isl:= Length(InputStr.s); + // check if user is typing a redundant closing hog-speech quotation mark + if (l = 1) and (isl >= 2) and (cursorPos = isl - 1) and charIsForHogSpeech(s[1]) + and (s[1] = InputStr.s[1]) and (s[1] = InputStr.s[isl]) then + begin + MoveCursorToNextChar(); + UpdateCursorCoords(); + end + else + begin + // don't add input that doesn't fit + if isl + l > MaxInputStrLen then exit; + s[0]:= char(l); + InsertIntoInputStr(s); - // add closing hog speech quotation marks automatically - if (l = 1) and (Length(InputStr.s) = 1) and charIsForHogSpeech(s[1]) then - begin - InsertIntoInputStr(s); - MoveCursorToPreviousChar(); - UpdateCursorCoords(); + // add closing hog speech quotation marks automagically + if (l = 1) and (Length(InputStr.s) = 1) and charIsForHogSpeech(s[1]) then + begin + InsertIntoInputStr(s); + MoveCursorToPreviousChar(); + UpdateCursorCoords(); + end; end; end