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
@@ -6,13 +6,14 @@
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
@@ -28,9 +29,12 @@ EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const c
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");
@@ -45,6 +49,8 @@ void EmulationHandler::recvEmulation(const char* src, int 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() {
@@ -145,3 +151,29 @@ QColor EmulationHandler::backColor(int col ) {
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
@@ -29,6 +29,7 @@ class 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:
@@ -48,6 +49,22 @@ public:
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& );
@@ -67,7 +84,7 @@ private:
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
@@ -107,7 +107,6 @@ EmulationLayer::EmulationLayer( WidgetLayer* gui )
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 ) ),
@@ -133,8 +132,6 @@ EmulationLayer::~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
@@ -232,9 +229,6 @@ void EmulationLayer::onKeyPress( QKeyEvent* ev )
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}
@@ -261,35 +255,6 @@ void EmulationLayer::onRcvBlock(const QByteArray &s )
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) {
@@ -406,3 +371,4 @@ void EmulationLayer::setColumns(int columns)
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
@@ -32,7 +32,6 @@
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
@@ -105,22 +104,6 @@ public:
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;
@@ -156,7 +139,6 @@ private:
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
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
@@ -286,29 +286,26 @@ void MainWindow::slotNew() {
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;
@@ -317,10 +314,9 @@ void MainWindow::slotRunScript() {
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() {
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
@@ -7,24 +7,23 @@ Script::Script() {
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
@@ -15,15 +15,15 @@ public:
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