Changeset 5780 in orxonox.OLD for trunk/src/lib/shell/shell_completion.cc
- Timestamp:
- Nov 26, 2005, 3:47:51 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_completion.cc
r5779 r5780 25 25 #include "base_object.h" 26 26 #include "class_list.h" 27 #include "list.h"28 27 #include "debug.h" 29 28 … … 37 36 ShellCompletion::ShellCompletion(ShellInput* input) 38 37 { 39 this->completionList = NULL;40 38 this->input = input; 41 39 } … … 47 45 ShellCompletion::~ShellCompletion () 48 46 { 49 // delete what has to be deleted here50 if (this->completionList)51 {52 this->emptyCompletionList();53 delete this->completionList;54 }55 47 } 56 48 … … 239 231 bool ShellCompletion::generalComplete(const char* begin, const char* displayAs, const char* addBack, const char* addFront) 240 232 { 241 if ( completionList == NULL ||this->input == NULL )242 return false; 243 if (completionList ->size() == 0)244 return false; 245 246 ShellC_Element * addElem = completionList->front();247 const char* addString = addElem ->name;233 if (this->input == NULL ) 234 return false; 235 if (completionList.size() == 0) 236 return false; 237 238 ShellC_Element addElem = completionList.front(); 239 const char* addString = addElem.name; 248 240 unsigned int addLength = 0; 249 241 unsigned int inputLenght = strlen(begin); … … 254 246 255 247 SHELLC_TYPE changeType = SHELLC_NONE; 256 list<ShellC_Element *>::iterator charIT;257 for (charIT = completionList ->begin(); charIT != completionList->end(); charIT++)258 { 259 if ((*charIT) ->type != changeType)248 list<ShellC_Element>::iterator charIT; 249 for (charIT = completionList.begin(); charIT != completionList.end(); charIT++) 250 { 251 if ((*charIT).type != changeType) 260 252 { 261 253 if (changeType != SHELLC_NONE) 262 254 PRINT(0)("\n"); 263 PRINT(0)("%s: ", ShellCompletion::typeToString((*charIT) ->type));264 changeType = (*charIT) ->type;255 PRINT(0)("%s: ", ShellCompletion::typeToString((*charIT).type)); 256 changeType = (*charIT).type; 265 257 } 266 PRINTF(0)("%s ", (*charIT) ->name);258 PRINTF(0)("%s ", (*charIT).name); 267 259 for (unsigned int i = inputLenght; i < addLength; i++) 268 if (addString[i] != (*charIT) ->name[i])260 if (addString[i] != (*charIT).name[i]) 269 261 { 270 262 addLength = i; … … 285 277 this->input->addCharacters(adder); 286 278 287 if (completionList ->size() == 1)279 if (completionList.size() == 1) 288 280 { 289 281 if ( addBack != NULL ) … … 315 307 !strncasecmp(*string, completionBegin, searchLength)) 316 308 { 317 printf("%s\n", *string); 318 ShellC_Element* newElem = new ShellC_Element; 319 newElem->name = *string; 320 newElem->type = type; 321 this->completionList->push_back(newElem); 309 ShellC_Element newElem; 310 newElem.name = *string; 311 newElem.type = type; 312 this->completionList.push_back(newElem); 322 313 } 323 314 } … … 344 335 !strncasecmp((*bo)->getName(), completionBegin, searchLength)) 345 336 { 346 ShellC_Element * newElem = new ShellC_Element;347 newElem ->name = (*bo)->getName();348 newElem ->type = type;349 this->completionList ->push_back(newElem);337 ShellC_Element newElem; 338 newElem.name = (*bo)->getName(); 339 newElem.type = type; 340 this->completionList.push_back(newElem); 350 341 } 351 342 } … … 361 352 void ShellCompletion::emptyCompletionList() 362 353 { 363 if (this->completionList != NULL) 364 { 365 while (this->completionList->size() > 0) 366 { 367 delete this->completionList->front(); 368 this->completionList->pop_front(); 369 } 370 } 354 this->completionList.erase(this->completionList.begin(), 355 this->completionList.end()); 371 356 } 372 357
Note: See TracChangeset
for help on using the changeset viewer.