hedgewars/uChat.pas
changeset 8743 0097855532f6
parent 8742 b7b8bd398c1b
child 8745 b3756c3f65e5
equal deleted inserted replaced
8742:b7b8bd398c1b 8743:0097855532f6
   308 var i, btw, index: integer;
   308 var i, btw, index: integer;
   309     utf8: shortstring;
   309     utf8: shortstring;
   310     action: boolean;
   310     action: boolean;
   311 begin
   311 begin
   312     action:= false;
   312     action:= false;
   313     if Sym <> 0 then
   313     case Sym of
   314         case Sym of
   314         SDLK_BACKSPACE:
   315             SDLK_BACKSPACE:
   315             begin
       
   316             action:= true;
       
   317             if Length(InputStr.s) > 0 then
   316                 begin
   318                 begin
   317                 action:= true;
   319                 InputStr.s[0]:= InputStrL[byte(InputStr.s[0])];
   318                 if Length(InputStr.s) > 0 then
   320                 SetLine(InputStr, InputStr.s, true)
   319                     begin
   321                 end
   320                     InputStr.s[0]:= InputStrL[byte(InputStr.s[0])];
   322             end;
   321                     SetLine(InputStr, InputStr.s, true)
   323         SDLK_ESCAPE: 
   322                     end
   324             begin
       
   325             action:= true;
       
   326             if Length(InputStr.s) > 0 then 
       
   327                 SetLine(InputStr, '', true)
       
   328             else CleanupInput
       
   329             end;
       
   330         SDLK_RETURN:
       
   331             begin
       
   332             action:= true;
       
   333             if Length(InputStr.s) > 0 then
       
   334                 begin
       
   335                 AcceptChatString(InputStr.s);
       
   336                 SetLine(InputStr, '', false)
   323                 end;
   337                 end;
   324             SDLK_ESCAPE: 
   338             CleanupInput
   325                 begin
   339             end;
   326                 action:= true;
   340         SDLK_UP, SDLK_DOWN:
   327                 if Length(InputStr.s) > 0 then 
   341             begin
   328                     SetLine(InputStr, '', true)
   342             action:= true;
   329                 else CleanupInput
   343             if (Sym = SDLK_UP) and (history < localLastStr) then inc(history);
   330                 end;
   344             if (Sym = SDLK_DOWN) and (history > 0) then dec(history);
   331             SDLK_RETURN:
   345             index:= localLastStr - history + 1;
   332                 begin
   346             if (index > localLastStr) then
   333                 action:= true;
   347                  SetLine(InputStr, '', true)
   334                 if Length(InputStr.s) > 0 then
   348             else SetLine(InputStr, LocalStrs[index], true)
   335                     begin
   349             end
   336                     AcceptChatString(InputStr.s);
       
   337                     SetLine(InputStr, '', false)
       
   338                     end;
       
   339                 CleanupInput
       
   340                 end;
       
   341             SDLK_UP, SDLK_DOWN:
       
   342                 begin
       
   343                 action:= true;
       
   344                 if (Sym = SDLK_UP) and (history < localLastStr) then inc(history);
       
   345                 if (Sym = SDLK_DOWN) and (history > 0) then dec(history);
       
   346                 index:= localLastStr - history + 1;
       
   347                 if (index > localLastStr) then
       
   348                      SetLine(InputStr, '', true)
       
   349                 else SetLine(InputStr, LocalStrs[index], true)
       
   350                 end
       
   351         end;
   350         end;
   352     if not action and (Key <> 0) then
   351     if not action and (Key <> 0) then
   353         begin
   352         begin
   354         if (Key < $80) then
   353         if (Key < $80) then
   355             btw:= 1
   354             btw:= 1