summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/emulation_handler.cpp
authorharlekin <harlekin>2004-10-08 20:03:40 (UTC)
committer harlekin <harlekin>2004-10-08 20:03:40 (UTC)
commit4e884ee63f16d1367ff7b854dbe5b50a6871c008 (patch) (unidiff)
treefb9d9d13e9329e6ee9048bfc0e857d3918f4ecca /noncore/apps/opie-console/emulation_handler.cpp
parent51e49f0bd035545b983c799f7089de6b0ff2547e (diff)
downloadopie-4e884ee63f16d1367ff7b854dbe5b50a6871c008.zip
opie-4e884ee63f16d1367ff7b854dbe5b50a6871c008.tar.gz
opie-4e884ee63f16d1367ff7b854dbe5b50a6871c008.tar.bz2
added a 10east define for some changed builds for them, also added a logging mode, also some changes to the "fix broken distros" part, snapshot
Diffstat (limited to 'noncore/apps/opie-console/emulation_handler.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 956ac76..e045aef 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,52 +1,59 @@
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#include "logger.h"
5 6
6/* OPIE */ 7/* OPIE */
7#include <opie2/odebug.h> 8#include <opie2/odebug.h>
9
10#include <qfile.h>
11#include <qtextstream.h>
12
8using namespace Opie::Core; 13using namespace Opie::Core;
9 14
10EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 15EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
11 : QObject(0, name ) 16 : QObject(0, name )
12{ 17{
13 m_teWid = new TEWidget( parent, "TerminalMain"); 18 m_teWid = new TEWidget( parent, "TerminalMain");
14 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) 19 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
15 // use setWrapAt(80) for normal console with scrollbar 20 // use setWrapAt(80) for normal console with scrollbar
16 setWrap(prof.readNumEntry("Wrap", 80) ? 0 : 80); 21 setWrap(prof.readNumEntry("Wrap", 80) ? 0 : 80);
17 m_teWid->setMinimumSize(150, 70 ); 22 m_teWid->setMinimumSize(150, 70 );
18 m_script = 0; 23 m_script = 0;
24 m_log = 0;
19 parent->resize( m_teWid->calcSize(80, 24 ) ); 25 parent->resize( m_teWid->calcSize(80, 24 ) );
20 m_teEmu = new TEmuVt102(m_teWid ); 26 m_teEmu = new TEmuVt102(m_teWid );
21 27
22 connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ), 28 connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ),
23 this, SIGNAL(changeSize(int,int) ) ); 29 this, SIGNAL(changeSize(int,int) ) );
24 connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ), 30 connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ),
25 this, SLOT(recvEmulation(const char*,int) ) ); 31 this, SLOT(recvEmulation(const char*,int) ) );
26 m_teEmu->setConnect( true ); 32 m_teEmu->setConnect( true );
27 m_teEmu->setHistory( TRUE ); 33 m_teEmu->setHistory( TRUE );
28 load( prof ); 34 load( prof );
29 35
30 36
31 37
32} 38}
33TEmulation* EmulationHandler::emulation() { 39TEmulation* EmulationHandler::emulation() {
34 return m_teEmu; 40 return m_teEmu;
35} 41}
36EmulationHandler::~EmulationHandler() { 42EmulationHandler::~EmulationHandler() {
37 if (isRecording()) 43 if (isRecording())
38 clearScript(); 44 clearScript();
39 delete m_teEmu; 45 delete m_teEmu;
40 delete m_teWid; 46 delete m_teWid;
47 delete m_log;
41} 48}
42 49
43void EmulationHandler::load( const Profile& prof) { 50void EmulationHandler::load( const Profile& prof) {
44 51
45// m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 52// m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
46 QFont font( prof.readEntry("Font"), prof.readNumEntry( "FontSize" ), QFont::Normal ); 53 QFont font( prof.readEntry("Font"), prof.readNumEntry( "FontSize" ), QFont::Normal );
47 font.setFixedPitch( TRUE ); 54 font.setFixedPitch( TRUE );
48 m_teWid->setVTFont( font ); 55 m_teWid->setVTFont( font );
49 56
50 int num = prof.readNumEntry("Color"); 57 int num = prof.readNumEntry("Color");
51 setColor( foreColor(num), backColor(num) ); 58 setColor( foreColor(num), backColor(num) );
52 m_teWid->setBackgroundColor(backColor(num) ); 59 m_teWid->setBackgroundColor(backColor(num) );
@@ -59,33 +66,39 @@ void EmulationHandler::load( const Profile& prof) {
59 m_teEmu->setKeytrans("vt100.keytab"); 66 m_teEmu->setKeytrans("vt100.keytab");
60 break; 67 break;
61 case Profile::Linux: 68 case Profile::Linux:
62 m_teEmu->setKeytrans("linux.keytab"); 69 m_teEmu->setKeytrans("linux.keytab");
63 break; 70 break;
64 case Profile::XTerm: 71 case Profile::XTerm:
65 m_teEmu->setKeytrans("default.Keytab"); 72 m_teEmu->setKeytrans("default.Keytab");
66 break; 73 break;
67 } 74 }
68} 75}
69void EmulationHandler::recv( const QByteArray& ar) { 76void EmulationHandler::recv( const QByteArray& ar) {
70 m_teEmu->onRcvBlock(ar.data(), ar.count() ); 77 m_teEmu->onRcvBlock(ar.data(), ar.count() );
78 if ( isLogging() ) {
79 m_log->append( ar );
71} 80}
81}
82
72void EmulationHandler::recvEmulation(const char* src, int len ) { 83void EmulationHandler::recvEmulation(const char* src, int len ) {
73 QByteArray ar(len); 84 QByteArray ar(len);
74 85
75 memcpy(ar.data(), src, sizeof(char) * len ); 86 memcpy(ar.data(), src, sizeof(char) * len );
76 if (isRecording()) 87 if (isRecording())
77 m_script->append(ar); 88 m_script->append(ar);
78 emit send(ar); 89 emit send(ar);
79} 90}
91
92
80QWidget* EmulationHandler::widget() { 93QWidget* EmulationHandler::widget() {
81 return m_teWid; 94 return m_teWid;
82} 95}
83/* 96/*
84 * allocate a new table of colors 97 * allocate a new table of colors
85 */ 98 */
86void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { 99void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
87 ColorEntry table[TABLE_COLORS]; 100 ColorEntry table[TABLE_COLORS];
88 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); 101 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
89 102
90 for (int i = 0; i < TABLE_COLORS; i++ ) { 103 for (int i = 0; i < TABLE_COLORS; i++ ) {
91 if ( i == 0 || i == 10 ) { 104 if ( i == 0 || i == 10 ) {
@@ -175,36 +188,57 @@ QPushButton* EmulationHandler::cornerButton() {
175 return m_teWid->cornerButton(); 188 return m_teWid->cornerButton();
176} 189}
177 190
178 191
179Script *EmulationHandler::script() { 192Script *EmulationHandler::script() {
180 return m_script; 193 return m_script;
181} 194}
182 195
183bool EmulationHandler::isRecording() { 196bool EmulationHandler::isRecording() {
184 return (m_script != 0); 197 return (m_script != 0);
185} 198}
186 199
200bool EmulationHandler::isLogging() {
201 return (m_log != 0);
202}
203
187void EmulationHandler::startRecording() { 204void EmulationHandler::startRecording() {
188 if (!isRecording()) 205 if (!isRecording())
189 m_script = new Script(); 206 m_script = new Script();
190} 207}
191 208
209void EmulationHandler::startLogging(const QString fileName) {
210 m_logFileName = fileName;
211 if (!isLogging())
212 m_log = new Logger(m_logFileName);
213}
214
215QString EmulationHandler::logFileName() {
216 return m_logFileName;
217}
218
192void EmulationHandler::clearScript() { 219void EmulationHandler::clearScript() {
193 if (isRecording()) { 220 if (isRecording()) {
194 delete m_script; 221 delete m_script;
195 m_script = 0; 222 m_script = 0;
196 } 223 }
197} 224}
198 225
226void EmulationHandler::clearLog() {
227 if (isLogging()) {
228 delete m_log;
229 m_log = 0;
230 }
231}
232
199void EmulationHandler::runScript(const Script *script) { 233void EmulationHandler::runScript(const Script *script) {
200 emit send(script->script()); 234 emit send(script->script());
201} 235}
202 236
203void EmulationHandler::copy() { 237void EmulationHandler::copy() {
204 m_teWid->emitSelection(); 238 m_teWid->emitSelection();
205} 239}
206void EmulationHandler::paste() { 240void EmulationHandler::paste() {
207 m_teWid->pasteClipboard(); 241 m_teWid->pasteClipboard();
208} 242}
209 243
210void EmulationHandler::setWrap(int columns) { 244void EmulationHandler::setWrap(int columns) {