hedgewars/uConsole.pas
changeset 46 c99140d2355a
parent 39 b78e7185ed13
child 48 0f396d0c429d
equal deleted inserted replaced
45:1072e7fe85c8 46:c99140d2355a
   213 case c of
   213 case c of
   214      '$': WriteLnToConsole(errmsgUnknownVariable + ': "$' + CmdStr + '"')
   214      '$': WriteLnToConsole(errmsgUnknownVariable + ': "$' + CmdStr + '"')
   215      else WriteLnToConsole(errmsgUnknownCommand  + ': "/' + CmdStr + '"') end
   215      else WriteLnToConsole(errmsgUnknownCommand  + ': "/' + CmdStr + '"') end
   216 end;
   216 end;
   217 
   217 
       
   218 procedure AutoComplete;
       
   219 var t: PVariable;
       
   220     c: char;
       
   221 begin
       
   222 if InputStr[0] = #0 then exit;
       
   223 c:= InputStr[1];
       
   224 if c in ['/', '$'] then Delete(InputStr, 1, 1)
       
   225                    else c:= #0;
       
   226 if InputStr[byte(InputStr[0])] = #32 then dec(InputStr[0]);
       
   227 t:= Variables;
       
   228 while t <> nil do
       
   229       begin
       
   230       if (c=#0) or ((t.VType =  vtCommand) and (c='/'))or
       
   231                    ((t.VType <> vtCommand) and (c='$'))then
       
   232          if copy(t.Name, 1, Length(InputStr)) = InputStr then
       
   233             begin
       
   234             if t.VType = vtCommand then InputStr:= '/' + t.Name + ' '
       
   235                                    else InputStr:= '$' + t.Name + ' ';
       
   236             exit
       
   237             end;
       
   238       t:= t.Next
       
   239       end
       
   240 end;
       
   241 
   218 procedure KeyPressConsole(Key: Longword);
   242 procedure KeyPressConsole(Key: Longword);
   219 begin
   243 begin
   220 case Key of
   244 case Key of
   221       8: if Length(InputStr)>0 then dec(InputStr[0]);
   245       8: if Length(InputStr)>0 then dec(InputStr[0]);
       
   246       9: AutoComplete;
   222  13,271: begin
   247  13,271: begin
   223          ParseCommand('/say ' + InputStr);
   248          if InputStr[1] in ['/', '$'] then
       
   249             ParseCommand(InputStr)
       
   250          else
       
   251             ParseCommand('/say ' + InputStr);
   224          InputStr:= ''
   252          InputStr:= ''
   225          end;
   253          end;
   226      96: begin
   254      96: begin
   227          GameState:= gsGame;
   255          GameState:= gsGame;
   228          cConsoleYAdd:= 0;
   256          cConsoleYAdd:= 0;