author | zecke <zecke> | 2002-10-14 22:58:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-14 22:58:11 (UTC) |
commit | d7290c6b24266303abd95e7f38c0fecae395f355 (patch) (side-by-side diff) | |
tree | f8202b056d9ae8de1cfa818de60ff2929c520f90 /noncore/apps/opie-console/emulation_handler.cpp | |
parent | f5d1ce4b3887e0f09704abad5b9414c9cd90be4b (diff) | |
download | opie-d7290c6b24266303abd95e7f38c0fecae395f355.zip opie-d7290c6b24266303abd95e7f38c0fecae395f355.tar.gz opie-d7290c6b24266303abd95e7f38c0fecae395f355.tar.bz2 |
A small console emulation layer...
And some configuration stuff
fonts are working colors are not fully working
BackGround and ForeGround both are black :(
Diffstat (limited to 'noncore/apps/opie-console/emulation_handler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 89 |
1 files changed, 84 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index 9e7f56c..48218e6 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp @@ -4,4 +4,5 @@ #include "TEmuVt102.h" +#include "profile.h" #include "emulation_handler.h" @@ -30,9 +31,9 @@ EmulationHandler::~EmulationHandler() { delete m_teWid; } -void EmulationHandler::load( const Profile& ) { - QFont font = QFont("Fixed", 12, QFont::Normal ); - font.setFixedPitch(TRUE); - m_teWid->setVTFont( font ); - m_teWid->setBackgroundColor(Qt::gray ); +void EmulationHandler::load( const Profile& prof) { + m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); + int num = prof.readNumEntry("Color"); + setColor( foreColor(num), backColor(num) ); + m_teWid->setBackgroundColor(backColor(num) ); } void EmulationHandler::recv( const QByteArray& ar) { @@ -51,2 +52,80 @@ QWidget* EmulationHandler::widget() { return m_teWid; } +/* + * allocate a new table of colors + */ +void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { + ColorEntry table[TABLE_COLORS]; + const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); + + for (int i = 0; i < TABLE_COLORS; i++ ) { + if ( i == 0 || i == 10 ) { + table[i].color = fore; + }else if ( i == 1 || i == 11 ) { + table[i].color = back; + table[i].transparent = 0; + }else { + table[i].color = defaultCt[i].color; + } + } +// m_teWid->setColorTable(table ); + m_teWid->update(); +} +QFont EmulationHandler::font( int id ) { + QString name; + int size = 0; + switch(id ) { + default: // fall through + case 0: + name = QString::fromLatin1("Micro"); + size = 4; + break; + case 1: + name = QString::fromLatin1("Fixed"); + size = 7; + break; + case 2: + name = QString::fromLatin1("Fixed"); + size = 12; + break; + } + QFont font(name, size, QFont::Normal ); + font.setFixedPitch(TRUE ); + return font; +} +QColor EmulationHandler::foreColor(int col) { + QColor co; + /* we need to switch it */ + switch( col ) { + default: + case Profile::White: + qWarning("Foreground black"); + /* color is black */ + co = Qt::black; + break; + case Profile::Black: + qWarning("Foreground white"); + co = Qt::white; + break; + } + + return co; +} +QColor EmulationHandler::backColor(int col ) { + QColor co; + /* we need to switch it */ + switch( col ) { + default: + case Profile::White: + qWarning("Background white"); + /* color is white */ + co = Qt::white; + break; + case Profile::Black: + qWarning("Background black"); + co = Qt::black; + break; + } + + return co; +} |