summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 1a0613f..c8022b9 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,142 +1,145 @@
1#include "TEmuVt102.h" 1#include "TEmuVt102.h"
2#include "profile.h" 2#include "profile.h"
3#include "emulation_handler.h" 3#include "emulation_handler.h"
4#include "script.h" 4#include "script.h"
5 5
6/* OPIE */ 6/* OPIE */
7#include <opie2/odebug.h> 7#include <opie2/odebug.h>
8using namespace Opie::Core; 8using namespace Opie::Core;
9 9
10EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 10EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
11 : QObject(0, name ) 11 : QObject(0, name )
12{ 12{
13 m_teWid = new TEWidget( parent, "TerminalMain"); 13 m_teWid = new TEWidget( parent, "TerminalMain");
14 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) 14 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
15 // use setWrapAt(80) for normal console with scrollbar 15 // use setWrapAt(80) for normal console with scrollbar
16 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80); 16 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80);
17 m_teWid->setMinimumSize(150, 70 ); 17 m_teWid->setMinimumSize(150, 70 );
18 m_script = 0; 18 m_script = 0;
19 parent->resize( m_teWid->calcSize(80, 24 ) ); 19 parent->resize( m_teWid->calcSize(80, 24 ) );
20 m_teEmu = new TEmuVt102(m_teWid ); 20 m_teEmu = new TEmuVt102(m_teWid );
21 21
22 connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ), 22 connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ),
23 this, SIGNAL(changeSize(int,int) ) ); 23 this, SIGNAL(changeSize(int,int) ) );
24 connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ), 24 connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ),
25 this, SLOT(recvEmulation(const char*,int) ) ); 25 this, SLOT(recvEmulation(const char*,int) ) );
26 m_teEmu->setConnect( true ); 26 m_teEmu->setConnect( true );
27 m_teEmu->setHistory( TRUE ); 27 m_teEmu->setHistory( TRUE );
28 load( prof ); 28 load( prof );
29 29
30 30
31 31
32} 32}
33TEmulation* EmulationHandler::emulation() { 33TEmulation* EmulationHandler::emulation() {
34 return m_teEmu; 34 return m_teEmu;
35} 35}
36EmulationHandler::~EmulationHandler() { 36EmulationHandler::~EmulationHandler() {
37 if (isRecording()) 37 if (isRecording())
38 clearScript(); 38 clearScript();
39 delete m_teEmu; 39 delete m_teEmu;
40 delete m_teWid; 40 delete m_teWid;
41} 41}
42 42
43void EmulationHandler::load( const Profile& prof) { 43void EmulationHandler::load( const Profile& prof) {
44 44
45// m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 45// m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
46 m_teWid->setVTFont( QFont( prof.readEntry("Font"), prof.readNumEntry( "FontSize" ), QFont::Normal ) ); 46 QFont font( prof.readEntry("Font"), prof.readNumEntry( "FontSize" ), QFont::Normal );
47 font.setFixedPitch( TRUE );
48 m_teWid->setVTFont( font );
49
47 int num = prof.readNumEntry("Color"); 50 int num = prof.readNumEntry("Color");
48 setColor( foreColor(num), backColor(num) ); 51 setColor( foreColor(num), backColor(num) );
49 m_teWid->setBackgroundColor(backColor(num) ); 52 m_teWid->setBackgroundColor(backColor(num) );
50 53
51 int term = prof.readNumEntry("Terminal", 0) ; 54 int term = prof.readNumEntry("Terminal", 0) ;
52 switch(term) { 55 switch(term) {
53 default: 56 default:
54 case Profile::VT102: 57 case Profile::VT102:
55 case Profile::VT100: 58 case Profile::VT100:
56 m_teEmu->setKeytrans("vt100.keytab"); 59 m_teEmu->setKeytrans("vt100.keytab");
57 break; 60 break;
58 case Profile::Linux: 61 case Profile::Linux:
59 m_teEmu->setKeytrans("linux.keytab"); 62 m_teEmu->setKeytrans("linux.keytab");
60 break; 63 break;
61 case Profile::XTerm: 64 case Profile::XTerm:
62 m_teEmu->setKeytrans("default.Keytab"); 65 m_teEmu->setKeytrans("default.Keytab");
63 break; 66 break;
64 } 67 }
65} 68}
66void EmulationHandler::recv( const QByteArray& ar) { 69void EmulationHandler::recv( const QByteArray& ar) {
67 m_teEmu->onRcvBlock(ar.data(), ar.count() ); 70 m_teEmu->onRcvBlock(ar.data(), ar.count() );
68} 71}
69void EmulationHandler::recvEmulation(const char* src, int len ) { 72void EmulationHandler::recvEmulation(const char* src, int len ) {
70 QByteArray ar(len); 73 QByteArray ar(len);
71 74
72 memcpy(ar.data(), src, sizeof(char) * len ); 75 memcpy(ar.data(), src, sizeof(char) * len );
73 if (isRecording()) 76 if (isRecording())
74 m_script->append(ar); 77 m_script->append(ar);
75 emit send(ar); 78 emit send(ar);
76} 79}
77QWidget* EmulationHandler::widget() { 80QWidget* EmulationHandler::widget() {
78 return m_teWid; 81 return m_teWid;
79} 82}
80/* 83/*
81 * allocate a new table of colors 84 * allocate a new table of colors
82 */ 85 */
83void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { 86void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
84 ColorEntry table[TABLE_COLORS]; 87 ColorEntry table[TABLE_COLORS];
85 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); 88 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
86 89
87 for (int i = 0; i < TABLE_COLORS; i++ ) { 90 for (int i = 0; i < TABLE_COLORS; i++ ) {
88 if ( i == 0 || i == 10 ) { 91 if ( i == 0 || i == 10 ) {
89 table[i].color = fore; 92 table[i].color = fore;
90 }else if ( i == 1 || i == 11 ) { 93 }else if ( i == 1 || i == 11 ) {
91 table[i].color = back; 94 table[i].color = back;
92 table[i].transparent = 0; 95 table[i].transparent = 0;
93 }else { 96 }else {
94 table[i].color = defaultCt[i].color; 97 table[i].color = defaultCt[i].color;
95 } 98 }
96 } 99 }
97 m_teWid->setColorTable(table ); 100 m_teWid->setColorTable(table );
98 m_teWid->update(); 101 m_teWid->update();
99} 102}
100QFont EmulationHandler::font( int id ) { 103QFont EmulationHandler::font( int id ) {
101 QString name; 104 QString name;
102 int size = 0; 105 int size = 0;
103 switch(id ) { 106 switch(id ) {
104 default: // fall through 107 default: // fall through
105 case 0: 108 case 0:
106 name = QString::fromLatin1("Micro"); 109 name = QString::fromLatin1("Micro");
107 size = 4; 110 size = 4;
108 break; 111 break;
109 case 1: 112 case 1:
110 name = QString::fromLatin1("Fixed"); 113 name = QString::fromLatin1("Fixed");
111 size = 7; 114 size = 7;
112 break; 115 break;
113 case 2: 116 case 2:
114 name = QString::fromLatin1("Fixed"); 117 name = QString::fromLatin1("Fixed");
115 size = 12; 118 size = 12;
116 break; 119 break;
117 } 120 }
118 QFont font(name, size, QFont::Normal ); 121 QFont font(name, size, QFont::Normal );
119 font.setFixedPitch(TRUE ); 122 font.setFixedPitch(TRUE );
120 return font; 123 return font;
121} 124}
122QColor EmulationHandler::foreColor(int col) { 125QColor EmulationHandler::foreColor(int col) {
123 QColor co; 126 QColor co;
124 /* we need to switch it */ 127 /* we need to switch it */
125 switch( col ) { 128 switch( col ) {
126 default: 129 default:
127 case Profile::White: 130 case Profile::White:
128 /* color is black */ 131 /* color is black */
129 co = Qt::white; 132 co = Qt::white;
130 break; 133 break;
131 case Profile::Black: 134 case Profile::Black:
132 co = Qt::black; 135 co = Qt::black;
133 break; 136 break;
134 case Profile::Green: 137 case Profile::Green:
135 owarn << "Foreground green" << oendl; 138 owarn << "Foreground green" << oendl;
136 co = Qt::green; 139 co = Qt::green;
137 break; 140 break;
138 case Profile::Orange: 141 case Profile::Orange:
139 owarn << "Foreground orange" << oendl; 142 owarn << "Foreground orange" << oendl;
140 co.setRgb( 231, 184, 98 ); 143 co.setRgb( 231, 184, 98 );
141 break; 144 break;
142 } 145 }