Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5180 in orxonox.OLD for trunk/src/lib/shell/shell.cc


Ignore:
Timestamp:
Sep 13, 2005, 11:45:51 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Shell Input is totally out of shell.cc/h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/shell/shell.cc

    r5179 r5180  
    5858  // INPUT LINE
    5959  this->shellInput = new ShellInput;
    60   this->delayed = 0;
    61   this->shellInput->setRepeatDelay(.3, .05);
    6260  //this->commandList = new tList<ShellCommand>;
    6361
     
    6563  this->completionList = NULL;
    6664
    67   // EVENT-Handler subscription of '`' to all States, and all other keyboard commands to ES_SEHLL
    68   EventHandler* evh = EventHandler::getInstance();
    69   evh->subscribe(this, ES_ALL, SDLK_BACKQUOTE);
    70   for (int i = 1; i < SDLK_LAST; i++)
    71     evh->subscribe(this, ES_SHELL, i);
     65  // EVENT-Handler subscription of '`' to all States.
     66  EventHandler::getInstance()->subscribe(this, ES_ALL, SDLK_BACKQUOTE);
     67
    7268}
    7369
     
    8581
    8682  // delete the inputLine
     83  delete this->shellInput;
    8784
    8885  Shell::singletonRef = NULL;
     
    250247  if (event.bPressed)
    251248  {
    252     PRINTF(5)("Shell received command %s\n", SDLKToKeyname(event.type));
    253249    if (event.type == SDLK_BACKQUOTE)
    254250    {
     
    258254        this->deactivate();
    259255    }
    260     else if (event.type == SDLK_F1)
    261       this->help();
    262     else if (event.type == SDLK_F2)
    263       this->debug();
    264     else if (event.type == SDLK_TAB)
    265       ;//this->autoComplete();
    266     else if (event.type == SDLK_BACKSPACE)
    267     {
    268       this->delayed = this->repeatDelay;
    269       this->pressedKey = SDLK_BACKSPACE;
    270       this->shellInput->removeCharacters(1);
    271     }
    272     else if (event.type == SDLK_RETURN)
    273       this->shellInput->executeCommand();
    274     /*
    275     else if (event.type == SDLK_UP)
    276     {
    277 //      this->flushInputLine();
    278       tIterator<char>* iterator = this->commandList->getIterator();
    279       char* command = iterator->lastElement();
    280       while (command)
    281       {
    282         if (!strcmp (command, inputLine))
    283         {
    284           inputLine = iterator->prevElement();
    285           return;
    286         }
    287         command = iterator->prevElement();
    288       }
    289       inputLine = iterator->lastElement();
    290     }
    291     */
    292     else if (likely(event.type < 127))
    293     {
    294       Uint8 *keystate = SDL_GetKeyState(NULL);
    295       this->delayed = this->repeatDelay;
    296       if (unlikely( keystate[SDLK_LSHIFT] || keystate[SDLK_RSHIFT] ))
    297       {
    298         this->pressedKey = event.type-32;
    299         this->shellInput->addCharacter(event.type-32);
    300       }
    301       else
    302       {
    303         this->pressedKey = event.type;
    304         this->shellInput->addCharacter(event.type);
    305       }
    306     }
    307256  }
    308   else // if(!event.bPressed)
    309   {
    310     if (this->pressedKey == event.type || (this->pressedKey == event.type - 32))
    311     {
    312       this->pressedKey = SDLK_FIRST;
    313       this->delayed = 0.0;
    314     }
    315   }
    316 }
    317 
    318 /**
    319  * ticks the Shell for dt Seconds
    320  * @param dt the elapsed time since the last tick();
    321  */
    322 void Shell::tick(float dt)
    323 {
    324   if (this->delayed > 0.0)
    325     this->delayed -= dt;
    326   else if (this->pressedKey != SDLK_FIRST )
    327   {
    328     this->delayed = this->repeatRate;
    329     if (this->pressedKey == SDLK_BACKSPACE)
    330       this->shellInput->removeCharacters(1);
    331     else if (pressedKey < 127)
    332       this->shellInput->addCharacter(this->pressedKey);
    333   }
    334 }
     257}
     258
    335259/**
    336260 * displays the Shell
     
    365289}
    366290
    367 /**
    368  * prints out some nice help about the Shell
    369  */
    370 void Shell::help() const
    371 {
    372   PRINT(0)("Help for the most important Shell-commands\n");
    373   PRINT(0)("F1 - HELP; F2 - DEBUG; ` - open/close shell\n");
    374   PRINT(0)("input order:\n");
    375   PRINT(0)("ClassName::objectName function [parameter1, [parameter2 ...]]  or\n");
    376   PRINT(0)("Command [parameter]\n");
    377 }
    378 
    379 
    380291///////////////////////
    381292// HELPER FUNCTIONS  //
     
    401312  PRINT(3)("Debugging output to console (not this shell)\n");
    402313
    403   if (this->pressedKey != SDLK_FIRST)
    404     printf("%s::%f %f\n", SDLKToKeyname(this->pressedKey), this->delayed, this->repeatDelay);
     314//   if (this->pressedKey != SDLK_FIRST)
     315//     printf("%s::%f %f\n", SDLKToKeyname(this->pressedKey), this->delayed, this->repeatDelay);
    405316
    406317
Note: See TracChangeset for help on using the changeset viewer.