本文整理汇总了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();
}
}
示例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);
}
示例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;
}
示例4: InsertAction
public virtual bool InsertAction(TextArea textArea, char ch)
{
textArea.InsertString(description);
return false;
}
示例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;
}
示例6: InsertAction
public virtual bool InsertAction(TextArea textArea, char ch)
{
textArea.InsertString(this.text);
return false;
}
示例7: InsertAction
public bool InsertAction(TextArea textArea, char ch)
{
textArea.InsertString(text);
return false;
}
示例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)
{
}
}
示例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;
}
示例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;
}
示例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;
}
示例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)
{
}
}
示例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;
}
}
示例14: InsertAction
public override bool InsertAction(TextArea textArea, char ch)
{
textArea.InsertString(_insertText + _appendText);
return false;
}
示例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;
}