hedgewars/uConsole.pas
changeset 377 d9b88dbdf5a9
parent 371 731ad6d27bd1
child 393 db01cc79f278
equal deleted inserted replaced
376:b5175878dc11 377:d9b88dbdf5a9
   232       t:= t^.Next
   232       t:= t^.Next
   233       end
   233       end
   234 end;
   234 end;
   235 
   235 
   236 procedure KeyPressConsole(Key: Longword);
   236 procedure KeyPressConsole(Key: Longword);
   237 begin
   237 const firstByteMark: array[1..4] of byte = (0, $C0, $E0, $F0);
   238 case Key of
   238 var i, btw: integer;
       
   239     utf8: shortstring;
       
   240 begin
       
   241 if Key <> 0 then
       
   242   case Key of
   239       8: if Length(InputStr)>0 then dec(InputStr[0]);
   243       8: if Length(InputStr)>0 then dec(InputStr[0]);
   240       9: AutoComplete;
   244       9: AutoComplete;
   241  13,271: begin
   245  13,271: begin
   242          if InputStr[1] in ['/', '$'] then
   246          if InputStr[1] in ['/', '$'] then
   243             ParseCommand(InputStr, false)
   247             ParseCommand(InputStr, false)
   248      96: begin
   252      96: begin
   249          GameState:= gsGame;
   253          GameState:= gsGame;
   250          cConsoleYAdd:= 0;
   254          cConsoleYAdd:= 0;
   251          ResetKbd
   255          ResetKbd
   252          end;
   256          end;
   253      else InputStr:= InputStr + char(Key)
   257      else
       
   258      if (Key < $80) then btw:= 1
       
   259      else if (Key < $800) then btw:= 2
       
   260      else if (Key < $10000) then btw:= 3
       
   261      else btw:= 4;
       
   262      utf8:= '';
       
   263      for i:= btw downto 2 do
       
   264          begin
       
   265          utf8:= char((Key or $80) and $BF) + utf8;
       
   266          Key:= Key shr 6
       
   267          end;
       
   268      utf8:= char(Key or firstByteMark[btw]) + utf8;
       
   269      InputStr:= InputStr + utf8
   254      end
   270      end
   255 end;
   271 end;
   256 
   272 
   257 function GetLastConsoleLine: shortstring;
   273 function GetLastConsoleLine: shortstring;
   258 begin
   274 begin