1
|
The following classes are used to emulate a terminal:
|
2
|
|
3
|
ChuiWebDriver extends (ChuiScreenDriver implements ScreenDriver)
|
4
|
ChuiPrimitives extends DriverPrimitives
|
5
|
ChuiWebSimulator extends (ChuiSimulator extends JComponent implements Printable)
|
6
|
|
7
|
The following methods are used by the terminal driver:
|
8
|
|
9
|
ChuiScreenDriver:
|
10
|
================
|
11
|
O beep() -> sim.beep()
|
12
|
O clear() -> sim.clear();
|
13
|
I readKey() -> sim.readKey();
|
14
|
O setCursorStatus(boolean on) -> sim.setCursorStatus(on);
|
15
|
|
16
|
ChuiPrimitives:
|
17
|
===============
|
18
|
O append(String str, Color color) -> sim.append(data);
|
19
|
O cursorAt(int x, int y) -> sim.setCursor(x, y);
|
20
|
O cursorStay(int x, int y) -> sim.setCursor(x, y);
|
21
|
I getX() -> sim.getCursorX();
|
22
|
I getY() -> sim.getCursorY();
|
23
|
I screenHeight() -> sim.getRows();
|
24
|
I screenWidth() -> sim.getColumns();
|
25
|
O sync() -> sim.triggerRepaint(true);
|
26
|
O updateScreen(ScreenData screen) -> sim.replace(screen.asArray(), screen.getCursorX(), screen.getCursorY());
|
27
|
|
28
|
Translation of driver calls into simulator calls:
|
29
|
|
30
|
ChuiScreenDriver,ChuiPrimitives ChuiSimulator I/O Remarks
|
31
|
(ChuiWebDriver) (ChuiWebSimulator)
|
32
|
===============================================================================================
|
33
|
beep() beep() O
|
34
|
clear() clear() O
|
35
|
readKey() readKey() I
|
36
|
setCursorStatus(on) setCursorStatus(on) O
|
37
|
append(str, color) append(data) O
|
38
|
cursorAt(x, y) setCursor(x, y) 0
|
39
|
cursorStay(x, y) setCursor(x, y) 0
|
40
|
getX() getCursorX() I (update by mouse event)
|
41
|
getY() getCursorY() I (update by mouse event)
|
42
|
screenHeight getRows() I (from config)
|
43
|
screenWidth getColumns() I (from config)
|
44
|
sync() triggerRepaint(true) O
|
45
|
updateScreen(screen) replace(arry, x, y) O
|
46
|
|
47
|
|
48
|
A possible binary protocol might looks like:
|
49
|
|
50
|
(O)utput Protocol Packet
|
51
|
===============================================================================================
|
52
|
beep() 0x80
|
53
|
clear() 0x81
|
54
|
setCursorStatus(on) 0x82 // cursor on
|
55
|
0x83 // cursor off
|
56
|
setCursor(x, y) 0x83 x y // new x, y cursor position
|
57
|
setCursor(x, y) 0x83 x y // new x, y cursor position
|
58
|
triggerRepaint(full) 0x84 size cell cell cell ... cell // synchronize screen memory
|
59
|
// cell = [x, y, colour, character]
|
60
|
// should be efficient implemented
|
61
|
// the cell list shoud contains only the changed cells.
|
62
|
|
63
|
(I)nput Protocol Packet
|
64
|
===============================================================================================
|
65
|
KeyEvent 0x00 meta key // meta = CTRL, ALT, SHIFT etc.
|
66
|
// key = key code
|
67
|
MouseEvent 0x01 meta x y // meta = click, contextmenu, dblclick
|
68
|
// x, y = mouse cursor position (row and col not pixels)
|
69
|
|