Changeset 5080 in orxonox.OLD for trunk/src/util
- Timestamp:
- Aug 19, 2005, 11:28:29 AM (19 years ago)
- Location:
- trunk/src/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/shell.cc
r5079 r5080 35 35 this->setName("Shell"); 36 36 37 this->bufferText = new tList<Text>;38 37 this->buffer = new tList<char>; 39 38 39 this->textSize = 10; 40 40 41 //this->bufferSize = 0; 41 //this->bufferDisplaySize = 0;42 this->bufferText = NULL; 42 43 this->setBufferSize(100); 43 this->setBufferDisplaySize(1 );44 45 // this->inputLineText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 0, 255, 0);46 //this->inputLineText->setText(NULL);44 this->setBufferDisplaySize(10); 45 46 this->inputLineText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 255, 0, 0); 47 this->inputLineText->setText(NULL); 47 48 48 49 //this->addBufferLineStatic("asjflksjdvklasmv %s", "doom"); … … 59 60 { 60 61 // delete what has to be deleted here 61 tIterator<Text>* textIterator = this->bufferText->getIterator(); 62 Text* textElem = textIterator->nextElement(); 63 64 while (textElem != NULL) 65 { 66 delete textElem; 67 68 textElem = textIterator->nextElement(); 69 } 70 delete textIterator; 62 for (int i = 0; i < this->bufferDisplaySize; i++) 63 delete this->bufferText[i]; 71 64 delete this->bufferText; 65 delete this->inputLineText; 72 66 73 67 Shell::singletonRef = NULL; … … 80 74 void Shell::setBufferDisplaySize(unsigned int bufferDisplaySize) 81 75 { 76 if (this->bufferText != NULL) 77 { 78 for (unsigned int i = 0; i < this->bufferDisplaySize; i++) 79 delete this->bufferText[i]; 80 delete this->bufferText; 81 } 82 83 this->bufferText = new Text*[bufferDisplaySize]; 84 for (unsigned int i = 0; i < bufferDisplaySize; i++) 85 { 86 this->bufferText[i] = TextEngine::getInstance()->createText("fonts/earth.ttf", this->textSize, TEXT_DYNAMIC, 255, 0, 0); 87 this->bufferText[i]->setAlignment(TEXT_ALIGN_LEFT); 88 this->bufferText[i]->setPosition2D(5, 400 + 12*i); 89 this->bufferText[i]->setText(NULL); 90 } 91 92 82 93 this->bufferDisplaySize = bufferDisplaySize; 83 84 while (bufferDisplaySize < this->bufferText->getSize())85 {86 delete this->bufferText->lastElement();87 this->bufferText->removeLast();88 }89 while(bufferDisplaySize > this->bufferText->getSize())90 {91 Text* newText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 0, 255, 0);92 newText->setAlignment(TEXT_ALIGN_LEFT);93 newText->setPosition2D(5, 500);94 newText->setText("");95 this->bufferText->add(newText);96 }97 94 } 98 95 … … 103 100 { 104 101 // remove all chars from the BufferTexts. 105 tIterator<Text>* textIterator = this->bufferText->getIterator(); 106 Text* textElem = textIterator->nextElement(); 107 108 while (textElem != NULL) 109 { 110 textElem->setText(NULL); 111 112 textElem = textIterator->nextElement(); 113 } 114 delete textIterator; 102 if (this->bufferText) 103 for (int i; i < this->bufferDisplaySize; i++) 104 { 105 this->bufferText[i]->setText(NULL); 106 } 115 107 116 108 … … 146 138 return true; 147 139 } 148 140 int curr = 0; 141 142 /** 143 * add a Line to the List of Buffers 144 * @param line 145 * @param arguments 146 * 147 * This function Adds one line to the buffer. 148 * and displays the line as the First Line of the display-buffer 149 */ 149 150 void Shell::addBufferLine(const char* line, va_list arguments) 150 151 { … … 154 155 strcpy(newLine, this->bufferArray); 155 156 156 // this->buffer->add(newLine); 157 // 158 // if (this->buffer->getSize() > this->bufferSize) 159 // { 160 // delete this->buffer->firstElement(); 161 // this->buffer->remove(this->buffer->firstElement()); 162 // } 163 164 this->bufferText->firstElement()->setText(newLine); 165 // this->inputLineText->setText(line); 157 this->buffer->add(newLine); 158 159 if (this->buffer->getSize() > this->bufferSize) 160 { 161 delete this->buffer->firstElement(); 162 this->buffer->remove(this->buffer->firstElement()); 163 } 164 165 if (likely(bufferText != NULL)) 166 { 167 Text* moveText = this->bufferText[this->bufferDisplaySize-1]; 168 for (int i = this->bufferDisplaySize-1; i > 0; i--) 169 { 170 this->bufferText[i] = this->bufferText[i-1]; 171 // this->bufferText[i] 172 } 173 this->bufferText[0] = moveText; 174 } 175 this->bufferText[0]->setText(newLine); 176 // this->bufferText-> 177 // this->inputLineText->setText(newLine); 166 178 } 167 179 -
trunk/src/util/shell.h
r5075 r5080 78 78 tList<char>* buffer; //!< A list of stored char-arrays(strings) to store the history 79 79 80 tList<Text>*bufferText; //!< A list of stored bufferTexts for the display of the buffer80 Text** bufferText; //!< A list of stored bufferTexts for the display of the buffer 81 81 Text* inputLineText; //!< The inputLine of the Shell 82 unsigned int textSize; //!< The size of the text. 83 unsigned int lineSpacing; //!< The Spacing between lines. 82 84 83 85 char bufferArray[10000]; //!< a BUFFER for fast writing 84 85 86 }; 86 87
Note: See TracChangeset
for help on using the changeset viewer.