author | wazlaf <wazlaf> | 2002-10-20 14:53:08 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-10-20 14:53:08 (UTC) |
commit | 18ba3be9ca69c42476e310649e3068d2d5f8a03b (patch) (unidiff) | |
tree | d6a68e8f1a319ef8320d714356beebcf440a630f /noncore/apps/opie-console/emulation_handler.cpp | |
parent | 9f442f5af601d1e15bb4d0509ed012e61609260d (diff) | |
download | opie-18ba3be9ca69c42476e310649e3068d2d5f8a03b.zip opie-18ba3be9ca69c42476e310649e3068d2d5f8a03b.tar.gz opie-18ba3be9ca69c42476e310649e3068d2d5f8a03b.tar.bz2 |
scripting fixed (moved from emulation_layer to emulation_handler). Scripts now use QByteArray instead of QString
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.cpp | 34 |
1 files changed, 33 insertions, 1 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,59 +1,65 @@ | |||
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 | ||
11 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) | 11 | EmulationHandler::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 | } |
30 | EmulationHandler::~EmulationHandler() { | 31 | EmulationHandler::~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 | |||
34 | void EmulationHandler::load( const Profile& prof) { | 38 | void 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 | } |
40 | void EmulationHandler::recv( const QByteArray& ar) { | 44 | void EmulationHandler::recv( const QByteArray& ar) { |
41 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); | 45 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); |
42 | } | 46 | } |
43 | void EmulationHandler::recvEmulation(const char* src, int len ) { | 47 | void 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 | } |
50 | QWidget* EmulationHandler::widget() { | 56 | QWidget* 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 | */ |
56 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { | 62 | void 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 | ||
@@ -136,12 +142,38 @@ QColor EmulationHandler::backColor(int col ) { | |||
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 | ||
145 | QPushButton* EmulationHandler::cornerButton() { | 151 | QPushButton* EmulationHandler::cornerButton() { |
146 | return m_teWid->cornerButton(); | 152 | return m_teWid->cornerButton(); |
147 | } | 153 | } |
154 | |||
155 | |||
156 | Script *EmulationHandler::script() { | ||
157 | return m_script; | ||
158 | } | ||
159 | |||
160 | bool EmulationHandler::isRecording() { | ||
161 | return (m_script != 0); | ||
162 | } | ||
163 | |||
164 | void EmulationHandler::startRecording() { | ||
165 | if (!isRecording()) | ||
166 | m_script = new Script(); | ||
167 | } | ||
168 | |||
169 | void EmulationHandler::clearScript() { | ||
170 | if (isRecording()) { | ||
171 | delete m_script; | ||
172 | m_script = 0; | ||
173 | } | ||
174 | } | ||
175 | |||
176 | void EmulationHandler::runScript(const Script *script) { | ||
177 | emit send(script->script()); | ||
178 | } | ||
179 | |||