This class views the line numbers and folding markers.
Inheritance: System.Windows.Forms.Control
Example #1
0
 public void Refresh(AbstractMargin margin)
 {
     updateMargin = margin;
     Invalidate(updateMargin.DrawingPosition);
     Update();
     updateMargin = null;
 }
Example #2
0
 protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
 {
     base.OnMouseMove(e);
     foreach (AbstractMargin margin in leftMargins)
     {
         if (margin.DrawingPosition.Contains(e.X, e.Y))
         {
             this.Cursor = margin.Cursor;
             margin.HandleMouseMove(new Point(e.X, e.Y), e.Button);
             if (lastMouseInMargin != margin)
             {
                 if (lastMouseInMargin != null)
                 {
                     lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
                 }
                 lastMouseInMargin = margin;
             }
             return;
         }
     }
     if (lastMouseInMargin != null)
     {
         lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
         lastMouseInMargin = null;
     }
     if (textView.DrawingPosition.Contains(e.X, e.Y))
     {
         this.Cursor = textView.Cursor;
         return;
     }
     this.Cursor = Cursors.Default;
 }
        public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl)
        {
            this.motherTextAreaControl   = motherTextAreaControl;
            this.motherTextEditorControl = motherTextEditorControl;
            this.caret                    = new ICSharpCode.TextEditor.Caret(this);
            this.selectionManager         = new ICSharpCode.TextEditor.Document.SelectionManager(this.Document, this);
            this.textAreaClipboardHandler = new TextAreaClipboardHandler(this);
            base.ResizeRedraw             = true;
            base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            base.SetStyle(ControlStyles.Opaque, false);
            base.SetStyle(ControlStyles.ResizeRedraw, true);
            base.SetStyle(ControlStyles.Selectable, true);
            this.textView      = new ICSharpCode.TextEditor.TextView(this);
            this.gutterMargin  = new ICSharpCode.TextEditor.GutterMargin(this);
            this.foldMargin    = new ICSharpCode.TextEditor.FoldMargin(this);
            this.iconBarMargin = new ICSharpCode.TextEditor.IconBarMargin(this);
            List <AbstractMargin> abstractMargins = this.leftMargins;

            AbstractMargin[] abstractMarginArray = new AbstractMargin[] { this.iconBarMargin, this.gutterMargin, this.foldMargin };
            abstractMargins.AddRange(abstractMarginArray);
            this.OptionsChanged();
            (new TextAreaMouseHandler(this)).Attach();
            (new TextAreaDragDropHandler()).Attach(this);
            this.bracketshemes.Add(new BracketHighlightingSheme('{', '}'));
            this.bracketshemes.Add(new BracketHighlightingSheme('(', ')'));
            this.bracketshemes.Add(new BracketHighlightingSheme('[', ']'));
            this.caret.PositionChanged                   += new EventHandler(this.SearchMatchingBracket);
            this.Document.TextContentChanged             += new EventHandler(this.TextContentChanged);
            this.Document.FoldingManager.FoldingsChanged += new EventHandler(this.DocumentFoldingsChanged);
        }
 public void Refresh(AbstractMargin margin)
 {
     this.updateMargin = margin;
     base.Invalidate(this.updateMargin.DrawingPosition);
     base.Update();
     this.updateMargin = null;
 }
Example #5
0
 protected override void OnMouseLeave(System.EventArgs e)
 {
     base.OnMouseLeave(e);
     this.Cursor = Cursors.Default;
     if (lastMouseInMargin != null)
     {
         lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
         lastMouseInMargin = null;
     }
 }
