Inheritance: System.Windows.Forms.Control
        public TextAreaControl(TextEditorControl motherTextEditorControl)
        {
            this.motherTextEditorControl = motherTextEditorControl;

            this.textArea                = new TextArea(motherTextEditorControl, this);
            Controls.Add(textArea);

            vScrollBar.ValueChanged += new EventHandler(VScrollBarValueChanged);
            Controls.Add(this.vScrollBar);

            hScrollBar.ValueChanged += new EventHandler(HScrollBarValueChanged);
            Controls.Add(this.hScrollBar);
            ResizeRedraw = true;

            Document.TextContentChanged += DocumentTextContentChanged;
            Document.DocumentChanged += AdjustScrollBarsOnDocumentChange;
            Document.UpdateCommited  += DocumentUpdateCommitted;

            vScrollBar.VisibleChanged += (sender, e) =>
            {
                if (!vScrollBar.Visible)
                    vScrollBar.Value = 0;
            };

            hScrollBar.VisibleChanged += (sender, e) =>
            {
                if (!hScrollBar.Visible)
                    hScrollBar.Value = 0;
            };
        }
 /// <summary>
 /// Called when entry should be inserted. Forward to the insertion action of the completion data.
 /// </summary>
 public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
 {
     textArea.SelectionManager.SetSelection(textArea.Document.OffsetToPosition(
         Math.Min(insertionOffset - ((AEGISCompletionData)data).Expression.Length, textArea.Document.TextLength)
         ), textArea.Caret.Position);
     return data.InsertAction(textArea, key);
 }
        public ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
        {
            // We can return code-completion items like this:

            //			return new ICompletionData[] {
            //				new DefaultCompletionData("Text", "Description", 1)
            //			};

            NRefactoryResolver resolver = new NRefactoryResolver(mainForm.myProjectContent);
            Dom.ResolveResult rr = resolver.Resolve(FindExpression(textArea),
                                                    textArea.Caret.Line,
                                                    textArea.Caret.Column,
                                                    fileName,
                                                    textArea.MotherTextEditorControl.Text);
            List<ICompletionData> resultList = new List<ICompletionData>();
            if (rr != null) {
                ArrayList completionData = rr.GetCompletionData(mainForm.myProjectContent);
                if (completionData != null) {
                    AddCompletionData(resultList, completionData);
                }
            }

            //textArea.MotherTextEditorControl.Text = backup;

            return resultList.ToArray();
        }
Ejemplo n.º 4
0
        public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            textArea.Caret.Position = textArea.Document.OffsetToPosition(
                Math.Min(insertionOffset, textArea.Document.TextLength));

            return data.InsertAction(textArea, key);
        }
		/// <summary>
		/// This function sets the indentlevel in a range of lines.
		/// </summary>
		public override void IndentLines(TextArea textArea, int begin, int end)
		{
			if (textArea.Document.TextEditorProperties.IndentStyle != IndentStyle.Smart) {
				base.IndentLines(textArea, begin, end);
				return;
			}
			int cursorPos = textArea.Caret.Position.Y;
			int oldIndentLength = 0;
			
			if (cursorPos >= begin && cursorPos <= end)
				oldIndentLength = GetIndentation(textArea, cursorPos).Length;
			
			IndentationSettings set = new IndentationSettings();
			set.IndentString = Tab.GetIndentationString(textArea.Document);
			IndentationReformatter r = new IndentationReformatter();
			DocumentAccessor acc = new DocumentAccessor(textArea.Document, begin, end);
			r.Reformat(acc, set);
			
			if (cursorPos >= begin && cursorPos <= end) {
				int newIndentLength = GetIndentation(textArea, cursorPos).Length;
				if (oldIndentLength != newIndentLength) {
					// fix cursor position if indentation was changed
					int newX = textArea.Caret.Position.X - oldIndentLength + newIndentLength;
					textArea.Caret.Position = new TextLocation(Math.Max(newX, 0), cursorPos);
				}
			}
		}
Ejemplo n.º 6
0
        public override void Execute(TextArea textArea)
        {
            try
            {
                int num_line = 0;

                string var = null;
                if (!textArea.SelectionManager.HasSomethingSelected)
                    var = WorkbenchServiceFactory.DebuggerManager.GetVariable(textArea, out num_line);
                else
                {
                    var = textArea.SelectionManager.SelectedText;
                    //num_line = textArea.SelectionManager.SelectionStart.Line;
                }
                if (var == null || var == "")
                {
                    WorkbenchServiceFactory.DebuggerOperationsService.GotoWatch();
                    return;
                    //VisualPABCSingleton.MainForm.SetCursorInWatch();
                }
                ValueItem vi = WorkbenchServiceFactory.DebuggerManager.FindVarByName(var, num_line) as ValueItem;
                if (vi != null)
                {
                    VisualPABCSingleton.MainForm.AddVariable(vi);
                }
                else
                {
                    WorkbenchServiceFactory.DebuggerOperationsService.AddVariable(var, true);
                }
            }
            catch (System.Exception e)
            {
                WorkbenchServiceFactory.DebuggerOperationsService.GotoWatch();
            }
        }
 private void templateEditor_KeyUp(object sender, KeyEventArgs e)
 {
     ICSharpCode.TextEditor.TextArea textArea = (ICSharpCode.TextEditor.TextArea)sender;
     template.TemplateText = textArea.Document.TextContent;
     doc.Data    = template.Output;
     doc.Changed = true;
 }
Ejemplo n.º 8
0
		public virtual void GenerateCode(TextArea textArea, IList items)
		{
			List<AbstractNode> nodes = new List<AbstractNode>();
			GenerateCode(nodes, items);
			codeGen.InsertCodeInClass(currentClass, new TextEditorDocument(textArea.Document), textArea.Caret.Line, nodes.ToArray());
			ParserService.ParseCurrentViewContent();
		}
		void AddTemplates(TextArea textArea, char charTyped)
		{
			if (!ShowTemplates)
				return;
			ICompletionData suggestedData = DefaultIndex >= 0 ? completionData[DefaultIndex] : null;
			ICompletionData[] templateCompletionData = new TemplateCompletionDataProvider().GenerateCompletionData(fileName, textArea, charTyped);
			if (templateCompletionData == null || templateCompletionData.Length == 0)
				return;
			for (int i = 0; i < completionData.Count; i++) {
				if (completionData[i].ImageIndex == ClassBrowserIconService.KeywordIndex) {
					string text = completionData[i].Text;
					for (int j = 0; j < templateCompletionData.Length; j++) {
						if (templateCompletionData[j] != null && templateCompletionData[j].Text == text) {
							// replace keyword with template
							completionData[i] = templateCompletionData[j];
							templateCompletionData[j] = null;
						}
					}
				}
			}
			// add non-keyword code templates
			for (int j = 0; j < templateCompletionData.Length; j++) {
				if (templateCompletionData[j] != null)
					completionData.Add(templateCompletionData[j]);
			}
			if (suggestedData != null) {
				completionData.Sort(DefaultCompletionData.Compare);
				DefaultIndex = completionData.IndexOf(suggestedData);
			}
		}
        public void Validate(String doc,TextArea textArea)
        {
            this.textArea = textArea;
            textArea.Document.MarkerStrategy.RemoveAll(p => true);
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.CloseInput = true;
            settings.ValidationEventHandler += new ValidationEventHandler(settings_ValidationEventHandler);  // Your callback...
            settings.ValidationType = ValidationType.Schema;
            settings.Schemas.Add(schemaset);
            settings.ValidationFlags =
              XmlSchemaValidationFlags.ReportValidationWarnings |
              XmlSchemaValidationFlags.ProcessIdentityConstraints |
              XmlSchemaValidationFlags.ProcessInlineSchema |
              XmlSchemaValidationFlags.ProcessSchemaLocation;

            // Wrap document in an XmlNodeReader and run validation on top of that
            try
            {
                using (XmlReader validatingReader = XmlReader.Create(new StringReader(doc), settings))
                {
                    while (validatingReader.Read()) { /* just loop through document */ }
                }
            }
            catch (XmlException e)
            {
                var offset = textArea.Document.PositionToOffset(new TextLocation(e.LinePosition, e.LineNumber));

                var mk = new TextMarker(offset, 5, TextMarkerType.WaveLine,  Color.DarkBlue );
                mk.ToolTip = e.Message;
                textArea.Document.MarkerStrategy.AddMarker(mk);
            }
        }
		public override void Execute(TextArea services)
		{
			XmlEditorControl editor = services.MotherTextEditorControl as XmlEditorControl;
			if (editor != null) {
				editor.ShowCompletionWindow();			
			}
		}
Ejemplo n.º 12
0
        void OnToolTipRequest(object sender, TextEditor.ToolTipRequestEventArgs e)
        {
            if (e.InDocument && !e.ToolTipShown)
            {
                IExpressionFinder expressionFinder;
                if (MainForm.IsVisualBasic)
                {
                    expressionFinder = new VBExpressionFinder();
                }
                else
                {
                    expressionFinder = new CSharpExpressionFinder(mainForm.parseInformation);
                }
                ExpressionResult expression = expressionFinder.FindFullExpression(
                    editor.Text,
                    editor.Document.PositionToOffset(e.LogicalPosition));
                if (expression.Region.IsEmpty)
                {
                    expression.Region = new DomRegion(e.LogicalPosition.Line + 1, e.LogicalPosition.Column + 1);
                }

                TextEditor.TextArea textArea = editor.ActiveTextAreaControl.TextArea;
                NRefactoryResolver  resolver = new NRefactoryResolver(mainForm.myProjectContent.Language);
                ResolveResult       rr       = resolver.Resolve(expression,
                                                                mainForm.parseInformation,
                                                                textArea.MotherTextEditorControl.Text);
                string toolTipText = GetText(rr);
                if (toolTipText != null)
                {
                    e.ShowToolTip(toolTipText);
                }
            }
        }
Ejemplo n.º 13
0
 public GutterMargin(TextArea textArea)
     : base(textArea)
 {
     numberStringFormat.LineAlignment = StringAlignment.Far;
     numberStringFormat.FormatFlags   = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.FitBlackBox |
         StringFormatFlags.NoWrap | StringFormatFlags.NoClip;
 }
		public void SetupDataProvider(string fileName, TextArea textArea)
		{
			if (setupOnlyOnce && this.textArea != null) return;
			IDocument document = textArea.Document;
			this.fileName = fileName;
			this.document = document;
			this.textArea = textArea;
			int useOffset = (lookupOffset < 0) ? textArea.Caret.Offset : lookupOffset;
			initialOffset = useOffset;
			
			
			IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(fileName);
			ExpressionResult expressionResult;
			if (expressionFinder == null)
				expressionResult = new ExpressionResult(TextUtilities.GetExpressionBeforeOffset(textArea, useOffset));
			else
				expressionResult = expressionFinder.FindExpression(textArea.Document.TextContent, useOffset);
			
			if (expressionResult.Expression == null) // expression is null when cursor is in string/comment
				return;
			expressionResult.Expression = expressionResult.Expression.Trim();
			
			if (LoggingService.IsDebugEnabled) {
				if (expressionResult.Context == ExpressionContext.Default)
					LoggingService.DebugFormatted("ShowInsight for >>{0}<<", expressionResult.Expression);
				else
					LoggingService.DebugFormatted("ShowInsight for >>{0}<<, context={1}", expressionResult.Expression, expressionResult.Context);
			}
			
			int caretLineNumber = document.GetLineNumberForOffset(useOffset);
			int caretColumn     = useOffset - document.GetLineSegment(caretLineNumber).Offset;
			// the parser works with 1 based coordinates
			SetupDataProvider(fileName, document, expressionResult, caretLineNumber + 1, caretColumn + 1);
		}
		/// <summary>
		/// Define CSharp specific smart indenting for a line :)
		/// </summary>
		protected override int SmartIndentLine(TextArea textArea, int lineNr)
		{
			if (lineNr <= 0) {
				return AutoIndentLine(textArea, lineNr);
			}
			
			string oldText = textArea.Document.GetText(textArea.Document.GetLineSegment(lineNr));
			
			DocumentAccessor acc = new DocumentAccessor(textArea.Document, lineNr, lineNr);
			
			IndentationSettings set = new IndentationSettings();
			set.IndentString = Tab.GetIndentationString(textArea.Document);
			set.LeaveEmptyLines = false;
			IndentationReformatter r = new IndentationReformatter();
			
			r.Reformat(acc, set);
			
			string t = acc.Text;
			if (t.Length == 0) {
				// use AutoIndentation for new lines in comments / verbatim strings.
				return AutoIndentLine(textArea, lineNr);
			} else {
				int newIndentLength = t.Length - t.TrimStart().Length;
				int oldIndentLength = oldText.Length - oldText.TrimStart().Length;
				if (oldIndentLength != newIndentLength && lineNr == textArea.Caret.Position.Y) {
					// fix cursor position if indentation was changed
					int newX = textArea.Caret.Position.X - oldIndentLength + newIndentLength;
					textArea.Caret.Position = new TextLocation(Math.Max(newX, 0), lineNr);
				}
				return newIndentLength;
			}
		}
		/// <summary>
		/// Indents the specified line based on the current depth of the XML hierarchy.
		/// </summary>
		/// <param name="p_txaTextArea">The text area containing the line to indent.</param>
		/// <param name="p_intLineNumber">The line number of the line to indent.</param>
		/// <returns>The indent depth of the specified line.</returns>
		protected override int AutoIndentLine(TextArea p_txaTextArea, int p_intLineNumber)
		{
			XmlParser.TagStack stkTags = XmlParser.ParseTags(p_txaTextArea.Document, p_intLineNumber, null, null);
			Int32 intDepth = 0;
			Int32 intLastLineNum = -1;
			while (stkTags.Count > 0)
			{
				if (stkTags.Peek().LineNumber != intLastLineNum)
				{
					intLastLineNum = stkTags.Peek().LineNumber;
					intDepth++;
				}
				stkTags.Pop();
			}

			StringBuilder stbLineWithIndent = new StringBuilder();
			for (Int32 i = 0; i < intDepth; i++)
				stbLineWithIndent.Append("\t");
			stbLineWithIndent.Append(TextUtilities.GetLineAsString(p_txaTextArea.Document, p_intLineNumber).Trim());
			LineSegment oldLine = p_txaTextArea.Document.GetLineSegment(p_intLineNumber);
			Int32 intCaretOffset = stbLineWithIndent.Length - oldLine.Length;
			SmartReplaceLine(p_txaTextArea.Document, oldLine, stbLineWithIndent.ToString());
			p_txaTextArea.Caret.Column += intCaretOffset;

			return intDepth;
		}
Ejemplo n.º 17
0
        void OnTextEditorKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.F9)
            {
                return;
            }

            ICSharpCode.TextEditor.TextArea area_obj = (ICSharpCode.TextEditor.TextArea)sender;

            ICSharpCode.TextEditor.Document.LineSegment l = area_obj.Document.GetLineSegment(area_obj.Caret.Line);
            string s = area_obj.Document.GetText(l);

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

            ICSharpCode.TextEditor.Document.BookmarkManager bm = this.textEditor.Document.BookmarkManager;

            if (bm.IsMarked(area_obj.Caret.Line))
            {
                bm.RemoveMark(bm.GetNextMark(area_obj.Caret.Line - 1));
            }
            else
            {
                this.textEditor.Document.BookmarkManager.AddMark(new Breakpoint(this._filename, this.textEditor.Document, area_obj.Caret.Line));
            }

            // this.textEditor.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, area_obj.Caret.Line));

            this.RedrawBreakpoints();

            // area_obj.IconBarMargin.Paint(area_obj.IconBarMargin.TextArea.CreateGraphics(), area_obj.IconBarMargin.TextArea.DisplayRectangle);
        }
		/// <summary>
		/// Inserts the PInvoke signature at the current cursor position.
		/// </summary>
		/// <param name="textArea">The text editor.</param>
		/// <param name="signature">A PInvoke signature string.</param>
		public void Generate(TextArea textArea, string signature)
		{
			IndentStyle oldIndentStyle = textArea.TextEditorProperties.IndentStyle;
			bool oldEnableEndConstructs = PropertyService.Get("VBBinding.TextEditor.EnableEndConstructs", true);

			try {

				textArea.BeginUpdate();
				textArea.Document.UndoStack.StartUndoGroup();
				textArea.TextEditorProperties.IndentStyle = IndentStyle.Smart;
				PropertyService.Set("VBBinding.TextEditor.EnableEndConstructs", false);

				string[] lines = signature.Replace("\r\n", "\n").Split('\n');
				
				for (int i = 0; i < lines.Length; ++i) {
					
					textArea.InsertString(lines[i]);
					
					// Insert new line if not the last line.
					if ( i < (lines.Length - 1))
					{
						Return(textArea);
					}
				}
				
			} finally {
				textArea.Document.UndoStack.EndUndoGroup();
				textArea.TextEditorProperties.IndentStyle = oldIndentStyle;
				PropertyService.Set("VBBinding.TextEditor.EnableEndConstructs", oldEnableEndConstructs);
				textArea.EndUpdate();
				textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
				textArea.Document.CommitUpdate();	
			}
		}
		public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
		{
			ICompletionData[] data = new ICompletionData[texts.Length];
			for (int i = 0; i < data.Length; i++) {
				data[i] = new DefaultCompletionData(texts[i], null, ClassBrowserIconService.GotoArrowIndex);
			}
			return data;
		}
		void IndentLine(TextArea textArea)
		{
			int delta = textArea.Document.FormattingStrategy.IndentLine(textArea, textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset));
			if (delta != 0) {
				LineSegment caretLine = textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset);
				textArea.Caret.Position = textArea.Document.OffsetToPosition(Math.Min(textArea.Caret.Offset + delta, caretLine.Offset + caretLine.Length));
			}
		}		
		protected override void GenerateCompletionData(TextArea textArea, char charTyped)
		{
			preSelection = null;
			if (fixedExpression.Expression == null)
				GenerateCompletionData(textArea, GetExpression(textArea));
			else
				GenerateCompletionData(textArea, fixedExpression);
		}
		public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
		{
			this.textArea = textArea;
			this.startOffset = textArea.Caret.Offset;
			this.nonMatchingCharTyped = false;
			this.DefaultIndex = 0;
			return new ICompletionData[] { new DefaultCompletionData("{res", null, ClassBrowserIconService.GotoArrowIndex) };
		}
Ejemplo n.º 23
0
 /// <summary>
 /// Execute the Goto Line action
 /// </summary>
 /// <param name="textArea">The text area in which to perform the
 /// action</param>
 public override void Execute(TextArea textArea)
 {
     using(GotoLineDlg dlg = new GotoLineDlg())
     {
         if(dlg.ShowDialog() == DialogResult.OK)
             textArea.Caret.Line = dlg.LineNumber - 1;
     }
 }
 public override int FormatLine(TextArea textArea, int lineNr, int caretOffset, char charTyped) // used for comment tag formater/inserter
 {
     try
     {
         if (charTyped == '>')
         {
             StringBuilder stringBuilder = new StringBuilder();
             int offset = Math.Min(caretOffset - 2, textArea.Document.TextLength - 1);
             while (true)
             {
                 if (offset < 0)
                 {
                     break;
                 }
                 char ch = textArea.Document.GetCharAt(offset);
                 if (ch == '<')
                 {
                     string reversedTag = stringBuilder.ToString().Trim();
                     if (!reversedTag.StartsWith("/") && !reversedTag.EndsWith("/"))
                     {
                         bool validXml = true;
                         try
                         {
                             XmlDocument doc = new XmlDocument();
                             doc.LoadXml(textArea.Document.TextContent);
                         }
                         catch (Exception)
                         {
                             validXml = false;
                         }
                         // only insert the tag, if something is missing
                         if (!validXml)
                         {
                             StringBuilder tag = new StringBuilder();
                             for (int i = reversedTag.Length - 1; i >= 0 && !Char.IsWhiteSpace(reversedTag[i]); --i)
                             {
                                 tag.Append(reversedTag[i]);
                             }
                             string tagString = tag.ToString();
                             if (tagString.Length > 0 && !tagString.StartsWith("!") && !tagString.StartsWith("?"))
                             {
                                 textArea.Document.Insert(caretOffset, "</" + tagString + ">");
                             }
                         }
                     }
                     break;
                 }
                 stringBuilder.Append(ch);
                 --offset;
             }
         }
     }
     catch (Exception e)
     { // Insanity check
         Debug.Assert(false, e.ToString());
     }
     return charTyped == '\n' ? IndentLine(textArea, lineNr) : 0;
 }
