summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp34
-rw-r--r--noncore/apps/opie-console/emulation_handler.h19
-rw-r--r--noncore/apps/opie-console/emulation_layer.cpp36
-rw-r--r--noncore/apps/opie-console/emulation_layer.h18
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp16
-rw-r--r--noncore/apps/opie-console/script.cpp15
-rw-r--r--noncore/apps/opie-console/script.h6
7 files changed, 68 insertions, 76 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 8846959..df8e573 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,95 +1,101 @@
1#include <qwidget.h> 1#include <qwidget.h>
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3 3
4#include "TEWidget.h" 4#include "TEWidget.h"
5#include "TEmuVt102.h" 5#include "TEmuVt102.h"
6 6
7#include "profile.h" 7#include "profile.h"
8#include "emulation_handler.h" 8#include "emulation_handler.h"
9 9#include "script.h"
10 10
11EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 11EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
12 : QObject(0, name ) 12 : QObject(0, name )
13{ 13{
14 m_teWid = new TEWidget( parent, "TerminalMain"); 14 m_teWid = new TEWidget( parent, "TerminalMain");
15 m_teWid->setMinimumSize(150, 70 ); 15 m_teWid->setMinimumSize(150, 70 );
16 m_script = 0;
16 parent->resize( m_teWid->calcSize(80, 24 ) ); 17 parent->resize( m_teWid->calcSize(80, 24 ) );
17 m_teEmu = new TEmuVt102(m_teWid ); 18 m_teEmu = new TEmuVt102(m_teWid );
18 19
19 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), 20 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ),
20 this, SIGNAL(changeSize(int, int) ) ); 21 this, SIGNAL(changeSize(int, int) ) );
21 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), 22 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ),
22 this, SLOT(recvEmulation(const char*, int) ) ); 23 this, SLOT(recvEmulation(const char*, int) ) );
23 m_teEmu->setConnect( true ); 24 m_teEmu->setConnect( true );
24 m_teEmu->setHistory( TRUE ); 25 m_teEmu->setHistory( TRUE );
25 load( prof ); 26 load( prof );
26 27
27 28
28 29
29} 30}
30EmulationHandler::~EmulationHandler() { 31EmulationHandler::~EmulationHandler() {
32 if (isRecording())
33 clearScript();
31 delete m_teEmu; 34 delete m_teEmu;
32 delete m_teWid; 35 delete m_teWid;
33} 36}
37
34void EmulationHandler::load( const Profile& prof) { 38void EmulationHandler::load( const Profile& prof) {
35 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 39 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
36 int num = prof.readNumEntry("Color"); 40 int num = prof.readNumEntry("Color");
37 setColor( foreColor(num), backColor(num) ); 41 setColor( foreColor(num), backColor(num) );
38 m_teWid->setBackgroundColor(backColor(num) ); 42 m_teWid->setBackgroundColor(backColor(num) );
39} 43}
40void EmulationHandler::recv( const QByteArray& ar) { 44void EmulationHandler::recv( const QByteArray& ar) {
41 m_teEmu->onRcvBlock(ar.data(), ar.count() ); 45 m_teEmu->onRcvBlock(ar.data(), ar.count() );
42} 46}
43void EmulationHandler::recvEmulation(const char* src, int len ) { 47void EmulationHandler::recvEmulation(const char* src, int len ) {
44 QByteArray ar(len); 48 QByteArray ar(len);
45 49
46 memcpy(ar.data(), src, sizeof(char) * len ); 50 memcpy(ar.data(), src, sizeof(char) * len );
47 51
52 if (isRecording())
53 m_script->append(ar);
48 emit send(ar); 54 emit send(ar);
49} 55}
50QWidget* EmulationHandler::widget() { 56QWidget* EmulationHandler::widget() {
51 return m_teWid; 57 return m_teWid;
52} 58}
53/* 59/*
54 * allocate a new table of colors 60 * allocate a new table of colors
55 */ 61 */
56void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { 62void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
57 ColorEntry table[TABLE_COLORS]; 63 ColorEntry table[TABLE_COLORS];
58 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); 64 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
59 65
60 for (int i = 0; i < TABLE_COLORS; i++ ) { 66 for (int i = 0; i < TABLE_COLORS; i++ ) {
61 if ( i == 0 || i == 10 ) { 67 if ( i == 0 || i == 10 ) {
62 table[i].color = fore; 68 table[i].color = fore;
63 }else if ( i == 1 || i == 11 ) { 69 }else if ( i == 1 || i == 11 ) {
64 table[i].color = back; 70 table[i].color = back;
65 table[i].transparent = 0; 71 table[i].transparent = 0;
66 }else { 72 }else {
67 table[i].color = defaultCt[i].color; 73 table[i].color = defaultCt[i].color;
68 } 74 }
69 } 75 }
70 m_teWid->setColorTable(table ); 76 m_teWid->setColorTable(table );
71 m_teWid->update(); 77 m_teWid->update();
72} 78}
73QFont EmulationHandler::font( int id ) { 79QFont EmulationHandler::font( int id ) {
74 QString name; 80 QString name;
75 int size = 0; 81 int size = 0;
76 switch(id ) { 82 switch(id ) {
77 default: // fall through 83 default: // fall through
78 case 0: 84 case 0:
79 name = QString::fromLatin1("Micro"); 85 name = QString::fromLatin1("Micro");
80 size = 4; 86 size = 4;
81 break; 87 break;
82 case 1: 88 case 1:
83 name = QString::fromLatin1("Fixed"); 89 name = QString::fromLatin1("Fixed");
84 size = 7; 90 size = 7;
85 break; 91 break;
86 case 2: 92 case 2:
87 name = QString::fromLatin1("Fixed"); 93 name = QString::fromLatin1("Fixed");
88 size = 12; 94 size = 12;
89 break; 95 break;
90 } 96 }
91 QFont font(name, size, QFont::Normal ); 97 QFont font(name, size, QFont::Normal );
92 font.setFixedPitch(TRUE ); 98 font.setFixedPitch(TRUE );
93 return font; 99 return font;
94} 100}
95QColor EmulationHandler::foreColor(int col) { 101QColor EmulationHandler::foreColor(int col) {
@@ -100,48 +106,74 @@ QColor EmulationHandler::foreColor(int col) {
100 case Profile::White: 106 case Profile::White:
101 /* color is black */ 107 /* color is black */
102 co = Qt::white; 108 co = Qt::white;
103 break; 109 break;
104 case Profile::Black: 110 case Profile::Black:
105 co = Qt::black; 111 co = Qt::black;
106 break; 112 break;
107 case Profile::Green: 113 case Profile::Green:
108 qWarning("Foreground green"); 114 qWarning("Foreground green");
109 co = Qt::green; 115 co = Qt::green;
110 break; 116 break;
111 case Profile::Orange: 117 case Profile::Orange:
112 qWarning("Foreground orange"); 118 qWarning("Foreground orange");
113 // FIXME needs better color here 119 // FIXME needs better color here
114 co = Qt::darkYellow; 120 co = Qt::darkYellow;
115 break; 121 break;
116 } 122 }
117 123
118 return co; 124 return co;
119} 125}
120QColor EmulationHandler::backColor(int col ) { 126QColor EmulationHandler::backColor(int col ) {
121 QColor co; 127 QColor co;
122 /* we need to switch it */ 128 /* we need to switch it */
123 switch( col ) { 129 switch( col ) {
124 default: 130 default:
125 case Profile::White: 131 case Profile::White:
126 /* color is white */ 132 /* color is white */
127 co = Qt::black; 133 co = Qt::black;
128 break; 134 break;
129 case Profile::Black: 135 case Profile::Black:
130 co = Qt::white; 136 co = Qt::white;
131 break; 137 break;
132 case Profile::Green: 138 case Profile::Green:
133 qWarning("Background black"); 139 qWarning("Background black");
134 co = Qt::black; 140 co = Qt::black;
135 break; 141 break;
136 case Profile::Orange: 142 case Profile::Orange:
137 qWarning("Background black"); 143 qWarning("Background black");
138 co = Qt::black; 144 co = Qt::black;
139 break; 145 break;
140 } 146 }
141 147
142 return co; 148 return co;
143} 149}
144 150
145QPushButton* EmulationHandler::cornerButton() { 151QPushButton* EmulationHandler::cornerButton() {
146 return m_teWid->cornerButton(); 152 return m_teWid->cornerButton();
147} 153}
154
155
156Script *EmulationHandler::script() {
157 return m_script;
158}
159
160bool EmulationHandler::isRecording() {
161 return (m_script != 0);
162}
163
164void EmulationHandler::startRecording() {
165 if (!isRecording())
166 m_script = new Script();
167}
168
169void EmulationHandler::clearScript() {
170 if (isRecording()) {
171 delete m_script;
172 m_script = 0;
173 }
174}
175
176void EmulationHandler::runScript(const Script *script) {
177 emit send(script->script());
178}
179
diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h
index 9ceafc6..7ca2cf3 100644
--- a/noncore/apps/opie-console/emulation_handler.h
+++ b/noncore/apps/opie-console/emulation_handler.h
@@ -1,73 +1,90 @@
1#ifndef OPIE_EMULATION_HANDLER_H 1#ifndef OPIE_EMULATION_HANDLER_H
2#define OPIE_EMULATION_HANDLER_H 2#define OPIE_EMULATION_HANDLER_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qcolor.h> 5#include <qcolor.h>
6#include <qcstring.h> 6#include <qcstring.h>
7 7
8/* 8/*
9 * Badly ibotty lacks the time to finish 9 * Badly ibotty lacks the time to finish
10 * his widget in time.. 10 * his widget in time..
11 * Never the less we've to have an EmulationWidget 11 * Never the less we've to have an EmulationWidget
12 * This is why I'm taking the inferior not cleaned 12 * This is why I'm taking the inferior not cleaned
13 * up TE* KDE STUFF 13 * up TE* KDE STUFF
14 */ 14 */
15 15
16/** 16/**
17 * This is the layer above the IOLayer* 17 * This is the layer above the IOLayer*
18 * This nice QObject here will get stuff from 18 * This nice QObject here will get stuff from
19 * got a slot and a signal 19 * got a slot and a signal
20 * the signal for data 20 * the signal for data
21 * the slot for receiving 21 * the slot for receiving
22 * it'll set up the widget internally 22 * it'll set up the widget internally
23 * and manage the communication between 23 * and manage the communication between
24 * the pre QByteArray world! 24 * the pre QByteArray world!
25 */ 25 */
26class Profile; 26class Profile;
27class QWidget; 27class QWidget;
28class QPushButton; 28class QPushButton;
29class TEWidget; 29class TEWidget;
30class TEmulation; 30class TEmulation;
31class QFont; 31class QFont;
32class Script;
32class EmulationHandler : public QObject { 33class EmulationHandler : public QObject {
33 Q_OBJECT 34 Q_OBJECT
34public: 35public:
35 /** 36 /**
36 * simple c'tor the parent of the TEWdiget 37 * simple c'tor the parent of the TEWdiget
37 * and a name 38 * and a name
38 * and a Profile 39 * and a Profile
39 */ 40 */
40 EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); 41 EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l );
41 42
42 /** 43 /**
43 * delete all components 44 * delete all components
44 */ 45 */
45 ~EmulationHandler(); 46 ~EmulationHandler();
46 47
47 void load( const Profile& ); 48 void load( const Profile& );
48 QWidget* widget(); 49 QWidget* widget();
49 void setColor( const QColor& fore, const QColor& back ); 50 void setColor( const QColor& fore, const QColor& back );
50 QPushButton* cornerButton(); 51 QPushButton* cornerButton();
52
53 /* Scripts */
54 /* Create a new script and record all typed characters */
55 void startRecording();
56
57 /* Return whether we are currently recording a script */
58 bool isRecording();
59
60 /* Return the current script (or NULL) */
61 Script *script();
62
63 /* Stop recording and remove the current script from memory */
64 void clearScript();
65
66 /* Run a script by forwarding its keys to the EmulationLayer */
67 void runScript(const Script *);
51 68
52signals: 69signals:
53 void send( const QByteArray& ); 70 void send( const QByteArray& );
54 void changeSize(int rows, int cols ); 71 void changeSize(int rows, int cols );
55 72
56 73
57public slots: 74public slots:
58 void recv( const QByteArray& ); 75 void recv( const QByteArray& );
59 76
60private slots: 77private slots:
61 void recvEmulation( const char*, int len ); 78 void recvEmulation( const char*, int len );
62private: 79private:
63 QFont font( int ); 80 QFont font( int );
64 QColor foreColor(int ); 81 QColor foreColor(int );
65 QColor backColor(int ); 82 QColor backColor(int );
66 83
67private: 84private:
68 TEWidget* m_teWid; 85 TEWidget* m_teWid;
69 TEmulation* m_teEmu; 86 TEmulation* m_teEmu;
70 87 Script * m_script;
71}; 88};
72 89
73#endif 90#endif
diff --git a/noncore/apps/opie-console/emulation_layer.cpp b/noncore/apps/opie-console/emulation_layer.cpp
index 265c11f..6a2679e 100644
--- a/noncore/apps/opie-console/emulation_layer.cpp
+++ b/noncore/apps/opie-console/emulation_layer.cpp
@@ -62,124 +62,121 @@
62 well as individual characters typed. 62 well as individual characters typed.
63 (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). 63 (BULK_TIMEOUT < 1000 / max characters received from keyboard per second).
64 64
65 Additionally, we trigger refreshing by newlines comming in to make visual 65 Additionally, we trigger refreshing by newlines comming in to make visual
66 snapshots of lists as produced by `cat', `ls' and likely programs, thereby 66 snapshots of lists as produced by `cat', `ls' and likely programs, thereby
67 producing the illusion of a permanent and immediate display operation. 67 producing the illusion of a permanent and immediate display operation.
68 68
69 As a sort of catch-all needed for cases where none of the above 69 As a sort of catch-all needed for cases where none of the above
70 conditions catch, the screen refresh is also triggered by a count 70 conditions catch, the screen refresh is also triggered by a count
71 of incoming bulks (`bulk_incnt'). 71 of incoming bulks (`bulk_incnt').
72*/ 72*/
73 73
74/* FIXME 74/* FIXME
75 - evtl. the bulk operations could be made more transparent. 75 - evtl. the bulk operations could be made more transparent.
76*/ 76*/
77 77
78#include "emulation_layer.h" 78#include "emulation_layer.h"
79#include "widget_layer.h" 79#include "widget_layer.h"
80#include "screen.h" 80#include "screen.h"
81#include <stdio.h> 81#include <stdio.h>
82#include <stdlib.h> 82#include <stdlib.h>
83#include <unistd.h> 83#include <unistd.h>
84#include <qkeycode.h> 84#include <qkeycode.h>
85 85
86 86
87/* ------------------------------------------------------------------------- */ 87/* ------------------------------------------------------------------------- */
88/* */ 88/* */
89/* EmulationLayer */ 89/* EmulationLayer */
90/* */ 90/* */
91/* ------------------------------------------------------------------------- */ 91/* ------------------------------------------------------------------------- */
92 92
93#define CNTL(c) ((c)-'@') 93#define CNTL(c) ((c)-'@')
94 94
95/*! 95/*!
96*/ 96*/
97 97
98EmulationLayer::EmulationLayer( WidgetLayer* gui ) 98EmulationLayer::EmulationLayer( WidgetLayer* gui )
99: decoder((QTextDecoder*)NULL) 99: decoder((QTextDecoder*)NULL)
100{ 100{
101 this->gui = gui; 101 this->gui = gui;
102 102
103 screen[0] = new Screen(gui->lines(),gui->columns()); 103 screen[0] = new Screen(gui->lines(),gui->columns());
104 screen[1] = new Screen(gui->lines(),gui->columns()); 104 screen[1] = new Screen(gui->lines(),gui->columns());
105 scr = screen[0]; 105 scr = screen[0];
106 106
107 bulk_nlcnt = 0; // reset bulk newline counter 107 bulk_nlcnt = 0; // reset bulk newline counter
108 bulk_incnt = 0; // reset bulk counter 108 bulk_incnt = 0; // reset bulk counter
109 connected = FALSE; 109 connected = FALSE;
110 m_script = 0;
111 110
112 QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) ); 111 QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) );
113 QObject::connect(gui,SIGNAL( imageSizeChanged( int, int ) ), 112 QObject::connect(gui,SIGNAL( imageSizeChanged( int, int ) ),
114 this,SLOT( onImageSizeChange( int, int ) ) ); 113 this,SLOT( onImageSizeChange( int, int ) ) );
115 QObject::connect(gui,SIGNAL( changedHistoryCursor( int ) ), 114 QObject::connect(gui,SIGNAL( changedHistoryCursor( int ) ),
116 this,SLOT( historyCursorChange( int ) ) ); 115 this,SLOT( historyCursorChange( int ) ) );
117 QObject::connect(gui,SIGNAL( keyPressed( QKeyEvent* ) ), 116 QObject::connect(gui,SIGNAL( keyPressed( QKeyEvent* ) ),
118 this,SLOT( onKeyPress( QKeyEvent* ) ) ); 117 this,SLOT( onKeyPress( QKeyEvent* ) ) );
119 QObject::connect(gui,SIGNAL( selectionBegin( const int, const int) ), 118 QObject::connect(gui,SIGNAL( selectionBegin( const int, const int) ),
120 this,SLOT( onSelectionBegin( const int, const int ) ) ); 119 this,SLOT( onSelectionBegin( const int, const int ) ) );
121 QObject::connect(gui,SIGNAL( selectionExtended( const int, const int ) ), 120 QObject::connect(gui,SIGNAL( selectionExtended( const int, const int ) ),
122 this,SLOT( onSelectionExtend( const int,const int ) ) ); 121 this,SLOT( onSelectionExtend( const int,const int ) ) );
123 QObject::connect(gui,SIGNAL( selectionEnd( const bool ) ), 122 QObject::connect(gui,SIGNAL( selectionEnd( const bool ) ),
124 this,SLOT( setSelection( const bool ) ) ); 123 this,SLOT( setSelection( const bool ) ) );
125 QObject::connect(gui,SIGNAL( selectionCleared() ), 124 QObject::connect(gui,SIGNAL( selectionCleared() ),
126 this,SLOT( clearSelection() ) ); 125 this,SLOT( clearSelection() ) );
127} 126}
128 127
129/*! 128/*!
130*/ 129*/
131 130
132EmulationLayer::~EmulationLayer() 131EmulationLayer::~EmulationLayer()
133{ 132{
134 delete screen[0]; 133 delete screen[0];
135 delete screen[1]; 134 delete screen[1];
136 if (isRecording())
137 clearScript();
138 bulk_timer.stop(); 135 bulk_timer.stop();
139} 136}
140 137
141/*! change between primary and alternate screen 138/*! change between primary and alternate screen
142*/ 139*/
143 140
144void EmulationLayer::setScreen(int n) 141void EmulationLayer::setScreen(int n)
145{ 142{
146 scr = screen[n&1]; 143 scr = screen[n&1];
147} 144}
148 145
149void EmulationLayer::setHistory(bool on) 146void EmulationLayer::setHistory(bool on)
150{ 147{
151 screen[0]->setScroll(on); 148 screen[0]->setScroll(on);
152 if (!connected) return; 149 if (!connected) return;
153 showBulk(); 150 showBulk();
154} 151}
155 152
156bool EmulationLayer::history() 153bool EmulationLayer::history()
157{ 154{
158 return screen[0]->hasScroll(); 155 return screen[0]->hasScroll();
159} 156}
160 157
161void EmulationLayer::setCodec(int c) 158void EmulationLayer::setCodec(int c)
162{ 159{
163 //FIXME: check whether we have to free codec 160 //FIXME: check whether we have to free codec
164 codec = c ? QTextCodec::codecForName("utf8") 161 codec = c ? QTextCodec::codecForName("utf8")
165 : QTextCodec::codecForLocale(); 162 : QTextCodec::codecForLocale();
166 if (decoder) delete decoder; 163 if (decoder) delete decoder;
167 decoder = codec->makeDecoder(); 164 decoder = codec->makeDecoder();
168} 165}
169 166
170void EmulationLayer::setKeytrans(int no) 167void EmulationLayer::setKeytrans(int no)
171{ 168{
172 keytrans = KeyTrans::find(no); 169 keytrans = KeyTrans::find(no);
173} 170}
174 171
175void EmulationLayer::setKeytrans(const char * no) 172void EmulationLayer::setKeytrans(const char * no)
176{ 173{
177 keytrans = KeyTrans::find(no); 174 keytrans = KeyTrans::find(no);
178} 175}
179 176
180// Interpreting Codes --------------------------------------------------------- 177// Interpreting Codes ---------------------------------------------------------
181 178
182/* 179/*
183 This section deals with decoding the incoming character stream. 180 This section deals with decoding the incoming character stream.
184 Decoding means here, that the stream is first seperated into `tokens' 181 Decoding means here, that the stream is first seperated into `tokens'
185 which are then mapped to a `meaning' provided as operations by the 182 which are then mapped to a `meaning' provided as operations by the
@@ -187,154 +184,122 @@ void EmulationLayer::setKeytrans(const char * no)
187*/ 184*/
188 185
189/*! 186/*!
190*/ 187*/
191 188
192void EmulationLayer::onRcvChar(int c) 189void EmulationLayer::onRcvChar(int c)
193// process application unicode input to terminal 190// process application unicode input to terminal
194// this is a trivial scanner 191// this is a trivial scanner
195{ 192{
196 c &= 0xff; 193 c &= 0xff;
197 switch (c) 194 switch (c)
198 { 195 {
199 case '\b' : scr->BackSpace(); break; 196 case '\b' : scr->BackSpace(); break;
200 case '\t' : scr->Tabulate(); break; 197 case '\t' : scr->Tabulate(); break;
201 case '\n' : scr->NewLine(); break; 198 case '\n' : scr->NewLine(); break;
202 case '\r' : scr->Return(); break; 199 case '\r' : scr->Return(); break;
203 case 0x07 : gui->bell(); break; 200 case 0x07 : gui->bell(); break;
204 default : scr->ShowCharacter(c); break; 201 default : scr->ShowCharacter(c); break;
205 }; 202 };
206} 203}
207 204
208/* ------------------------------------------------------------------------- */ 205/* ------------------------------------------------------------------------- */
209/* */ 206/* */
210/* Keyboard Handling */ 207/* Keyboard Handling */
211/* */ 208/* */
212/* ------------------------------------------------------------------------- */ 209/* ------------------------------------------------------------------------- */
213 210
214/*! 211/*!
215*/ 212*/
216 213
217void EmulationLayer::onKeyPress( QKeyEvent* ev ) 214void EmulationLayer::onKeyPress( QKeyEvent* ev )
218{ 215{
219 if (!connected) return; // someone else gets the keys 216 if (!connected) return; // someone else gets the keys
220 if (scr->getHistCursor() != scr->getHistLines()); 217 if (scr->getHistCursor() != scr->getHistLines());
221 scr->setHistCursor(scr->getHistLines()); 218 scr->setHistCursor(scr->getHistLines());
222 if (!ev->text().isEmpty()) 219 if (!ev->text().isEmpty())
223 { // A block of text 220 { // A block of text
224 // Note that the text is proper unicode. 221 // Note that the text is proper unicode.
225 // We should do a conversion here, but since this 222 // We should do a conversion here, but since this
226 // routine will never be used, we simply emit plain ascii. 223 // routine will never be used, we simply emit plain ascii.
227 sendString( ev->text().ascii() ); //,ev->text().length()); 224 sendString( ev->text().ascii() ); //,ev->text().length());
228 } 225 }
229 else if (ev->ascii()>0) 226 else if (ev->ascii()>0)
230 { 227 {
231 QByteArray c = QByteArray( 1 ); 228 QByteArray c = QByteArray( 1 );
232 c.at( 0 ) = ev->ascii(); 229 c.at( 0 ) = ev->ascii();
233 // ibot: qbytearray is emited not char* 230 // ibot: qbytearray is emited not char*
234 231
235 /* Are we currently recording a script? If so, store the typed character */
236 if (isRecording())
237 m_script->appendString(ev->text());
238 emit sndBlock( (QByteArray) c ); 232 emit sndBlock( (QByteArray) c );
239 } 233 }
240} 234}
241 235
242// Unblocking, Byte to Unicode translation --------------------------------- -- 236// Unblocking, Byte to Unicode translation --------------------------------- --
243 237
244/* 238/*
245 We are doing code conversion from locale to unicode first. 239 We are doing code conversion from locale to unicode first.
246*/ 240*/
247 241
248void EmulationLayer::onRcvBlock(const QByteArray &s ) 242void EmulationLayer::onRcvBlock(const QByteArray &s )
249{ 243{
250 bulkStart(); 244 bulkStart();
251 bulk_incnt += 1; 245 bulk_incnt += 1;
252 for (int i = 0; i < s.size(); i++) 246 for (int i = 0; i < s.size(); i++)
253 { 247 {
254 //TODO: ibot: maybe decoding qbytearray to unicode in io_layer? 248 //TODO: ibot: maybe decoding qbytearray to unicode in io_layer?
255 QString result = decoder->toUnicode(&s[i],1); 249 QString result = decoder->toUnicode(&s[i],1);
256 int reslen = result.length(); 250 int reslen = result.length();
257 for (int j = 0; j < reslen; j++) 251 for (int j = 0; j < reslen; j++)
258 onRcvChar(result[j].unicode()); 252 onRcvChar(result[j].unicode());
259 if (s[i] == '\n') bulkNewline(); 253 if (s[i] == '\n') bulkNewline();
260 } 254 }
261 bulkEnd(); 255 bulkEnd();
262} 256}
263 257
264// Scripts ----------------------------------------------------------------- --
265
266
267Script *EmulationLayer::script() {
268 return m_script;
269}
270
271bool EmulationLayer::isRecording() {
272 return (m_script != 0);
273}
274
275void EmulationLayer::startRecording() {
276 if (!isRecording())
277 m_script = new Script();
278}
279
280void EmulationLayer::clearScript() {
281 if (isRecording()) {
282
283 }
284}
285
286void EmulationLayer::runScript(const Script *script) {
287 QByteArray a = QByteArray();
288 QString str = script->script();
289 a.setRawData(str.ascii(), str.length());
290 emit sndBlock(a);
291}
292
293// Selection --------------------------------------------------------------- -- 258// Selection --------------------------------------------------------------- --
294 259
295void EmulationLayer::onSelectionBegin(const int x, const int y) { 260void EmulationLayer::onSelectionBegin(const int x, const int y) {
296 if (!connected) return; 261 if (!connected) return;
297 scr->setSelBeginXY(x,y); 262 scr->setSelBeginXY(x,y);
298 showBulk(); 263 showBulk();
299} 264}
300 265
301void EmulationLayer::onSelectionExtend(const int x, const int y) { 266void EmulationLayer::onSelectionExtend(const int x, const int y) {
302 if (!connected) return; 267 if (!connected) return;
303 scr->setSelExtentXY(x,y); 268 scr->setSelExtentXY(x,y);
304 showBulk(); 269 showBulk();
305} 270}
306 271
307void EmulationLayer::setSelection(const BOOL preserve_line_breaks) { 272void EmulationLayer::setSelection(const BOOL preserve_line_breaks) {
308 if (!connected) return; 273 if (!connected) return;
309 QString t = scr->getSelText(preserve_line_breaks); 274 QString t = scr->getSelText(preserve_line_breaks);
310 if (!t.isNull()) gui->setSelection(t); 275 if (!t.isNull()) gui->setSelection(t);
311} 276}
312 277
313void EmulationLayer::clearSelection() { 278void EmulationLayer::clearSelection() {
314 if (!connected) return; 279 if (!connected) return;
315 scr->clearSelection(); 280 scr->clearSelection();
316 showBulk(); 281 showBulk();
317} 282}
318 283
319// Refreshing -------------------------------------------------------------- -- 284// Refreshing -------------------------------------------------------------- --
320 285
321#define BULK_TIMEOUT 20 286#define BULK_TIMEOUT 20
322 287
323/*! 288/*!
324 called when \n comes in. Evtl. triggers showBulk at endBulk 289 called when \n comes in. Evtl. triggers showBulk at endBulk
325*/ 290*/
326 291
327void EmulationLayer::bulkNewline() 292void EmulationLayer::bulkNewline()
328{ 293{
329 bulk_nlcnt += 1; 294 bulk_nlcnt += 1;
330 bulk_incnt = 0; // reset bulk counter since `nl' rule applies 295 bulk_incnt = 0; // reset bulk counter since `nl' rule applies
331} 296}
332 297
333/*! 298/*!
334*/ 299*/
335 300
336void EmulationLayer::showBulk() 301void EmulationLayer::showBulk()
337{ 302{
338 bulk_nlcnt = 0; // reset bulk newline counter 303 bulk_nlcnt = 0; // reset bulk newline counter
339 bulk_incnt = 0; // reset bulk counter 304 bulk_incnt = 0; // reset bulk counter
340 if (connected) 305 if (connected)
@@ -361,48 +326,49 @@ void EmulationLayer::bulkEnd()
361 else 326 else
362 bulk_timer.start(BULK_TIMEOUT,TRUE); 327 bulk_timer.start(BULK_TIMEOUT,TRUE);
363} 328}
364 329
365void EmulationLayer::setConnect(bool c) 330void EmulationLayer::setConnect(bool c)
366{ 331{
367 connected = c; 332 connected = c;
368 if ( connected) 333 if ( connected)
369 { 334 {
370 onImageSizeChange(gui->lines(), gui->columns()); 335 onImageSizeChange(gui->lines(), gui->columns());
371 showBulk(); 336 showBulk();
372 } 337 }
373 else 338 else
374 { 339 {
375 scr->clearSelection(); 340 scr->clearSelection();
376 } 341 }
377} 342}
378 343
379// --------------------------------------------------------------------------- 344// ---------------------------------------------------------------------------
380 345
381/*! triggered by image size change of the Widget `gui'. 346/*! triggered by image size change of the Widget `gui'.
382 347
383 This event is simply propagated to the attached screens 348 This event is simply propagated to the attached screens
384 and to the related serial line. 349 and to the related serial line.
385*/ 350*/
386 351
387void EmulationLayer::onImageSizeChange(int lines, int columns) 352void EmulationLayer::onImageSizeChange(int lines, int columns)
388{ 353{
389 if (!connected) return; 354 if (!connected) return;
390 screen[0]->resizeImage(lines,columns); 355 screen[0]->resizeImage(lines,columns);
391 screen[1]->resizeImage(lines,columns); 356 screen[1]->resizeImage(lines,columns);
392 showBulk(); 357 showBulk();
393 emit ImageSizeChanged(lines,columns); // propagate event to serial line 358 emit ImageSizeChanged(lines,columns); // propagate event to serial line
394} 359}
395 360
396void EmulationLayer::onHistoryCursorChange(int cursor) 361void EmulationLayer::onHistoryCursorChange(int cursor)
397{ 362{
398 if (!connected) return; 363 if (!connected) return;
399 scr->setHistCursor(cursor); 364 scr->setHistCursor(cursor);
400 showBulk(); 365 showBulk();
401} 366}
402 367
403void EmulationLayer::setColumns(int columns) 368void EmulationLayer::setColumns(int columns)
404{ 369{
405 //FIXME: this goes strange ways. 370 //FIXME: this goes strange ways.
406 // Can we put this straight or explain it at least? 371 // Can we put this straight or explain it at least?
407 emit changeColumns(columns); 372 emit changeColumns(columns);
408} 373}
374
diff --git a/noncore/apps/opie-console/emulation_layer.h b/noncore/apps/opie-console/emulation_layer.h
index 928ad04..73e5bf6 100644
--- a/noncore/apps/opie-console/emulation_layer.h
+++ b/noncore/apps/opie-console/emulation_layer.h
@@ -1,163 +1,145 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [emulation.h] Fundamental Terminal Emulation */ 3/* [emulation.h] Fundamental Terminal Emulation */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12 /* */ 12 /* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14 /* */ 14 /* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16 /* */ 16 /* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18/* -------------------------------------------------------------------------- */ 18/* -------------------------------------------------------------------------- */
19 /* */ 19 /* */
20/* made to a layer between io_layer and widget */ 20/* made to a layer between io_layer and widget */
21 /* */ 21 /* */
22/* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ 22/* Copyright (C) 2002 by opie developers <opie@handhelds.org> */
23 /* */ 23 /* */
24/* -------------------------------------------------------------------------- */ 24/* -------------------------------------------------------------------------- */
25 25
26#ifndef EMULATION_LAYER_H 26#ifndef EMULATION_LAYER_H
27#define EMULATION_LAYER_H 27#define EMULATION_LAYER_H
28 28
29#include "widget_layer.h" 29#include "widget_layer.h"
30#include "screen.h" 30#include "screen.h"
31#include <qtimer.h> 31#include <qtimer.h>
32#include <stdio.h> 32#include <stdio.h>
33#include <qtextcodec.h> 33#include <qtextcodec.h>
34#include "keytrans.h" 34#include "keytrans.h"
35#include "script.h"
36 35
37class EmulationLayer : public QObject 36class EmulationLayer : public QObject
38{ Q_OBJECT 37{ Q_OBJECT
39 38
40public: 39public:
41 40
42 EmulationLayer( WidgetLayer* gui ); 41 EmulationLayer( WidgetLayer* gui );
43 ~EmulationLayer(); 42 ~EmulationLayer();
44 43
45public: 44public:
46 virtual void setHistory(bool on); 45 virtual void setHistory(bool on);
47 virtual bool history(); 46 virtual bool history();
48 47
49public slots: // signals incoming from Widget 48public slots: // signals incoming from Widget
50 49
51 virtual void onImageSizeChange(int lines, int columns); 50 virtual void onImageSizeChange(int lines, int columns);
52 virtual void onHistoryCursorChange(int cursor); 51 virtual void onHistoryCursorChange(int cursor);
53 virtual void onKeyPress(QKeyEvent*); 52 virtual void onKeyPress(QKeyEvent*);
54 53
55 virtual void clearSelection(); 54 virtual void clearSelection();
56 virtual void onSelectionBegin(const int x, const int y); 55 virtual void onSelectionBegin(const int x, const int y);
57 virtual void onSelectionExtend(const int x, const int y); 56 virtual void onSelectionExtend(const int x, const int y);
58 virtual void setSelection(const bool preserve_line_breaks); 57 virtual void setSelection(const bool preserve_line_breaks);
59 58
60public slots: // signals incoming from data source 59public slots: // signals incoming from data source
61 60
62 /** 61 /**
63 * to be called, when new data arrives 62 * to be called, when new data arrives
64 */ 63 */
65 void onRcvBlock(const QByteArray&); 64 void onRcvBlock(const QByteArray&);
66 65
67signals: 66signals:
68 67
69 /** 68 /**
70 * will send data, encoded to suit emulation 69 * will send data, encoded to suit emulation
71 */ 70 */
72 void sndBlock(const QByteArray&); 71 void sndBlock(const QByteArray&);
73 72
74 void ImageSizeChanged(int lines, int columns); 73 void ImageSizeChanged(int lines, int columns);
75 74
76 void changeColumns(int columns); 75 void changeColumns(int columns);
77 76
78 void changeTitle(int arg, const char* str); 77 void changeTitle(int arg, const char* str);
79 78
80 79
81public: 80public:
82 81
83 /** 82 /**
84 * process single char (decode) 83 * process single char (decode)
85 */ 84 */
86 virtual void onRcvChar(int); 85 virtual void onRcvChar(int);
87 86
88 virtual void setMode (int) = 0; 87 virtual void setMode (int) = 0;
89 virtual void resetMode(int) = 0; 88 virtual void resetMode(int) = 0;
90 89
91 /** 90 /**
92 * @deprecated use qbytearray instead 91 * @deprecated use qbytearray instead
93 */ 92 */
94 virtual void sendString(const char*) = 0; 93 virtual void sendString(const char*) = 0;
95 94
96 /** 95 /**
97 * sends a string to IOLayer 96 * sends a string to IOLayer
98 * encodes to suit emulation before 97 * encodes to suit emulation before
99 */ 98 */
100 virtual void sendString(const QByteArray&) = 0; 99 virtual void sendString(const QByteArray&) = 0;
101 100
102 virtual void setConnect(bool r); 101 virtual void setConnect(bool r);
103 void setColumns(int columns); 102 void setColumns(int columns);
104 103
105 void setKeytrans(int no); 104 void setKeytrans(int no);
106 void setKeytrans(const char * no); 105 void setKeytrans(const char * no);
107 106
108 /* Scripts */
109
110 /* Create a new script and record all typed characters */
111 void startRecording();
112
113 /* Return whether we are currently recording a script */
114 bool isRecording();
115
116 /* Return the current script (or NULL) */
117 Script *script();
118
119 /* Stop recording and remove the current script from memory */
120 void clearScript();
121
122 /* Run a script by forwarding its keys to the EmulationLayer */
123 void runScript(const Script *);
124protected: 107protected:
125 108
126 WidgetLayer* gui; 109 WidgetLayer* gui;
127 Screen* scr; // referes to one `screen' 110 Screen* scr; // referes to one `screen'
128 Screen* screen[2]; // 0 = primary, 1 = alternate 111 Screen* screen[2]; // 0 = primary, 1 = alternate
129 void setScreen(int n); // set `scr' to `screen[n]' 112 void setScreen(int n); // set `scr' to `screen[n]'
130 113
131 bool connected; // communicate with widget 114 bool connected; // communicate with widget
132 115
133 void setCodec(int c); // codec number, 0 = locale, 1=utf8 116 void setCodec(int c); // codec number, 0 = locale, 1=utf8
134 117
135 QTextCodec* codec; 118 QTextCodec* codec;
136 QTextCodec* localeCodec; 119 QTextCodec* localeCodec;
137 QTextDecoder* decoder; 120 QTextDecoder* decoder;
138 121
139 KeyTrans* keytrans; 122 KeyTrans* keytrans;
140 123
141// refreshing related material. 124// refreshing related material.
142// this is localized in the class. 125// this is localized in the class.
143private slots: // triggered by timer 126private slots: // triggered by timer
144 127
145 void showBulk(); 128 void showBulk();
146 129
147private: 130private:
148 131
149 void bulkNewline(); 132 void bulkNewline();
150 void bulkStart(); 133 void bulkStart();
151 void bulkEnd(); 134 void bulkEnd();
152 135
153private: 136private:
154 137
155 QTimer bulk_timer; 138 QTimer bulk_timer;
156 int bulk_nlcnt; // bulk newline counter 139 int bulk_nlcnt; // bulk newline counter
157 char* SelectedText; 140 char* SelectedText;
158 int bulk_incnt; // bulk counter 141 int bulk_incnt; // bulk counter
159 Script *m_script;
160 142
161}; 143};
162 144
163#endif // ifndef EMULATION_H 145#endif // ifndef EMULATION_H
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index a7541f0..49f9653 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -241,131 +241,127 @@ void MainWindow::initUI() {
241 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 241 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
242 this, SLOT(slotSessionChanged(Session*) ) ); 242 this, SLOT(slotSessionChanged(Session*) ) );
243 setCentralWidget( m_consoleWindow ); 243 setCentralWidget( m_consoleWindow );
244 244
245} 245}
246 246
247ProfileManager* MainWindow::manager() { 247ProfileManager* MainWindow::manager() {
248 return m_manager; 248 return m_manager;
249} 249}
250TabWidget* MainWindow::tabWidget() { 250TabWidget* MainWindow::tabWidget() {
251 return m_consoleWindow; 251 return m_consoleWindow;
252} 252}
253void MainWindow::populateProfiles() { 253void MainWindow::populateProfiles() {
254 m_sessionsPop->clear(); 254 m_sessionsPop->clear();
255 Profile::ValueList list = manager()->all(); 255 Profile::ValueList list = manager()->all();
256 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 256 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
257 m_sessionsPop->insertItem( (*it).name() ); 257 m_sessionsPop->insertItem( (*it).name() );
258 } 258 }
259 259
260} 260}
261MainWindow::~MainWindow() { 261MainWindow::~MainWindow() {
262 delete m_factory; 262 delete m_factory;
263 manager()->save(); 263 manager()->save();
264} 264}
265 265
266MetaFactory* MainWindow::factory() { 266MetaFactory* MainWindow::factory() {
267 return m_factory; 267 return m_factory;
268} 268}
269 269
270Session* MainWindow::currentSession() { 270Session* MainWindow::currentSession() {
271 return m_curSession; 271 return m_curSession;
272} 272}
273 273
274QList<Session> MainWindow::sessions() { 274QList<Session> MainWindow::sessions() {
275 return m_sessions; 275 return m_sessions;
276} 276}
277 277
278void MainWindow::slotNew() { 278void MainWindow::slotNew() {
279 ProfileEditorDialog dlg(factory() ); 279 ProfileEditorDialog dlg(factory() );
280 dlg.showMaximized(); 280 dlg.showMaximized();
281 int ret = dlg.exec(); 281 int ret = dlg.exec();
282 282
283 if ( ret == QDialog::Accepted ) { 283 if ( ret == QDialog::Accepted ) {
284 create( dlg.profile() ); 284 create( dlg.profile() );
285 } 285 }
286} 286}
287 287
288void MainWindow::slotRecordScript() { 288void MainWindow::slotRecordScript() {
289/* if (currentSession()) { 289 if (currentSession()) {
290 currentSession()->emulationLayer()->startRecording(); 290 currentSession()->emulationHandler()->startRecording();
291 } 291 }
292 */
293} 292}
294 293
295void MainWindow::slotSaveScript() { 294void MainWindow::slotSaveScript() {
296/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { 295 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
297 MimeTypes types; 296 MimeTypes types;
298 QStringList script; 297 QStringList script;
299 script << "text/plain"; 298 script << "text/plain";
300 types.insert("Script", script); 299 types.insert("Script", script);
301 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 300 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
302 if (!filename.isEmpty()) { 301 if (!filename.isEmpty()) {
303 currentSession()->emulationLayer()->script()->saveTo(filename); 302 currentSession()->emulationHandler()->script()->saveTo(filename);
304 currentSession()->emulationLayer()->clearScript(); 303 currentSession()->emulationHandler()->clearScript();
305 } 304 }
306 } 305 }
307 */
308} 306}
309 307
310void MainWindow::slotRunScript() { 308void MainWindow::slotRunScript() {
311/*
312 if (currentSession()) { 309 if (currentSession()) {
313 MimeTypes types; 310 MimeTypes types;
314 QStringList script; 311 QStringList script;
315 script << "text/plain"; 312 script << "text/plain";
316 types.insert("Script", script); 313 types.insert("Script", script);
317 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); 314 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
318 if (!filename.isEmpty()) { 315 if (!filename.isEmpty()) {
319 Script script(DocLnk(filename).file()); 316 Script script(DocLnk(filename).file());
320 currentSession()->emulationLayer()->runScript(&script); 317 currentSession()->emulationHandler()->runScript(&script);
321 } 318 }
322 } 319 }
323 */
324} 320}
325 321
326void MainWindow::slotConnect() { 322void MainWindow::slotConnect() {
327 if ( currentSession() ) { 323 if ( currentSession() ) {
328 bool ret = currentSession()->layer()->open(); 324 bool ret = currentSession()->layer()->open();
329 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 325 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
330 QObject::tr("Failed"), 326 QObject::tr("Failed"),
331 QObject::tr("Connecting failed for this session.")); 327 QObject::tr("Connecting failed for this session."));
332 else { 328 else {
333 m_connect->setEnabled( false ); 329 m_connect->setEnabled( false );
334 m_disconnect->setEnabled( true ); 330 m_disconnect->setEnabled( true );
335 } 331 }
336 } 332 }
337} 333}
338 334
339void MainWindow::slotDisconnect() { 335void MainWindow::slotDisconnect() {
340 if ( currentSession() ) { 336 if ( currentSession() ) {
341 currentSession()->layer()->close(); 337 currentSession()->layer()->close();
342 m_connect->setEnabled( true ); 338 m_connect->setEnabled( true );
343 m_disconnect->setEnabled( false ); 339 m_disconnect->setEnabled( false );
344 } 340 }
345} 341}
346 342
347void MainWindow::slotTerminate() { 343void MainWindow::slotTerminate() {
348 if ( currentSession() ) 344 if ( currentSession() )
349 currentSession()->layer()->close(); 345 currentSession()->layer()->close();
350 346
351 slotClose(); 347 slotClose();
352 /* FIXME move to the next session */ 348 /* FIXME move to the next session */
353} 349}
354 350
355void MainWindow::slotConfigure() { 351void MainWindow::slotConfigure() {
356 ConfigDialog conf( manager()->all(), factory() ); 352 ConfigDialog conf( manager()->all(), factory() );
357 conf.showMaximized(); 353 conf.showMaximized();
358 354
359 int ret = conf.exec(); 355 int ret = conf.exec();
360 356
361 if ( QDialog::Accepted == ret ) { 357 if ( QDialog::Accepted == ret ) {
362 manager()->setProfiles( conf.list() ); 358 manager()->setProfiles( conf.list() );
363 manager()->save(); 359 manager()->save();
364 populateProfiles(); 360 populateProfiles();
365 } 361 }
366} 362}
367/* 363/*
368 * we will remove 364 * we will remove
369 * this window from the tabwidget 365 * this window from the tabwidget
370 * remove it from the list 366 * remove it from the list
371 * delete it 367 * delete it
diff --git a/noncore/apps/opie-console/script.cpp b/noncore/apps/opie-console/script.cpp
index a09fab6..9cb1cd3 100644
--- a/noncore/apps/opie-console/script.cpp
+++ b/noncore/apps/opie-console/script.cpp
@@ -1,30 +1,29 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <qtextstream.h> 2#include <qtextstream.h>
3#include "script.h" 3#include "script.h"
4 4
5Script::Script() { 5Script::Script() {
6} 6}
7 7
8Script::Script(const QString fileName) { 8Script::Script(const QString fileName) {
9 QFile file(fileName); 9 QFile file(fileName);
10 QTextStream stream(&file); 10 m_script = file.readAll();
11 while (!stream.atEnd()) {
12 appendString(stream.readLine());
13 }
14} 11}
15 12
16void Script::saveTo(const QString fileName) const { 13void Script::saveTo(const QString fileName) const {
17 QFile file(fileName); 14 QFile file(fileName);
18 file.open(IO_WriteOnly); 15 file.open(IO_WriteOnly);
19 file.writeBlock(m_script.ascii(), m_script.length()); 16 file.writeBlock(m_script);
20 file.close(); 17 file.close();
21} 18}
22 19
23 20
24void Script::appendString(const QString string) { 21void Script::append(const QByteArray &data) {
25 m_script += string; 22 int size = m_script.size();
23 m_script.resize(size + data.size());
24 memcpy(m_script.data() + size, data.data(), data.size());
26} 25}
27 26
28QString Script::script() const { 27QByteArray Script::script() const {
29 return m_script; 28 return m_script;
30} 29}
diff --git a/noncore/apps/opie-console/script.h b/noncore/apps/opie-console/script.h
index dc2351b..b3eac7f 100644
--- a/noncore/apps/opie-console/script.h
+++ b/noncore/apps/opie-console/script.h
@@ -1,30 +1,30 @@
1#ifndef CONSOLE_SCRIPT_H 1#ifndef CONSOLE_SCRIPT_H
2#define CONSOLE_SCRIPT_H 2#define CONSOLE_SCRIPT_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5 5
6/* Very simple scripting - this class stores keys received 6/* Very simple scripting - this class stores keys received
7 * by emulation_layer */ 7 * by emulation_layer */
8 8
9class Script { 9class Script {
10public: 10public:
11 /* Construct an empty script */ 11 /* Construct an empty script */
12 Script(); 12 Script();
13 13
14 /* Load a script from a text file */ 14 /* Load a script from a text file */
15 Script(const QString fileName); 15 Script(const QString fileName);
16 16
17 /* Append a line to the script */ 17 /* Append a line to the script */
18 void appendString(const QString string); 18 void append(const QByteArray &data);
19 19
20 /* Save this script to a file */ 20 /* Save this script to a file */
21 void saveTo(const QString fileName) const; 21 void saveTo(const QString fileName) const;
22 22
23 /* Return the script's content */ 23 /* Return the script's content */
24 QString script() const; 24 QByteArray script() const;
25protected: 25protected:
26 QString m_script; 26 QByteArray m_script;
27}; 27};
28 28
29 29
30#endif /* CONSOLE_SCRIPT_H */ 30#endif /* CONSOLE_SCRIPT_H */