Example #6
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (!toolTipRectangle.Contains(e.Location))
            {
                toolTipRectangle = Rectangle.Empty;
                if (toolTipActive)
                {
                    RequestToolTip(e.Location);
                }
            }

            foreach (AbstractMargin margin in _leftMargins)
            {
                if (margin.DrawingPosition.Contains(e.X, e.Y))
                {
                    this.Cursor = margin.Cursor;
                    margin.HandleMouseMove(new Point(e.X, e.Y), e.Button);
                    if (lastMouseInMargin != margin)
                    {
                        if (lastMouseInMargin != null)
                        {
                            lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
                        }
                        lastMouseInMargin = margin;
                    }
                    return;
                }
            }

            if (lastMouseInMargin != null)
            {
                lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
                lastMouseInMargin = null;
            }

            if (_textView.DrawingPosition.Contains(e.X, e.Y))
            {
                TextLocation realmousepos = TextView.GetLogicalPosition(e.X - TextView.DrawingPosition.X, e.Y - TextView.DrawingPosition.Y);
                if (SelectionManager.IsSelected(Document.PositionToOffset(realmousepos)) && MouseButtons == MouseButtons.None)
                {
                    // mouse is hovering over a selection, so show default mouse
                    this.Cursor = Cursors.Default;
                }
                else
                {
                    // mouse is hovering over text area, not a selection, so show the textView cursor
                    this.Cursor = _textView.Cursor;
                }
                return;
            }

            this.Cursor = Cursors.Default;
        }
 protected override void OnMouseLeave(EventArgs e)
 {
     base.OnMouseLeave(e);
     this.Cursor = Cursors.Default;
     if (this.lastMouseInMargin != null)
     {
         this.lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
         this.lastMouseInMargin = null;
     }
     this.CloseToolTip();
 }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (!this.toolTipRectangle.Contains(e.Location))
            {
                this.toolTipRectangle = Rectangle.Empty;
                if (this.toolTipActive)
                {
                    this.RequestToolTip(e.Location);
                }
            }
            foreach (AbstractMargin leftMargin in this.leftMargins)
            {
                if (!leftMargin.DrawingPosition.Contains(e.X, e.Y))
                {
                    continue;
                }
                this.Cursor = leftMargin.Cursor;
                leftMargin.HandleMouseMove(new Point(e.X, e.Y), e.Button);
                if (this.lastMouseInMargin != leftMargin)
                {
                    if (this.lastMouseInMargin != null)
                    {
                        this.lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
                    }
                    this.lastMouseInMargin = leftMargin;
                }
                return;
            }
            if (this.lastMouseInMargin != null)
            {
                this.lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
                this.lastMouseInMargin = null;
            }
            if (!this.textView.DrawingPosition.Contains(e.X, e.Y))
            {
                this.Cursor = Cursors.Default;
                return;
            }
            ICSharpCode.TextEditor.TextView textView = this.TextView;
            int          x = e.X - this.TextView.DrawingPosition.X;
            int          y = e.Y;
            Rectangle    drawingPosition = this.TextView.DrawingPosition;
            TextLocation logicalPosition = textView.GetLogicalPosition(x, y - drawingPosition.Y);

            if (this.SelectionManager.IsSelected(this.Document.PositionToOffset(logicalPosition)) && Control.MouseButtons == System.Windows.Forms.MouseButtons.None)
            {
                this.Cursor = Cursors.Default;
                return;
            }
            this.Cursor = this.textView.Cursor;
        }
Example #9
0
        void OnIconBarMarginMouseDown(ICSharpCode.TextEditor.AbstractMargin sender, Point mousepos, MouseButtons mouseButtons)
        {
            if (mouseButtons != MouseButtons.Left)
            {
                return;
            }

            ICSharpCode.TextEditor.IconBarMargin marginObj = (ICSharpCode.TextEditor.IconBarMargin)sender;

            Rectangle viewRect = marginObj.TextArea.TextView.DrawingPosition;
            Point     logicPos = marginObj.TextArea.TextView.GetLogicalPosition(0, mousepos.Y - viewRect.Top);

            if (logicPos.Y >= 0 && logicPos.Y < marginObj.TextArea.Document.TotalNumberOfLines)
            {
                LineSegment l = marginObj.Document.GetLineSegment(logicPos.Y);

                string s = marginObj.Document.GetText(l);

                if (s.Trim().Length == 0)
                {
                    return;
                }

                // FIXME:
                // Not quite happy with this. It's hidden. Also, removing
                // the breakpoint has extra code in OnBookmarkManager not
                // matching up with OnBookmarkAdded.
                this.textEditor.Document.BookmarkManager.AddMark
                (
                    new Breakpoint(
                        this._filename,
                        this.textEditor.Document,
                        logicPos.Y
                        )
                );

                this.RedrawBreakpoints();

                marginObj.Paint(marginObj.TextArea.CreateGraphics(), marginObj.TextArea.DisplayRectangle);
            }
        }
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (!toolTipRectangle.Contains(e.Location))
     {
         toolTipRectangle = Rectangle.Empty;
         if (toolTipActive)
         {
             RequestToolTip(e.Location);
         }
     }
     foreach (AbstractMargin margin in leftMargins)
     {
         if (margin.DrawingPosition.Contains(e.X, e.Y))
         {
             this.Cursor = margin.Cursor;
             margin.HandleMouseMove(new Point(e.X, e.Y), e.Button);
             if (lastMouseInMargin != margin)
             {
                 if (lastMouseInMargin != null)
                 {
                     lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
                 }
                 lastMouseInMargin = margin;
             }
             return;
         }
     }
     if (lastMouseInMargin != null)
     {
         lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
         lastMouseInMargin = null;
     }
     if (textView.DrawingPosition.Contains(e.X, e.Y))
     {
         this.Cursor = textView.Cursor;
         return;
     }
     this.Cursor = Cursors.Default;
 }
