当前位置: 首页>>代码示例>>C#>>正文


C# TextArea.InsertString方法代码示例

本文整理汇总了C#中ICSharpCode.TextEditor.TextArea.InsertString方法的典型用法代码示例。如果您正苦于以下问题:C# TextArea.InsertString方法的具体用法?C# TextArea.InsertString怎么用?C# TextArea.InsertString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.TextEditor.TextArea的用法示例。


在下文中一共展示了TextArea.InsertString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Generate

		/// <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();	
			}
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:39,代码来源:PInvokeCodeGenerator.cs

示例2: InsertAction

 /// <summary>
 /// Inserts this selection into the document.
 /// </summary>
 /// <param name="textArea">The text area into which to insert the selection.</param>
 /// <param name="ch">The character that was used to choose this completion selection.</param>
 /// <returns><lang cref="true"/> if the insertion of <paramref name="p_chrKey"/> was handled;
 /// <lang cref="false"/> otherwise.</returns>
 public override bool InsertAction(TextArea textArea, char ch)
 {
     switch (m_actCompletionType)
     {
         case AutoCompleteType.Attribute:
         case AutoCompleteType.AttributeValues:
             textArea.InsertString(Text);
             return false;
         case AutoCompleteType.Element:
             if (Text.EndsWith("["))
             {
                 Caret crtCaret = textArea.Caret;
                 textArea.InsertString(String.Concat(Text, "]]>"));
                 crtCaret.Position = textArea.Document.OffsetToPosition(crtCaret.Offset - 3);
                 return false;
             }
             break;
     }
     return base.InsertAction(textArea, ch);
 }
开发者ID:BioBrainX,项目名称:fomm,代码行数:27,代码来源:XmlCompletionData.cs

