Skip to content

Commit

Permalink
Shell|Curses: Basic key input handling
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 20, 2013
1 parent a43d7e7 commit decaa5e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
21 changes: 18 additions & 3 deletions doomsday/tools/shell/shell-text/src/cursesapp.cpp
Expand Up @@ -73,7 +73,7 @@ struct CursesApp::Instance

~Instance()
{
delete inputPollTimer;
shutdownCurses();
}

void initCurses()
Expand Down Expand Up @@ -138,14 +138,29 @@ struct CursesApp::Instance
{
if(key == KEY_RESIZE)
{
// Terminal has been resized.
de::Vector2i size = actualTerminalSize();
resize_term(size.y, size.x);

emit self.viewResized(size.x, size.y);
}
else if(key & KEY_CODE_YES)
{
// There is a curses key code.
switch(key)
{
default:
// This key code is ignored.
break;
}
}
else if(key == 0x1b) // Escape
{
self.quit();
}
else
{
qDebug() << "Got key" << QString("%1").arg(key, 0, 16);
qDebug() << "Got key" << QString("0x%1").arg(key, 0, 16).toAscii().constData();
}
}
}
Expand All @@ -157,7 +172,7 @@ struct CursesApp::Instance
};

CursesApp::CursesApp(int &argc, char **argv)
: QApplication(argc, argv, QApplication::Tty), d(new Instance(*this))
: QCoreApplication(argc, argv), d(new Instance(*this))
{
}

Expand Down
4 changes: 2 additions & 2 deletions doomsday/tools/shell/shell-text/src/cursesapp.h
Expand Up @@ -19,9 +19,9 @@
#ifndef CURSESAPP_H
#define CURSESAPP_H

#include <QApplication>
#include <QCoreApplication>

class CursesApp : public QApplication
class CursesApp : public QCoreApplication
{
Q_OBJECT

Expand Down

0 comments on commit decaa5e

Please sign in to comment.