summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/emulation_handler.cpp
Unidiff
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.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 2c1d888..99d069f 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,119 +1,119 @@
1 1
2#include "TEmuVt102.h" 2#include "TEmuVt102.h"
3 3
4#include "profile.h" 4#include "profile.h"
5#include "emulation_handler.h" 5#include "emulation_handler.h"
6#include "script.h" 6#include "script.h"
7 7
8EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 8EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
9 : QObject(0, name ) 9 : QObject(0, name )
10{ 10{
11 m_teWid = new TEWidget( parent, "TerminalMain"); 11 m_teWid = new TEWidget( parent, "TerminalMain");
12 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) 12 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
13 // use setWrapAt(80) for normal console with scrollbar 13 // use setWrapAt(80) for normal console with scrollbar
14 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80); 14 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80);
15 m_teWid->setMinimumSize(150, 70 ); 15 m_teWid->setMinimumSize(150, 70 );
16 m_script = 0; 16 m_script = 0;
17 parent->resize( m_teWid->calcSize(80, 24 ) ); 17 parent->resize( m_teWid->calcSize(80, 24 ) );
18 m_teEmu = new TEmuVt102(m_teWid ); 18 m_teEmu = new TEmuVt102(m_teWid );
19 19
20 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), 20 connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ),
21 this, SIGNAL(changeSize(int, int) ) ); 21 this, SIGNAL(changeSize(int,int) ) );
22 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), 22 connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ),
23 this, SLOT(recvEmulation(const char*, int) ) ); 23 this, SLOT(recvEmulation(const char*,int) ) );
24 m_teEmu->setConnect( true ); 24 m_teEmu->setConnect( true );
25 m_teEmu->setHistory( TRUE ); 25 m_teEmu->setHistory( TRUE );
26 load( prof ); 26 load( prof );
27 27
28 28
29 29
30} 30}
31TEmulation* EmulationHandler::emulation() { 31TEmulation* EmulationHandler::emulation() {
32 return m_teEmu; 32 return m_teEmu;
33} 33}
34EmulationHandler::~EmulationHandler() { 34EmulationHandler::~EmulationHandler() {
35 if (isRecording()) 35 if (isRecording())
36 clearScript(); 36 clearScript();
37 delete m_teEmu; 37 delete m_teEmu;
38 delete m_teWid; 38 delete m_teWid;
39} 39}
40 40
41void EmulationHandler::load( const Profile& prof) { 41void EmulationHandler::load( const Profile& prof) {
42 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 42 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
43 int num = prof.readNumEntry("Color"); 43 int num = prof.readNumEntry("Color");
44 setColor( foreColor(num), backColor(num) ); 44 setColor( foreColor(num), backColor(num) );
45 m_teWid->setBackgroundColor(backColor(num) ); 45 m_teWid->setBackgroundColor(backColor(num) );
46 46
47 int term = prof.readNumEntry("Terminal", 0) ; 47 int term = prof.readNumEntry("Terminal", 0) ;
48 switch(term) { 48 switch(term) {
49 default: 49 default:
50 case Profile::VT102: 50 case Profile::VT102:
51 case Profile::VT100: 51 case Profile::VT100:
52 m_teEmu->setKeytrans("vt100.keytab"); 52 m_teEmu->setKeytrans("vt100.keytab");
53 break; 53 break;
54 case Profile::Linux: 54 case Profile::Linux:
55 m_teEmu->setKeytrans("linux.keytab"); 55 m_teEmu->setKeytrans("linux.keytab");
56 break; 56 break;
57 case Profile::XTerm: 57 case Profile::XTerm:
58 m_teEmu->setKeytrans("default.Keytab"); 58 m_teEmu->setKeytrans("default.Keytab");
59 break; 59 break;
60 } 60 }
61} 61}
62void EmulationHandler::recv( const QByteArray& ar) { 62void EmulationHandler::recv( const QByteArray& ar) {
63 m_teEmu->onRcvBlock(ar.data(), ar.count() ); 63 m_teEmu->onRcvBlock(ar.data(), ar.count() );
64} 64}
65void EmulationHandler::recvEmulation(const char* src, int len ) { 65void EmulationHandler::recvEmulation(const char* src, int len ) {
66 QByteArray ar(len); 66 QByteArray ar(len);
67 67
68 memcpy(ar.data(), src, sizeof(char) * len ); 68 memcpy(ar.data(), src, sizeof(char) * len );
69 if (isRecording()) 69 if (isRecording())
70 m_script->append(ar); 70 m_script->append(ar);
71 emit send(ar); 71 emit send(ar);
72} 72}
73QWidget* EmulationHandler::widget() { 73QWidget* EmulationHandler::widget() {
74 return m_teWid; 74 return m_teWid;
75} 75}
76/* 76/*
77 * allocate a new table of colors 77 * allocate a new table of colors
78 */ 78 */
79void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { 79void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
80 ColorEntry table[TABLE_COLORS]; 80 ColorEntry table[TABLE_COLORS];
81 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); 81 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
82 82
83 for (int i = 0; i < TABLE_COLORS; i++ ) { 83 for (int i = 0; i < TABLE_COLORS; i++ ) {
84 if ( i == 0 || i == 10 ) { 84 if ( i == 0 || i == 10 ) {
85 table[i].color = fore; 85 table[i].color = fore;
86 }else if ( i == 1 || i == 11 ) { 86 }else if ( i == 1 || i == 11 ) {
87 table[i].color = back; 87 table[i].color = back;
88 table[i].transparent = 0; 88 table[i].transparent = 0;
89 }else { 89 }else {
90 table[i].color = defaultCt[i].color; 90 table[i].color = defaultCt[i].color;
91 } 91 }
92 } 92 }
93 m_teWid->setColorTable(table ); 93 m_teWid->setColorTable(table );
94 m_teWid->update(); 94 m_teWid->update();
95} 95}
96QFont EmulationHandler::font( int id ) { 96QFont EmulationHandler::font( int id ) {
97 QString name; 97 QString name;
98 int size = 0; 98 int size = 0;
99 switch(id ) { 99 switch(id ) {
100 default: // fall through 100 default: // fall through
101 case 0: 101 case 0:
102 name = QString::fromLatin1("Micro"); 102 name = QString::fromLatin1("Micro");
103 size = 4; 103 size = 4;
104 break; 104 break;
105 case 1: 105 case 1:
106 name = QString::fromLatin1("Fixed"); 106 name = QString::fromLatin1("Fixed");
107 size = 7; 107 size = 7;
108 break; 108 break;
109 case 2: 109 case 2:
110 name = QString::fromLatin1("Fixed"); 110 name = QString::fromLatin1("Fixed");
111 size = 12; 111 size = 12;
112 break; 112 break;
113 } 113 }
114 QFont font(name, size, QFont::Normal ); 114 QFont font(name, size, QFont::Normal );
115 font.setFixedPitch(TRUE ); 115 font.setFixedPitch(TRUE );
116 return font; 116 return font;
117} 117}
118QColor EmulationHandler::foreColor(int col) { 118QColor EmulationHandler::foreColor(int col) {
119 QColor co; 119 QColor co;