Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5973


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

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

Location:
code/branches/console/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/CMakeLists.txt

    r5781 r5973  
    9898ADD_SUBDIRECTORY(libraries)
    9999ADD_SUBDIRECTORY(orxonox)
    100 ADD_SUBDIRECTORY(modules)
     100#ADD_SUBDIRECTORY(modules)
    101101
    102102################ Executable ################
  • code/branches/console/src/libraries/core/Core.cc

    r5929 r5973  
    6464#include "Identifier.h"
    6565#include "Language.h"
     66#include "IOConsole.h"
    6667#include "LuaState.h"
    6768#include "ScopedSingletonManager.h"
     
    265266        // create a shell
    266267        this->shell_.reset(new Shell());
     268        // create persistent io console
     269        this->ioConsole_.reset(new IOConsole());
    267270
    268271        // Create singletons that always exist (in other libraries)
     
    444447            ScopedSingletonManager::update<ScopeID::Graphics>(time);
    445448        }
     449        // process console text
     450        this->ioConsole_->update(time);
    446451        // process thread commands
    447452        this->tclThreadManager_->update(time);
  • code/branches/console/src/libraries/core/Core.h

    r5929 r5973  
    4343{
    4444    class CoreConfiguration;
     45        class IOConsole;
    4546
    4647    /**
     
    9798            scoped_ptr<TclThreadManager>  tclThreadManager_;
    9899            scoped_ptr<Shell>             shell_;
     100            scoped_ptr<IOConsole>         ioConsole_;
    99101            // graphical
    100102            scoped_ptr<GraphicsManager>   graphicsManager_;     //!< Interface to OGRE
  • 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)
  • code/branches/console/src/libraries/core/IOConsole.h

    r5971 r5973  
    5858        void printOutputLine(const std::string& line);
    5959        void printInputLine();
    60         void insertCharacter(unsigned int position, char c);
    61         void deleteCharacter(unsigned int position);
    6260
    6361        // Methods from ShellListener
     
    7068
    7169        Shell&                  shell_;
    72         bool                    cleanLine_;
    7370        bool                    bEscapeMode_;
    7471        std::string             escapeSequence_;
    7572        InputBuffer*            buffer_;
    76         unsigned char*          commandLine_;
    77         unsigned int            inputIterator_;
    7873        static termios*         originalTerminalSettings_;
    79 
    80         unsigned int            cursorX_;
    81         unsigned int            cursorY_;
    8274
    8375        static IOConsole* singletonPtr_s;
  • code/branches/console/src/libraries/core/Shell.cc

    r5969 r5973  
    118118        this->inputBuffer_->registerListener(this, &Shell::inputChanged, true);
    119119        this->inputBuffer_->registerListener(this, &Shell::execute, '\r', false);
     120        this->inputBuffer_->registerListener(this, &Shell::execute, '\n', false);
    120121        this->inputBuffer_->registerListener(this, &Shell::hintandcomplete, '\t', true);
    121122        this->inputBuffer_->registerListener(this, &Shell::backspace, '\b', true);
     123        this->inputBuffer_->registerListener(this, &Shell::backspace, static_cast<char>(127), true);
    122124        this->inputBuffer_->registerListener(this, &Shell::deletechar, KeyCode::Delete);
    123125        this->inputBuffer_->registerListener(this, &Shell::exit, static_cast<char>(27), true);
  • code/branches/console/src/orxonox/gamestates/GSIOConsole.cc

    r5929 r5973  
    5858    void GSIOConsole::update(const Clock& time)
    5959    {
     60                /*
    6061        std::cout << ">";
    6162        std::string command;
    6263        std::getline(std::cin, command);
    6364        CommandExecutor::execute(command, true);
     65                */
    6466    }
    6567
Note: See TracChangeset for help on using the changeset viewer.