diff options
author | nyamatongwe <unknown> | 2007-07-25 09:58:17 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2007-07-25 09:58:17 +0000 |
commit | cc88e2af38e51d286b712a3ebef4dd46222be1dd (patch) | |
tree | 33ce9d88f5bddd18fa01537a9ec0c45f12701357 /src/ContractionState.h | |
parent | 8b609f7f8901b3ae3b8171a21858f35ae9703d15 (diff) | |
download | scintilla-mirror-cc88e2af38e51d286b712a3ebef4dd46222be1dd.tar.gz |
Changed ContractionState data structure to be more efficient by not only
modifying data near an insertion or deletion when there is good locality of
modification.
Diffstat (limited to 'src/ContractionState.h')
-rw-r--r-- | src/ContractionState.h | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/ContractionState.h b/src/ContractionState.h index dbee69db7..ba6297512 100644 --- a/src/ContractionState.h +++ b/src/ContractionState.h @@ -1,8 +1,8 @@ // Scintilla source code edit control /** @file ContractionState.h - ** Manages visibility of lines for folding. + ** Manages visibility of lines for folding and wrapping. **/ -// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> +// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org> // The License.txt file describes the conditions under which this software may be distributed. #ifndef CONTRACTIONSTATE_H @@ -14,31 +14,21 @@ namespace Scintilla { /** */ -class OneLine { -public: - int displayLine; ///< Position within set of visible lines - //int docLine; ///< Inverse of @a displayLine - int height; ///< Number of display lines needed to show all of the line - bool visible; - bool expanded; +class ContractionState { + // These contain 1 element for every document line. + RunStyles *visible; + RunStyles *expanded; + RunStyles *heights; + Partitioning *displayLines; + int linesInDocument; - OneLine(); - virtual ~OneLine() {} -}; + void EnsureData(); -/** - */ -class ContractionState { - void Grow(int sizeNew); - enum { growSize = 4000 }; - int linesInDoc; - mutable int linesInDisplay; - mutable OneLine *lines; - int size; - mutable int *docLines; - mutable int sizeDocLines; - mutable bool valid; - void MakeValid() const; + bool OneToOne() const { + // True when each document line is exactly one display line so need for + // complex data structures. + return visible == 0; + } public: ContractionState(); @@ -51,7 +41,9 @@ public: int DisplayFromDoc(int lineDoc) const; int DocFromDisplay(int lineDisplay) const; + void InsertLine(int lineDoc); void InsertLines(int lineDoc, int lineCount); + void DeleteLine(int lineDoc); void DeleteLines(int lineDoc, int lineCount); bool GetVisible(int lineDoc) const; @@ -64,6 +56,7 @@ public: bool SetHeight(int lineDoc, int height); void ShowAll(); + void Check() const; }; #ifdef SCI_NAMESPACE |