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.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 99d069f..89b70c6 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,55 +1,57 @@
1
2#include "TEmuVt102.h" 1#include "TEmuVt102.h"
3
4#include "profile.h" 2#include "profile.h"
5#include "emulation_handler.h" 3#include "emulation_handler.h"
6#include "script.h" 4#include "script.h"
7 5
6/* OPIE */
7#include <opie2/odebug.h>
8using namespace Opie::Core;
9
8EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 10EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
9 : QObject(0, name ) 11 : QObject(0, name )
10{ 12{
11 m_teWid = new TEWidget( parent, "TerminalMain"); 13 m_teWid = new TEWidget( parent, "TerminalMain");
12 // 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)
13 // use setWrapAt(80) for normal console with scrollbar 15 // use setWrapAt(80) for normal console with scrollbar
14 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80); 16 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80);
15 m_teWid->setMinimumSize(150, 70 ); 17 m_teWid->setMinimumSize(150, 70 );
16 m_script = 0; 18 m_script = 0;
17 parent->resize( m_teWid->calcSize(80, 24 ) ); 19 parent->resize( m_teWid->calcSize(80, 24 ) );
18 m_teEmu = new TEmuVt102(m_teWid ); 20 m_teEmu = new TEmuVt102(m_teWid );
19 21
20 connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ), 22 connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ),
21 this, SIGNAL(changeSize(int,int) ) ); 23 this, SIGNAL(changeSize(int,int) ) );
22 connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ), 24 connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ),
23 this, SLOT(recvEmulation(const char*,int) ) ); 25 this, SLOT(recvEmulation(const char*,int) ) );
24 m_teEmu->setConnect( true ); 26 m_teEmu->setConnect( true );
25 m_teEmu->setHistory( TRUE ); 27 m_teEmu->setHistory( TRUE );
26 load( prof ); 28 load( prof );
27 29
28 30
29 31
30} 32}
31TEmulation* EmulationHandler::emulation() { 33TEmulation* EmulationHandler::emulation() {
32 return m_teEmu; 34 return m_teEmu;
33} 35}
34EmulationHandler::~EmulationHandler() { 36EmulationHandler::~EmulationHandler() {
35 if (isRecording()) 37 if (isRecording())
36 clearScript(); 38 clearScript();
37 delete m_teEmu; 39 delete m_teEmu;
38 delete m_teWid; 40 delete m_teWid;
39} 41}
40 42
41void EmulationHandler::load( const Profile& prof) { 43void EmulationHandler::load( const Profile& prof) {
42 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 44 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
43 int num = prof.readNumEntry("Color"); 45 int num = prof.readNumEntry("Color");
44 setColor( foreColor(num), backColor(num) ); 46 setColor( foreColor(num), backColor(num) );
45 m_teWid->setBackgroundColor(backColor(num) ); 47 m_teWid->setBackgroundColor(backColor(num) );
46 48
47 int term = prof.readNumEntry("Terminal", 0) ; 49 int term = prof.readNumEntry("Terminal", 0) ;
48 switch(term) { 50 switch(term) {
49 default: 51 default:
50 case Profile::VT102: 52 case Profile::VT102:
51 case Profile::VT100: 53 case Profile::VT100:
52 m_teEmu->setKeytrans("vt100.keytab"); 54 m_teEmu->setKeytrans("vt100.keytab");
53 break; 55 break;
54 case Profile::Linux: 56 case Profile::Linux:
55 m_teEmu->setKeytrans("linux.keytab"); 57 m_teEmu->setKeytrans("linux.keytab");
@@ -83,124 +85,124 @@ void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
83 for (int i = 0; i < TABLE_COLORS; i++ ) { 85 for (int i = 0; i < TABLE_COLORS; i++ ) {
84 if ( i == 0 || i == 10 ) { 86 if ( i == 0 || i == 10 ) {
85 table[i].color = fore; 87 table[i].color = fore;
86 }else if ( i == 1 || i == 11 ) { 88 }else if ( i == 1 || i == 11 ) {
87 table[i].color = back; 89 table[i].color = back;
88 table[i].transparent = 0; 90 table[i].transparent = 0;
89 }else { 91 }else {
90 table[i].color = defaultCt[i].color; 92 table[i].color = defaultCt[i].color;
91 } 93 }
92 } 94 }
93 m_teWid->setColorTable(table ); 95 m_teWid->setColorTable(table );
94 m_teWid->update(); 96 m_teWid->update();
95} 97}
96QFont EmulationHandler::font( int id ) { 98QFont EmulationHandler::font( int id ) {
97 QString name; 99 QString name;
98 int size = 0; 100 int size = 0;
99 switch(id ) { 101 switch(id ) {
100 default: // fall through 102 default: // fall through
101 case 0: 103 case 0:
102 name = QString::fromLatin1("Micro"); 104 name = QString::fromLatin1("Micro");
103 size = 4; 105 size = 4;
104 break; 106 break;
105 case 1: 107 case 1:
106 name = QString::fromLatin1("Fixed"); 108 name = QString::fromLatin1("Fixed");
107 size = 7; 109 size = 7;
108 break; 110 break;
109 case 2: 111 case 2:
110 name = QString::fromLatin1("Fixed"); 112 name = QString::fromLatin1("Fixed");
111 size = 12; 113 size = 12;
112 break; 114 break;
113 } 115 }
114 QFont font(name, size, QFont::Normal ); 116 QFont font(name, size, QFont::Normal );
115 font.setFixedPitch(TRUE ); 117 font.setFixedPitch(TRUE );
116 return font; 118 return font;
117} 119}
118QColor EmulationHandler::foreColor(int col) { 120QColor EmulationHandler::foreColor(int col) {
119 QColor co; 121 QColor co;
120 /* we need to switch it */ 122 /* we need to switch it */
121 switch( col ) { 123 switch( col ) {
122 default: 124 default:
123 case Profile::White: 125 case Profile::White:
124 /* color is black */ 126 /* color is black */
125 co = Qt::white; 127 co = Qt::white;
126 break; 128 break;
127 case Profile::Black: 129 case Profile::Black:
128 co = Qt::black; 130 co = Qt::black;
129 break; 131 break;
130 case Profile::Green: 132 case Profile::Green:
131 qWarning("Foreground green"); 133 owarn << "Foreground green" << oendl;
132 co = Qt::green; 134 co = Qt::green;
133 break; 135 break;
134 case Profile::Orange: 136 case Profile::Orange:
135 qWarning("Foreground orange"); 137 owarn << "Foreground orange" << oendl;
136 co.setRgb( 231, 184, 98 ); 138 co.setRgb( 231, 184, 98 );
137 break; 139 break;
138 } 140 }
139 141
140 return co; 142 return co;
141} 143}
142QColor EmulationHandler::backColor(int col ) { 144QColor EmulationHandler::backColor(int col ) {
143 QColor co; 145 QColor co;
144 /* we need to switch it */ 146 /* we need to switch it */
145 switch( col ) { 147 switch( col ) {
146 default: 148 default:
147 case Profile::White: 149 case Profile::White:
148 /* color is white */ 150 /* color is white */
149 co = Qt::black; 151 co = Qt::black;
150 break; 152 break;
151 case Profile::Black: 153 case Profile::Black:
152 co = Qt::white; 154 co = Qt::white;
153 break; 155 break;
154 case Profile::Green: 156 case Profile::Green:
155 qWarning("Background black"); 157 owarn << "Background black" << oendl;
156 co = Qt::black; 158 co = Qt::black;
157 break; 159 break;
158 case Profile::Orange: 160 case Profile::Orange:
159 qWarning("Background black"); 161 owarn << "Background black" << oendl;
160 co = Qt::black; 162 co = Qt::black;
161 break; 163 break;
162 } 164 }
163 165
164 return co; 166 return co;
165} 167}
166 168
167QPushButton* EmulationHandler::cornerButton() { 169QPushButton* EmulationHandler::cornerButton() {
168 return m_teWid->cornerButton(); 170 return m_teWid->cornerButton();
169} 171}
170 172
171 173
172Script *EmulationHandler::script() { 174Script *EmulationHandler::script() {
173 return m_script; 175 return m_script;
174} 176}
175 177
176bool EmulationHandler::isRecording() { 178bool EmulationHandler::isRecording() {
177 return (m_script != 0); 179 return (m_script != 0);
178} 180}
179 181
180void EmulationHandler::startRecording() { 182void EmulationHandler::startRecording() {
181 if (!isRecording()) 183 if (!isRecording())
182 m_script = new Script(); 184 m_script = new Script();
183} 185}
184 186
185void EmulationHandler::clearScript() { 187void EmulationHandler::clearScript() {
186 if (isRecording()) { 188 if (isRecording()) {
187 delete m_script; 189 delete m_script;
188 m_script = 0; 190 m_script = 0;
189 } 191 }
190} 192}
191 193
192void EmulationHandler::runScript(const Script *script) { 194void EmulationHandler::runScript(const Script *script) {
193 emit send(script->script()); 195 emit send(script->script());
194} 196}
195 197
196void EmulationHandler::copy() { 198void EmulationHandler::copy() {
197 m_teWid->emitSelection(); 199 m_teWid->emitSelection();
198} 200}
199void EmulationHandler::paste() { 201void EmulationHandler::paste() {
200 m_teWid->pasteClipboard(); 202 m_teWid->pasteClipboard();
201} 203}
202 204
203void EmulationHandler::setWrap(int columns) { 205void EmulationHandler::setWrap(int columns) {
204 m_teWid->setWrapAt(columns); 206 m_teWid->setWrapAt(columns);
205} 207}
206 208