Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5986


Ignore:
Timestamp:
Oct 22, 2009, 11:32:30 PM (14 years ago)
Author:
scheusso
Message:

added a new feature to the IOConsole: you can now search the history (like in bash shells) with PgUP
just enter a few signs/characters of a command you once typed in and press PgUP to complete the command
if the found command is not the one you were looking for just press PgUP again

Location:
code/branches/console/src/libraries/core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/libraries/core/IOConsole.cc

    r5985 r5986  
    127127                    this->buffer_->buttonPressed(KeyEvent(KeyCode::End,      0, 0));
    128128                else if (this->escapeSequence_ == "5~")
    129                     this->buffer_->buttonPressed(KeyEvent(KeyCode::PageUp,   0, 0));
     129                    this->buffer_->buttonPressed(KeyEvent(KeyCode::AltPageUp,   0, 0));
    130130                else if (this->escapeSequence_ == "6~")
    131                     this->buffer_->buttonPressed(KeyEvent(KeyCode::PageDown, 0, 0));
     131                    this->buffer_->buttonPressed(KeyEvent(KeyCode::AltPageDown, 0, 0));
    132132                else if (this->escapeSequence_.size() > 4)
    133133                    // User probably very quickly pressed ESC and [
  • code/branches/console/src/libraries/core/Shell.cc

    r5983 r5986  
    3030
    3131#include "util/OutputHandler.h"
     32#include "util/StringUtils.h"
    3233#include "CommandExecutor.h"
    3334#include "CoreIncludes.h"
     
    132133        this->inputBuffer_->registerListener(this, &Shell::scroll_up, KeyCode::PageUp);
    133134        this->inputBuffer_->registerListener(this, &Shell::scroll_down, KeyCode::PageDown);
     135        this->inputBuffer_->registerListener(this, &Shell::history_search_up, KeyCode::AltPageUp);
     136        this->inputBuffer_->registerListener(this, &Shell::history_search_down, KeyCode::AltPageDown);
    134137    }
    135138
     
    357360    }
    358361
     362    void Shell::history_search_up()
     363    {
     364        if (this->historyPosition_ == this->historyOffset_)
     365            return;
     366        unsigned int cursorPosition = this->getCursorPosition();
     367        std::string input_str( this->getInput().substr(0,cursorPosition) ); //only search for the expression from the beginning of the inputline untill the cursor position
     368        for (unsigned int newPos = this->historyPosition_+1; newPos<=this->historyOffset_; newPos++)
     369        {
     370            if (getLowercase(this->commandHistory_[this->historyOffset_ - newPos]).find(getLowercase(input_str)) == 0) //search case insensitive
     371            {
     372                this->historyPosition_ = newPos;
     373                this->inputBuffer_->set(this->getFromHistory());
     374                this->setCursorPosition( cursorPosition );
     375                return;
     376            }
     377        }
     378    }
     379
     380    void Shell::history_search_down()
     381    {
     382        if (this->historyPosition_ == 0)
     383            return;
     384        unsigned int cursorPosition = this->getCursorPosition();
     385        std::string input_str( this->getInput().substr(0,cursorPosition) ); //only search for the expression from the beginn$
     386        for (unsigned int newPos = this->historyPosition_-1; newPos>0; newPos--)
     387        {
     388            if (getLowercase(this->commandHistory_[this->historyOffset_ - newPos]).find(getLowercase(input_str)) == 0) //sear$
     389            {
     390                this->historyPosition_ = newPos;
     391                this->inputBuffer_->set(this->getFromHistory());
     392                this->setCursorPosition( cursorPosition );
     393                return;
     394            }
     395        }
     396    }
     397
    359398    void Shell::scroll_up()
    360399    {
  • code/branches/console/src/libraries/core/Shell.h

    r5983 r5986  
    129129            void history_up();
    130130            void history_down();
     131            void history_search_up();
     132            void history_search_down();
    131133            void scroll_up();
    132134            void scroll_down();
  • code/branches/console/src/libraries/core/input/InputPrereqs.h

    r5781 r5986  
    179179            Up            = OIS::KC_UP,              // UpArrow on arrow keypad
    180180            PageUp        = OIS::KC_PGUP,            // PgUp on arrow keypad
     181            AltPageUp     = OIS::KC_PGUP+1,          // Alternative PgUp for the IOConsole
    181182            Left          = OIS::KC_LEFT,            // LeftArrow on arrow keypad
    182183            Right         = OIS::KC_RIGHT,           // RightArrow on arrow keypad
     
    184185            Down          = OIS::KC_DOWN,            // DownArrow on arrow keypad
    185186            PageDown      = OIS::KC_PGDOWN,          // PgDn on arrow keypad
     187            AltPageDown   = OIS::KC_END-1,           // Alternative PgUp for IOConsole
    186188            Insert        = OIS::KC_INSERT,          // Insert on arrow keypad
    187189            Delete        = OIS::KC_DELETE,          // Delete on arrow keypad
     
    286288            "UP",
    287289            "PageUp",
    288             "",
     290            "", // used for AltPageUp
    289291            "Left",
    290292            "",
    291293            "Right",
    292             "",
     294            "", // used for AltPageDown
    293295            "End", "Down", "PageDown", "Insert", "Delete",
    294296            "","","","","","","",
Note: See TracChangeset for help on using the changeset viewer.