--- a/hedgewars/uChat.pas Tue Mar 29 22:36:59 2016 +0300
+++ b/hedgewars/uChat.pas Mon Apr 25 22:10:06 2016 +0300
@@ -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,9 +1025,30 @@
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 automagically
+ if (l = 1) and (Length(InputStr.s) = 1) and charIsForHogSpeech(s[1]) then
+ begin
+ InsertIntoInputStr(s);
+ MoveCursorToPreviousChar();
+ UpdateCursorCoords();
+ end;
+ end;
+
end
end;