comparison libgui/qterminal/libqterminal/unix/Screen.h @ 19630:0e1f5a750d00

maint: Periodic merge of gui-release to default.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 10:24:46 -0500
parents 96751a74bbbb 446c46af4b42
children
comparison
equal deleted inserted replaced
19626:37d37297acf8 19630:0e1f5a750d00
54 54
55 The terminal emulation ( Emulation ) receives a serial stream of 55 The terminal emulation ( Emulation ) receives a serial stream of
56 characters from the program currently running in the terminal. 56 characters from the program currently running in the terminal.
57 From this stream it creates an image of characters which is ultimately 57 From this stream it creates an image of characters which is ultimately
58 rendered by the display widget ( TerminalDisplay ). Some types of emulation 58 rendered by the display widget ( TerminalDisplay ). Some types of emulation
59 may have more than one screen image. 59 may have more than one screen image.
60 60
61 getImage() is used to retrieve the currently visible image 61 getImage() is used to retrieve the currently visible image
62 which is then used by the display widget to draw the output from the 62 which is then used by the display widget to draw the output from the
63 terminal. 63 terminal.
64 64
65 The number of lines of output history which are kept in addition to the current 65 The number of lines of output history which are kept in addition to the current
66 screen image depends on the history scroll being used to store the output. 66 screen image depends on the history scroll being used to store the output.
67 The scroll is specified using setScroll() 67 The scroll is specified using setScroll()
68 The output history can be retrieved using writeToStream() 68 The output history can be retrieved using writeToStream()
69 69
70 The screen image has a selection associated with it, specified using 70 The screen image has a selection associated with it, specified using
71 setSelectionStart() and setSelectionEnd(). The selected text can be retrieved 71 setSelectionStart() and setSelectionEnd(). The selected text can be retrieved
72 using selectedText(). When getImage() is used to retrieve the the visible image, 72 using selectedText(). When getImage() is used to retrieve the the visible image,
73 characters which are part of the selection have their colours inverted. 73 characters which are part of the selection have their colours inverted.
74 */ 74 */
75 class Screen 75 class Screen
76 { 76 {
77 public: 77 public:
78 /** Construct a new screen image of size @p lines by @p columns. */ 78 /** Construct a new screen image of size @p lines by @p columns. */
79 Screen(int lines, int columns); 79 Screen(int lines, int columns);
80 ~Screen(); 80 ~Screen();
81 81
82 // VT100/2 Operations 82 // VT100/2 Operations
83 // Cursor Movement 83 // Cursor Movement
84 84
85 /** Move the cursor up by @p n lines. */ 85 /** Move the cursor up by @p n lines. */
86 void cursorUp (int n); 86 void cursorUp (int n);
87 /** Move the cursor down by @p n lines. */ 87 /** Move the cursor down by @p n lines. */
88 void cursorDown (int n); 88 void cursorDown (int n);
89 /** Move the cursor to the left by @p n columns. */ 89 /** Move the cursor to the left by @p n columns. */
97 /** Position the cursor at line @p y, column @p x. */ 97 /** Position the cursor at line @p y, column @p x. */
98 void setCursorYX (int y, int x); 98 void setCursorYX (int y, int x);
99 /** 99 /**
100 * Sets the margins for scrolling the screen. 100 * Sets the margins for scrolling the screen.
101 * 101 *
102 * @param topLine The top line of the new scrolling margin. 102 * @param topLine The top line of the new scrolling margin.
103 * @param bottomLine The bottom line of the new scrolling margin. 103 * @param bottomLine The bottom line of the new scrolling margin.
104 */ 104 */
105 void setMargins (int topLine , int bottomLine); 105 void setMargins (int topLine , int bottomLine);
106 /** Returns the top line of the scrolling region. */ 106 /** Returns the top line of the scrolling region. */
107 int topMargin() const; 107 int topMargin() const;
108 /** Returns the bottom line of the scrolling region. */ 108 /** Returns the bottom line of the scrolling region. */
109 int bottomMargin() const; 109 int bottomMargin() const;
110 110
111 /** 111 /**
112 * Resets the scrolling margins back to the top and bottom lines 112 * Resets the scrolling margins back to the top and bottom lines
113 * of the screen. 113 * of the screen.
114 */ 114 */
115 void setDefaultMargins(); 115 void setDefaultMargins();
116 116
117 /** 117 /**
118 * Moves the cursor down one line, if the MODE_NewLine mode 118 * Moves the cursor down one line, if the MODE_NewLine mode
119 * flag is enabled then the cursor is returned to the leftmost 119 * flag is enabled then the cursor is returned to the leftmost
120 * column first. 120 * column first.
121 * 121 *
122 * Equivalent to NextLine() if the MODE_NewLine flag is set 122 * Equivalent to NextLine() if the MODE_NewLine flag is set
123 * or index() otherwise. 123 * or index() otherwise.
124 */ 124 */
125 void NewLine (); 125 void NewLine ();
126 /** 126 /**
127 * Moves the cursor down one line and positions it at the beginning 127 * Moves the cursor down one line and positions it at the beginning
128 * of the line. 128 * of the line.
129 */ 129 */
130 void NextLine (); 130 void NextLine ();
131 131
132 /** 132 /**
133 * Move the cursor down one line. If the cursor is on the bottom 133 * Move the cursor down one line. If the cursor is on the bottom
134 * line of the scrolling region (as returned by bottomMargin()) the 134 * line of the scrolling region (as returned by bottomMargin()) the
135 * scrolling region is scrolled up by one line instead. 135 * scrolling region is scrolled up by one line instead.
136 */ 136 */
137 void index (); 137 void index ();
139 * Move the cursor up one line. If the cursor is on the top line 139 * Move the cursor up one line. If the cursor is on the top line
140 * of the scrolling region (as returned by topMargin()) the scrolling 140 * of the scrolling region (as returned by topMargin()) the scrolling
141 * region is scrolled down by one line instead. 141 * region is scrolled down by one line instead.
142 */ 142 */
143 void reverseIndex(); 143 void reverseIndex();
144 144
145 /** 145 /**
146 * Scroll the scrolling region of the screen up by @p n lines. 146 * Scroll the scrolling region of the screen up by @p n lines.
147 * The scrolling region is initially the whole screen, but can be changed 147 * The scrolling region is initially the whole screen, but can be changed
148 * using setMargins() 148 * using setMargins()
149 */ 149 */
150 void scrollUp(int n); 150 void scrollUp(int n);
151 /** 151 /**
152 * Scroll the scrolling region of the screen down by @p n lines. 152 * Scroll the scrolling region of the screen down by @p n lines.
153 * The scrolling region is initially the whole screen, but can be changed 153 * The scrolling region is initially the whole screen, but can be changed
154 * using setMargins() 154 * using setMargins()
155 */ 155 */
156 void scrollDown(int n); 156 void scrollDown(int n);
157 157
158 /** 158 /**
159 * Moves the cursor to the beginning of the current line. 159 * Moves the cursor to the beginning of the current line.
160 * Equivalent to setCursorX(0) 160 * Equivalent to setCursorX(0)
161 */ 161 */
162 void Return (); 162 void Return ();
163 /** 163 /**
164 * Moves the cursor one column to the left and erases the character 164 * Moves the cursor one column to the left and erases the character
165 * at the new cursor position. 165 * at the new cursor position.
166 */ 166 */
167 void BackSpace (); 167 void BackSpace ();
168 /** 168 /**
169 * Moves the cursor @p n tab-stops to the right. 169 * Moves the cursor @p n tab-stops to the right.
170 */ 170 */
171 void Tabulate (int n = 1); 171 void Tabulate (int n = 1);
172 /** 172 /**
173 * Moves the cursor @p n tab-stops to the left. 173 * Moves the cursor @p n tab-stops to the left.
174 */ 174 */
175 void backTabulate(int n); 175 void backTabulate(int n);
176 176
177 // Editing 177 // Editing
178 178
179 /** 179 /**
180 * Erase @p n characters beginning from the current cursor position. 180 * Erase @p n characters beginning from the current cursor position.
181 * This is equivalent to over-writing @p n characters starting with the current 181 * This is equivalent to over-writing @p n characters starting with the current
182 * cursor position with spaces. 182 * cursor position with spaces.
183 * If @p n is 0 then one character is erased. 183 * If @p n is 0 then one character is erased.
184 */ 184 */
185 void eraseChars (int n); 185 void eraseChars (int n);
186 /** 186 /**
187 * Delete @p n characters beginning from the current cursor position. 187 * Delete @p n characters beginning from the current cursor position.
188 * If @p n is 0 then one character is deleted. 188 * If @p n is 0 then one character is deleted.
189 */ 189 */
190 void deleteChars (int n); 190 void deleteChars (int n);
191 /** 191 /**
192 * Insert @p n blank characters beginning from the current cursor position. 192 * Insert @p n blank characters beginning from the current cursor position.
193 * The position of the cursor is not altered. 193 * The position of the cursor is not altered.
194 * If @p n is 0 then one character is inserted. 194 * If @p n is 0 then one character is inserted.
195 */ 195 */
196 void insertChars (int n); 196 void insertChars (int n);
197 /** 197 /**
198 * Removes @p n lines beginning from the current cursor position. 198 * Removes @p n lines beginning from the current cursor position.
199 * The position of the cursor is not altered. 199 * The position of the cursor is not altered.
200 * If @p n is 0 then one line is removed. 200 * If @p n is 0 then one line is removed.
201 */ 201 */
202 void deleteLines (int n); 202 void deleteLines (int n);
206 * If @p n is 0 then one line is inserted. 206 * If @p n is 0 then one line is inserted.
207 */ 207 */
208 void insertLines (int n); 208 void insertLines (int n);
209 /** Clears all the tab stops. */ 209 /** Clears all the tab stops. */
210 void clearTabStops(); 210 void clearTabStops();
211 /** Sets or removes a tab stop at the cursor's current column. */ 211 /** Sets or removes a tab stop at the cursor's current column. */
212 void changeTabStop(bool set); 212 void changeTabStop(bool set);
213 213
214 /** Resets (clears) the specified screen @p mode. */ 214 /** Resets (clears) the specified screen @p mode. */
215 void resetMode (int mode); 215 void resetMode (int mode);
216 /** Sets (enables) the specified screen @p mode. */ 216 /** Sets (enables) the specified screen @p mode. */
217 void setMode (int mode); 217 void setMode (int mode);
218 /** 218 /**
219 * Saves the state of the specified screen @p mode. It can be restored 219 * Saves the state of the specified screen @p mode. It can be restored
220 * using restoreMode() 220 * using restoreMode()
221 */ 221 */
222 void saveMode (int mode); 222 void saveMode (int mode);
223 /** Restores the state of a screen @p mode saved by calling saveMode() */ 223 /** Restores the state of a screen @p mode saved by calling saveMode() */
224 void restoreMode (int mode); 224 void restoreMode (int mode);
225 /** Returns whether the specified screen @p mode is enabled or not .*/ 225 /** Returns whether the specified screen @p mode is enabled or not .*/
226 bool getMode (int mode) const; 226 bool getMode (int mode) const;
227 227
228 /** 228 /**
229 * Saves the current position and appearence (text color and style) of the cursor. 229 * Saves the current position and appearence (text color and style) of the cursor.
230 * It can be restored by calling restoreCursor() 230 * It can be restored by calling restoreCursor()
231 */ 231 */
232 void saveCursor (); 232 void saveCursor ();
233 /** Restores the position and appearence of the cursor. See saveCursor() */ 233 /** Restores the position and appearence of the cursor. See saveCursor() */
234 void restoreCursor(); 234 void restoreCursor();
235 235
236 /** Clear the whole screen, moving the current screen contents into the history first. */ 236 /** Clear the whole screen, moving the current screen contents into the history first. */
237 void clearEntireScreen(); 237 void clearEntireScreen();
238 /** 238 /**
239 * Clear the area of the screen from the current cursor position to the end of 239 * Clear the area of the screen from the current cursor position to the end of
240 * the screen. 240 * the screen.
241 */ 241 */
242 void clearToEndOfScreen(); 242 void clearToEndOfScreen();
243 /** 243 /**
244 * Clear the area of the screen from the current cursor position to the start 244 * Clear the area of the screen from the current cursor position to the start
249 void clearEntireLine(); 249 void clearEntireLine();
250 /** Clears from the current cursor position to the end of the line. */ 250 /** Clears from the current cursor position to the end of the line. */
251 void clearToEndOfLine(); 251 void clearToEndOfLine();
252 /** Clears from the current cursor position to the beginning of the line. */ 252 /** Clears from the current cursor position to the beginning of the line. */
253 void clearToBeginOfLine(); 253 void clearToBeginOfLine();
254 254
255 /** Fills the entire screen with the letter 'E' */ 255 /** Fills the entire screen with the letter 'E' */
256 void helpAlign (); 256 void helpAlign ();
257 257
258 /** 258 /**
259 * Enables the given @p rendition flag. Rendition flags control the appearence 259 * Enables the given @p rendition flag. Rendition flags control the appearence
260 * of characters on the screen. 260 * of characters on the screen.
261 * 261 *
262 * @see Character::rendition 262 * @see Character::rendition
263 */ 263 */
264 void setRendition (int rendition); 264 void setRendition (int rendition);
265 /** 265 /**
266 * Disables the given @p rendition flag. Rendition flags control the appearence 266 * Disables the given @p rendition flag. Rendition flags control the appearence
267 * of characters on the screen. 267 * of characters on the screen.
268 * 268 *
269 * @see Character::rendition 269 * @see Character::rendition
270 */ 270 */
271 void resetRendition(int rendition); 271 void resetRendition(int rendition);
272 272
273 /** 273 /**
274 * Sets the cursor's foreground color. 274 * Sets the cursor's foreground color.
275 * @param space The color space used by the @p color argument 275 * @param space The color space used by the @p color argument
276 * @param color The new foreground color. The meaning of this depends on 276 * @param color The new foreground color. The meaning of this depends on
277 * the color @p space used. 277 * the color @p space used.
278 * 278 *
286 * the color @p space used. 286 * the color @p space used.
287 * 287 *
288 * @see CharacterColor 288 * @see CharacterColor
289 */ 289 */
290 void setBackColor (int space, int color); 290 void setBackColor (int space, int color);
291 /** 291 /**
292 * Resets the cursor's color back to the default and sets the 292 * Resets the cursor's color back to the default and sets the
293 * character's rendition flags back to the default settings. 293 * character's rendition flags back to the default settings.
294 */ 294 */
295 void setDefaultRendition(); 295 void setDefaultRendition();
296 296
297 /** Returns the column which the cursor is positioned at. */ 297 /** Returns the column which the cursor is positioned at. */
298 int getCursorX() const; 298 int getCursorX() const;
299 /** Returns the line which the cursor is positioned on. */ 299 /** Returns the line which the cursor is positioned on. */
300 int getCursorY() const; 300 int getCursorY() const;
301 301
302 /** TODO Document me */ 302 /** TODO Document me */
303 void clear(); 303 void clear();
304 /** 304 /**
305 * Sets the position of the cursor to the 'home' position at the top-left 305 * Sets the position of the cursor to the 'home' position at the top-left
306 * corner of the screen (0,0) 306 * corner of the screen (0,0)
307 */ 307 */
308 void home(); 308 void home();
309 /** 309 /**
310 * Resets the state of the screen. This resets the various screen modes 310 * Resets the state of the screen. This resets the various screen modes
311 * back to their default states. The cursor style and colors are reset 311 * back to their default states. The cursor style and colors are reset
318 * <li>Cursor mode is enabled. TODO Document me</li> 318 * <li>Cursor mode is enabled. TODO Document me</li>
319 * <li>Screen mode is disabled. TODO Document me</li> 319 * <li>Screen mode is disabled. TODO Document me</li>
320 * <li>New line mode is disabled. TODO Document me</li> 320 * <li>New line mode is disabled. TODO Document me</li>
321 * </ul> 321 * </ul>
322 * 322 *
323 * If @p clearScreen is true then the screen contents are erased entirely, 323 * If @p clearScreen is true then the screen contents are erased entirely,
324 * otherwise they are unaltered. 324 * otherwise they are unaltered.
325 */ 325 */
326 void reset(bool clearScreen = true); 326 void reset(bool clearScreen = true);
327 327
328 /** 328 /**
329 * Displays a new character at the current cursor position. 329 * Displays a new character at the current cursor position.
330 * 330 *
331 * If the cursor is currently positioned at the right-edge of the screen and 331 * If the cursor is currently positioned at the right-edge of the screen and
332 * line wrapping is enabled then the character is added at the start of a new 332 * line wrapping is enabled then the character is added at the start of a new
333 * line below the current one. 333 * line below the current one.
334 * 334 *
335 * If the MODE_Insert screen mode is currently enabled then the character 335 * If the MODE_Insert screen mode is currently enabled then the character
336 * is inserted at the current cursor position, otherwise it will replace the 336 * is inserted at the current cursor position, otherwise it will replace the
337 * character already at the current cursor position. 337 * character already at the current cursor position.
338 */ 338 */
339 void ShowCharacter(unsigned short c); 339 void ShowCharacter(unsigned short c);
340 340
341 // Do composition with last shown character FIXME: Not implemented yet for KDE 4 341 // Do composition with last shown character FIXME: Not implemented yet for KDE 4
342 void compose(const QString& compose); 342 void compose(const QString& compose);
343 343
344 /** 344 /**
345 * Resizes the image to a new fixed size of @p new_lines by @p new_columns. 345 * Resizes the image to a new fixed size of @p new_lines by @p new_columns.
346 * In the case that @p new_columns is smaller than the current number of columns, 346 * In the case that @p new_columns is smaller than the current number of columns,
347 * existing lines are not truncated. This prevents characters from being lost 347 * existing lines are not truncated. This prevents characters from being lost
348 * if the terminal display is resized smaller and then larger again. 348 * if the terminal display is resized smaller and then larger again.
349 * 349 *
350 * (note that in versions of Konsole prior to KDE 4, existing lines were 350 * (note that in versions of Konsole prior to KDE 4, existing lines were
351 * truncated when making the screen image smaller) 351 * truncated when making the screen image smaller)
352 */ 352 */
353 void resizeImage(int new_lines, int new_columns); 353 void resizeImage(int new_lines, int new_columns);
354 354
355 /** 355 /**
356 * Returns the current screen image. 356 * Returns the current screen image.
357 * The result is an array of Characters of size [getLines()][getColumns()] which 357 * The result is an array of Characters of size [getLines()][getColumns()] which
358 * must be freed by the caller after use. 358 * must be freed by the caller after use.
359 * 359 *
360 * @param dest Buffer to copy the characters into 360 * @param dest Buffer to copy the characters into
361 * @param size Size of @p dest in Characters 361 * @param size Size of @p dest in Characters
362 * @param startLine Index of first line to copy 362 * @param startLine Index of first line to copy
363 * @param endLine Index of last line to copy 363 * @param endLine Index of last line to copy
364 */ 364 */
365 void getImage( Character* dest , int size , int startLine , int endLine ) const; 365 void getImage( Character* dest , int size , int startLine , int endLine ) const;
366 366
367 /** 367 /**
368 * Returns the additional attributes associated with lines in the image. 368 * Returns the additional attributes associated with lines in the image.
369 * The most important attribute is LINE_WRAPPED which specifies that the 369 * The most important attribute is LINE_WRAPPED which specifies that the
370 * line is wrapped, 370 * line is wrapped,
371 * other attributes control the size of characters in the line. 371 * other attributes control the size of characters in the line.
372 */ 372 */
373 QVector<LineProperty> getLineProperties( int startLine , int endLine ) const; 373 QVector<LineProperty> getLineProperties( int startLine , int endLine ) const;
374 374
377 int getLines() { return lines; } 377 int getLines() { return lines; }
378 /** Return the number of columns. */ 378 /** Return the number of columns. */
379 int getColumns() { return columns; } 379 int getColumns() { return columns; }
380 /** Return the number of lines in the history buffer. */ 380 /** Return the number of lines in the history buffer. */
381 int getHistLines (); 381 int getHistLines ();
382 /** 382 /**
383 * Sets the type of storage used to keep lines in the history. 383 * Sets the type of storage used to keep lines in the history.
384 * If @p copyPreviousScroll is true then the contents of the previous 384 * If @p copyPreviousScroll is true then the contents of the previous
385 * history buffer are copied into the new scroll. 385 * history buffer are copied into the new scroll.
386 */ 386 */
387 void setScroll(const HistoryType& , bool copyPreviousScroll = true); 387 void setScroll(const HistoryType& , bool copyPreviousScroll = true);
388 /** Returns the type of storage used to keep lines in the history. */ 388 /** Returns the type of storage used to keep lines in the history. */
389 const HistoryType& getScroll(); 389 const HistoryType& getScroll();
390 /** 390 /**
391 * Returns true if this screen keeps lines that are scrolled off the screen 391 * Returns true if this screen keeps lines that are scrolled off the screen
392 * in a history buffer. 392 * in a history buffer.
393 */ 393 */
394 bool hasScroll(); 394 bool hasScroll();
395 395
396 /** 396 /**
397 * Sets the start of the selection. 397 * Sets the start of the selection.
398 * 398 *
399 * @param column The column index of the first character in the selection. 399 * @param column The column index of the first character in the selection.
400 * @param line The line index of the first character in the selection. 400 * @param line The line index of the first character in the selection.
401 * @param columnmode True if the selection is in column mode. 401 * @param columnmode True if the selection is in column mode.
402 */ 402 */
403 void setSelectionStart(const int column, const int line, const bool columnmode); 403 void setSelectionStart(const int column, const int line, const bool columnmode);
404 404
405 /** 405 /**
406 * Sets the end of the current selection. 406 * Sets the end of the current selection.
407 * 407 *
408 * @param column The column index of the last character in the selection. 408 * @param column The column index of the last character in the selection.
409 * @param line The line index of the last character in the selection. 409 * @param line The line index of the last character in the selection.
410 */ 410 */
411 void setSelectionEnd(const int column, const int line); 411 void setSelectionEnd(const int column, const int line);
412 412
413 /** 413 /**
414 * Retrieves the start of the selection or the cursor position if there 414 * Retrieves the start of the selection or the cursor position if there
415 * is no selection. 415 * is no selection.
416 */ 416 */
417 void getSelectionStart(int& column , int& line); 417 void getSelectionStart(int& column , int& line);
418 418
419 /** 419 /**
420 * Retrieves the end of the selection or the cursor position if there 420 * Retrieves the end of the selection or the cursor position if there
421 * is no selection. 421 * is no selection.
422 */ 422 */
423 void getSelectionEnd(int& column , int& line); 423 void getSelectionEnd(int& column , int& line);
425 /** Clears the current selection */ 425 /** Clears the current selection */
426 void clearSelection(); 426 void clearSelection();
427 427
428 void setBusySelecting(bool busy) { sel_busy = busy; } 428 void setBusySelecting(bool busy) { sel_busy = busy; }
429 429
430 /** 430 /**
431 * Returns true if the character at (@p column, @p line) is part of the 431 * Returns true if the character at (@p column, @p line) is part of the
432 * current selection. 432 * current selection.
433 */ 433 */
434 bool isSelected(const int column,const int line) const; 434 bool isSelected(const int column,const int line) const;
435 435
436 /** 436 /**
437 * Convenience method. Returns the currently selected text. 437 * Convenience method. Returns the currently selected text.
438 * @param preserveLineBreaks Specifies whether new line characters should 438 * @param preserveLineBreaks Specifies whether new line characters should
439 * be inserted into the returned text at the end of each terminal line. 439 * be inserted into the returned text at the end of each terminal line.
440 */ 440 */
441 QString selectedText(bool preserveLineBreaks); 441 QString selectedText(bool preserveLineBreaks);
442 442
443 /** 443 /**
444 * Copies part of the output to a stream. 444 * Copies part of the output to a stream.
445 * 445 *
446 * @param decoder A decoder which coverts terminal characters into text 446 * @param decoder A decoder which coverts terminal characters into text
447 * @param from The first line in the history to retrieve 447 * @param from The first line in the history to retrieve
448 * @param to The last line in the history to retrieve 448 * @param to The last line in the history to retrieve
449 */ 449 */
450 void writeToStream(TerminalCharacterDecoder* decoder, int from, int to); 450 void writeToStream(TerminalCharacterDecoder* decoder, int from, int to);
451 451
452 /** 452 /**
453 * Sets the selection to line @p no in the history and returns 453 * Sets the selection to line @p no in the history and returns
454 * the text of that line from the history buffer. 454 * the text of that line from the history buffer.
455 */ 455 */
456 QString getHistoryLine(int no); 456 QString getHistoryLine(int no);
457 457
458 /** 458 /**
459 * Copies the selected characters, set using @see setSelBeginXY and @see setSelExtentXY 459 * Copies the selected characters, set using @see setSelBeginXY and @see setSelExtentXY
460 * into a stream. 460 * into a stream.
461 * 461 *
462 * @param decoder A decoder which converts terminal characters into text. 462 * @param decoder A decoder which converts terminal characters into text.
463 * PlainTextDecoder is the most commonly used decoder which coverts characters 463 * PlainTextDecoder is the most commonly used decoder which coverts characters
464 * into plain text with no formatting. 464 * into plain text with no formatting.
465 * @param preserveLineBreaks Specifies whether new line characters should 465 * @param preserveLineBreaks Specifies whether new line characters should
466 * be inserted into the returned text at the end of each terminal line. 466 * be inserted into the returned text at the end of each terminal line.
467 */ 467 */
468 void writeSelectionToStream(TerminalCharacterDecoder* decoder , bool 468 void writeSelectionToStream(TerminalCharacterDecoder* decoder , bool
469 preserveLineBreaks = true); 469 preserveLineBreaks = true);
470 470
471 /** TODO Document me */ 471 /** TODO Document me */
472 void checkSelection(int from, int to); 472 void checkSelection(int from, int to);
473 473
474 /** 474 /**
475 * Sets or clears an attribute of the current line. 475 * Sets or clears an attribute of the current line.
476 * 476 *
477 * @param property The attribute to set or clear 477 * @param property The attribute to set or clear
478 * Possible properties are: 478 * Possible properties are:
479 * LINE_WRAPPED: Specifies that the line is wrapped. 479 * LINE_WRAPPED: Specifies that the line is wrapped.
480 * LINE_DOUBLEWIDTH: Specifies that the characters in the current line should be double the normal width. 480 * LINE_DOUBLEWIDTH: Specifies that the characters in the current line should be double the normal width.
481 * LINE_DOUBLEHEIGHT:Specifies that the characters in the current line should be double the normal height. 481 * LINE_DOUBLEHEIGHT:Specifies that the characters in the current line should be double the normal height.
482 * Double-height lines are formed of two lines containing the same characters, 482 * Double-height lines are formed of two lines containing the same characters,
483 * with both having the LINE_DOUBLEHEIGHT attribute. This allows other parts of the 483 * with both having the LINE_DOUBLEHEIGHT attribute. This allows other parts of the
484 * code to work on the assumption that all lines are the same height. 484 * code to work on the assumption that all lines are the same height.
485 * 485 *
486 * @param enable true to apply the attribute to the current line or false to remove it 486 * @param enable true to apply the attribute to the current line or false to remove it
487 */ 487 */
488 void setLineProperty(LineProperty property , bool enable); 488 void setLineProperty(LineProperty property , bool enable);
489 489
490 490
491 /** 491 /**
492 * Returns the number of lines that the image has been scrolled up or down by, 492 * Returns the number of lines that the image has been scrolled up or down by,
493 * since the last call to resetScrolledLines(). 493 * since the last call to resetScrolledLines().
494 * 494 *
495 * a positive return value indicates that the image has been scrolled up, 495 * a positive return value indicates that the image has been scrolled up,
496 * a negative return value indicates that the image has been scrolled down. 496 * a negative return value indicates that the image has been scrolled down.
497 */ 497 */
498 int scrolledLines() const; 498 int scrolledLines() const;
499 499
500 /** 500 /**
501 * Returns the region of the image which was last scrolled. 501 * Returns the region of the image which was last scrolled.
502 * 502 *
503 * This is the area of the image from the top margin to the 503 * This is the area of the image from the top margin to the
504 * bottom margin when the last scroll occurred. 504 * bottom margin when the last scroll occurred.
505 */ 505 */
506 QRect lastScrolledRegion() const; 506 QRect lastScrolledRegion() const;
507 507
508 /** 508 /**
509 * Resets the count of the number of lines that the image has been scrolled up or down by, 509 * Resets the count of the number of lines that the image has been scrolled up or down by,
510 * see scrolledLines() 510 * see scrolledLines()
511 */ 511 */
512 void resetScrolledLines(); 512 void resetScrolledLines();
513 513
516 * dropped from the history since the last call 516 * dropped from the history since the last call
517 * to resetDroppedLines() 517 * to resetDroppedLines()
518 * 518 *
519 * If the history is not unlimited then it will drop 519 * If the history is not unlimited then it will drop
520 * the oldest lines of output if new lines are added when 520 * the oldest lines of output if new lines are added when
521 * it is full. 521 * it is full.
522 */ 522 */
523 int droppedLines() const; 523 int droppedLines() const;
524 524
525 /** 525 /**
526 * Resets the count of the number of lines dropped from 526 * Resets the count of the number of lines dropped from
527 * the history. 527 * the history.
528 */ 528 */
529 void resetDroppedLines(); 529 void resetDroppedLines();
530 530
531 /** 531 /**
532 * Fills the buffer @p dest with @p count instances of the default (ie. blank) 532 * Fills the buffer @p dest with @p count instances of the default (ie. blank)
533 * Character style. 533 * Character style.
534 */ 534 */
535 static void fillWithDefaultChar(Character* dest, int count); 535 static void fillWithDefaultChar(Character* dest, int count);
536 536
537 private: 537 private:
538 538
539 //copies a line of text from the screen or history into a stream using a 539 //copies a line of text from the screen or history into a stream using a
540 //specified character decoder 540 //specified character decoder
541 //line - the line number to copy, from 0 (the earliest line in the history) up to 541 //line - the line number to copy, from 0 (the earliest line in the history) up to
542 // hist->getLines() + lines - 1 542 // hist->getLines() + lines - 1
543 //start - the first column on the line to copy 543 //start - the first column on the line to copy
544 //count - the number of characters on the line to copy 544 //count - the number of characters on the line to copy
545 //decoder - a decoder which coverts terminal characters (an Character array) into text 545 //decoder - a decoder which coverts terminal characters (an Character array) into text
546 //appendNewLine - if true a new line character (\n) is appended to the end of the line 546 //appendNewLine - if true a new line character (\n) is appended to the end of the line
547 void copyLineToStream(int line, 547 void copyLineToStream(int line,
548 int start, 548 int start,
549 int count, 549 int count,
550 TerminalCharacterDecoder* decoder, 550 TerminalCharacterDecoder* decoder,
551 bool appendNewLine, 551 bool appendNewLine,
552 bool preserveLineBreaks); 552 bool preserveLineBreaks);
553 553
554 //fills a section of the screen image with the character 'c' 554 //fills a section of the screen image with the character 'c'
558 558
559 //move screen image between 'sourceBegin' and 'sourceEnd' to 'dest'. 559 //move screen image between 'sourceBegin' and 'sourceEnd' to 'dest'.
560 //the parameters are specified as offsets from the start of the screen image. 560 //the parameters are specified as offsets from the start of the screen image.
561 //the loc(x,y) macro can be used to generate these values from a column,line pair. 561 //the loc(x,y) macro can be used to generate these values from a column,line pair.
562 void moveImage(int dest, int sourceBegin, int sourceEnd); 562 void moveImage(int dest, int sourceBegin, int sourceEnd);
563 563
564 void scrollUp(int from, int i); 564 void scrollUp(int from, int i);
565 void scrollDown(int from, int i); 565 void scrollDown(int from, int i);
566 566
567 void addHistLine(); 567 void addHistLine();
568 568
591 int _scrolledLines; 591 int _scrolledLines;
592 QRect _lastScrolledRegion; 592 QRect _lastScrolledRegion;
593 593
594 int _droppedLines; 594 int _droppedLines;
595 595
596 QVarLengthArray<LineProperty,64> lineProperties; 596 QVarLengthArray<LineProperty,64> lineProperties;
597 597
598 // history buffer --------------- 598 // history buffer ---------------
599 HistoryScroll *hist; 599 HistoryScroll *hist;
600 600
601 // cursor location 601 // cursor location
602 int cuX; 602 int cuX;
603 int cuY; 603 int cuY;
604 604
605 // cursor color and rendition info 605 // cursor color and rendition info
630 CharacterColor ef_bg; // the cu_* variables above 630 CharacterColor ef_bg; // the cu_* variables above
631 quint8 ef_re; // to speed up operation 631 quint8 ef_re; // to speed up operation
632 632
633 // 633 //
634 // save cursor, rendition & states ------------ 634 // save cursor, rendition & states ------------
635 // 635 //
636 636
637 // cursor location 637 // cursor location
638 int sa_cuX; 638 int sa_cuX;
639 int sa_cuY; 639 int sa_cuY;
640 640
641 // rendition info 641 // rendition info
642 quint8 sa_cu_re; 642 quint8 sa_cu_re;
643 CharacterColor sa_cu_fg; 643 CharacterColor sa_cu_fg;
644 CharacterColor sa_cu_bg; 644 CharacterColor sa_cu_bg;
645 645
646 // last position where we added a character 646 // last position where we added a character
647 int lastPos; 647 int lastPos;
648 648
649 // modes 649 // modes
650 ScreenParm saveParm; 650 ScreenParm saveParm;