Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

EmulationLayer Class Reference

Mediator between Widget and Screen. More...

#include </home/clem/local/src/opie/noncore/apps/opie-console/emulation_layer.h>

Collaboration diagram for EmulationLayer:

Collaboration graph
[legend]
List of all members.

Public Slots

virtual void onImageSizeChange (int lines, int columns)
virtual void onHistoryCursorChange (int cursor)
virtual void onKeyPress (QKeyEvent *)
virtual void clearSelection ()
virtual void onSelectionBegin (const int x, const int y)
virtual void onSelectionExtend (const int x, const int y)
virtual void setSelection (const bool preserve_line_breaks)
void onRcvBlock (const QByteArray &)

Signals

void sndBlock (const QByteArray &)
void ImageSizeChanged (int lines, int columns)
void changeColumns (int columns)
void changeTitle (int arg, const char *str)

Public Member Functions

 EmulationLayer (WidgetLayer *gui)
 ~EmulationLayer ()
virtual void setHistory (bool on)
virtual bool history ()
virtual void onRcvChar (int)
virtual void setMode (int)=0
virtual void resetMode (int)=0
virtual void sendString (const char *)=0
virtual void sendString (const QByteArray &)=0
virtual void setConnect (bool r)
void setColumns (int columns)
void setKeytrans (int no)
void setKeytrans (const char *no)

Protected Member Functions

void setScreen (int n)
void setCodec (int c)

Protected Attributes

WidgetLayer * gui
Screenscr
Screenscreen [2]
bool connected
QTextCodeccodec
QTextCodeclocaleCodec
QTextDecoderdecoder
KeyTranskeytrans

Private Slots

void showBulk ()

Private Member Functions

void bulkNewline ()
void bulkStart ()
void bulkEnd ()

Private Attributes

QTimer bulk_timer
int bulk_nlcnt
char * SelectedText
int bulk_incnt

Detailed Description

Mediator between Widget and Screen.

This class is responsible to scan the escapes sequences of the terminal emulation and to map it to their corresponding semantic complements. Thus this module knows mainly about decoding escapes sequences and is a stateless device w.r.t. the semantics.

It is also responsible to refresh the Widget by certain rules.

See also:
Widget

Screen

A note on refreshing
Although the modifications to the current screen image could immediately be propagated via `Widget' to the graphical surface, we have chosen another way here.

The reason for doing so is twofold.

First, experiments show that directly displaying the operation results in slowing down the overall performance of emulations. Displaying individual characters using X11 creates a lot of overhead.

Second, by using the following refreshing method, the screen operations can be completely separated from the displaying. This greatly simplifies the programmer's task of coding and maintaining the screen operations, since one need not worry about differential modifications on the display affecting the operation of concern.

We use a refreshing algorithm here that has been adoped from rxvt/kvt.

By this, refreshing is driven by a timer, which is (re)started whenever a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger refresh. This rule suits both bulk display operation as done by curses as well as individual characters typed. (BULK_TIMEOUT < 1000 / max characters received from keyboard per second).

Additionally, we trigger refreshing by newlines comming in to make visual snapshots of lists as produced by `cat', `ls' and likely programs, thereby producing the illusion of a permanent and immediate display operation.