Example #11
0
        /// <summary>
        /// Toggles breakpoints when clicked on the icon margin of the editor.
        /// </summary>
        private void IconBarMargin_MouseDown(AbstractMargin sender, Point mousepos, MouseButtons mouseButtons)
        {
            var textArea = textEditorControl.ActiveTextAreaControl.TextArea;
            int clickedVisibleLine = (mousepos.Y + textArea.VirtualTop.Y) / textArea.TextView.FontHeight;
            int lineNumber = textArea.Document.GetFirstLogicalLine(clickedVisibleLine);

            if ((mouseButtons & MouseButtons.Left) == MouseButtons.Left)
            {
                ToggleBreakpointAt(lineNumber + 1);
            }
        }
Example #12
0
		public void Refresh(AbstractMargin margin)
		{
			updateMargin = margin;
			Invalidate(updateMargin.DrawingPosition);
			Update();
			updateMargin = null;
		}
Example #13
0
		protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
		{
			toolTipSet = false;
			base.OnMouseMove(e);
			if (!toolTipSet)
				SetToolTip(null);
			foreach (AbstractMargin margin in leftMargins) {
				if (margin.DrawingPosition.Contains(e.X, e.Y)) {
					this.Cursor = margin.Cursor;
					margin.HandleMouseMove(new Point(e.X, e.Y), e.Button);
					if (lastMouseInMargin != margin) {
						if (lastMouseInMargin != null) {
							lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
						}
						lastMouseInMargin = margin;
					}
					return;
				}
			}
			if (lastMouseInMargin != null) {
				lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
				lastMouseInMargin = null;
			}
			if (textView.DrawingPosition.Contains(e.X, e.Y)) {
				this.Cursor = textView.Cursor;
				return;
			}
			this.Cursor = Cursors.Default;
		}
Example #14
0
		protected override void OnMouseLeave(System.EventArgs e)
		{
			base.OnMouseLeave(e);
			this.Cursor = Cursors.Default;
			if (lastMouseInMargin != null) {
				lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
				lastMouseInMargin = null;
			}
		}
Example #15
0
 public void InsertLeftMargin(int index, AbstractMargin margin)
 {
     leftMargins.Insert(index, margin);
     Refresh();
 }
Example #16
0
 public static void IconBarMouseDown(AbstractMargin iconBar, Point mousepos, MouseButtons mouseButtons)
 {
     try
     {
         if (mouseButtons != MouseButtons.Left)
         {
         	if (mouseButtons == MouseButtons.Right)
         	{
         		iconBar.TextArea.MotherTextEditorControl.ContextMenuStrip = null;
         		Rectangle viewRect = iconBar.TextArea.TextView.DrawingPosition;
         		ICSharpCode.TextEditor.TextLocation logicPos = iconBar.TextArea.TextView.GetLogicalPosition(0, mousepos.Y - viewRect.Top);
         		if (logicPos.Y >= 0 && logicPos.Y < iconBar.TextArea.Document.TotalNumberOfLines)
         		{
         			cur_bookmark = IsOnBreakpoint(iconBar.TextArea.Document,logicPos.Y);
         			if (cur_bookmark != null)
         			{
         				iconBar.TextArea.MotherTextEditorControl.ContextMenuStrip = VisualPABCSingleton.MainForm.BreakpointMenuStrip;
         			}
         		}
         	}
         	return;
         }
         else
         {
         	Rectangle viewRect = iconBar.TextArea.TextView.DrawingPosition;
         	//Point logicPos = iconBar.TextArea.TextView.GetLogicalPosition(0, mousepos.Y - viewRect.Top);
         	ICSharpCode.TextEditor.TextLocation logicPos = iconBar.TextArea.TextView.GetLogicalPosition(0, mousepos.Y - viewRect.Top);
         	if (logicPos.Y >= 0 && logicPos.Y < iconBar.TextArea.Document.TotalNumberOfLines)
         	{
             	string s = iconBar.TextArea.MotherTextEditorControl.FileName;
             	if (s == null) s = TextAreaHelper.GetFileNameByTextArea(iconBar.TextArea);
             	ToggleBreakpointAt(iconBar.TextArea.Document, s, logicPos.Y);
            	 	iconBar.TextArea.Refresh(iconBar);
        	 	}
         }
     }
     catch (System.Exception e)
     {
     }
 }