示例3: InsertAction

		/// <summary>
		/// Insert the element represented by the completion data into the text
		/// editor.
		/// </summary>
		/// <param name="textArea">TextArea to insert the completion data in.</param>
		/// <param name="ch">Character that should be inserted after the completion data.
		/// \0 when no character should be inserted.</param>
		/// <returns>Returns true when the insert action has processed the character
		/// <paramref name="ch"/>; false when the character was not processed.</returns>
		public override bool InsertAction(TextArea textArea, char ch)
		{
			string insertString;
			
			if (this.outputVisitor != null) {
				PrimitiveExpression pre = new PrimitiveExpression(this.Text, this.Text);
				pre.AcceptVisitor(this.outputVisitor, null);
				insertString = this.outputVisitor.Text;
			} else {
				insertString = this.Text;
			}
			
			textArea.InsertString(insertString);
			if (ch == insertString[insertString.Length - 1]) {
				return true;
			}
			return false;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:27,代码来源:ResourceCodeCompletionData.cs

示例4: InsertAction

 public virtual bool InsertAction(TextArea textArea, char ch)
 {
     textArea.InsertString(description);
     return false;
 }
开发者ID:scriptord3,项目名称:RagnarokNPCEditor,代码行数:5,代码来源:AEGISCompletionData.cs

示例5: InsertAction

		public bool InsertAction(TextArea textArea, char ch)
		{
			if ((dataType == DataType.XmlElement))
            {
				textArea.InsertString(text);
			}
            else if (dataType == DataType.XmlAttributeValue)
            {
                if( XmlParser.IsInsideAttributeValue(textArea.Document.TextContent,textArea.Caret.Offset))
                {
                    int first, last;
                    XmlParser.GetCurrentAttributeValueSpan(textArea.Document.TextContent, textArea.Caret.Offset, out first, out last);
                    if (last > first && last > 0)
                    {
                        textArea.SelectionManager.SetSelection(textArea.Document.OffsetToPosition(first)
                                                               , textArea.Document.OffsetToPosition(last)
                                                               );
                        textArea.SelectionManager.RemoveSelectedText();
                    }
                }
                textArea.InsertString(text);
                Caret caret = textArea.Caret;
                // Move caret outside of the attribute quotes.
                caret.Position = textArea.Document.OffsetToPosition(caret.Offset + 1);
            }
			else if (dataType == DataType.NamespaceUri) {
				textArea.InsertString(String.Concat("\"", text, "\""));
			} else {
				// Insert an attribute.
				Caret caret = textArea.Caret;
				textArea.InsertString(String.Concat(text, "=\""));	
				
				// Move caret into the middle of the attribute quotes.
				caret.Position = textArea.Document.OffsetToPosition(caret.Offset - 1);
                textArea.SimulateKeyPress('\"');
			}
			return false;
		}
开发者ID:FelicePollano,项目名称:Fatica.Labs.XmlEditor,代码行数:38,代码来源:XmlCompletionData.cs

示例6: InsertAction

 public virtual bool InsertAction(TextArea textArea, char ch)
 {
     textArea.InsertString(this.text);
     return false;
 }
开发者ID:fizikci,项目名称:Cinar,代码行数:5,代码来源:CinarScriptEditor.cs

示例7: InsertAction

			public bool InsertAction(TextArea textArea, char ch)
			{
				textArea.InsertString(text);
				return false;
			}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:5,代码来源:CommentCompletionDataProvider.cs

示例8: GenerateMethodImplementationHeaders

        public static void GenerateMethodImplementationHeaders(TextArea textArea)
        {
            try
            {
                if (CodeCompletion.CodeCompletionController.CurrentParser == null) return;
                ccp = new CodeCompletionProvider();
                Position pos = new Position();
                //string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos);
                string text = ccp.GetMethodImplementationTextToAdd(textArea.MotherTextEditorControl.FileName, textArea.Caret.Line, textArea.Caret.Column, ref pos, textArea);
                if (!string.IsNullOrEmpty(text) && pos.file_name != null)
                {
                    textArea.Caret.Line = pos.line - 1;
                    textArea.Caret.Column = 0;
                    textArea.InsertString(text);
                    textArea.Caret.Line = pos.line - 1;
                    textArea.Caret.Column = 0;
                }
            }
            catch (System.Exception e)
            {

            }
        }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:23,代码来源:CodeCompletionActions.cs

示例9: InsertAction

		public bool InsertAction(TextArea textArea, char ch)
		{
			if (dotnetName != null) {
				CodeCompletionDataUsageCache.IncrementUsage(dotnetName);
			}
			if (c != null && text.Length > c.Name.Length) {
				textArea.InsertString(text.Substring(0, c.Name.Length + 1));
				Point start = textArea.Caret.Position;
				Point end;
				int pos = text.IndexOf(',');
				if (pos < 0) {
					textArea.InsertString(text.Substring(c.Name.Length + 1));
					end = textArea.Caret.Position;
					end.X -= 1;
				} else {
					textArea.InsertString(text.Substring(c.Name.Length + 1, pos - c.Name.Length - 1));
					end = textArea.Caret.Position;
					textArea.InsertString(text.Substring(pos));
				}
				textArea.Caret.Position = start;
				textArea.SelectionManager.SetSelection(start, end);
				if (!char.IsLetterOrDigit(ch)) {
					return true;
				}
			} else {
				textArea.InsertString(text);
			}
			return false;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:29,代码来源:CodeCompletionData.cs

示例10: InsertAction

        public bool InsertAction(TextArea textArea, char ch)
        {
            if ((dataType == DataType.XmlElement) || (dataType == DataType.XmlAttributeValue))
            {
                textArea.InsertString(text);
            }
            else if (dataType == DataType.NamespaceUri)
            {
                textArea.InsertString(String.Concat("\"", text, "\""));
            }
            else
            {
                // Insert an attribute.
                Caret caret = textArea.Caret;
                textArea.InsertString(String.Concat(text, "=\"\""));

                // Move caret into the middle of the attribute quotes.
                caret.Position = textArea.Document.OffsetToPosition(caret.Offset - 1);
            }
            return false;
        }
开发者ID:punker76,项目名称:kaxaml,代码行数:21,代码来源:XmlCompletionData.cs

示例11: GenerateCommentTemplate

 public static bool GenerateCommentTemplate(TextArea textArea)
 {
     if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false;
     ccp = new CodeCompletionProvider();
     //if (!should_insert_comment(textArea))
     //	return false;
     string lineText = get_next_line(textArea);
     string addit = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.GetDocumentTemplate(
         lineText, textArea.Document.TextContent, textArea.Caret.Line, textArea.Caret.Column, textArea.Caret.Offset);
     if (addit == null)
         return false;
     int col = textArea.Caret.Column;
     int line = textArea.Caret.Line;
     int len;
     string desc = get_possible_description(textArea, out len);
     StringBuilder sb = new StringBuilder();
     sb.AppendLine(" <summary>");
     for (int i = 0; i < col - 3; i++)
         sb.Append(' ');
     sb.Append("/// ");
     if (desc != null)
         sb.Append(desc);
     sb.AppendLine();
     for (int i = 0; i < col - 3; i++)
         sb.Append(' ');
     sb.Append("/// </summary>");
     if (addit != "")
     {
         sb.Append(addit);
     }
     if (desc == null)
         textArea.InsertString(sb.ToString());
     else
     {
         IDocument doc = textArea.Document;
         TextLocation tl_beg = new TextLocation(col, line);
         //TextLocation tl_end = new TextLocation(svs.SourceLocation.EndPosition.Line,svs.SourceLocation.EndPosition.Column);
         int offset = doc.PositionToOffset(tl_beg);
         doc.Replace(offset, len, "");
         doc.CommitUpdate();
         textArea.InsertString(sb.ToString());
     }
     textArea.Caret.Line = line + 1;
     textArea.Caret.Column = col + 1;
     return true;
 }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:46,代码来源:CodeCompletionActions.cs

示例12: GenerateTemplate

        public static void GenerateTemplate(string pattern, TextArea textArea)
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                IDocument doc = textArea.Document;

                int line = textArea.Caret.Line;
                int col = textArea.Caret.Column;
                string name = templateManager.GetTemplateHeader(pattern);
                if (name == null) return;
                string templ = templateManager.GetTemplate(name);
                int ind = pattern.Length;
                int cline;
                int ccol;
                find_cursor_pos(templ, out cline, out ccol);
                sb.Append(templ);
                int cur_ind = templ.IndexOf('|');
                if (cur_ind != -1)
                    sb = sb.Remove(cur_ind, 1);
                sb = sb.Replace("<filename>", Path.GetFileNameWithoutExtension(textArea.MotherTextEditorControl.FileName));
                templ = sb.ToString();
                int i = 0;
                i = templ.IndexOf('\n', i);
                while (i != -1)
                {
                    if (i + 1 < sb.Length)
                        sb.Insert(i + 1, " ", col - ind);
                    i = sb.ToString().IndexOf('\n', i + 1);
                }
                TextLocation tl_beg = new TextLocation(col - ind, line);
                int offset = doc.PositionToOffset(tl_beg);
                doc.Replace(offset, ind, "");
                doc.CommitUpdate();
                textArea.Caret.Column = col - ind;
                textArea.InsertString(sb.ToString());
                textArea.Caret.Line = line + cline;
                textArea.Caret.Column = col - ind + ccol;
            }
            catch (Exception e)
            {

            }
        }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:44,代码来源:CodeCompletionActions.cs

