Changeset View
Changeset View
Standalone View
Standalone View
src/Screen.h
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 50 | /** | |||
---|---|---|---|---|---|
68 | The screen image has a selection associated with it, specified using | 68 | The screen image has a selection associated with it, specified using | ||
69 | setSelectionStart() and setSelectionEnd(). The selected text can be retrieved | 69 | setSelectionStart() and setSelectionEnd(). The selected text can be retrieved | ||
70 | using selectedText(). When getImage() is used to retrieve the visible image, | 70 | using selectedText(). When getImage() is used to retrieve the visible image, | ||
71 | characters which are part of the selection have their colors inverted. | 71 | characters which are part of the selection have their colors inverted. | ||
72 | */ | 72 | */ | ||
73 | class Screen | 73 | class Screen | ||
74 | { | 74 | { | ||
75 | public: | 75 | public: | ||
76 | enum DecodingOption { | ||||
77 | PlainText = 0x0, | ||||
78 | ConvertToHtml = 0x1, | ||||
79 | PreserveLineBreaks = 0x2, | ||||
80 | TrimLeadingWhitespace = 0x4, | ||||
81 | TrimTrailingWhitespace = 0x8 | ||||
82 | }; | ||||
83 | Q_DECLARE_FLAGS(DecodingOptions, DecodingOption) | ||||
84 | | ||||
76 | /** Construct a new screen image of size @p lines by @p columns. */ | 85 | /** Construct a new screen image of size @p lines by @p columns. */ | ||
77 | Screen(int lines, int columns); | 86 | Screen(int lines, int columns); | ||
78 | ~Screen(); | 87 | ~Screen(); | ||
79 | 88 | | |||
80 | Screen(const Screen &) = delete; | 89 | Screen(const Screen &) = delete; | ||
81 | Screen &operator=(const Screen &) = delete; | 90 | Screen &operator=(const Screen &) = delete; | ||
82 | 91 | | |||
83 | // VT100/2 Operations | 92 | // VT100/2 Operations | ||
▲ Show 20 Lines • Show All 354 Lines • ▼ Show 20 Line(s) | |||||
438 | bool isSelected(const int column, const int line) const; | 447 | bool isSelected(const int column, const int line) const; | ||
439 | 448 | | |||
440 | /** | 449 | /** | ||
441 | * Convenience method. Returns the currently selected text. | 450 | * Convenience method. Returns the currently selected text. | ||
442 | * @param preserveLineBreaks Specifies whether new line characters should | 451 | * @param preserveLineBreaks Specifies whether new line characters should | ||
443 | * be inserted into the returned text at the end of each terminal line. | 452 | * be inserted into the returned text at the end of each terminal line. | ||
444 | * @param trimTrailingSpaces Specifies whether trailing spaces should be | 453 | * @param trimTrailingSpaces Specifies whether trailing spaces should be | ||
445 | * trimmed in the returned text. | 454 | * trimmed in the returned text. | ||
455 | * @param trimLeadingSpaces Specifies whether leading spaces should be | ||||
456 | * trimmed in the returned text. | ||||
446 | * @param html Specifies if returned text should have HTML tags. | 457 | * @param html Specifies if returned text should have HTML tags. | ||
447 | */ | 458 | */ | ||
448 | QString selectedText(bool preserveLineBreaks, bool trimTrailingSpaces = false, | 459 | QString selectedText(const DecodingOptions options) const; | ||
449 | bool html = false) const; | | |||
450 | 460 | | |||
451 | /** | 461 | /** | ||
452 | * Convenience method. Returns the text between two indices. | 462 | * Convenience method. Returns the text between two indices. | ||
453 | * @param startIndex Specifies the starting text index | 463 | * @param startIndex Specifies the starting text index | ||
454 | * @param endIndex Specifies the ending text index | 464 | * @param endIndex Specifies the ending text index | ||
455 | * @param preserveLineBreaks Specifies whether new line characters should | 465 | * @param preserveLineBreaks Specifies whether new line characters should | ||
456 | * 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. | ||
457 | * @param trimTrailingSpaces Specifies whether trailing spaces should be | 467 | * @param trimTrailingSpaces Specifies whether trailing spaces should be | ||
458 | * trimmed in the returned text. | 468 | * trimmed in the returned text. | ||
469 | * @param trimLeadingSpaces Specifies whether leading spaces should be | ||||
470 | * trimmed in the returned text. | ||||
459 | * @param html Specifies if returned text should have HTML tags. | 471 | * @param html Specifies if returned text should have HTML tags. | ||
460 | */ | 472 | */ | ||
461 | QString text(int startIndex, int endIndex, bool preserveLineBreaks, | 473 | QString text(int startIndex, int endIndex, const DecodingOptions options) const; | ||
462 | bool trimTrailingSpaces = false, bool html = false) const; | | |||
463 | 474 | | |||
464 | /** | 475 | /** | ||
465 | * Copies part of the output to a stream. | 476 | * Copies part of the output to a stream. | ||
466 | * | 477 | * | ||
467 | * @param decoder A decoder which converts terminal characters into text | 478 | * @param decoder A decoder which converts terminal characters into text | ||
468 | * @param fromLine The first line in the history to retrieve | 479 | * @param fromLine The first line in the history to retrieve | ||
469 | * @param toLine The last line in the history to retrieve | 480 | * @param toLine The last line in the history to retrieve | ||
470 | */ | 481 | */ | ||
471 | void writeLinesToStream(TerminalCharacterDecoder *decoder, int fromLine, int toLine) const; | 482 | void writeLinesToStream(TerminalCharacterDecoder *decoder, int fromLine, int toLine) const; | ||
472 | 483 | | |||
473 | /** | 484 | /** | ||
474 | * Copies the selected characters, set using @see setSelBeginXY and @see setSelExtentXY | 485 | * Copies the selected characters, set using @see setSelBeginXY and @see setSelExtentXY | ||
475 | * into a stream. | 486 | * into a stream. | ||
476 | * | 487 | * | ||
477 | * @param decoder A decoder which converts terminal characters into text. | 488 | * @param decoder A decoder which converts terminal characters into text. | ||
478 | * PlainTextDecoder is the most commonly used decoder which converts characters | 489 | * PlainTextDecoder is the most commonly used decoder which converts characters | ||
479 | * into plain text with no formatting. | 490 | * into plain text with no formatting. | ||
480 | * @param preserveLineBreaks Specifies whether new line characters should | 491 | * @param preserveLineBreaks Specifies whether new line characters should | ||
481 | * be inserted into the returned text at the end of each terminal line. | 492 | * be inserted into the returned text at the end of each terminal line. | ||
482 | * @param trimTrailingSpaces Specifies whether trailing spaces should be | 493 | * @param trimTrailingSpaces Specifies whether trailing spaces should be | ||
483 | * trimmed in the returned text. | 494 | * trimmed in the returned text. | ||
495 | * @param trimLeadingSpaces Specifies whether leading spaces should be | ||||
496 | * trimmed in the returned text. | ||||
484 | */ | 497 | */ | ||
485 | void writeSelectionToStream(TerminalCharacterDecoder *decoder, bool | 498 | void writeSelectionToStream(TerminalCharacterDecoder *decoder, const Konsole::Screen::DecodingOptions options) const; | ||
486 | preserveLineBreaks = true, bool trimTrailingSpaces = false) const; | | |||
487 | 499 | | |||
488 | /** | 500 | /** | ||
489 | * Checks if the text between from and to is inside the current | 501 | * Checks if the text between from and to is inside the current | ||
490 | * selection. If this is the case, the selection is cleared. The | 502 | * selection. If this is the case, the selection is cleared. The | ||
491 | * from and to are coordinates in the current viewable window. | 503 | * from and to are coordinates in the current viewable window. | ||
492 | * The loc(x,y) macro can be used to generate these values from a | 504 | * The loc(x,y) macro can be used to generate these values from a | ||
493 | * column,line pair. | 505 | * column,line pair. | ||
494 | * | 506 | * | ||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Line(s) | 603 | private: | |||
596 | // | 608 | // | ||
597 | //line - the line number to copy, from 0 (the earliest line in the history) up to | 609 | //line - the line number to copy, from 0 (the earliest line in the history) up to | ||
598 | // history->getLines() + lines - 1 | 610 | // history->getLines() + lines - 1 | ||
599 | //start - the first column on the line to copy | 611 | //start - the first column on the line to copy | ||
600 | //count - the number of characters on the line to copy | 612 | //count - the number of characters on the line to copy | ||
601 | //decoder - a decoder which converts terminal characters (an Character array) into text | 613 | //decoder - a decoder which converts terminal characters (an Character array) into text | ||
602 | //appendNewLine - if true a new line character (\n) is appended to the end of the line | 614 | //appendNewLine - if true a new line character (\n) is appended to the end of the line | ||
603 | int copyLineToStream(int line, int start, int count, TerminalCharacterDecoder *decoder, | 615 | int copyLineToStream(int line, int start, int count, TerminalCharacterDecoder *decoder, | ||
604 | bool appendNewLine, bool preserveLineBreaks, | 616 | bool appendNewLine, const Konsole::Screen::DecodingOptions options) const; | ||
605 | bool trimTrailingSpaces) const; | | |||
606 | 617 | | |||
607 | //fills a section of the screen image with the character 'c' | 618 | //fills a section of the screen image with the character 'c' | ||
608 | //the parameters are specified as offsets from the start of the screen image. | 619 | //the parameters are specified as offsets from the start of the screen image. | ||
609 | //the loc(x,y) macro can be used to generate these values from a column,line pair. | 620 | //the loc(x,y) macro can be used to generate these values from a column,line pair. | ||
610 | void clearImage(int loca, int loce, char c); | 621 | void clearImage(int loca, int loce, char c); | ||
611 | 622 | | |||
612 | //move screen image between 'sourceBegin' and 'sourceEnd' to 'dest'. | 623 | //move screen image between 'sourceBegin' and 'sourceEnd' to 'dest'. | ||
613 | //the parameters are specified as offsets from the start of the screen image. | 624 | //the parameters are specified as offsets from the start of the screen image. | ||
Show All 15 Lines | |||||
629 | 640 | | |||
630 | void updateEffectiveRendition(); | 641 | void updateEffectiveRendition(); | ||
631 | void reverseRendition(Character &p) const; | 642 | void reverseRendition(Character &p) const; | ||
632 | 643 | | |||
633 | bool isSelectionValid() const; | 644 | bool isSelectionValid() const; | ||
634 | // copies text from 'startIndex' to 'endIndex' to a stream | 645 | // copies text from 'startIndex' to 'endIndex' to a stream | ||
635 | // startIndex and endIndex are positions generated using the loc(x,y) macro | 646 | // startIndex and endIndex are positions generated using the loc(x,y) macro | ||
636 | void writeToStream(TerminalCharacterDecoder *decoder, int startIndex, int endIndex, | 647 | void writeToStream(TerminalCharacterDecoder *decoder, int startIndex, int endIndex, | ||
637 | bool preserveLineBreaks = true, bool trimTrailingSpaces = false) const; | 648 | const Konsole::Screen::DecodingOptions options) const; | ||
638 | // copies 'count' lines from the screen buffer into 'dest', | 649 | // copies 'count' lines from the screen buffer into 'dest', | ||
639 | // starting from 'startLine', where 0 is the first line in the screen buffer | 650 | // starting from 'startLine', where 0 is the first line in the screen buffer | ||
640 | void copyFromScreen(Character *dest, int startLine, int count) const; | 651 | void copyFromScreen(Character *dest, int startLine, int count) const; | ||
641 | // copies 'count' lines from the history buffer into 'dest', | 652 | // copies 'count' lines from the history buffer into 'dest', | ||
642 | // starting from 'startLine', where 0 is the first line in the history | 653 | // starting from 'startLine', where 0 is the first line in the history | ||
643 | void copyFromHistory(Character *dest, int startLine, int count) const; | 654 | void copyFromHistory(Character *dest, int startLine, int count) const; | ||
644 | 655 | | |||
645 | // screen image ---------------- | 656 | // screen image ---------------- | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 708 | public: | |||
710 | CharacterColor foreground; | 721 | CharacterColor foreground; | ||
711 | CharacterColor background; | 722 | CharacterColor background; | ||
712 | }; | 723 | }; | ||
713 | SavedState _savedState; | 724 | SavedState _savedState; | ||
714 | 725 | | |||
715 | // last position where we added a character | 726 | // last position where we added a character | ||
716 | int _lastPos; | 727 | int _lastPos; | ||
717 | }; | 728 | }; | ||
729 | | ||||
718 | } | 730 | } | ||
719 | 731 | | |||
732 | Q_DECLARE_OPERATORS_FOR_FLAGS(Konsole::Screen::DecodingOptions) | ||||
733 | | ||||
734 | | ||||
720 | #endif // SCREEN_H | 735 | #endif // SCREEN_H |