예제 #1
0
 /// <inheritdoc/>
 public override int GetFirstInterestedOffset(int startOffset)
 {
     if (foldingManager != null)
     {
         foreach (FoldingSection fs in foldingManager.GetFoldingsContaining(startOffset))
         {
             // Test whether we're currently within a folded folding (that didn't just end).
             // If so, create the fold marker immediately.
             // This is necessary if the actual beginning of the fold marker got skipped due to another VisualElementGenerator.
             if (fs.IsFolded && fs.EndOffset > startOffset)
             {
                 //return startOffset;
             }
         }
         return(foldingManager.GetNextFoldedFoldingStart(startOffset));
     }
     else
     {
         return(-1);
     }
 }
예제 #2
0
        /// <summary>
        /// Calculates fold lines for all folding sections that start in front of the current view
        /// and run into the current view.
        /// </summary>
        void CalculateFoldLinesForFoldingsActiveAtStart(List <TextLine> allTextLines, Pen[] colors, Pen[] endMarker)
        {
            int viewStartOffset = TextView.VisualLines[0].FirstDocumentLine.Offset;
            int viewEndOffset   = TextView.VisualLines.Last().LastDocumentLine.EndOffset;
            var foldings        = FoldingManager.GetFoldingsContaining(viewStartOffset);
            int maxEndOffset    = 0;

            foreach (FoldingSection fs in foldings)
            {
                int end = fs.EndOffset;
                if (end <= viewEndOffset && !fs.IsFolded)
                {
                    int textLineNr = GetTextLineIndexFromOffset(allTextLines, end);
                    if (textLineNr >= 0)
                    {
                        endMarker[textLineNr] = foldingControlPen;
                    }
                }
                if (end > maxEndOffset && fs.StartOffset < viewStartOffset)
                {
                    maxEndOffset = end;
                }
            }
            if (maxEndOffset > 0)
            {
                if (maxEndOffset > viewEndOffset)
                {
                    for (int i = 0; i < colors.Length; i++)
                    {
                        colors[i] = foldingControlPen;
                    }
                }
                else
                {
                    int maxTextLine = GetTextLineIndexFromOffset(allTextLines, maxEndOffset);
                    for (int i = 0; i <= maxTextLine; i++)
                    {
                        colors[i] = foldingControlPen;
                    }
                }
            }
        }