summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/emulation_layer.cpp
authorwazlaf <wazlaf>2002-10-13 13:49:11 (UTC)
committer wazlaf <wazlaf>2002-10-13 13:49:11 (UTC)
commit68c37a3412ef4609ba0209318ef2b06f7dd1aaf1 (patch) (side-by-side diff)
treef81ee5460dd49c4fcb8a61bf50911c5036742bed /noncore/apps/opie-console/emulation_layer.cpp
parent0e6d241e26211a8ffff07ba8e23f4a3cec9065be (diff)
downloadopie-68c37a3412ef4609ba0209318ef2b06f7dd1aaf1.zip
opie-68c37a3412ef4609ba0209318ef2b06f7dd1aaf1.tar.gz
opie-68c37a3412ef4609ba0209318ef2b06f7dd1aaf1.tar.bz2
Scripting functionality added. What this currently does is catch keys in the emulation_layer
and store them in a "Script" instance. This can later be saved to a file and on request "replayed" by sending the typed keys to the associated IOLayer
Diffstat (limited to 'noncore/apps/opie-console/emulation_layer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_layer.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/emulation_layer.cpp b/noncore/apps/opie-console/emulation_layer.cpp
index 5baf05c..265c11f 100644
--- a/noncore/apps/opie-console/emulation_layer.cpp
+++ b/noncore/apps/opie-console/emulation_layer.cpp
@@ -107,6 +107,7 @@ EmulationLayer::EmulationLayer( WidgetLayer* gui )
bulk_nlcnt = 0; // reset bulk newline counter
bulk_incnt = 0; // reset bulk counter
connected = FALSE;
+ m_script = 0;
QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) );
QObject::connect(gui,SIGNAL( imageSizeChanged( int, int ) ),
@@ -132,6 +133,8 @@ EmulationLayer::~EmulationLayer()
{
delete screen[0];
delete screen[1];
+ if (isRecording())
+ clearScript();
bulk_timer.stop();
}
@@ -228,6 +231,10 @@ void EmulationLayer::onKeyPress( QKeyEvent* ev )
QByteArray c = QByteArray( 1 );
c.at( 0 ) = ev->ascii();
// ibot: qbytearray is emited not char*
+
+ /* Are we currently recording a script? If so, store the typed character */
+ if (isRecording())
+ m_script->appendString(ev->text());
emit sndBlock( (QByteArray) c );
}
}
@@ -254,6 +261,35 @@ void EmulationLayer::onRcvBlock(const QByteArray &s )
bulkEnd();
}
+// Scripts ----------------------------------------------------------------- --
+
+
+Script *EmulationLayer::script() {
+ return m_script;
+}
+
+bool EmulationLayer::isRecording() {
+ return (m_script != 0);
+}
+
+void EmulationLayer::startRecording() {
+ if (!isRecording())
+ m_script = new Script();
+}
+
+void EmulationLayer::clearScript() {
+ if (isRecording()) {
+
+ }
+}
+
+void EmulationLayer::runScript(const Script *script) {
+ QByteArray a = QByteArray();
+ QString str = script->script();
+ a.setRawData(str.ascii(), str.length());
+ emit sndBlock(a);
+}
+
// Selection --------------------------------------------------------------- --
void EmulationLayer::onSelectionBegin(const int x, const int y) {