public void Unfold (FoldMarker marker, int lineNumber, int count)
		{
			lock (tree) {
				if (marker == null || !markers.Contains (marker))
					return;
				markers.Remove (marker);
				
				GetSingleLineNode (lineNumber);
				lineNumber++;
				for (int i = lineNumber; i < lineNumber + count; i++) {
					var node = GetSingleLineNode (i);
					node.foldLevel--;
					node.UpdateAugmentedData ();
				}
				OnLineUpdateFrom (new HeightChangedEventArgs (lineNumber - 1));
			}
		}
Exemple #2
0
		public void Unfold (FoldMarker marker, int lineNumber, int count)
		{
			if (marker == null || !markers.Contains (marker))
				return;
			markers.Remove (marker);
			
			GetSingleLineNode (lineNumber);
			lineNumber++;
			for (int i = lineNumber; i < lineNumber + count; i++) {
				var node = GetSingleLineNode (i);
				node.foldLevel--;
				node.UpdateAugmentedData ();
			}
		}
		public FoldMarker Fold (int lineNumber, int count)
		{
			lock (tree) {
				GetSingleLineNode (lineNumber);
				lineNumber++;
				
				for (int i = lineNumber; i < lineNumber + count; i++) {
					var node = GetSingleLineNode (i);
					node.foldLevel++;
					node.UpdateAugmentedData ();
				}
				var result = new FoldMarker (lineNumber, count);
				markers.Add (result);
				OnLineUpdateFrom (new HeightChangedEventArgs (lineNumber - 1));
				return result;
			}
		}
Exemple #4
0
		public FoldMarker Fold (int lineNumber, int count)
		{
			GetSingleLineNode (lineNumber);
			lineNumber++;
			
			for (int i = lineNumber; i < lineNumber + count; i++) {
				var node = GetSingleLineNode (i);
				node.foldLevel++;
				node.UpdateAugmentedData ();
			}
			var result = new FoldMarker (lineNumber, count);
			markers.Add (result);
			return result;
		}
 /// <summary>
 /// Create an element fold if the start and end tag are on 
 /// different lines.
 /// </summary>
 void CreateElementFold(IDocument document, List<FoldMarker> foldMarkers, XmlTextReader reader, XmlFoldStart foldStart)
 {
   int endLine = reader.LineNumber - 1;
   if (endLine > foldStart.Line)
   {
     int endCol = reader.LinePosition + foldStart.Name.Length;
     FoldMarker foldMarker = new FoldMarker(document, foldStart.Line, foldStart.Column, endLine, endCol, foldStart.FoldText);
     foldMarkers.Add(foldMarker);
   }
 }
    /// <summary>
    /// Creates a comment fold if the comment spans more than one line.
    /// </summary>
    /// <remarks>The text displayed when the comment is folded is the first 
    /// line of the comment.</remarks>
    void CreateCommentFold(IDocument document, List<FoldMarker> foldMarkers, XmlTextReader reader)
    {
      if (reader.Value != null)
      {
        string comment = reader.Value.Replace("\r\n", "\n");
        string[] lines = comment.Split('\n');
        if (lines.Length > 1)
        {

          // Take off 5 chars to get the actual comment start (takes
          // into account the <!-- chars.

          int startCol = reader.LinePosition - 5;
          int startLine = reader.LineNumber - 1;

          // Add 3 to the end col value to take into account the '-->'
          int endCol = lines[lines.Length - 1].Length + startCol + 3;
          int endLine = startLine + lines.Length - 1;
          string foldText = String.Concat("<!--", lines[0], "-->");
          FoldMarker foldMarker = new FoldMarker(document, startLine, startCol, endLine, endCol, foldText);
          foldMarkers.Add(foldMarker);
        }
      }
    }
