~ubuntu-branches/ubuntu/saucy/konsole/saucy-proposed

« back to all changes in this revision

Viewing changes to src/Screen.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-06 14:29:24 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120606142924-1rekqv6j25lw2k41
Tags: 4:4.8.80-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <QtCore/QSet>
29
29
#include <QtCore/QVector>
30
30
#include <QtCore/QBitArray>
31
 
#include <QtCore/QTextStream>
32
31
#include <QtCore/QVarLengthArray>
33
32
 
34
33
// Konsole
44
43
 
45
44
namespace Konsole
46
45
{
47
 
 
48
46
class TerminalCharacterDecoder;
49
47
class TerminalDisplay;
50
48
class HistoryType;
370
368
     * @param startLine Index of first line to copy
371
369
     * @param endLine Index of last line to copy
372
370
     */
373
 
    void getImage( Character* dest , int size , int startLine , int endLine ) const;
 
371
    void getImage(Character* dest , int size , int startLine , int endLine) const;
374
372
 
375
373
    /**
376
374
     * Returns the additional attributes associated with lines in the image.
378
376
     * line is wrapped,
379
377
     * other attributes control the size of characters in the line.
380
378
     */
381
 
    QVector<LineProperty> getLineProperties( int startLine , int endLine ) const;
382
 
 
 
379
    QVector<LineProperty> getLineProperties(int startLine , int endLine) const;
383
380
 
384
381
    /** Return the number of lines. */
385
 
    int getLines() const   
386
 
    { return lines; }
 
382
    int getLines() const {
 
383
        return _lines;
 
384
    }
387
385
    /** Return the number of columns. */
388
 
    int getColumns() const 
389
 
    { return columns; }
 
386
    int getColumns() const {
 
387
        return _columns;
 
388
    }
390
389
    /** Return the number of lines in the history buffer. */
391
390
    int getHistLines() const;
392
391
    /**
439
438
      *  Returns true if the character at (@p column, @p line) is part of the
440
439
      *  current selection.
441
440
      */
442
 
    bool isSelected(const int column,const int line) const;
 
441
    bool isSelected(const int column, const int line) const;
443
442
 
444
443
    /**
445
444
     * Convenience method.  Returns the currently selected text.
449
448
    QString selectedText(bool preserveLineBreaks) const;
450
449
 
451
450
    /**
 
451
     * Convenience method.  Returns the text from @p startIndex to @p endIndex.
 
452
     * @param preserveLineBreaks Specifies whether new line characters should
 
453
     * be inserted into the returned text at the end of each terminal line.
 
454
     */
 
455
    QString text(int startIndex, int endIndex, bool preserveLineBreaks) const;
 
456
 
 
457
    /**
452
458
     * Copies part of the output to a stream.
453
459
     *
454
460
     * @param decoder A decoder which converts terminal characters into text
547
553
      */
548
554
    static void fillWithDefaultChar(Character* dest, int count);
549
555
 
550
 
    void setCurrentTerminalDisplay(TerminalDisplay* display)
551
 
    {
552
 
           _currentTerminalDisplay = display;
 
556
    void setCurrentTerminalDisplay(TerminalDisplay* display) {
 
557
        _currentTerminalDisplay = display;
553
558
    }
554
559
 
555
 
    TerminalDisplay* currentTerminalDisplay()
556
 
    {
 
560
    TerminalDisplay* currentTerminalDisplay() {
557
561
        return _currentTerminalDisplay;
558
562
    }
559
563
 
560
 
    QSet<ushort> usedExtendedChars() const
561
 
    {
 
564
    QSet<ushort> usedExtendedChars() const {
562
565
        QSet<ushort> result;
563
 
        for (int i = 0; i < lines; ++i)
564
 
        {
565
 
            const ImageLine& il = screenLines[i];
566
 
            for (int j = 0; j < columns; ++j)
567
 
            {
568
 
                if (il[j].rendition & RE_EXTENDED_CHAR)
569
 
                {
 
566
        for (int i = 0; i < _lines; ++i) {
 
567
            const ImageLine& il = _screenLines[i];
 
568
            for (int j = 0; j < _columns; ++j) {
 
569
                if (il[j].rendition & RE_EXTENDED_CHAR) {
570
570
                    result << il[j].character;
571
571
                }
572
572
            }
574
574
        return result;
575
575
    }
576
576
 
577
 
    static const Character defaultChar;
 
577
    static const Character DefaultChar;
578
578
 
579
579
private:
580
 
 
581
580
    //copies a line of text from the screen or history into a stream using a
582
581
    //specified character decoder.  Returns the number of lines actually copied,
583
582
    //which may be less than 'count' if (start+count) is more than the number of characters on
589
588
    //count - the number of characters on the line to copy
590
589
    //decoder - a decoder which converts terminal characters (an Character array) into text
591
590
    //appendNewLine - if true a new line character (\n) is appended to the end of the line
592
 
    int  copyLineToStream(int line, 
593
 
                          int start, 
594
 
                          int count, 
 
591
    int  copyLineToStream(int line,
 
592
                          int start,
 
593
                          int count,
595
594
                          TerminalCharacterDecoder* decoder,
596
595
                          bool appendNewLine,
597
596
                          bool preserveLineBreaks) const;
625
624
    bool isSelectionValid() const;
626
625
    // copies text from 'startIndex' to 'endIndex' to a stream
627
626
    // startIndex and endIndex are positions generated using the loc(x,y) macro
628
 
    void writeToStream(TerminalCharacterDecoder* decoder, int startIndex, 
 
627
    void writeToStream(TerminalCharacterDecoder* decoder, int startIndex,
629
628
                       int endIndex, bool preserveLineBreaks = true) const;
630
629
    // copies 'count' lines from the screen buffer into 'dest',
631
630
    // starting from 'startLine', where 0 is the first line in the screen buffer
634
633
    // starting from 'startLine', where 0 is the first line in the history
635
634
    void copyFromHistory(Character* dest, int startLine, int count) const;
636
635
 
637
 
 
638
636
    // screen image ----------------
639
 
    int lines;
640
 
    int columns;
 
637
    int _lines;
 
638
    int _columns;
641
639
 
642
640
    typedef QVector<Character> ImageLine;      // [0..columns]
643
 
    ImageLine*          screenLines;    // [lines]
 
641
    ImageLine*          _screenLines;    // [lines]
644
642
 
645
643
    int _scrolledLines;
646
644
    QRect _lastScrolledRegion;
647
645
 
648
646
    int _droppedLines;
649
647
 
650
 
    QVarLengthArray<LineProperty,64> lineProperties;    
 
648
    QVarLengthArray<LineProperty, 64> _lineProperties;
651
649
 
652
650
    // history buffer ---------------
653
 
    HistoryScroll* history;
 
651
    HistoryScroll* _history;
654
652
 
655
653
    // cursor location
656
 
    int cuX;
657
 
    int cuY;
 
654
    int _cuX;
 
655
    int _cuY;
658
656
 
659
657
    // cursor color and rendition info
660
 
    CharacterColor currentForeground;
661
 
    CharacterColor currentBackground;
662
 
    quint8 currentRendition; 
 
658
    CharacterColor _currentForeground;
 
659
    CharacterColor _currentBackground;
 
660
    quint8 _currentRendition;
663
661
 
664
662
    // margins ----------------
665
663
    int _topMargin;
666
664
    int _bottomMargin;
667
665
 
668
666
    // states ----------------
669
 
    int currentModes[MODES_SCREEN];
670
 
    int savedModes[MODES_SCREEN];
 
667
    int _currentModes[MODES_SCREEN];
 
668
    int _savedModes[MODES_SCREEN];
671
669
 
672
670
    // ----------------------------
673
671
 
674
 
    QBitArray tabStops;
 
672
    QBitArray _tabStops;
675
673
 
676
674
    // selection -------------------
677
 
    int selBegin; // The first location selected.
678
 
    int selTopLeft;    // TopLeft Location.
679
 
    int selBottomRight;    // Bottom Right Location.
680
 
    bool blockSelectionMode;  // Column selection mode
 
675
    int _selBegin; // The first location selected.
 
676
    int _selTopLeft;    // TopLeft Location.
 
677
    int _selBottomRight;    // Bottom Right Location.
 
678
    bool _blockSelectionMode;  // Column selection mode
681
679
 
682
680
    // effective colors and rendition ------------
683
 
    CharacterColor effectiveForeground; // These are derived from
684
 
    CharacterColor effectiveBackground; // the cu_* variables above
685
 
    quint8 effectiveRendition;          // to speed up operation
 
681
    CharacterColor _effectiveForeground; // These are derived from
 
682
    CharacterColor _effectiveBackground; // the cu_* variables above
 
683
    quint8 _effectiveRendition;          // to speed up operation
686
684
 
687
 
    class SavedState  
 
685
    class SavedState
688
686
    {
689
687
    public:
690
688
        SavedState()
691
 
        : cursorColumn(0),cursorLine(0),rendition(0) {}
 
689
            : cursorColumn(0), cursorLine(0), rendition(0) {}
692
690
 
693
691
        int cursorColumn;
694
692
        int cursorLine;
696
694
        CharacterColor foreground;
697
695
        CharacterColor background;
698
696
    };
699
 
    SavedState savedState;
 
697
    SavedState _savedState;
700
698
 
701
699
    // last position where we added a character
702
 
    int lastPos;
703
 
 
 
700
    int _lastPos;
704
701
};
705
 
 
706
702
}
707
703
 
708
704
#endif // SCREEN_H