summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/emulation_layer.cpp
authoribotty <ibotty>2002-10-09 17:40:35 (UTC)
committer ibotty <ibotty>2002-10-09 17:40:35 (UTC)
commitc80818d8388c07c1606a70306aea0c9a1e17ea3c (patch) (unidiff)
treec010af190b398b698299a42ce06217c950d6525d /noncore/apps/opie-console/emulation_layer.cpp
parente0b4cca74ec611583c38901a83c448592e8ebec6 (diff)
downloadopie-c80818d8388c07c1606a70306aea0c9a1e17ea3c.zip
opie-c80818d8388c07c1606a70306aea0c9a1e17ea3c.tar.gz
opie-c80818d8388c07c1606a70306aea0c9a1e17ea3c.tar.bz2
updated emulationLayer to use WidgetLayer (not Widget, which is b0rked)
default.cpp is broken, because there is still no new widget (coming soon...)
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.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/noncore/apps/opie-console/emulation_layer.cpp b/noncore/apps/opie-console/emulation_layer.cpp
index 6c420e0..5baf05c 100644
--- a/noncore/apps/opie-console/emulation_layer.cpp
+++ b/noncore/apps/opie-console/emulation_layer.cpp
@@ -67,71 +67,71 @@
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.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(Widget* 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 110
111 QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); 111 QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) );
112 QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), 112 QObject::connect(gui,SIGNAL( imageSizeChanged( int, int ) ),
113 this,SLOT(onImageSizeChange(int,int))); 113 this,SLOT( onImageSizeChange( int, int ) ) );
114 QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), 114 QObject::connect(gui,SIGNAL( changedHistoryCursor( int ) ),
115 this,SLOT(onHistoryCursorChange(int))); 115 this,SLOT( historyCursorChange( int ) ) );
116 QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), 116 QObject::connect(gui,SIGNAL( keyPressed( QKeyEvent* ) ),
117 this,SLOT(onKeyPress(QKeyEvent*))); 117 this,SLOT( onKeyPress( QKeyEvent* ) ) );
118 QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), 118 QObject::connect(gui,SIGNAL( selectionBegin( const int, const int) ),
119 this,SLOT(onSelectionBegin(const int,const int)) ); 119 this,SLOT( onSelectionBegin( const int, const int ) ) );
120 QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), 120 QObject::connect(gui,SIGNAL( selectionExtended( const int, const int ) ),
121 this,SLOT(onSelectionExtend(const int,const int)) ); 121 this,SLOT( onSelectionExtend( const int,const int ) ) );
122 QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), 122 QObject::connect(gui,SIGNAL( selectionEnd( const bool ) ),
123 this,SLOT(setSelection(const BOOL)) ); 123 this,SLOT( setSelection( const bool ) ) );
124 QObject::connect(gui,SIGNAL(clearSelectionSignal()), 124 QObject::connect(gui,SIGNAL( selectionCleared() ),
125 this,SLOT(clearSelection()) ); 125 this,SLOT( clearSelection() ) );
126} 126}
127 127
128/*! 128/*!
129*/ 129*/
130 130
131EmulationLayer::~EmulationLayer() 131EmulationLayer::~EmulationLayer()
132{ 132{
133 delete screen[0]; 133 delete screen[0];
134 delete screen[1]; 134 delete screen[1];
135 bulk_timer.stop(); 135 bulk_timer.stop();
136} 136}
137 137
@@ -188,25 +188,25 @@ void EmulationLayer::setKeytrans(const char * no)
188 188
189void EmulationLayer::onRcvChar(int c) 189void EmulationLayer::onRcvChar(int c)
190// process application unicode input to terminal 190// process application unicode input to terminal
191// this is a trivial scanner 191// this is a trivial scanner
192{ 192{
193 c &= 0xff; 193 c &= 0xff;
194 switch (c) 194 switch (c)
195 { 195 {
196 case '\b' : scr->BackSpace(); break; 196 case '\b' : scr->BackSpace(); break;
197 case '\t' : scr->Tabulate(); break; 197 case '\t' : scr->Tabulate(); break;
198 case '\n' : scr->NewLine(); break; 198 case '\n' : scr->NewLine(); break;
199 case '\r' : scr->Return(); break; 199 case '\r' : scr->Return(); break;
200 case 0x07 : gui->Bell(); break; 200 case 0x07 : gui->bell(); break;
201 default : scr->ShowCharacter(c); break; 201 default : scr->ShowCharacter(c); break;
202 }; 202 };
203} 203}
204 204
205/* ------------------------------------------------------------------------- */ 205/* ------------------------------------------------------------------------- */
206/* */ 206/* */
207/* Keyboard Handling */ 207/* Keyboard Handling */
208/* */ 208/* */
209/* ------------------------------------------------------------------------- */ 209/* ------------------------------------------------------------------------- */
210 210
211/*! 211/*!
212*/ 212*/
@@ -294,53 +294,53 @@ void EmulationLayer::bulkNewline()
294 bulk_incnt = 0; // reset bulk counter since `nl' rule applies 294 bulk_incnt = 0; // reset bulk counter since `nl' rule applies
295} 295}
296 296
297/*! 297/*!
298*/ 298*/
299 299
300void EmulationLayer::showBulk() 300void EmulationLayer::showBulk()
301{ 301{
302 bulk_nlcnt = 0; // reset bulk newline counter 302 bulk_nlcnt = 0; // reset bulk newline counter
303 bulk_incnt = 0; // reset bulk counter 303 bulk_incnt = 0; // reset bulk counter
304 if (connected) 304 if (connected)
305 { 305 {
306 Character* image = scr->getCookedImage(); // get the image 306 QArray<Character> image = scr->getCookedImage(); // get the image
307 gui->setImage(image, 307 gui->setImage(image,
308 scr->getLines(), 308 scr->getLines(),
309 scr->getColumns()); // actual refresh 309 scr->getColumns()); // actual refresh
310 free(image); 310 delete image;
311 //FIXME: check that we do not trigger other draw event here. 311 //FIXME: check that we do not trigger other draw event here.
312 gui->setScroll(scr->getHistCursor(),scr->getHistLines()); 312 gui->setScroll(scr->getHistCursor(),scr->getHistLines());
313 } 313 }
314} 314}
315 315
316void EmulationLayer::bulkStart() 316void EmulationLayer::bulkStart()
317{ 317{
318 if (bulk_timer.isActive()) bulk_timer.stop(); 318 if (bulk_timer.isActive()) bulk_timer.stop();
319} 319}
320 320
321void EmulationLayer::bulkEnd() 321void EmulationLayer::bulkEnd()
322{ 322{
323 if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) 323 if ( bulk_nlcnt > gui->lines() || bulk_incnt > 20 )
324 showBulk(); // resets bulk_??cnt to 0, too. 324 showBulk(); // resets bulk_??cnt to 0, too.
325 else 325 else
326 bulk_timer.start(BULK_TIMEOUT,TRUE); 326 bulk_timer.start(BULK_TIMEOUT,TRUE);
327} 327}
328 328
329void EmulationLayer::setConnect(bool c) 329void EmulationLayer::setConnect(bool c)
330{ 330{
331 connected = c; 331 connected = c;
332 if ( connected) 332 if ( connected)
333 { 333 {
334 onImageSizeChange(gui->Lines(), gui->Columns()); 334 onImageSizeChange(gui->lines(), gui->columns());
335 showBulk(); 335 showBulk();
336 } 336 }
337 else 337 else
338 { 338 {
339 scr->clearSelection(); 339 scr->clearSelection();
340 } 340 }
341} 341}
342 342
343// --------------------------------------------------------------------------- 343// ---------------------------------------------------------------------------
344 344
345/*! triggered by image size change of the Widget `gui'. 345/*! triggered by image size change of the Widget `gui'.
346 346