As a sort of catch-all needed for cases where none of the above conditions catch, the screen refresh is also triggered by a count of incoming bulks (`bulk_incnt').

Definition at line 36 of file emulation_layer.h.


Constructor & Destructor Documentation

EmulationLayer::EmulationLayer WidgetLayer *  gui  ) 
 

Definition at line 95 of file emulation_layer.cpp.

References bulk_incnt, bulk_nlcnt, bulk_timer, clearSelection(), connected, FALSE, onImageSizeChange(), onKeyPress(), onSelectionBegin(), onSelectionExtend(), scr, screen, setSelection(), and showBulk().

EmulationLayer::~EmulationLayer  ) 
 

Definition at line 128 of file emulation_layer.cpp.

References bulk_timer, and screen.


Member Function Documentation

void EmulationLayer::bulkEnd  )  [private]
 

Definition at line 319 of file emulation_layer.cpp.

References bulk_incnt, bulk_nlcnt, BULK_TIMEOUT, bulk_timer, gui, showBulk(), and TRUE.

Referenced by onRcvBlock().

void EmulationLayer::bulkNewline  )  [private]
 

called when
comes in. Evtl. triggers showBulk at endBulk

Definition at line 289 of file emulation_layer.cpp.

References bulk_incnt, and bulk_nlcnt.

Referenced by onRcvBlock().

void EmulationLayer::bulkStart  )  [private]
 

Definition at line 314 of file emulation_layer.cpp.

References bulk_timer.

Referenced by onRcvBlock().

void EmulationLayer::changeColumns int  columns  )  [signal]
 

Referenced by setColumns().

void EmulationLayer::changeTitle int  arg,
const char *  str
[signal]
 

void EmulationLayer::clearSelection  )  [virtual, slot]
 

Definition at line 275 of file emulation_layer.cpp.

References Screen::clearSelection(), connected, scr, and showBulk().

Referenced by EmulationLayer().

bool EmulationLayer::history  )  [virtual]
 

Definition at line 150 of file emulation_layer.cpp.

References Screen::hasScroll(), and screen.

void EmulationLayer::ImageSizeChanged int  lines,
int  columns
[signal]
 

Referenced by onImageSizeChange().

void EmulationLayer::onHistoryCursorChange int  cursor  )  [virtual, slot]
 

Definition at line 358 of file emulation_layer.cpp.

References connected, scr, Screen::setHistCursor(), and showBulk().

void EmulationLayer::onImageSizeChange int  lines,
int  columns
[virtual, slot]
 

triggered by image size change of the Widget `gui'.

This event is simply propagated to the attached screens and to the related serial line.

Definition at line 349 of file emulation_layer.cpp.

References connected, ImageSizeChanged(), Screen::resizeImage(), screen, and showBulk().

Referenced by EmulationLayer(), and setConnect().

void EmulationLayer::onKeyPress QKeyEvent *   )  [virtual, slot]
 

Definition at line 211 of file emulation_layer.cpp.

References connected, Screen::getHistCursor(), Screen::getHistLines(), scr, sendString(), Screen::setHistCursor(), and sndBlock().

Referenced by EmulationLayer().

void EmulationLayer::onRcvBlock const QByteArray  )  [slot]
 

to be called, when new data arrives

Definition at line 239 of file emulation_layer.cpp.

References bulk_incnt, bulkEnd(), bulkNewline(), bulkStart(), decoder, i, QString::length(), onRcvChar(), and QTextDecoder::toUnicode().

void EmulationLayer::onRcvChar int   )  [virtual]
 

process single char (decode)

Definition at line 186 of file emulation_layer.cpp.

References Screen::BackSpace(), gui, Screen::NewLine(), Screen::Return(), scr, Screen::ShowCharacter(), and Screen::Tabulate().

Referenced by onRcvBlock().

void EmulationLayer::onSelectionBegin const int  x,
const int  y
[virtual, slot]
 

Definition at line 257 of file emulation_layer.cpp.

References connected, scr, Screen::setSelBeginXY(), and showBulk().

Referenced by EmulationLayer().

void EmulationLayer::onSelectionExtend const int  x,
const int  y
[virtual, slot]
 

Definition at line 263 of file emulation_layer.cpp.

References connected, scr, Screen::setSelExtentXY(), and showBulk().

Referenced by EmulationLayer().

virtual void EmulationLayer::resetMode int   )  [pure virtual]
 

virtual void EmulationLayer::sendString const QByteArray  )  [pure virtual]
 

sends a string to IOLayer encodes to suit emulation before

virtual void EmulationLayer::sendString const char *   )  [pure virtual]
 

Deprecated:
use qbytearray instead

Referenced by onKeyPress().

void EmulationLayer::setCodec int  c  )  [protected]
 

Definition at line 155 of file emulation_layer.cpp.

References codec, QTextCodec::codecForLocale(), QTextCodec::codecForName(), decoder, and QTextCodec::makeDecoder().

void EmulationLayer::setColumns int  columns  ) 
 

Definition at line 365 of file emulation_layer.cpp.

References changeColumns().

void EmulationLayer::setConnect bool  r  )  [virtual]
 

Definition at line 327 of file emulation_layer.cpp.

