hedgewars/uChat.pas
changeset 10835 8ac09cd322b7
parent 10834 2e83f33dfe5b
child 10836 0b415bc2e0eb
equal deleted inserted replaced
10834:2e83f33dfe5b 10835:8ac09cd322b7
    43     s: shortstring;
    43     s: shortstring;
    44     Color: TSDL_Color;
    44     Color: TSDL_Color;
    45     end;
    45     end;
    46     TChatCmd = (ccQuit, ccPause, ccFinish, ccShowHistory, ccFullScreen);
    46     TChatCmd = (ccQuit, ccPause, ccFinish, ccShowHistory, ccFullScreen);
    47 
    47 
       
    48 type TInputStrL = array[0..260] of byte;
       
    49 
    48 var Strs: array[0 .. MaxStrIndex] of TChatLine;
    50 var Strs: array[0 .. MaxStrIndex] of TChatLine;
    49     MStrs: array[0 .. MaxStrIndex] of shortstring;
    51     MStrs: array[0 .. MaxStrIndex] of shortstring;
    50     LocalStrs: array[0 .. MaxStrIndex] of shortstring;
    52     LocalStrs: array[0 .. MaxStrIndex] of shortstring;
       
    53     LocalStrsL: array[0 .. MaxStrIndex] of TInputStrL;
    51     missedCount: LongWord;
    54     missedCount: LongWord;
    52     lastStr: LongWord;
    55     lastStr: LongWord;
    53     localLastStr: LongInt;
    56     localLastStr: LongInt;
    54     history: LongInt;
    57     history: LongInt;
    55     visibleCount: LongWord;
    58     visibleCount: LongWord;
    56     InputStr: TChatLine;
    59     InputStr: TChatLine;
    57     InputStrL: array[0..260] of byte; // for full str + 4-byte utf-8 char
    60     InputStrL: TInputStrL; // for full str + 4-byte utf-8 char
    58     ChatReady: boolean;
    61     ChatReady: boolean;
    59     showAll: boolean;
    62     showAll: boolean;
    60     liveLua: boolean;
    63     liveLua: boolean;
    61     ChatHidden: boolean;
    64     ChatHidden: boolean;
    62     InputLinePrefix: shortstring;
    65     InputLinePrefix: shortstring;
   300 if s <> LocalStrs[localLastStr] then
   303 if s <> LocalStrs[localLastStr] then
   301     begin
   304     begin
   302     // put in input history
   305     // put in input history
   303     localLastStr:= (localLastStr + 1) mod MaxStrIndex;
   306     localLastStr:= (localLastStr + 1) mod MaxStrIndex;
   304     LocalStrs[localLastStr]:= s;
   307     LocalStrs[localLastStr]:= s;
       
   308     LocalStrsL[localLastStr]:= InputStrL;
   305     end;
   309     end;
   306 
   310 
   307 t:= LocalTeam;
   311 t:= LocalTeam;
   308 x:= 0;
   312 x:= 0;
   309 if (s[1] = '"') and (s[Length(s)] = '"')
   313 if (s[1] = '"') and (s[Length(s)] = '"')
   554             begin
   558             begin
   555             if (Sym = SDLK_UP) and (history < localLastStr) then inc(history);
   559             if (Sym = SDLK_UP) and (history < localLastStr) then inc(history);
   556             if (Sym = SDLK_DOWN) and (history > 0) then dec(history);
   560             if (Sym = SDLK_DOWN) and (history > 0) then dec(history);
   557             index:= localLastStr - history + 1;
   561             index:= localLastStr - history + 1;
   558             if (index > localLastStr) then
   562             if (index > localLastStr) then
   559                  SetLine(InputStr, '', true)
   563                 begin
   560             else SetLine(InputStr, LocalStrs[index], true);
   564                 SetLine(InputStr, '', true);
       
   565                 FillChar(InputStrL, sizeof(InputStrL), InputStrLNoPred);
       
   566                 end
       
   567             else
       
   568                 begin
       
   569                 SetLine(InputStr, LocalStrs[index], true);
       
   570                 InputStrL:= LocalStrsL[index];
       
   571                 end;
   561             // TODO rebuild/restore InputStrL!!
   572             // TODO rebuild/restore InputStrL!!
   562             cursorPos:= Length(InputStr.s);
   573             cursorPos:= Length(InputStr.s);
   563             UpdateCursorCoords();
   574             UpdateCursorCoords();
   564             end;
   575             end;
   565         SDLK_HOME:
   576         SDLK_HOME: