Inheritance: System.IDisposable
Exemple #1
0
        public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl)
        {
            this.motherTextAreaControl   = motherTextAreaControl;
            this.motherTextEditorControl = motherTextEditorControl;

            caret            = new Caret(this);
            selectionManager = new SelectionManager(Document, this);

            this.textAreaClipboardHandler = new TextAreaClipboardHandler(this);

            ResizeRedraw = true;

            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
//			SetStyle(ControlStyles.AllPaintingInWmPaint, true);
//			SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.Opaque, false);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.Selectable, true);

            textView = new TextView(this);

            gutterMargin  = new GutterMargin(this);
            foldMargin    = new FoldMargin(this);
            iconBarMargin = new IconBarMargin(this);
            leftMargins.AddRange(new AbstractMargin[] { iconBarMargin, gutterMargin, foldMargin });
            OptionsChanged();


            new TextAreaMouseHandler(this).Attach();
            new TextAreaDragDropHandler().Attach(this);

            bracketshemes.Add(new BracketHighlightingSheme('{', '}'));
            bracketshemes.Add(new BracketHighlightingSheme('(', ')'));
            bracketshemes.Add(new BracketHighlightingSheme('[', ']'));

            caret.PositionChanged                   += new EventHandler(SearchMatchingBracket);
            Document.TextContentChanged             += new EventHandler(TextContentChanged);
            Document.FoldingManager.FoldingsChanged += new EventHandler(DocumentFoldingsChanged);
        }
Exemple #2
0
        public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl)
        {
            MotherTextAreaControl   = motherTextAreaControl;
            MotherTextEditorControl = motherTextEditorControl;

            Caret            = new Caret(this);
            SelectionManager = new SelectionManager(Document, this);
            MousePos         = new Point(0, 0);

            ResizeRedraw = true;

            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            //			SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            //			SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.Opaque, false);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.Selectable, true);

            TextView = new TextView(this);

            GutterMargin  = new GutterMargin(this);
            FoldMargin    = new FoldMargin(this);
            IconBarMargin = new IconBarMargin(this);
            _leftMargins.AddRange(new IMargin[] { IconBarMargin, GutterMargin, FoldMargin });
            OptionsChanged();


            new TextAreaMouseHandler(this).Attach(); //TODO1 refactor all these
            new TextAreaDragDropHandler().Attach(this);

            _bracketSchemes.Add(new BracketHighlightingSheme('{', '}')); //TODO1 hardcoded
            _bracketSchemes.Add(new BracketHighlightingSheme('(', ')'));
            _bracketSchemes.Add(new BracketHighlightingSheme('[', ']'));

            Caret.PositionChanged                   += new EventHandler(SearchMatchingBracket);
            Document.TextContentChanged             += TextContentChanged;
            Document.FoldingManager.FoldingsChanged += new EventHandler(DocumentFoldingsChanged);
        }
Exemple #3
0
        /// <summary>
        /// This method executes a dialog key
        /// </summary>
        public bool ExecuteDialogKey(Keys keyData)
        {
            // try, if a dialog key processor was set to use this
            if (DoProcessDialogKey != null && DoProcessDialogKey(keyData))
            {
                return(true);
            }

            // if not (or the process was 'silent', use the standard edit actions
            IEditAction action = _motherTextEditorControl.GetEditAction(keyData);

            AutoClearSelection = true;
            if (action != null)
            {
                BeginUpdate();
                try
                {
                    lock (Document)
                    {
                        action.Execute(this);
                        if (SelectionManager.HasSomethingSelected && AutoClearSelection /*&& caretchanged*/)
                        {
                            if (Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal)
                            {
                                SelectionManager.ClearSelection();
                            }
                        }
                    }
                }
                finally
                {
                    EndUpdate();
                    Caret.UpdateCaretPosition();
                }
                return(true);
            }
            return(false);
        }
        public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl)
        {
            MotherTextAreaControl   = motherTextAreaControl;
            MotherTextEditorControl = motherTextEditorControl;

            Caret            = new Caret(this);
            SelectionManager = new SelectionManager(Document, this);

            ClipboardHandler = new TextAreaClipboardHandler(this);

            ResizeRedraw = true;

            SetStyle(ControlStyles.OptimizedDoubleBuffer, value: true);
//            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
//            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.Opaque, value: false);
            SetStyle(ControlStyles.ResizeRedraw, value: true);
            SetStyle(ControlStyles.Selectable, value: true);

            TextView = new TextView(this);

            GutterMargin  = new GutterMargin(this);
            FoldMargin    = new FoldMargin(this);
            IconBarMargin = new IconBarMargin(this);
            leftMargins.AddRange(new AbstractMargin[] { IconBarMargin, GutterMargin, FoldMargin });
            OptionsChanged();

            new TextAreaMouseHandler(this).Attach();
            new TextAreaDragDropHandler().Attach(this);

            bracketshemes.Add(new BracketHighlightingSheme(opentag: '{', closingtag: '}'));
            bracketshemes.Add(new BracketHighlightingSheme(opentag: '(', closingtag: ')'));
            bracketshemes.Add(new BracketHighlightingSheme(opentag: '[', closingtag: ']'));

            Caret.PositionChanged                   += SearchMatchingBracket;
            Document.TextContentChanged             += TextContentChanged;
            Document.FoldingManager.FoldingsChanged += DocumentFoldingsChanged;
        }
Exemple #5
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                if (!_disposed)
                {
                    _disposed = true;
                    if (Caret != null)
                    {
                        Caret.PositionChanged -= new EventHandler(SearchMatchingBracket);
                        Caret.Dispose();
                    }

                    if (SelectionManager != null)
                    {
                        SelectionManager.Dispose();
                    }

                    Document.TextContentChanged             -= TextContentChanged;
                    Document.FoldingManager.FoldingsChanged -= DocumentFoldingsChanged;
                    MotherTextAreaControl   = null;
                    MotherTextEditorControl = null;

                    foreach (IMargin margin in _leftMargins)
                    {
                        if (margin is IDisposable)
                        {
                            (margin as IDisposable).Dispose();
                        }
                    }

                    TextView.Dispose();
                }
            }
        }
Exemple #6
0
        public void ShowFor(TextEditorControl editor, bool replaceMode)
        {
            Editor = editor;

            _search.ClearScanRegion();
            var sm = editor.ActiveTextAreaControl.SelectionManager;

            if (sm.HasSomethingSelected && sm.SelectionCollection.Count == 1)
            {
                var sel = sm.SelectionCollection[0];
                if (sel.StartPosition.Line == sel.EndPosition.Line)
                {
                    txtLookFor.Text = sm.SelectedText;
                }
                else
                {
                    _search.SetScanRegion(sel);
                }
            }
            else
            {
                // Get the current word that the caret is on
                Caret caret = editor.ActiveTextAreaControl.Caret;
                int   start = TextUtilities.FindWordStart(editor.Document, caret.Offset);
                int   endAt = TextUtilities.FindWordEnd(editor.Document, caret.Offset);
                txtLookFor.Text = editor.Document.GetText(start, endAt - start);
            }

            ReplaceMode = replaceMode;

            this.Owner = (Form)editor.TopLevelControl;
            this.Show();

            txtLookFor.SelectAll();
            txtLookFor.Focus();
        }
		public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl)
		{
			this.motherTextAreaControl      = motherTextAreaControl;
			this.motherTextEditorControl    = motherTextEditorControl;
			
			caret            = new Caret(this);
			selectionManager = new SelectionManager(Document);
			
			this.textAreaClipboardHandler = new TextAreaClipboardHandler(this);
			
			ResizeRedraw = true;
			
			SetStyle(ControlStyles.DoubleBuffer, false);
//			SetStyle(ControlStyles.AllPaintingInWmPaint, true);
//			SetStyle(ControlStyles.UserPaint, true);
			SetStyle(ControlStyles.Opaque, false);
			SetStyle(ControlStyles.ResizeRedraw, true);
			SetStyle(ControlStyles.Selectable, true);
			
			textView = new TextView(this);
			
			gutterMargin = new GutterMargin(this);
			foldMargin   = new FoldMargin(this);
			iconBarMargin = new IconBarMargin(this);
			leftMargins.AddRange(new AbstractMargin[] { iconBarMargin, gutterMargin, foldMargin });
			OptionsChanged();
			
			
			new TextAreaMouseHandler(this).Attach();
			new TextAreaDragDropHandler().Attach(this);
			
			bracketshemes.Add(new BracketHighlightingSheme('{', '}'));
			bracketshemes.Add(new BracketHighlightingSheme('(', ')'));
			bracketshemes.Add(new BracketHighlightingSheme('[', ']'));
			
			caret.PositionChanged += new EventHandler(SearchMatchingBracket);
			Document.TextContentChanged += new EventHandler(TextContentChanged);
			Document.FoldingManager.FoldingsChanged += new EventHandler(DocumentFoldingsChanged);
		}
Exemple #8
0
 public Win32Caret(Caret caret)
 {
     this.textArea = caret.textArea;
 }
Exemple #9
0
 void DocumentFoldingsChanged(object sender, EventArgs e)
 {
     Caret.UpdateCaretPosition();
     Invalidate();
     this.motherTextAreaControl.AdjustScrollBars();
 }
Exemple #10
0
			public Win32Caret(Caret caret)
			{
				this.textArea = caret.textArea;
			}
Exemple #11
0
			public ManagedCaret(Caret caret)
			{
				base.RequireRedrawOnPositionChange = true;
				this.textArea = caret.textArea;
				this.parentCaret = caret;
				timer.Tick += CaretTimerTick;
			}
        /// <summary>
        /// This method executes a dialog key
        /// </summary>
        public bool ExecuteDialogKey(Keys keyData)
        {
            // try, if a dialog key processor was set to use this
            if (DoProcessDialogKey != null && DoProcessDialogKey(keyData))
            {
                return(true);
            }

            if (keyData == Keys.Back || keyData == Keys.Delete || keyData == Keys.Enter)
            {
                if (TextEditorProperties.UseCustomLine == true)
                {
                    if (SelectionManager.HasSomethingSelected)
                    {
                        if (Document.CustomLineManager.IsReadOnly(SelectionManager.SelectionCollection[0], false))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        int curLineNr = Document.GetLineNumberForOffset(Caret.Offset);
                        if (Document.CustomLineManager.IsReadOnly(curLineNr, false) == true)
                        {
                            return(true);
                        }
                        if ((Caret.Column == 0) && (curLineNr - 1 >= 0) && keyData == Keys.Back &&
                            Document.CustomLineManager.IsReadOnly(curLineNr - 1, false) == true)
                        {
                            return(true);
                        }
                        if (keyData == Keys.Delete)
                        {
                            LineSegment curLine = Document.GetLineSegment(curLineNr);
                            if (curLine.Offset + curLine.Length == Caret.Offset &&
                                Document.CustomLineManager.IsReadOnly(curLineNr + 1, false) == true)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            // if not (or the process was 'silent', use the standard edit actions
            IEditAction action = motherTextEditorControl.GetEditAction(keyData);

            AutoClearSelection = true;
            if (action != null)
            {
                motherTextEditorControl.BeginUpdate();
                try {
                    lock (Document) {
                        action.Execute(this);
                        if (SelectionManager.HasSomethingSelected && AutoClearSelection /*&& caretchanged*/)
                        {
                            if (Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal)
                            {
                                SelectionManager.ClearSelection();
                            }
                        }
                    }
                } finally {
                    motherTextEditorControl.EndUpdate();
                    Caret.UpdateCaretPosition();
                }
                return(true);
            }
            return(false);
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            int       currentXPos      = 0;
            int       currentYPos      = 0;
            bool      adjustScrollBars = false;
            Graphics  g             = e.Graphics;
            Rectangle clipRectangle = e.ClipRectangle;


            if (updateMargin != null)
            {
                updateMargin.Paint(g, updateMargin.DrawingPosition);
//				clipRectangle.Intersect(updateMargin.DrawingPosition);
            }

            if (clipRectangle.Width <= 0 || clipRectangle.Height <= 0)
            {
                return;
            }

            if (this.TextEditorProperties.UseAntiAliasedFont)
            {
                g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            }
            else
            {
                g.TextRenderingHint = TextRenderingHint.SystemDefault;
            }

            foreach (AbstractMargin margin in leftMargins)
            {
                if (margin.IsVisible)
                {
                    Rectangle marginRectangle = new Rectangle(currentXPos, currentYPos, margin.Size.Width, Height - currentYPos);
                    if (marginRectangle != margin.DrawingPosition)
                    {
                        adjustScrollBars       = true;
                        margin.DrawingPosition = marginRectangle;
                    }
                    currentXPos += margin.DrawingPosition.Width;
                    if (clipRectangle.IntersectsWith(marginRectangle))
                    {
                        marginRectangle.Intersect(clipRectangle);
                        if (!marginRectangle.IsEmpty)
                        {
                            margin.Paint(g, marginRectangle);
                        }
                    }
                }
            }

            Rectangle textViewArea = new Rectangle(currentXPos, currentYPos, Width - currentXPos, Height - currentYPos);

            if (textViewArea != textView.DrawingPosition)
            {
                adjustScrollBars         = true;
                textView.DrawingPosition = textViewArea;
            }
            if (clipRectangle.IntersectsWith(textViewArea))
            {
                textViewArea.Intersect(clipRectangle);
                if (!textViewArea.IsEmpty)
                {
                    textView.Paint(g, textViewArea);
                }
            }

            if (adjustScrollBars)
            {
                this.motherTextAreaControl.AdjustScrollBars(null, null);
            }

            Caret.UpdateCaretPosition();

            base.OnPaint(e);
        }
        void caretMoved(Caret caret)
        {
            // same code as the one in "public static INode iNode(this O2MappedAstData o2MappedAstData, string file, Caret caret)" in O2MappedAstData_ExtensionMethods.cs (O2 Script)
            var o2MappedAstData = compiledFileAstData;
            var file = sPathToFileLoaded;

            if (o2MappedAstData != null && file != null && caret != null)
            {
                if (o2MappedAstData.FileToINodes.hasKey(file))
                {
                    var allINodes = o2MappedAstData.FileToINodes[file];
                    var adjustedLine = caret.Line + 1;
                    var adjustedColumn = caret.Column + 1;
                    CurrentINode = allINodes.getINodeAt(adjustedLine, adjustedColumn);
                    if (CurrentINode != null)                    
                        lbCurrentAstNode.set_Text("Current Ast Node: {0}".format(CurrentINode.typeName()));                                                                    
                }
                
            }
            if (compiledFileAstData.notNull())
            {
                //var iNode = compiledFileAstData.iNode(sPathToFileLoaded, caret);
				//if (iNode != null)	
				//{					
					//CurrentINode = iNode;
					//lbCurrentAstNode.set_Text("Current Ast Node: {0}".format(iNode.typeName()))
                //}
            }
        }
Exemple #15
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            int       currentXPos      = 0;
            int       currentYPos      = 0;
            bool      adjustScrollBars = false;
            Graphics  g             = e.Graphics;
            Rectangle clipRectangle = e.ClipRectangle;

            bool isFullRepaint = clipRectangle.X == 0 && clipRectangle.Y == 0 &&
                                 clipRectangle.Width == this.Width && clipRectangle.Height == this.Height;

            g.TextRenderingHint = this.TextEditorProperties.TextRenderingHint;

            if (updateMargin != null)
            {
                updateMargin.Paint(g, updateMargin.DrawingPosition);
//				clipRectangle.Intersect(updateMargin.DrawingPosition);
            }

            if (clipRectangle.Width <= 0 || clipRectangle.Height <= 0)
            {
                return;
            }

            foreach (AbstractMargin margin in leftMargins)
            {
                if (margin.IsVisible)
                {
                    Rectangle marginRectangle = new Rectangle(currentXPos, currentYPos, margin.Size.Width, Height - currentYPos);
                    if (marginRectangle != margin.DrawingPosition)
                    {
                        // margin changed size
                        if (!isFullRepaint && !clipRectangle.Contains(marginRectangle))
                        {
                            Invalidate();                             // do a full repaint
                        }
                        adjustScrollBars       = true;
                        margin.DrawingPosition = marginRectangle;
                    }
                    currentXPos += margin.DrawingPosition.Width;
                    if (clipRectangle.IntersectsWith(marginRectangle))
                    {
                        marginRectangle.Intersect(clipRectangle);
                        if (!marginRectangle.IsEmpty)
                        {
                            margin.Paint(g, marginRectangle);
                        }
                    }
                }
            }

            Rectangle textViewArea = new Rectangle(currentXPos, currentYPos, Width - currentXPos, Height - currentYPos);

            if (textViewArea != textView.DrawingPosition)
            {
                adjustScrollBars         = true;
                textView.DrawingPosition = textViewArea;
            }
            if (clipRectangle.IntersectsWith(textViewArea))
            {
                textViewArea.Intersect(clipRectangle);
                if (!textViewArea.IsEmpty)
                {
                    textView.Paint(g, textViewArea);
                }
            }

            if (adjustScrollBars)
            {
                this.motherTextAreaControl.AdjustScrollBars();
            }

            Caret.UpdateCaretPosition();

            base.OnPaint(e);
        }