* Recurse up from this line to find any folds that prevent this line from being visible * and unfold them all. */
| 7202 | * and unfold them all. |
| 7203 | */ |
| 7204 | void Editor::EnsureLineVisible ( int lineDoc, bool enforcePolicy ) |
| 7205 | { |
| 7206 | // In case in need of wrapping to ensure DisplayFromDoc works. |
| 7207 | if ( lineDoc >= wrapStart ) { |
| 7208 | WrapLines ( true, -1 ); |
| 7209 | } |
| 7210 | if ( !cs.GetVisible ( lineDoc ) ) { |
| 7211 | // Back up to find a non-blank line |
| 7212 | int lookLine = lineDoc; |
| 7213 | int lookLineLevel = pdoc->GetLevel ( lookLine ); |
| 7214 | while ( ( lookLine > 0 ) && ( lookLineLevel & SC_FOLDLEVELWHITEFLAG ) ) { |
| 7215 | lookLineLevel = pdoc->GetLevel ( --lookLine ); |
| 7216 | } |
| 7217 | int lineParent = pdoc->GetFoldParent ( lookLine ); |
| 7218 | if ( lineParent < 0 ) { |
| 7219 | // Backed up to a top level line, so try to find parent of initial line |
| 7220 | lineParent = pdoc->GetFoldParent ( lineDoc ); |
| 7221 | } |
| 7222 | if ( lineParent >= 0 ) { |
| 7223 | if ( lineDoc != lineParent ) { |
| 7224 | EnsureLineVisible ( lineParent, enforcePolicy ); |
| 7225 | } |
| 7226 | if ( !cs.GetExpanded ( lineParent ) ) { |
| 7227 | cs.SetExpanded ( lineParent, 1 ); |
| 7228 | ExpandLine ( lineParent ); |
| 7229 | } |
| 7230 | } |
| 7231 | SetScrollBars(); |
| 7232 | Redraw(); |
| 7233 | } |
| 7234 | if ( enforcePolicy ) { |
| 7235 | int lineDisplay = cs.DisplayFromDoc ( lineDoc ); |
| 7236 | if ( visiblePolicy & VISIBLE_SLOP ) { |
| 7237 | if ( ( topLine > lineDisplay ) || ( ( visiblePolicy & VISIBLE_STRICT ) && ( topLine + visibleSlop > lineDisplay ) ) ) { |
| 7238 | SetTopLine ( Platform::Clamp ( lineDisplay - visibleSlop, 0, MaxScrollPos() ) ); |
| 7239 | SetVerticalScrollPos(); |
| 7240 | Redraw(); |
| 7241 | } else if ( ( lineDisplay > topLine + LinesOnScreen() - 1 ) || |
| 7242 | ( ( visiblePolicy & VISIBLE_STRICT ) && ( lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop ) ) ) { |
| 7243 | SetTopLine ( Platform::Clamp ( lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos() ) ); |
| 7244 | SetVerticalScrollPos(); |
| 7245 | Redraw(); |
| 7246 | } |
| 7247 | } else { |
| 7248 | if ( ( topLine > lineDisplay ) || ( lineDisplay > topLine + LinesOnScreen() - 1 ) || ( visiblePolicy & VISIBLE_STRICT ) ) { |
| 7249 | SetTopLine ( Platform::Clamp ( lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos() ) ); |
| 7250 | SetVerticalScrollPos(); |
| 7251 | Redraw(); |
| 7252 | } |
| 7253 | } |
| 7254 | } |
| 7255 | } |
| 7256 | |
| 7257 | void Editor::FoldAll ( int action ) |
| 7258 | { |
nothing calls this directly
no test coverage detected