Example #17
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (!toolTipRectangle.Contains(e.Location)) {
         toolTipRectangle = Rectangle.Empty;
         if (toolTipActive)
             RequestToolTip(e.Location);
     }
     foreach (AbstractMargin margin in leftMargins) {
         if (margin.DrawingPosition.Contains(e.X, e.Y)) {
             this.Cursor = margin.Cursor;
             margin.HandleMouseMove(new Point(e.X, e.Y), e.Button);
             if (lastMouseInMargin != margin) {
                 if (lastMouseInMargin != null) {
                     lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
                 }
                 lastMouseInMargin = margin;
             }
             return;
         }
     }
     if (lastMouseInMargin != null) {
         lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
         lastMouseInMargin = null;
     }
     if (textView.DrawingPosition.Contains(e.X, e.Y)) {
         TextLocation realmousepos = TextView.GetLogicalPosition(e.X - TextView.DrawingPosition.X, e.Y - TextView.DrawingPosition.Y);
         if(SelectionManager.IsSelected(Document.PositionToOffset(realmousepos)) && MouseButtons == MouseButtons.None) {
             // mouse is hovering over a selection, so show default mouse
             this.Cursor = Cursors.Default;
         } else {
             // mouse is hovering over text area, not a selection, so show the textView cursor
             this.Cursor = textView.Cursor;
         }
         return;
     }
     this.Cursor = Cursors.Default;
 }
Example #18
0
 public void InsertLeftMargin(int index, AbstractMargin margin)
 {
     leftMargins.Insert(index, margin);
     Refresh();
 }
		static void IconBarMouseDown(AbstractMargin iconBar, Point mousepos, MouseButtons mouseButtons)
		{
			if (mouseButtons != MouseButtons.Left) return;
			Rectangle viewRect = iconBar.TextArea.TextView.DrawingPosition;
			TextLocation logicPos = iconBar.TextArea.TextView.GetLogicalPosition(0, mousepos.Y - viewRect.Top);
			
			if (logicPos.Y >= 0 && logicPos.Y < iconBar.TextArea.Document.TotalNumberOfLines) {
				ToggleBreakpointAt(iconBar.TextArea.Document, iconBar.TextArea.MotherTextEditorControl.FileName, logicPos.Y);
				iconBar.TextArea.Refresh(iconBar);
			}
		}
Example #20
0
 public static void IconBarMouseDown(AbstractMargin iconBar, Point mousepos, MouseButtons mouseButtons)
 {
     try
     {
         if (mouseButtons != MouseButtons.Left) return;
         Rectangle viewRect = iconBar.TextArea.TextView.DrawingPosition;
         //Point logicPos = iconBar.TextArea.TextView.GetLogicalPosition(0, mousepos.Y - viewRect.Top);
         ICSharpCode.TextEditor.TextLocation logicPos = iconBar.TextArea.TextView.GetLogicalPosition(0, mousepos.Y - viewRect.Top);
         if (logicPos.Y >= 0 && logicPos.Y < iconBar.TextArea.Document.TotalNumberOfLines)
         {
             string s = iconBar.TextArea.MotherTextEditorControl.FileName;
             if (s == null) s = TextAreaHelper.GetFileNameByTextArea(iconBar.TextArea);
             ToggleBreakpointAt(iconBar.TextArea.Document, s, logicPos.Y);
             iconBar.TextArea.Refresh(iconBar);
         }
     }
     catch (System.Exception e)
     {
     }
 }
Example #21
0
		protected override void OnMouseMove(MouseEventArgs e)
		{
			base.OnMouseMove(e);
			if (!toolTipRectangle.Contains(e.Location)) {
				toolTipRectangle = Rectangle.Empty;
				if (toolTipActive)
					RequestToolTip(e.Location);
			}
			foreach (AbstractMargin margin in leftMargins) {
				if (margin.DrawingPosition.Contains(e.X, e.Y)) {
					this.Cursor = margin.Cursor;
					margin.HandleMouseMove(new Point(e.X, e.Y), e.Button);
					if (lastMouseInMargin != margin) {
						if (lastMouseInMargin != null) {
							lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
						}
						lastMouseInMargin = margin;
					}
					return;
				}
			}
			if (lastMouseInMargin != null) {
				lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
				lastMouseInMargin = null;
			}
			if (textView.DrawingPosition.Contains(e.X, e.Y)) {
				this.Cursor = textView.Cursor;
				return;
			}
			this.Cursor = Cursors.Default;
		}
 public void IconBarMargin_MouseDown(AbstractMargin sender, Point mousepos, MouseButtons mouseButtons)
 {
     /*    IconBarMargin margin = (IconBarMargin)sender;
         Graphics g = margin.TextArea.CreateGraphics();
         //g.Clear(Color.Red);
         //g.DrawString("B", new Font("Arial", 16), new SolidBrush(Color.Black), 0, mousepos.Y);
         //margin.DrawBookmark(g, mousepos.Y, true);
         margin.DrawBreakpoint(g, mousepos.Y, true,true);
     */
     //tecSourceCode.Document.BookmarkManager.AddMark(bookmark);
 }