diff options
author | nyamatongwe <devnull@localhost> | 2013-06-18 14:55:30 +1000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2013-06-18 14:55:30 +1000 |
commit | 82eecd91fd37c732f492eeec808a0b65d36e1707 (patch) | |
tree | 9efcc4e18c6827a054dd2de2141d4fa65f055d9c /src/Editor.h | |
parent | 88ab035bd1811b97d6dbd789ebe2f3157864ebee (diff) | |
download | scintilla-mirror-82eecd91fd37c732f492eeec808a0b65d36e1707.tar.gz |
Simplify line wrapping code, minimize lines wrapped and avoid rewrapping lines.
Diffstat (limited to 'src/Editor.h')
-rw-r--r-- | src/Editor.h | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/src/Editor.h b/src/Editor.h index b47bd24c0..9105db468 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -125,6 +125,41 @@ private: } }; +struct WrapPending { + // The range of lines that need to be wrapped + enum { lineLarge = 0x7ffffff }; + int start; // When there are wraps pending, will be in document range + int end; // May be lineLarge to indicate all of document after start + WrapPending() { + start = lineLarge; + end = lineLarge; + } + void Reset() { + start = lineLarge; + end = lineLarge; + } + void Wrapped(int line) { + if (start == line) + start++; + } + bool NeedsWrap() const { + return start < end; + } + bool AddRange(int lineStart, int lineEnd) { + const bool neededWrap = NeedsWrap(); + bool changed = false; + if (start > lineStart) { + start = lineStart; + changed = true; + } + if ((end < lineEnd) || !neededWrap) { + end = lineEnd; + changed = true; + } + return changed; + } +}; + /** */ class Editor : public DocWatcher { @@ -273,10 +308,8 @@ protected: // ScintillaBase subclass needs access to much of Editor // Wrapping support enum { eWrapNone, eWrapWord, eWrapChar } wrapState; - enum { wrapLineLarge = 0x7ffffff }; int wrapWidth; - int wrapStart; - int wrapEnd; + WrapPending wrapPending; int wrapVisualFlags; int wrapVisualFlagsLocation; int wrapVisualStartIndent; @@ -390,9 +423,10 @@ protected: // ScintillaBase subclass needs access to much of Editor void InvalidateCaret(); virtual void UpdateSystemCaret(); - void NeedWrapping(int docLineStart = 0, int docLineEnd = wrapLineLarge); + void NeedWrapping(int docLineStart=0, int docLineEnd=WrapPending::lineLarge); bool WrapOneLine(Surface *surface, int lineToWrap); - bool WrapLines(bool fullWrap, int priorityWrapLineStart); + enum wrapScope {wsAll, wsVisible, wsIdle}; + bool WrapLines(enum wrapScope ws); void LinesJoin(); void LinesSplit(int pixelWidth); |