Ejemplo n.º 25
0
        public void SetupDataProvider(string fileName, ICSharpCode.TextEditor.TextArea textArea)
        {
            _textArea = textArea;
            _document = textArea.Document;
            _keywords = KeywordFactory.GetKeywords();

            //TODO: just put these keywords in the factory and add a flag for "IsRequired" or something.
            //      it may just require a KeywordType (Header, Action, etc). This needs cleaned up
            //      in the code completion data provider as well.

            // the keyword factory just has the non-required words
            Keyword sightDist = new Keyword("bot_SightDist", "", "", false);

            sightDist.Inputs.Add(new KeywordInput(KeywordInputType.Action, "Sight Distance", "How far the highest skill bot can see on this map. 1500 is good for non-foggy maps, 700 is good for foggy maps."));
            _keywords.Add(sightDist);

            _keywords.Add(new Keyword("spawnflag_is_priority", "", "Whether or no bots focus on spawnflags.", false));
            _keywords.Add(new Keyword("cmdpost_is_priority", "", "Whether or not command posts critical on this map.", false));
            _keywords.Add(new Keyword("construct_is_priority", "", "Whether or not engineers focus more on constructibles.", false));
            _keywords.Add(new Keyword("map_has_vehicle", "", "Type of vehicle 0 = none, 1 = tank, 2 = train", false));
            _keywords.Add(new Keyword("vehicle_entity_number", "", "The entity number of the vehicle.", false));
            _keywords.Add(new Keyword("vehicle_team_owner", "", "The owner of the vehicle.", false));

            LineSegment line = textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset);

            if (line != null)
            {
                TextWord first = GetWord(line, 1);

                if (first != null)
                {
                    Keyword keyword = _keywords.GetWord(first.Word);

                    if (keyword != null)
                    {
                        if (keyword.Inputs.Count > 0)
                        {
                            for (int x = 0; x < keyword.Inputs.Count; x++)
                            {
                                TextWord param = GetWord(line, x + 2);

                                if (param == null)
                                {
                                    KeywordInput inputParam = (KeywordInput)keyword.Inputs[x];

                                    if (inputParam.InputType != KeywordInputType.PredefinedList)
                                    {
                                        _insightKeywords.Add(new Keyword(inputParam.Label, inputParam.Label, inputParam.HelpText, false));
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 26
0
		public void Attach(TextArea textArea)
		{
			this.textArea = textArea;
			textArea.AllowDrop = true;
			
			textArea.DragEnter += MakeDragEventHandler(OnDragEnter);
			textArea.DragDrop  += MakeDragEventHandler(OnDragDrop);
			textArea.DragOver  += MakeDragEventHandler(OnDragOver);
		}
		public virtual bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
		{
			if (InsertSpace) {
				textArea.Document.Insert(insertionOffset++, " ");
			}
			textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);
			
			return data.InsertAction(textArea, key);
		}
 void InsertString(ICSharpCode.TextEditor.TextArea textArea, int offset, string str)
 {
     textArea.Document.Insert(offset, str);
     //textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document,
     //                                                            textArea.Document.OffsetToPosition(offset),
     //                                                            textArea.Document.OffsetToPosition(offset + str.Length)));
     textArea.Caret.Position = textArea.Document.OffsetToPosition(offset + str.Length);
     textArea.Refresh();
 }
			public override bool InsertAction(TextArea textArea, char ch)
			{
				if (ch == '\t' || automaticInsert) {
					((SharpDevelopTextAreaControl)textArea.MotherTextEditorControl).InsertTemplate(template);
					return false;
				} else {
					return base.InsertAction(textArea, ch);
				}
			}
		public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
		{
			if (completionData == null) {
				completionData = baseProvider.GenerateCompletionData(fileName, textArea, charTyped);
				preSelection = baseProvider.PreSelection;
				this.DefaultIndex = baseProvider.DefaultIndex;
			}
			return completionData;
		}
Ejemplo n.º 31
0
        public override void Execute(TextArea textArea)
        {
            TextLocation position = textArea.Caret.Position;
            position.Line = _line;

            textArea.Caret.Position = position;
            textArea.SelectionManager.ClearSelection();
            textArea.SetDesiredColumn();
            
        }
Ejemplo n.º 32
0
        void Init()
        {
            propertyGridComboBox.SelectedIndex = 1;
            textArea = textEditorControl.ActiveTextAreaControl.TextArea;
            textArea.KeyEventHandler += ProcessKey;

            PopulateHighlightingComboBox();

            highlightingToolStripComboBox.Text = "C#";
        }
Ejemplo n.º 33
0
 public Caret(TextArea textArea)
 {
     this.textArea = textArea;
     textArea.GotFocus  += new EventHandler(GotFocus);
     textArea.LostFocus += new EventHandler(LostFocus);
     if (Environment.OSVersion.Platform == PlatformID.Unix)
         caretImplementation = new ManagedCaret(this);
     else
         caretImplementation = new Win32Caret(this);
 }
		/// <summary>
		/// Define XML specific smart indenting for a line :)
		/// </summary>
		protected override int SmartIndentLine(TextArea textArea, int lineNr)
		{
			if (lineNr <= 0) return AutoIndentLine(textArea, lineNr);
			try {
				TryIndent(textArea, lineNr, lineNr);
				return GetIndentation(textArea, lineNr).Length;
			} catch (XmlException) {
				return AutoIndentLine(textArea, lineNr);
			}
		}
        public bool InsertAction(ICompletionData data, ICSharpCode.TextEditor.TextArea textArea, int insertionOffset, char key)
        {
            if (InsertSpace)
            {
                textArea.Document.Insert(insertionOffset++, " ");
            }
            textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);

            return(data.InsertAction(textArea, key));
        }
Ejemplo n.º 36
0
        public ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
        {
            string text = String.Concat(textArea.Document.GetText(0, textArea.Caret.Offset), charTyped);

            switch (charTyped)
            {
                case '<':
                    // Child element intellisense.
                    XmlElementPath parentPath = XmlParser.GetParentElementPath(text);
                    if (parentPath.Elements.Count > 0)
                    {
                        ICompletionData[] data = GetChildElementCompletionData(parentPath);
                        //returnval = data;
                        return data;
                    }
                    else if (defaultSchemaCompletionData != null)
                    {
                        return defaultSchemaCompletionData.GetElementCompletionData(defaultNamespacePrefix);
                    }
                    break;

                case ' ':
                    // Attribute intellisense.
                    if (!XmlParser.IsInsideAttributeValue(text, text.Length))
                    {
                        XmlElementPath path = XmlParser.GetActiveElementStartPath(text, text.Length);
                        if (path.Elements.Count > 0)
                        {
                            return GetAttributeCompletionData(path);
                        }
                    }
                    break;

                case '\'':
                case '\"':

                    // Attribute value intellisense.
                    //if (XmlParser.IsAttributeValueChar(charTyped)) {
                    text = text.Substring(0, text.Length - 1);
                    string attributeName = XmlParser.GetAttributeName(text, text.Length);
                    if (attributeName.Length > 0)
                    {
                        XmlElementPath elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
                        if (elementPath.Elements.Count > 0)
                        {
                            preSelection = charTyped.ToString();
                            return GetAttributeValueCompletionData(elementPath, attributeName);
                            //		}
                        }
                    }
                    break;
            }

            return null;
        }
Ejemplo n.º 37
0
        public override void Execute(SD.TextArea textArea)
        {
            TextLocation newPos = textArea.Caret.Position;

            newPos.X = 0;
            if (newPos != textArea.Caret.Position)
            {
                textArea.Caret.Position = newPos;
                textArea.SetDesiredColumn();
            }
        }
        private void templateEditor_DragDrop(object sender, DragEventArgs e)
        {
            TreeNode node = (TreeNode)e.Data.GetData(typeof(TreeNode));

            ICSharpCode.TextEditor.TextArea textArea = (ICSharpCode.TextEditor.TextArea)sender;
            try
            {
                Hashtable idPack = node.Tag as Hashtable;
                switch (idPack["Type"] as string)
                {
                case "promptgroup":
                    return;

                case "prompt":
                    break;
                }

                //Build the variable to insert here
                Prompt prompt = idPack["Data"] as Prompt;

                Point p = textArea.PointToClient(new Point(e.X, e.Y));
                textArea.BeginUpdate();
                textArea.Document.UndoStack.StartUndoGroup();

                int offset = textArea.Caret.Offset;
                if (e.Data.GetDataPresent(typeof(DefaultSelection)))
                {
                    ISelection sel = (ISelection)e.Data.GetData(typeof(DefaultSelection));
                    if (sel.ContainsPosition(textArea.Caret.Position))
                    {
                        return;
                    }
                    int len = sel.Length;
                    textArea.Document.Remove(sel.Offset, len);
                    if (sel.Offset < offset)
                    {
                        offset -= len;
                    }
                }
                insertIntoTemplateEditor(textArea, offset, prompt.VariableName);
            }
            finally
            {
                textArea.Document.UndoStack.EndUndoGroup();
                textArea.EndUpdate();
            }
        }
Ejemplo n.º 39
0
        public void ShowForm(ICSharpCode.TextEditor.TextArea textArea, TextLocation logicTextPos)
        {
            frm = new TooltipForm();
            frm.AllowResizing = false;
            frm.Owner         = textArea.FindForm();
            int   ypos = (textArea.Document.GetVisibleLine(logicTextPos.Y) + 1) * textArea.TextView.FontHeight - textArea.VirtualTop.Y;
            Point p    = new Point(0, ypos);

            p    = textArea.PointToScreen(p);
            p.X  = Control.MousePosition.X - 16;
            p.Y -= 1;
            frm.StartPosition = FormStartPosition.Manual;
            frm.ShowInTaskbar = false;
            frm.Location      = p;
            frm.ClientSize    = new Size(Width + 2, row.Height + 2);
            Dock = DockStyle.Fill;
            frm.Controls.Add(this);
            frm.ShowWindowWithoutActivation = true;
            frm.Show();
            textArea.Click   += OnTextAreaClick;
            textArea.KeyDown += OnTextAreaClick;
            frm.ClientSize    = new Size(frm.ClientSize.Width, row.Height + 2);
        }
Ejemplo n.º 40
0
        void OnToolTipRequest(object sender, ToolTipRequestEventArgs e)
        {
            if (e.InDocument && !e.ToolTipShown && _xdebugClient.State == XdebugClientState.Break)
            {
                ICSharpCode.TextEditor.TextArea area_obj = (ICSharpCode.TextEditor.TextArea)sender;

                string s = ICSharpCode.TextEditor.Document.TextUtilities.GetWordAt(area_obj.Document, area_obj.Document.PositionToOffset(new Point(e.LogicalPosition.X, e.LogicalPosition.Y)));

                if (area_obj.Document.GetCharAt(MyFindWordStart(area_obj.Document, area_obj.Document.PositionToOffset(new Point(e.LogicalPosition.X, e.LogicalPosition.Y))) - 1).ToString() == "$")
                {
                    s = "$" + s;
                }

                if (s != "")
                {
                    Property p = _xdebugClient.GetPropertyValue(s, 0);

                    if (p != null)
                    {
                        e.ShowToolTip(p.Value);
                    }
                }
            }
        }
Ejemplo n.º 41
0
 public override void Execute(SD.TextArea textArea)
 {
     ((TextEdit)textArea.Parent).PromptFindReplace(true);
 }
Ejemplo n.º 42
0
 public override void Execute(SD.TextArea textArea)
 {
     ((TextEdit)textArea.Parent).FindAgain();
 }
        private void listBox1_MouseDoubleClick_1(object sender, MouseEventArgs e)
        {
            if (listBox1.SelectedItems == null)
            {
                return;
            }
            var s = listBox1.SelectedItems[0].Text;

            ICSharpCode.TextEditor.TextArea ta = MainForm.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea;
            ta.Focus();
            var full = schoolManager.ht.Keys.FirstOrDefault(st => st.StartsWith(s));

            //if (schoolManager.ht.Keys.Select(st=>st.Substring(0,s.IndexOf('/'))).Contains(s))
            if (full != null)
            {
                // Если шаблон начинается с begin и предыдущая конструкция с начала строки - управляющий оператор, то сдвинуть курсор, выровняв по предыдущей конструкции
                if (s.StartsWith("begin … end"))
                {
                    var   Prev = GetPrevLine(ta.Caret.Line);
                    Match m    = null;
                    if (Prev != null)
                    {
                        m = Regex.Match(Prev, @"^\s*(loop|for|while|if|else)", RegexOptions.IgnoreCase);
                        if (m.Groups[1].Value.Length > 0)
                        {
                            var Curr = GetLine(ta.Caret.Line);
                            if (Curr.Length > m.Groups[1].Index)
                            {
                                ta.Caret.Column = Curr.Length;
                                ta.InsertString(new string(' ', Curr.Length - m.Groups[1].Index));
                            }

                            ta.Caret.Column = m.Groups[1].Index;

                            var doc    = ta.Document;
                            var tl_beg = new TextLocation(ta.Caret.Column, ta.Caret.Line);
                            int offset = doc.PositionToOffset(tl_beg);

                            if (Curr.Length > ta.Caret.Column && Curr.Substring(ta.Caret.Column).TrimEnd().Length == 0)
                            {
                                doc.Remove(offset, Curr.Length - ta.Caret.Column);
                            }
                        }
                    }
                    var Next = GetNextLine(ta.Caret.Line);
                    if (m != null && m.Groups[1].Value.ToLower().Equals("if") && Next != null && Next.TrimStart().ToLower().StartsWith("else"))
                    {
                        CodeCompletionActionsManager.GenerateTemplate(s, ta, schoolManager, false, str => str.Remove(str.Length - 1)); // Удалить ; в begin end перед else
                    }
                    else
                    {
                        CodeCompletionActionsManager.GenerateTemplate(s, ta, schoolManager, false);
                    }
                }
                else
                {
                    CodeCompletionActionsManager.GenerateTemplate(s, ta, schoolManager, false);
                }
            }
            else
            {
                ta.InsertString(s);
            }
            ta.Focus();
        }
Ejemplo n.º 44
0
 /// <summary>
 /// 入力補完リストに表示するデータリストを生成する
 /// 継承クラス側で上書きすること
 /// </summary>
 /// <param name="fileName">ファイル名</param>
 /// <param name="textArea">アクティブなテキストエディタ</param>
 /// <param name="charTyped">入力された文字</param>
 /// <returns>リストに表示するデータリスト</returns>
 public abstract ICompletionData[] GenerateCompletionData(string fileName, ICSharpCode.TextEditor.TextArea textArea, char charTyped);
 public FoldMargin(TextArea textArea) : base(textArea)
 {
 }
Ejemplo n.º 46
0
 void InsertString(ICSharpCode.TextEditor.TextArea textArea, int offset, string str)
 {
     textArea.Document.Insert(offset, str);
     textArea.Caret.Position = textArea.Document.OffsetToPosition(offset + str.Length);
     textArea.Refresh();
 }