diff options
author | nyamatongwe <devnull@localhost> | 2002-01-16 07:26:01 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2002-01-16 07:26:01 +0000 |
commit | cac2d7ef4ec04021d201bfd3d0a831aca0686f82 (patch) | |
tree | 315e5052bc040c2926145968ffa558dd00482231 | |
parent | 78722b7203a111e9283874296c8de492930799b0 (diff) | |
download | scintilla-mirror-cac2d7ef4ec04021d201bfd3d0a831aca0686f82.tar.gz |
WrapLines performs scroll bar and top line maintenance.
WrapLines called before ensuring a lin eis visible so doc<->visible mapping
correct.
When modification changes number of lines, NeedWrapping starts one line
before.
Horizontal scrolling disallowed even more when in wrap mode.
-rw-r--r-- | src/Editor.cxx | 31 | ||||
-rw-r--r-- | src/Editor.h | 2 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 8c4a5cb9b..bdc322645 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -627,7 +627,7 @@ void Editor::HorizontalScrollTo(int xPos) { //Platform::DebugPrintf("HorizontalScroll %d\n", xPos); if (xPos < 0) xPos = 0; - if (xOffset != xPos) { + if ((wrapState == eWrapNone) && (xOffset != xPos)) { xOffset = xPos; SetHorizontalScrollPos(); RedrawRect(GetClientRectangle()); @@ -750,12 +750,14 @@ void Editor::InvalidateCaret() { void Editor::NeedWrapping(int docLineStartWrapping) { docLineLastWrapped = docLineStartWrapping - 1; + if (docLineLastWrapped < -1) + docLineLastWrapped = -1; } // Check if wrapping needed and perform any needed wrapping. // Return true if wrapping occurred. -bool Editor::WrapLines(int *goodTopLine) { - *goodTopLine = topLine; +bool Editor::WrapLines() { + int goodTopLine = topLine; bool wrapOccurred = false; if (docLineLastWrapped < pdoc->LinesTotal()) { if (wrapState == eWrapNone) { @@ -787,13 +789,18 @@ bool Editor::WrapLines(int *goodTopLine) { wrapOccurred = true; } } - *goodTopLine = cs.DisplayFromDoc(lineDocTop); + goodTopLine = cs.DisplayFromDoc(lineDocTop); if (subLineTop < cs.GetHeight(lineDocTop)) - *goodTopLine += subLineTop; + goodTopLine += subLineTop; else - *goodTopLine += cs.GetHeight(lineDocTop); + goodTopLine += cs.GetHeight(lineDocTop); } } + if (wrapOccurred) { + SetScrollBars(); + SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos())); + SetVerticalScrollPos(); + } return wrapOccurred; } @@ -1433,11 +1440,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n", // rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); - int goodTopLine = topLine; - if (WrapLines(&goodTopLine)) { - SetScrollBars(); - SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos())); - SetVerticalScrollPos(); + if (WrapLines()) { // The wrapping process has changed the height of some lines so abandon this // paint for a complete repaint. paintState = paintAbandoned; @@ -2263,7 +2266,7 @@ void Editor::CheckModificationForWrap(DocModification mh) { LineLayout ll; LayoutLine(lineDoc, surface, vs, ll, wrapWidth); if (cs.GetHeight(lineDoc) != ll.lines) { - NeedWrapping(lineDoc); + NeedWrapping(lineDoc-1); Redraw(); } } else { @@ -3708,6 +3711,10 @@ void Editor::ToggleContraction(int line) { // Recurse up from this line to find any folds that prevent this line from being visible // and unfold them all. void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { + + // In case in need of wrapping to ensure DisplayFromDoc works. + WrapLines(); + if (!cs.GetVisible(lineDoc)) { int lineParent = pdoc->GetFoldParent(lineDoc); if (lineParent >= 0) { diff --git a/src/Editor.h b/src/Editor.h index 3a02ebd2a..16dae7eac 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -276,7 +276,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void InvalidateCaret(); void NeedWrapping(int docLineStartWrapping=0); - bool WrapLines(int *goodTopLine); + bool WrapLines(); int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault); void PaintSelMargin(Surface *surface, PRectangle &rc); |