Exemple #7
0
        void OnMouseDown(object sender, MouseEventArgs e)
        {
            Point mousepos;

            textArea.mousepos = e.Location;
            mousepos          = e.Location;

            if (dodragdrop)
            {
                return;
            }

            if (doubleclick)
            {
                doubleclick = false;
                return;
            }

            if (textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y))
            {
                gotmousedown = true;
                textArea.SelectionManager.selectFrom.where = WhereFrom.TArea;
                button = e.Button;

                // double-click
                if (button == MouseButtons.Left && e.Clicks == 2)
                {
                    int deltaX = Math.Abs(lastmousedownpos.X - e.X);
                    int deltaY = Math.Abs(lastmousedownpos.Y - e.Y);
                    if (deltaX <= SystemInformation.DoubleClickSize.Width &&
                        deltaY <= SystemInformation.DoubleClickSize.Height)
                    {
                        DoubleClickSelectionExtend();
                        lastmousedownpos = new Point(e.X, e.Y);

                        if (textArea.SelectionManager.selectFrom.where == WhereFrom.Gutter)
                        {
                            if (!minSelection.IsEmpty && !maxSelection.IsEmpty && textArea.SelectionManager.SelectionCollection.Count > 0)
                            {
                                textArea.SelectionManager.SelectionCollection[0].StartPosition = minSelection;
                                textArea.SelectionManager.SelectionCollection[0].EndPosition   = maxSelection;
                                textArea.SelectionManager.SelectionStart = minSelection;

                                minSelection = TextLocation.Empty;
                                maxSelection = TextLocation.Empty;
                            }
                        }
                        return;
                    }
                }
                minSelection = TextLocation.Empty;
                maxSelection = TextLocation.Empty;

                lastmousedownpos = mousedownpos = new Point(e.X, e.Y);

                if (button == MouseButtons.Left)
                {
                    FoldMarker marker = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X,
                                                                                    mousepos.Y - textArea.TextView.DrawingPosition.Y);
                    if (marker != null && marker.IsFolded)
                    {
                        if (textArea.SelectionManager.HasSomethingSelected)
                        {
                            clickedOnSelectedText = true;
                        }

                        TextLocation startLocation = new TextLocation(marker.StartColumn, marker.StartLine);
                        TextLocation endLocation   = new TextLocation(marker.EndColumn, marker.EndLine);
                        textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.TextView.Document, startLocation, endLocation));
                        textArea.Caret.Position = startLocation;
                        textArea.SetDesiredColumn();
                        textArea.Focus();
                        return;
                    }

                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        ExtendSelectionToMouse();
                    }
                    else
                    {
                        TextLocation realmousepos = textArea.TextView.GetLogicalPosition(mousepos.X - textArea.TextView.DrawingPosition.X, mousepos.Y - textArea.TextView.DrawingPosition.Y);
                        clickedOnSelectedText = false;

                        int offset = textArea.Document.PositionToOffset(realmousepos);

                        if (textArea.SelectionManager.HasSomethingSelected &&
                            textArea.SelectionManager.IsSelected(offset))
                        {
                            clickedOnSelectedText = true;
                        }
                        else
                        {
                            textArea.SelectionManager.ClearSelection();
                            if (mousepos.Y > 0 && mousepos.Y < textArea.TextView.DrawingPosition.Height)
                            {
                                TextLocation pos = new TextLocation();
                                pos.Y = Math.Min(textArea.Document.TotalNumberOfLines - 1, realmousepos.Y);
                                pos.X = realmousepos.X;
                                textArea.Caret.Position = pos;
                                textArea.SetDesiredColumn();
                            }
                        }
                    }
                }
                else if (button == MouseButtons.Right)
                {
                    // Rightclick sets the cursor to the click position unless
                    // the previous selection was clicked
                    TextLocation realmousepos = textArea.TextView.GetLogicalPosition(mousepos.X - textArea.TextView.DrawingPosition.X, mousepos.Y - textArea.TextView.DrawingPosition.Y);
                    int          offset       = textArea.Document.PositionToOffset(realmousepos);
                    if (!textArea.SelectionManager.HasSomethingSelected ||
                        !textArea.SelectionManager.IsSelected(offset))
                    {
                        textArea.SelectionManager.ClearSelection();
                        if (mousepos.Y > 0 && mousepos.Y < textArea.TextView.DrawingPosition.Height)
                        {
                            TextLocation pos = new TextLocation();
                            pos.Y = Math.Min(textArea.Document.TotalNumberOfLines - 1, realmousepos.Y);
                            pos.X = realmousepos.X;
                            textArea.Caret.Position = pos;
                            textArea.SetDesiredColumn();
                        }
                    }
                }
            }
            textArea.Focus();
        }
Exemple #8
0
        void DoubleClickSelectionExtend()
        {
            Point mousepos;

            mousepos = textArea.mousepos;

            textArea.SelectionManager.ClearSelection();
            if (textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y))
            {
                FoldMarker marker = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X,
                                                                                mousepos.Y - textArea.TextView.DrawingPosition.Y);
                if (marker != null && marker.IsFolded)
                {
                    marker.IsFolded = false;
                    textArea.MotherTextAreaControl.AdjustScrollBars();
                }
                if (textArea.Caret.Offset < textArea.Document.TextLength)
                {
                    switch (textArea.Document.GetCharAt(textArea.Caret.Offset))
                    {
                    case '"':
                        if (textArea.Caret.Offset < textArea.Document.TextLength)
                        {
                            int next = FindNext(textArea.Document, textArea.Caret.Offset + 1, '"');
                            minSelection = textArea.Caret.Position;
                            if (next > textArea.Caret.Offset && next < textArea.Document.TextLength)
                            {
                                next += 1;
                            }
                            maxSelection = textArea.Document.OffsetToPosition(next);
                        }
                        break;

                    default:
                        minSelection = textArea.Document.OffsetToPosition(FindWordStart(textArea.Document, textArea.Caret.Offset));
                        maxSelection = textArea.Document.OffsetToPosition(FindWordEnd(textArea.Document, textArea.Caret.Offset));
                        break;
                    }
                    textArea.Caret.Position = maxSelection;
                    textArea.SelectionManager.ExtendSelection(minSelection, maxSelection);
                }

                if (textArea.SelectionManager.selectionCollection.Count > 0)
                {
                    ISelection selection = textArea.SelectionManager.selectionCollection[0];

                    selection.StartPosition = minSelection;
                    selection.EndPosition   = maxSelection;
                    textArea.SelectionManager.SelectionStart = minSelection;
                }

                // after a double-click selection, the caret is placed correctly,
                // but it is not positioned internally.  The effect is when the cursor
                // is moved up or down a line, the caret will take on the column first
                // clicked on for the double-click
                textArea.SetDesiredColumn();

                // HACK WARNING !!!
                // must refresh here, because when a error tooltip is showed and the underlined
                // code is double clicked the textArea don't update corrctly, updateline doesn't
                // work ... but the refresh does.
                // Mike
                textArea.Refresh();
            }
        }