示例13: GenerateClassOrMethodRealization

 public static void GenerateClassOrMethodRealization(TextArea textArea)
 {
     if (CodeCompletion.CodeCompletionController.CurrentParser == null) return;
     ccp = new CodeCompletionProvider();
     Position pos = new Position();
     //string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos);
     string text = ccp.GetRealizationTextToAdd(textArea.MotherTextEditorControl.FileName, textArea.Caret.Line, textArea.Caret.Column, ref pos, textArea);
     if (text != null && pos.file_name != null)
     {
         textArea.Caret.Line = pos.line - 1;
         textArea.Caret.Column = pos.column - 1;
         textArea.InsertString(text);
         textArea.Caret.Line = pos.line + 4 - 1;
         textArea.Caret.Column = VisualPABCSingleton.MainForm.UserOptions.CursorTabCount + 1;
     }
 }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:16,代码来源:CodeCompletionActions.cs

示例14: InsertAction

 public override bool InsertAction(TextArea textArea, char ch)
 {
     textArea.InsertString(_insertText + _appendText);
     return false;
 }
开发者ID:kanbang,项目名称:Colt,代码行数:5,代码来源:FdoExpressionCompletionDataProvider.cs

示例15: Execute

        /// <summary>
        /// Execute the Insert Matching action
        /// </summary>
        /// <param name="textArea">The text area in which to perform the
        /// action</param>
        public override void Execute(TextArea textArea)
        {
            int col = textArea.Caret.Column;

            textArea.InsertString(matchedChars);
            textArea.Caret.Column = col + 1;
        }
开发者ID:,项目名称:,代码行数:12,代码来源:


注:本文中的ICSharpCode.TextEditor.TextArea.InsertString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。