Exemplo n.º 1
0
void ConsoleInput::parse()
{
    if ( kbhit() )
    {
        char ch = getch();

        if( (int)ch == 13 && !mInputBuffer.empty() )
        {
            // Enter
            std::cout << "Lua: " << mInputBuffer << std::endl;
            mCommandCallback( mInputBuffer );
            String spaces( mInputBuffer.size(), ' ' );
            std::cout << spaces << "\r" << std::flush;
            mInputBuffer.clear();
        }
        else if( (int)ch == 8 && !mInputBuffer.empty() )
        {
            // Backspace
            mInputBuffer[ mInputBuffer.size() - 1 ] = ' ';
            std::cout << mInputBuffer << "\r" << std::flush;
            mInputBuffer.erase( mInputBuffer.size() - 1 );
        }
        else if( (int)ch >= 32 && (int)ch <= 126 )
        {
            // Normal input
            mInputBuffer.append( 1, ch );
        }

        std::cout << mInputBuffer << "\r" << std::flush;
    }
}
Exemplo n.º 2
0
bool
WndForm::ClientAreaWindow::on_command(unsigned id, unsigned code)
{
  return (mCommandCallback != NULL && mCommandCallback(id))
    || ContainerWindow::on_command(id, code);
}