The following classes are used to emulate a terminal: ChuiWebDriver extends (ChuiScreenDriver implements ScreenDriver) ChuiPrimitives extends DriverPrimitives ChuiWebSimulator extends (ChuiSimulator extends JComponent implements Printable) The following methods are used by the terminal driver: ChuiScreenDriver: ================ O beep() -> sim.beep() O clear() -> sim.clear(); I readKey() -> sim.readKey(); O setCursorStatus(boolean on) -> sim.setCursorStatus(on); ChuiPrimitives: =============== O append(String str, Color color) -> sim.append(data); O cursorAt(int x, int y) -> sim.setCursor(x, y); O cursorStay(int x, int y) -> sim.setCursor(x, y); I getX() -> sim.getCursorX(); I getY() -> sim.getCursorY(); I screenHeight() -> sim.getRows(); I screenWidth() -> sim.getColumns(); O sync() -> sim.triggerRepaint(true); O updateScreen(ScreenData screen) -> sim.replace(screen.asArray(), screen.getCursorX(), screen.getCursorY()); Translation of driver calls into simulator calls: ChuiScreenDriver,ChuiPrimitives ChuiSimulator I/O Remarks (ChuiWebDriver) (ChuiWebSimulator) =============================================================================================== beep() beep() O clear() clear() O readKey() readKey() I setCursorStatus(on) setCursorStatus(on) O append(str, color) append(data) O cursorAt(x, y) setCursor(x, y) 0 cursorStay(x, y) setCursor(x, y) 0 getX() getCursorX() I (update by mouse event) getY() getCursorY() I (update by mouse event) screenHeight getRows() I (from config) screenWidth getColumns() I (from config) sync() triggerRepaint(true) O updateScreen(screen) replace(arry, x, y) O A possible binary protocol might looks like: (O)utput Protocol Packet =============================================================================================== beep() 0x80 clear() 0x81 setCursorStatus(on) 0x82 // cursor on 0x83 // cursor off setCursor(x, y) 0x83 x y // new x, y cursor position setCursor(x, y) 0x83 x y // new x, y cursor position triggerRepaint(full) 0x84 size cell cell cell ... cell // synchronize screen memory // cell = [x, y, colour, character] // should be efficient implemented // the cell list shoud contains only the changed cells. (I)nput Protocol Packet =============================================================================================== KeyEvent 0x00 meta key // meta = CTRL, ALT, SHIFT etc. // key = key code MouseEvent 0x01 meta x y // meta = click, contextmenu, dblclick // x, y = mouse cursor position (row and col not pixels)