References Screen::clearSelection(), connected, gui, onImageSizeChange(), scr, and showBulk().

void EmulationLayer::setHistory bool  on  )  [virtual]
 

Definition at line 143 of file emulation_layer.cpp.

References connected, screen, Screen::setScroll(), and showBulk().

void EmulationLayer::setKeytrans const char *  no  ) 
 

Definition at line 169 of file emulation_layer.cpp.

References KeyTrans::find(), and keytrans.

void EmulationLayer::setKeytrans int  no  ) 
 

Definition at line 164 of file emulation_layer.cpp.

References KeyTrans::find(), and keytrans.

virtual void EmulationLayer::setMode int   )  [pure virtual]
 

void EmulationLayer::setScreen int  n  )  [protected]
 

change between primary and alternate screen

Definition at line 138 of file emulation_layer.cpp.

References scr, and screen.

virtual void EmulationLayer::setSelection const bool  preserve_line_breaks  )  [virtual, slot]
 

Referenced by EmulationLayer().

void EmulationLayer::showBulk  )  [private, slot]
 

Definition at line 298 of file emulation_layer.cpp.

References bulk_incnt, bulk_nlcnt, connected, Screen::getColumns(), Screen::getCookedImage(), Screen::getHistCursor(), Screen::getHistLines(), Screen::getLines(), gui, image, and scr.

Referenced by bulkEnd(), clearSelection(), EmulationLayer(), onHistoryCursorChange(), onImageSizeChange(), onSelectionBegin(), onSelectionExtend(), setConnect(), and setHistory().

void EmulationLayer::sndBlock const QByteArray  )  [signal]
 

will send data, encoded to suit emulation

Referenced by onKeyPress().


Member Data Documentation

int EmulationLayer::bulk_incnt [private]
 

Definition at line 141 of file emulation_layer.h.

Referenced by bulkEnd(), bulkNewline(), EmulationLayer(), onRcvBlock(), and showBulk().

int EmulationLayer::bulk_nlcnt [private]
 

Definition at line 139 of file emulation_layer.h.

Referenced by bulkEnd(), bulkNewline(), EmulationLayer(), and showBulk().

QTimer EmulationLayer::bulk_timer [private]
 

Definition at line 138 of file emulation_layer.h.

Referenced by bulkEnd(), bulkStart(), EmulationLayer(), and ~EmulationLayer().

QTextCodec* EmulationLayer::codec [protected]
 

Definition at line 118 of file emulation_layer.h.

Referenced by setCodec().

bool EmulationLayer::connected [protected]
 

Definition at line 114 of file emulation_layer.h.

Referenced by clearSelection(), EmulationLayer(), onHistoryCursorChange(), onImageSizeChange(), onKeyPress(), onSelectionBegin(), onSelectionExtend(), setConnect(), setHistory(), and showBulk().

QTextDecoder* EmulationLayer::decoder [protected]
 

Definition at line 120 of file emulation_layer.h.

Referenced by onRcvBlock(), and setCodec().

WidgetLayer* EmulationLayer::gui [protected]
 

Definition at line 109 of file emulation_layer.h.

Referenced by bulkEnd(), onRcvChar(), setConnect(), and showBulk().

KeyTrans* EmulationLayer::keytrans [protected]
 

Definition at line 122 of file emulation_layer.h.

Referenced by setKeytrans().

QTextCodec* EmulationLayer::localeCodec [protected]
 

Definition at line 119 of file emulation_layer.h.

Screen* EmulationLayer::scr [protected]
 

Definition at line 110 of file emulation_layer.h.

Referenced by clearSelection(), EmulationLayer(), onHistoryCursorChange(), onKeyPress(), onRcvChar(), onSelectionBegin(), onSelectionExtend(), setConnect(), setScreen(), and showBulk().

Screen* EmulationLayer::screen[2] [protected]
 

Definition at line 111 of file emulation_layer.h.

Referenced by EmulationLayer(), history(), onImageSizeChange(), setHistory(), setScreen(), and ~EmulationLayer().

char* EmulationLayer::SelectedText [private]
 

Definition at line 140 of file emulation_layer.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:32:01 2005 for OPIE by  doxygen 1.4.2