hedgewars/uChat.pas
branchqmlfrontend
changeset 11704 83c40c1eb0e7
parent 11702 446ce60700dd
child 11781 f2031643fe98
equal deleted inserted replaced
11639:0af93f018701 11704:83c40c1eb0e7
  1009 end;
  1009 end;
  1010 
  1010 
  1011 procedure TextInput(var event: TSDL_TextInputEvent);
  1011 procedure TextInput(var event: TSDL_TextInputEvent);
  1012 var s: shortstring;
  1012 var s: shortstring;
  1013     l: byte;
  1013     l: byte;
       
  1014     isl: integer;
  1014 begin
  1015 begin
  1015     DeleteSelected();
  1016     DeleteSelected();
  1016 
  1017 
  1017     l:= 0;
  1018     l:= 0;
       
  1019     // fetch all bytes of character/input
  1018     while event.text[l] <> #0 do
  1020     while event.text[l] <> #0 do
  1019         begin
  1021         begin
  1020         s[l + 1]:= event.text[l];
  1022         s[l + 1]:= event.text[l];
  1021         inc(l)
  1023         inc(l)
  1022         end;
  1024         end;
  1023 
  1025 
  1024     if l > 0 then
  1026     if l > 0 then
  1025         begin
  1027         begin
  1026         if byte(InputStr.s[0]) + l > 240 then exit;
  1028         isl:= Length(InputStr.s);
  1027         s[0]:= char(l);
  1029         // check if user is typing a redundant closing hog-speech quotation mark
  1028         InsertIntoInputStr(s);
  1030         if (l = 1) and (isl >= 2) and (cursorPos = isl - 1) and charIsForHogSpeech(s[1])
       
  1031           and (s[1] = InputStr.s[1]) and (s[1] = InputStr.s[isl]) then
       
  1032             begin
       
  1033             MoveCursorToNextChar();
       
  1034             UpdateCursorCoords();
       
  1035             end
       
  1036         else
       
  1037             begin
       
  1038             // don't add input that doesn't fit
       
  1039             if isl + l > MaxInputStrLen then exit;
       
  1040             s[0]:= char(l);
       
  1041             InsertIntoInputStr(s);
       
  1042 
       
  1043             // add closing hog speech quotation marks automagically
       
  1044             if (l = 1) and (Length(InputStr.s) = 1) and charIsForHogSpeech(s[1]) then
       
  1045                 begin
       
  1046                 InsertIntoInputStr(s);
       
  1047                 MoveCursorToPreviousChar();
       
  1048                 UpdateCursorCoords();
       
  1049                 end;
       
  1050             end;
       
  1051 
  1029         end
  1052         end
  1030 end;
  1053 end;
  1031 
  1054 
  1032 
  1055 
  1033 procedure chChatMessage(var s: shortstring);
  1056 procedure chChatMessage(var s: shortstring);