Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 20, 2009, 10:32:06 PM (15 years ago)
Author:
rgrieder
Message:

Input part of the IOConsole should be working (at least with SSH on tardis). Note: removed modules from compilation

File:
1 edited

Legend:

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

    r5972 r5973  
    5757    IOConsole::IOConsole()
    5858        : shell_(Shell::getInstance())
    59         , cleanLine_(true)
    6059        , bEscapeMode_(false)
    6160        , buffer_(Shell::getInstance().getInputBuffer())
    62         , inputIterator_(0)
    63         , cursorX_(0)
    64         , cursorY_(0)
    6561    {
    6662        this->originalTerminalSettings_ = new termios;
     
    8177        termios new_settings;
    8278
    83         tcgetattr(0,this->originalTerminalSettings_);
     79        tcgetattr(0, this->originalTerminalSettings_);
    8480        new_settings = *this->originalTerminalSettings_;
    85         new_settings.c_lflag &= ~( ICANON | ECHO );
     81        new_settings.c_lflag &= ~(ICANON | ECHO);
    8682        //         new_settings.c_lflag |= ( ISIG | IEXTEN );
    8783        new_settings.c_cc[VTIME] = 1;
    88         new_settings.c_cc[VMIN] = 0;
    89         tcsetattr(0,TCSANOW,&new_settings);
     84        new_settings.c_cc[VMIN]  = 0;
     85        tcsetattr(0, TCSANOW, &new_settings);
    9086        COUT(0) << endl;
    9187        //       atexit(&IOConsole::resetTerminalMode);
     
    9995    void IOConsole::update(const Clock& time)
    10096    {
    101         unsigned c;
     97        unsigned char c;
    10298        while (read(STDIN_FILENO, &c, 1) == 1)
    10399        {
     
    105101            {
    106102                this->escapeSequence_ += c;
    107                 bool clear = true;
    108                 if      (this->escapeSequence_ == "\033")
    109                     this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape,   0, 0));
    110                 else if (this->escapeSequence_ == "[A")
     103                bool endOfSeq = true;
     104                if      (this->escapeSequence_ == "[A")
    111105                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Up,       0, 0));
    112106                else if (this->escapeSequence_ == "[B")
     
    120114                else if (this->escapeSequence_ == "[2~")
    121115                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Insert,   0, 0));
     116                else if (this->escapeSequence_ == "[3~")
     117                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Delete,   0, 0));
    122118                else if (this->escapeSequence_ == "[4~")
    123119                    this->buffer_->buttonPressed(KeyEvent(KeyCode::End,      0, 0));
     
    130126                    this->buffer_->buttonPressed(KeyEvent(KeyCode::Tab, '\t', KeyboardModifier::Alt));
    131127                else if (this->escapeSequence_.size() > 4)
    132                     clear = true; // Something went wrong, start over
     128                    endOfSeq = true; // Something went wrong, start over
    133129                else
    134                     clear = false;
    135 
    136                 if (clear)
    137                     this->escapeSequence_.clear();
     130                    endOfSeq = false;
     131
     132                //this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape,   0, 0));
     133
     134                if (endOfSeq)
     135                    this->bEscapeMode_ = false;
    138136            }
    139137            else // not in an escape sequence
    140138            {
    141139                if (c == '\033')
     140                                {
    142141                    this->bEscapeMode_ = true;
     142                                        this->escapeSequence_.clear();
     143                                }
    143144                else
    144145                {
     
    147148                    {
    148149                    case '\n': code = KeyCode::Return; break;
    149                     case  127: code = KeyCode::Delete; break;
     150                    case '\r': code = KeyCode::Return; break;
     151                    case  127: code = KeyCode::Back;   break;
    150152                    case '\b': code = KeyCode::Back;   break;
    151153                    case '\t': code = KeyCode::Tab;    break;
     
    160162            }
    161163        }
     164
     165                // Print input line
     166                this->printInputLine();
    162167    }
    163168
    164169    void IOConsole::printOutputLine(const std::string& line)
    165170    {
     171                COUT(0) << "print output" << std::endl;
    166172        // Save cursor position
    167173        std::cout << "\033[s";
     
    199205        std::cout << "\033[u";
    200206        std::cout.flush();
     207
     208                this->printInputLine();
    201209    }
    202210
     
    206214        std::cout << "\033[0G\033[K";
    207215        // print status line
    208         std::cout << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, " << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms avg ticktime # ";
     216        //std::cout << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, " << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms avg ticktime # ";
     217                // Show an arrow to indicate a command prompt
     218                std::cout << ">";
    209219        // save cursor position
    210220        std::cout << "\033[s";
    211221        // print commandLine buffer
    212222        std::cout << this->shell_.getInput();
    213         // restore cursor position and move it cursorX_ to the right
     223        // restore cursor position and move it to the right
    214224        std::cout << "\033[u";
    215225        if (this->buffer_->getCursorPosition() > 0)
Note: See TracChangeset for help on using the changeset viewer.