Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/util/shell.cc @ 5123

Last change on this file since 5123 was 5123, checked in by bensch, 19 years ago

orxonox/trunk: patches, to make TextEngine more intuitive

File size: 20.0 KB
RevLine 
[4744]1/*
[1853]2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
[1855]10
11   ### File Specific:
[5068]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[3955]16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
[1853]17
[5068]18#include "shell.h"
[1853]19
[5072]20#include "text_engine.h"
21#include "list.h"
[5093]22#include "graphics_engine.h"
23#include "event_handler.h"
[5072]24
[5100]25#include "load_param.h"
[5113]26#include "class_list.h"
27
28#include "key_names.h"
[5093]29#include "debug.h"
[5075]30#include <stdarg.h>
31#include <stdio.h>
32
[1856]33using namespace std;
[1853]34
[1856]35
[3245]36/**
[4838]37 * standard constructor
[5068]38 */
39Shell::Shell ()
[3365]40{
[5072]41  this->setClassID(CL_SHELL, "Shell");
42  this->setName("Shell");
43
[5113]44  this->shellHeight = 400;
45  this->bActive = false;
[5072]46  this->buffer = new tList<char>;
[5118]47  this->bufferIterator = this->buffer->getIterator();
[5072]48
[5113]49  this->textSize = 15;
50  this->lineSpacing = 5;
[5080]51
[5074]52  //this->bufferSize = 0;
[5080]53  this->bufferText = NULL;
[5072]54  this->setBufferSize(100);
[5113]55  this->bufferDisplaySize = 10;
56  this->setAbsCoor2D(3, -400);
[5095]57  this->delayed = 0;
[5097]58  this->setRepeatDelay(.3, .05);
[5095]59  this->pressedKey = SDLK_FIRST;
[5074]60
[5113]61  this->inputLineText = NULL;
[5093]62  this->inputLine = new char[1];
63  this->inputLine[0] = '\0';
64
[5113]65  this->rebuildText();
66  this->completionList = NULL;
[5093]67
[5113]68  // EVENT-Handler subscription of '`' to all States, and all other keyboard commands to ES_SEHLL
[5093]69  EventHandler* evh = EventHandler::getInstance();
[5096]70  evh->subscribe(this, ES_ALL, SDLK_BACKQUOTE);
[5119]71  for (int i = 1; i < SDLK_LAST; i++)
[5095]72    evh->subscribe(this, ES_SHELL, i);
[5068]73}
[4320]74
[5068]75Shell* Shell::singletonRef = NULL;
[1853]76
[3245]77/**
[4838]78 * standard deconstructor
[5068]79 */
80Shell::~Shell ()
[3543]81{
[5099]82  // delete the displayable Buffers
[5080]83  for (int i = 0; i < this->bufferDisplaySize; i++)
84    delete this->bufferText[i];
[5113]85  delete[] this->bufferText;
[5093]86
[5099]87  // delete the inputLine
[5080]88  delete this->inputLineText;
[5093]89  delete this->inputLine;
[5079]90
[5099]91  // delete all the Chars in the Buffers
[5118]92  char* charElem = this->bufferIterator->firstElement();
[5099]93  while (charElem != NULL)
94  {
95    delete charElem;
[5118]96    charElem = this->bufferIterator->nextElement();
[5099]97  }
[5118]98  delete this->bufferIterator;
[5099]99
[5113]100//  if (this->completionList != NULL)
101    //delete this->completionList;
102
[5068]103  Shell::singletonRef = NULL;
[3543]104}
[5068]105
[5113]106
[5119]107/**
108 * activates the shell
109 *
110 * This also feeds the Last few lines from the main buffers into the displayBuffer
111 */
[5113]112void Shell::activate()
113{
114  if (this->bActive == true)
115    PRINTF(3)("The shell is already active\n");
116  this->bActive = true;
117
118  EventHandler::getInstance()->setState(ES_SHELL);
119  this->setRelCoorSoft2D(0, 0, 1, 5);
[5118]120
121  this->bufferIterator->lastElement();
122  for (int i = 0; i < this->bufferDisplaySize; i++)
123    this->bufferText[i]->setText(this->bufferIterator->prevElement());
[5113]124}
125
[5119]126/**
127 * deactiveates the Shell.
128 */
[5113]129void Shell::deactivate()
130{
131  if (this->bActive == false)
132    PRINTF(3)("The shell is already inactive\n");
133  this->bActive = false;
134
135  EventHandler::getInstance()->setState(ES_GAME);
136  this->setRelCoorSoft2D(0, -400, 1, 5);
[5118]137
[5113]138}
139
[5119]140/**
141 * sets the size of the text and spacing
142 * @param textSize the size of the Text in Pixels
143 * @param lineSpacing the size of the Spacing between two lines in pixels
144 *
145 * this also rebuilds the entire Text, inputLine and displayBuffer,
146 * to be accurate again.
147 */
[5113]148void Shell::setTextSize(unsigned int textSize, unsigned int lineSpacing)
149{
150  this->textSize = textSize;
151  this->lineSpacing = lineSpacing;
152
153  this->rebuildText();
154}
155
156void Shell::rebuildText()
157{
158  if (this->inputLineText == NULL)
159    delete this->inputLineText;
[5122]160  this->inputLineText = TextEngine::getInstance()->createText("fonts/Aniron_Bold.ttf", this->textSize, TEXT_RENDER_DYNAMIC);
[5121]161  this->inputLineText->setColor(1, 0, 0);
[5113]162  this->inputLineText->setAlignment(TEXT_ALIGN_LEFT);
163  this->inputLineText->setText(NULL);
164  this->inputLineText->setParent2D(this);
165  this->inputLineText->setRelCoor2D(5, (this->textSize + this->lineSpacing)*this->bufferDisplaySize);
166
167  this->setBufferDisplaySize(this->bufferDisplaySize);
168}
169
[5074]170/**
171 * sets The count of Lines to display in the buffer.
172 * @param bufferDisplaySize the count of lines to display in the Shell-Buffer.
173 */
[5072]174void Shell::setBufferDisplaySize(unsigned int bufferDisplaySize)
175{
[5080]176  if (this->bufferText != NULL)
[5072]177  {
[5080]178    for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
179      delete this->bufferText[i];
[5113]180    delete[] this->bufferText;
[5072]181  }
[5080]182
183  this->bufferText = new Text*[bufferDisplaySize];
184  for (unsigned int i = 0; i < bufferDisplaySize; i++)
[5072]185  {
[5122]186    this->bufferText[i] = TextEngine::getInstance()->createText("fonts/Aniron_Bold.ttf", this->textSize, TEXT_RENDER_DYNAMIC);
[5121]187    this->bufferText[i]->setColor(1, 0, 0);
[5080]188    this->bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);
[5120]189    this->bufferText[i]->setRelCoor2D(calculateLinePosition(i));
[5080]190    this->bufferText[i]->setText(NULL);
[5089]191    this->bufferText[i]->setParent2D(this);
[5072]192  }
[5113]193  this->bufferDisplaySize = bufferDisplaySize;
[5111]194
[5113]195  this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
[5072]196}
[5068]197
198/**
199 * deletes all the Buffers
200 */
201void Shell::flushBuffers()
202{
[5072]203  // remove all chars from the BufferTexts.
[5080]204  if (this->bufferText)
205    for (int i; i < this->bufferDisplaySize; i++)
206    {
207      this->bufferText[i]->setText(NULL);
208    }
[5068]209
[5072]210
211  // delete all the Chars in the Buffers
212  tIterator<char>* charIterator = this->buffer->getIterator();
[5115]213  char* charElem = charIterator->firstElement();
[5072]214
215  while (charElem != NULL)
216  {
217    delete charElem;
218
219    charElem = charIterator->nextElement();
220  }
221  delete charIterator;
[5068]222}
223
224/**
225 * adds a new Line to the List of Buffers
226 * @param line the Line as in the first argument in printf
227 * @param args the arguments as a va_list
228 */
[5075]229bool Shell::addBufferLineStatic(const char* line, ...)
[5068]230{
[5075]231  va_list arguments;
232  va_start(arguments, line);
[5072]233
[5092]234#if DEBUG < 3
[5075]235  if (Shell::singletonRef == NULL)
[5089]236#endif
237
238  vprintf(line, arguments);
[5092]239#if DEBUG < 3
[5075]240  else
[5092]241#else
242  if (Shell::singletonRef != NULL)
[5089]243#endif
[5075]244    Shell::singletonRef->addBufferLine(line, arguments);
245  return true;
246}
[5072]247
[5080]248/**
249 * add a Line to the List of Buffers
250 * @param line
251 * @param arguments
252 *
253 * This function Adds one line to the buffer.
254 * and displays the line as the First Line of the display-buffer
255 */
[5075]256void Shell::addBufferLine(const char* line, va_list arguments)
257{
[5078]258   vsprintf(this->bufferArray, line, arguments);
[5072]259
[5078]260   char* newLine = new char[strlen(this->bufferArray)+1];
261   strcpy(newLine, this->bufferArray);
[5073]262
[5080]263   this->buffer->add(newLine);
[5075]264
[5080]265   if (this->buffer->getSize() > this->bufferSize)
266   {
267     delete this->buffer->firstElement();
268     this->buffer->remove(this->buffer->firstElement());
269   }
270
[5118]271   if (this->bActive)
[5080]272   {
[5118]273     this->printToDisplayBuffer(newLine);
274   }
275}
[5113]276
[5118]277/**
278 * prints out some text to the input-buffers
279 * @param text the text to output.
280 */
281void Shell::printToDisplayBuffer(const char* text)
282{
283  if(likely(bufferText != NULL))
284  {
285    Text* lastText = this->bufferText[this->bufferDisplaySize-1];
[5113]286
[5118]287    Text* swapText;
288    Text* moveText = this->bufferText[0];
[5120]289    this->bufferText[0]->setRelCoorSoft2D(this->calculateLinePosition(1),10);
[5118]290    for (unsigned int i = 1; i < this->bufferDisplaySize; i++)
291    {
292      if ( i < this->bufferDisplaySize-1)
[5120]293        this->bufferText[i]->setRelCoorSoft2D(this->calculateLinePosition(i+1),5);
[5118]294      swapText = this->bufferText[i];
295      this  ->bufferText[i] = moveText;
296      moveText = swapText;
297    }
[5120]298    lastText->setRelCoor2D(this->calculateLinePosition(0));
[5118]299    this->bufferText[0] = lastText;
300
[5122]301    this->bufferText[0]->setText(text, true);
[5118]302  }
[5068]303}
304
305/**
306 * moves the buffer around lineCount lines upwards (negative values move down)
307 * @param lineCount the Count of lines to move upwards
[5072]308 *
309 * @todo
[5068]310 */
311void Shell::moveBuffer(int lineCount)
312{
313}
314
315/**
316 * @param lineNumber the n-th line from the bottom
317 * @returns the Buffer at Line lineNumber
318 */
319const char* Shell::getBufferLine(unsigned int lineNumber)
320{
[5072]321  tIterator<char>* charIterator = this->buffer->getIterator();
[5115]322  char* charElem = charIterator->firstElement();
[5072]323
324  int i = 1;
325  while (charElem != NULL)
326  {
327    if (i++ < lineNumber)
328    {
329      delete charIterator;
330      return charElem;
331    }
332
333    charElem = charIterator->nextElement();
334  }
335  delete charIterator;
[5068]336}
337
338/**
339 * deletes the InputLine
340 */
341void Shell::flushInputLine()
342{
[5072]343  if (likely(this->inputLine != NULL))
344  {
345    delete [] this->inputLine;
346  }
347  this->inputLine = new char[1];
348  *this->inputLine = '\0';
[5068]349}
350
351/**
352 * adds one character to the inputLine
353 * @param character the character to add to the inputLine
354 */
355void Shell::addCharacter(char character)
356{
[5072]357  char* addCharLine = new char[strlen(inputLine)+2];
358
359  sprintf(addCharLine, "%s%c", this->inputLine, character);
360  delete this->inputLine;
361  this->inputLine = addCharLine;
[5123]362  this->inputLineText->setText(inputLine, true);
[5068]363}
364
365/**
366 * adds multiple Characters to thr inputLine
367 * @param characters a '\0' terminated char-array to add to the InputLine
368 */
369void Shell::addCharacters(const char* characters)
370{
[5072]371  char* addCharLine = new char[strlen(inputLine)+strlen(characters)+1];
372
373  sprintf(addCharLine, "%s%s", this->inputLine, characters);
374  delete this->inputLine;
375  this->inputLine = addCharLine;
[5093]376  this->inputLineText->setText(inputLine);
[5068]377}
378
379/**
380 * removes characterCount characters from the InputLine
381 * @param characterCount the count of Characters to remove from the input Line
382 */
383void Shell::removeCharacters(unsigned int characterCount)
384{
[5093]385  if (strlen(this->inputLine) == 0)
386    return;
387
[5072]388  if (characterCount > strlen(this->inputLine))
389    characterCount = strlen(this->inputLine);
390
391  char* removeCharLine = new char[strlen(inputLine)-characterCount+1];
392
393  strncpy(removeCharLine, this->inputLine, strlen(inputLine)-characterCount);
[5093]394  removeCharLine[strlen(inputLine)-characterCount] = '\0';
[5072]395  delete this->inputLine;
396  this->inputLine = removeCharLine;
[5093]397  this->inputLineText->setText(inputLine);
[5068]398}
399
[5096]400/**
401 * executes the command stored in the inputLine
402 * @return true if the command was commited successfully, false otherwise
403 */
404bool Shell::executeCommand()
405{
406  this->addBufferLineStatic("Execute Command: %s\n", this->inputLine);
407  delete this->inputLine;
408  this->inputLine = new char[1];
409  this->inputLine[0]='\0';
410  this->inputLineText->setText(this->inputLine);
411  return false;
412}
413
[5097]414/**
415 * sets the Repeate-delay and rate
416 * @param repeatDelay the Delay it takes, to repeate a key
417 * @param repeatRate the rate to repeate a pressed key
418 */
419void Shell::setRepeatDelay(float repeatDelay, float repeatRate)
420{
421  this->repeatDelay = repeatDelay;
422  this->repeatRate = repeatRate;
423
424}
425
[5069]426/**
427 * listens for some event
428 * @param event the Event happened
429 */
430void Shell::process(const Event &event)
431{
[5093]432  if (event.bPressed)
433  {
434    PRINTF(4)("Shell received command %s\n", SDLKToKeyname(event.type));
435    if (event.type == SDLK_BACKQUOTE)
436    {
437      if (EventHandler::getInstance()->getState() == ES_GAME)
[5113]438        this->activate();
[5093]439      else
[5113]440        this->deactivate();
[5093]441    }
[5119]442    else if (event.type == SDLK_F1)
443      this->help();
444    else if (event.type == SDLK_F2)
445      this->debug();
[5093]446    else if (event.type == SDLK_TAB)
447      this->autoComplete();
448    else if (event.type == SDLK_BACKSPACE)
[5095]449    {
450      this->delayed = this->repeatDelay;
451      this->pressedKey = SDLK_BACKSPACE;
[5093]452      this->removeCharacters(1);
[5095]453    }
[5096]454    else if (event.type == SDLK_RETURN)
455      this->executeCommand();
[5097]456    else if (likely(event.type < 127))
[5095]457    {
458      this->delayed = this->repeatDelay;
459      this->pressedKey = event.type;
[5093]460      this->addCharacter(event.type);
[5095]461    }
[5093]462  }
[5095]463  else // if(!event.bPressed)
464  {
465    if (this->pressedKey == event.type)
[5113]466    {
[5095]467      this->pressedKey = SDLK_FIRST;
[5113]468      this->delayed = 0.0;
469    }
[5095]470  }
[5069]471}
472
[5068]473/**
474 * ticks the Shell for dt Seconds
475 * @param dt the elapsed time since the last tick();
476 */
[5095]477void Shell::tick(float dt)
478{
479  if (this->delayed > 0.0)
480    this->delayed -= dt;
481  else if (this->pressedKey != SDLK_FIRST )
482  {
[5097]483    this->delayed = this->repeatRate;
[5095]484    if (this->pressedKey == SDLK_BACKSPACE)
485      this->removeCharacters(1);
486    else if (pressedKey < 127)
487      this->addCharacter(this->pressedKey);
488  }
489}
[5068]490
491/**
492 * displays the Shell
493 */
494void Shell::draw() const
495{
[5099]496  glPushMatrix();
497  // transform for alignment.
498  // setting the Blending effects
499
500  glColor4f(0.0f, 0.0f, 0.8f, .4);
501  glEnable(GL_BLEND);
502  glDisable(GL_TEXTURE_2D);
503  glBlendFunc(GL_SRC_ALPHA, GL_ONE);
504
505//  glBindTexture(GL_TEXTURE_2D, this->texture);
506  glBegin(GL_QUADS);
507
508//  glTexCoord2f(this->texCoord.minU, this->texCoord.minV);
509  glVertex2f(this->getAbsCoor2D().x,   this->getAbsCoor2D().);
510
511//  glTexCoord2f(this->texCoord.maxU, this->texCoord.minV);
[5113]512  glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().);
[5099]513
514//  glTexCoord2f(this->texCoord.maxU, this->texCoord.maxV);
[5113]515  glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight);
[5099]516
517//  glTexCoord2f(this->texCoord.minU, this->texCoord.maxV);
[5113]518  glVertex2f(this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight);
[5099]519
520  glEnd();
[5068]521}
522
523
524/**
525 * autocompletes the Shell's inputLine
526 * @returns true, if a result was found, false otherwise
[5100]527 *
528 * @todo implement it!!
[5068]529 */
530bool Shell::autoComplete()
531{
[5100]532  //PRINTF(3)("AutoCompletion not implemented yet\n");
533
534  char* completionLine = new char[strlen(inputLine)+1];
535  strcpy(completionLine, this->inputLine);
536
[5113]537  char* commandBegin = strrchr(completionLine, ' ');
[5100]538  if (commandBegin == NULL)
539    commandBegin = completionLine;
540  else
541  {
542    if(commandBegin >= completionLine + strlen(completionLine))
543      commandBegin = completionLine + strlen(completionLine);
544    else
545      commandBegin++;
546  }
547
[5113]548  char* objectStart;
549  if (objectStart = strstr(commandBegin, "::"))
550  {
551    char* classIdentity = new char[objectStart - commandBegin +1];
552    strncpy(classIdentity, commandBegin, objectStart - commandBegin);
553    classIdentity[objectStart - commandBegin] = '\0';
554    this->objectComplete(objectStart+2, ClassList::StringToID(classIdentity));
555    delete[] classIdentity;
556  }
557  else
558    this->classComplete(commandBegin);
[5102]559
[5113]560  delete[] completionLine;
561}
[5102]562
[5113]563/**
564 * autocompletes a className
565 * @param classBegin the Beginning of a String to autoComplete
566 * @return true on success, false otherwise
567 */
568bool Shell::classComplete(const char* classBegin)
569{
570  if (unlikely(classBegin == NULL))
571    return false;
572  const tList<const char>* clList = ClassList::getClassList();
573  if (clList != NULL)
574  {
575    const tList<const char>* classList = this->createCompleteList(clList, classBegin);
576    if (classList != NULL)
577      this->generalComplete(classList, classBegin, "%s::", "::");
578    else
579      return false;
580  }
581  else
582    return false;
583  return true;
[5105]584}
585
586/**
[5113]587 * autocompletes an ObjectName
588 * @param objectBegin the beginning string of a Object
589 * @param classID the ID of the Class to search for.
590 * @return true on success, false otherwise
591 */
592bool Shell::objectComplete(const char* objectBegin, long classID)
593{
594  printf("%s\n", objectBegin);
595
596  if (unlikely(objectBegin == NULL))
597    return false;
598  tList<BaseObject>* boList = ClassList::getList(classID);
599  if (boList != NULL)
600  {
601    printf("\n", boList->firstElement()->getName());
602    const tList<const char>* objectList = this->createCompleteList(boList, objectBegin);
603    if (objectList != NULL)
604      this->generalComplete(objectList, objectBegin, "%s");
605    else
606      return false;
607  }
608  else
609    return false;
610  return true;
611}
612
613bool Shell::functionComplete(const char* functionBegin)
614{
615}
616
617/**
618 * completes the inputline on grounds of an inputList
619 * @param stringList the List to parse through
620 * @param begin the String to search in the inputList, and to extend with it.
621 * @param displayAs how to display the found value to the user, printf-style, !!with only one %s!! ex.: "::%s::"
622 * @param addBack what should be added at the end of the completion
623 * @param addFront what should be added to the front of one finished completion
624 * @return true if ok, false otherwise
625 */
626bool Shell::generalComplete(const tList<const char>* stringList, const char* begin, const char* displayAs, const char* addBack, const char* addFront)
627{
628  if (stringList->getSize() == 0)
629    return false;
630
631  const char* addString = stringList->firstElement();
632  unsigned int addLength = 0;
633  unsigned int inputLenght = strlen(begin);
634
635  if (addString != NULL)
636    addLength = strlen(addString);
637  tIterator<const char>* charIterator = stringList->getIterator();
[5115]638  const char* charElem = charIterator->firstElement();
[5113]639  while (charElem != NULL)
640  {
641    PRINTF(0)(displayAs, charElem);
642    for (unsigned int i = inputLenght; i < addLength; i++)
643      if (addString[i] != charElem[i])
644    {
645      addLength = i;
646      break;
647    }
648    charElem = charIterator->nextElement();
649  }
650  delete charIterator;
651
652  if (addLength >= inputLenght)
653  {
654    char* adder = new char[addLength+1];
655    strncpy(adder, addString, addLength);
656    adder[addLength] = '\0';
657    this->removeCharacters(inputLenght);
658    this->addCharacters(adder);
659    if (addBack != NULL && stringList->getSize() == 1)
660      this->addCharacters("::");
661    delete[] adder;
662  }
663  return true;
664}
665
666/**
667 * searches for classes, which beginn with classNameBegin
668 * @param inputList the List to parse through
669 * @param classNameBegin the beginning string
670 * @return a NEW char-array with ClassNames. The LIST should be deleted afterwards,
671 * !! The strings MUST NOT be deleted !!
672 */
673const tList<const char>* Shell::createCompleteList(const tList<const char>* inputList, const char* classNameBegin)
674{
675  if (inputList == NULL || classNameBegin == NULL)
676    return NULL;
677  unsigned int searchLength = strlen(classNameBegin);
678  if (this->completionList != NULL)
679    delete this->completionList;
680  this->completionList = new tList<const char>;
681
682//  tList<const char>* classList = ClassList::getClassList();
683
684  tIterator<const char>* iterator = inputList->getIterator();
[5115]685  const char* enumString = iterator->firstElement();
[5113]686  while (enumString != NULL)
687  {
688    if (strlen(enumString)>searchLength+1 &&
689        !strncasecmp(enumString, classNameBegin, searchLength))
690    {
691      this->completionList->add(enumString);
692    }
693    enumString = iterator->nextElement();
694  }
695  delete iterator;
696
697  return this->completionList;
698}
699
700/**
701 * searches for classes, which beginn with classNameBegin
702 * @param inputList the List to parse through
703 * @param classNameBegin the beginning string
704 * @return a NEW char-array with ClassNames. The LIST should be deleted afterwards,
705 * !! The strings MUST NOT be deleted !!
706 */
707const tList<const char>* Shell::createCompleteList(const tList<BaseObject>* inputList, const char* classNameBegin)
708{
709  if (inputList == NULL || classNameBegin == NULL)
710    return NULL;
711  unsigned int searchLength = strlen(classNameBegin);
712  if (this->completionList != NULL)
713    delete this->completionList;
714  this->completionList = new tList<const char>;
715
716  tIterator<BaseObject>* iterator = inputList->getIterator();
[5115]717  BaseObject* enumBO = iterator->firstElement();
[5113]718  while (enumBO != NULL)
719  {
720    if (enumBO->getName() != NULL &&
721        strlen(enumBO->getName())>searchLength+1 &&
722        !strncasecmp(enumBO->getName(), classNameBegin, searchLength))
723    {
724      this->completionList->add(enumBO->getName());
725    }
726    enumBO = iterator->nextElement();
727  }
728  delete iterator;
729
730  return this->completionList;
731}
732
[5119]733void Shell::help() const
734{
735  PRINT(0)("Help for the most important Shell-commands\n");
736  PRINT(0)("F1 - HELP; F2 - DEBUG; ` - open/close shell\n");
737  PRINT(0)("input order:\n");
738  PRINT(0)("ClassName::objectName function [parameter1, [parameter2 ...]]  or\n");
739  PRINT(0)("Command [parameter]\n");
740}
741
[5120]742
743///////////////////////
744// HELPER FUNCTIONS  //
745///////////////////////
746Vector Shell::calculateLinePosition(unsigned int lineNumber)
747{
748  return Vector(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber -1), 0);
749}
750
751
752
[5113]753/**
[5068]754 * displays some nice output from the Shell
755 */
756void Shell::debug() const
757{
[5119]758  PRINT(3)("Debugging output to console (not this shell)\n");
759
[5096]760  if (this->pressedKey != SDLK_FIRST)
761    printf("%s::%f %f\n", SDLKToKeyname(this->pressedKey), this->delayed, this->repeatDelay);
[5119]762
763
764  char* tmpChar = this->bufferIterator->firstElement();
765  while(tmpChar != NULL)
766  {
767    printf(tmpChar);
768    tmpChar = this->bufferIterator->nextElement();
769  }
[5068]770}
Note: See TracBrowser for help on using the repository browser.