Example #1
0
 bool IWeakEventListener.ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
 {
     if (managerType == typeof(CaretWeakEventManager.PositionChanged))
     {
         Caret caret       = (Caret)sender;
         int   caretOffset = caret.Offset;
         foreach (FoldingSection s in manager.GetFoldingsContaining(caretOffset))
         {
             if (s.IsFolded && s.StartOffset < caretOffset && caretOffset < s.EndOffset)
             {
                 s.IsFolded = false;
             }
         }
         return(true);
     }
     return(false);
 }
Example #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] = grayPen;
                    }
                }
                if (end > maxEndOffset && fs.StartOffset < viewStartOffset)
                {
                    maxEndOffset = end;
                }
            }
            if (maxEndOffset > 0)
            {
                if (maxEndOffset > viewEndOffset)
                {
                    for (int i = 0; i < colors.Length; i++)
                    {
                        colors[i] = grayPen;
                    }
                }
                else
                {
                    int maxTextLine = GetTextLineIndexFromOffset(allTextLines, maxEndOffset);
                    for (int i = 0; i <= maxTextLine; i++)
                    {
                        colors[i] = grayPen;
                    }
                }
            }
        }