Diffstat (limited to 'core/apps/embeddedkonsole/TEScreen.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/TEScreen.h | 259 |
1 files changed, 259 insertions, 0 deletions
diff --git a/core/apps/embeddedkonsole/TEScreen.h b/core/apps/embeddedkonsole/TEScreen.h new file mode 100644 index 0000000..ba47ee5 --- a/dev/null +++ b/core/apps/embeddedkonsole/TEScreen.h | |||
@@ -0,0 +1,259 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* [te_screen.h] Screen Data Type */ | ||
4 | /* */ | ||
5 | /* -------------------------------------------------------------------------- */ | ||
6 | /* */ | ||
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | ||
8 | /* */ | ||
9 | /* This file is part of Konsole - an X terminal for KDE */ | ||
10 | /* */ | ||
11 | /* -------------------------------------------------------------------------- */ | ||
12 | /* */ | ||
13 | /* Ported Konsole to Qt/Embedded */ | ||
14 | /* */ | ||
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | ||
16 | /* */ | ||
17 | /* -------------------------------------------------------------------------- */ | ||
18 | |||
19 | #ifndef TESCREEN_H | ||
20 | #define TESCREEN_H | ||
21 | |||
22 | /*! \file | ||
23 | */ | ||
24 | |||
25 | #include "TECommon.h" | ||
26 | #include "TEHistory.h" | ||
27 | |||
28 | #define MODE_Origin 0 | ||
29 | #define MODE_Wrap 1 | ||
30 | #define MODE_Insert 2 | ||
31 | #define MODE_Screen 3 | ||
32 | #define MODE_Cursor 4 | ||
33 | #define MODE_NewLine 5 | ||
34 | #define MODES_SCREEN 6 | ||
35 | |||
36 | /*! | ||
37 | */ | ||
38 | struct ScreenParm | ||
39 | { | ||
40 | int mode[MODES_SCREEN]; | ||
41 | }; | ||
42 | |||
43 | |||
44 | class TEScreen | ||
45 | { | ||
46 | public: | ||
47 | TEScreen(int lines, int columns); | ||
48 | ~TEScreen(); | ||
49 | |||
50 | public: // these are all `Screen' operations | ||
51 | // | ||
52 | // VT100/2 Operations ------------------ | ||
53 | // | ||
54 | // Cursor Movement | ||
55 | // | ||
56 | void cursorUp (int n); | ||
57 | void cursorDown (int n); | ||
58 | void cursorLeft (int n); | ||
59 | void cursorRight (int n); | ||
60 | void setCursorY (int y); | ||
61 | void setCursorX (int x); | ||
62 | void setCursorYX (int y, int x); | ||
63 | void setMargins (int t, int b); | ||
64 | // | ||
65 | // Cursor Movement with Scrolling | ||
66 | // | ||
67 | void NewLine (); | ||
68 | void NextLine (); | ||
69 | void index (); | ||
70 | void reverseIndex(); | ||
71 | // | ||
72 | void Return (); | ||
73 | void BackSpace (); | ||
74 | void Tabulate (); | ||
75 | // | ||
76 | // Editing | ||
77 | // | ||
78 | void eraseChars (int n); | ||
79 | void deleteChars (int n); | ||
80 | void insertChars (int n); | ||
81 | void deleteLines (int n); | ||
82 | void insertLines (int n); | ||
83 | // | ||
84 | // ------------------------------------- | ||
85 | // | ||
86 | void clearTabStops(); | ||
87 | void changeTabStop(bool set); | ||
88 | // | ||
89 | void resetMode (int n); | ||
90 | void setMode (int n); | ||
91 | void saveMode (int n); | ||
92 | void restoreMode (int n); | ||
93 | // | ||
94 | void saveCursor (); | ||
95 | void restoreCursor(); | ||
96 | // | ||
97 | // ------------------------------------- | ||
98 | // | ||
99 | void clearEntireScreen(); | ||
100 | void clearToEndOfScreen(); | ||
101 | void clearToBeginOfScreen(); | ||
102 | // | ||
103 | void clearEntireLine(); | ||
104 | void clearToEndOfLine(); | ||
105 | void clearToBeginOfLine(); | ||
106 | // | ||
107 | void helpAlign (); | ||
108 | // | ||
109 | // ------------------------------------- | ||
110 | // | ||
111 | void setRendition (int rendition); | ||
112 | void resetRendition(int rendition); | ||
113 | void setForeColor (int fgcolor); | ||
114 | void setBackColor (int bgcolor); | ||
115 | // | ||
116 | void setDefaultRendition(); | ||
117 | void setForeColorToDefault(); | ||
118 | void setBackColorToDefault(); | ||
119 | // | ||
120 | // ------------------------------------- | ||
121 | // | ||
122 | BOOL getMode (int n); | ||
123 | // | ||
124 | // only for report cursor position | ||
125 | // | ||
126 | int getCursorX(); | ||
127 | int getCursorY(); | ||
128 | // | ||
129 | // ------------------------------------- | ||
130 | // | ||
131 | void clear(); | ||
132 | void home(); | ||
133 | void reset(); | ||
134 | // | ||
135 | void ShowCharacter(unsigned short c); | ||
136 | // | ||
137 | void resizeImage(int new_lines, int new_columns); | ||
138 | // | ||
139 | ca* getCookedImage(); | ||
140 | |||
141 | /*! return the number of lines. */ | ||
142 | int getLines() { return lines; } | ||
143 | /*! return the number of columns. */ | ||
144 | int getColumns() { return columns; } | ||
145 | |||
146 | /*! set the position of the history cursor. */ | ||
147 | void setHistCursor(int cursor); | ||
148 | /*! return the position of the history cursor. */ | ||
149 | int getHistCursor(); | ||
150 | |||
151 | int getHistLines (); | ||
152 | void setScroll(bool on); | ||
153 | bool hasScroll(); | ||
154 | |||
155 | // | ||
156 | // Selection | ||
157 | // | ||
158 | void setSelBeginXY(const int x, const int y); | ||
159 | void setSelExtentXY(const int x, const int y); | ||
160 | void clearSelection(); | ||
161 | QString getSelText(const BOOL preserve_line_breaks); | ||
162 | |||
163 | void checkSelection(int from, int to); | ||
164 | |||
165 | private: // helper | ||
166 | |||
167 | void clearImage(int loca, int loce, char c); | ||
168 | void moveImage(int dst, int loca, int loce); | ||
169 | |||
170 | void scrollUp(int from, int i); | ||
171 | void scrollDown(int from, int i); | ||
172 | |||
173 | void addHistLine(); | ||
174 | |||
175 | void initTabStops(); | ||
176 | |||
177 | void effectiveRendition(); | ||
178 | void reverseRendition(ca* p); | ||
179 | |||
180 | private: | ||
181 | |||
182 | /* | ||
183 | The state of the screen is more complex as one would | ||
184 | expect first. The screem does really do part of the | ||
185 | emulation providing state informations in form of modes, | ||
186 | margins, tabulators, cursor etc. | ||
187 | |||
188 | Even more unexpected are variables to save and restore | ||
189 | parts of the state. | ||
190 | */ | ||
191 | |||
192 | // screen image ---------------- | ||
193 | |||
194 | int lines; | ||
195 | int columns; | ||
196 | ca *image; // [lines][columns] | ||
197 | |||
198 | // history buffer --------------- | ||
199 | |||
200 | int histCursor; // display position relative to start of the history buffer | ||
201 | HistoryScroll hist; | ||
202 | |||
203 | // cursor location | ||
204 | |||
205 | int cuX; | ||
206 | int cuY; | ||
207 | |||
208 | // cursor color and rendition info | ||
209 | |||
210 | UINT8 cu_fg; // foreground | ||
211 | UINT8 cu_bg; // background | ||
212 | UINT8 cu_re; // rendition | ||
213 | |||
214 | // margins ---------------- | ||
215 | |||
216 | int tmargin; // top margin | ||
217 | int bmargin; // bottom margin | ||
218 | |||
219 | // states ---------------- | ||
220 | |||
221 | ScreenParm currParm; | ||
222 | |||
223 | // ---------------------------- | ||
224 | |||
225 | bool* tabstops; | ||
226 | |||
227 | // selection ------------------- | ||
228 | |||
229 | int sel_begin; // The first location selected. | ||
230 | int sel_TL; // TopLeft Location. | ||
231 | int sel_BR; // Bottom Right Location. | ||
232 | |||
233 | // effective colors and rendition ------------ | ||
234 | |||
235 | UINT8 ef_fg; // These are derived from | ||
236 | UINT8 ef_bg; // the cu_* variables above | ||
237 | UINT8 ef_re; // to speed up operation | ||
238 | |||
239 | // | ||
240 | // save cursor, rendition & states ------------ | ||
241 | // | ||
242 | |||
243 | // cursor location | ||
244 | |||
245 | int sa_cuX; | ||
246 | int sa_cuY; | ||
247 | |||
248 | // rendition info | ||
249 | |||
250 | UINT8 sa_cu_re; | ||
251 | UINT8 sa_cu_fg; | ||
252 | UINT8 sa_cu_bg; | ||
253 | |||
254 | // modes | ||
255 | |||
256 | ScreenParm saveParm; | ||
257 | }; | ||
258 | |||
259 | #endif // TESCREEN_H | ||