本文整理汇总了C#中ICSharpCode.TextEditor.TextArea类的典型用法代码示例。如果您正苦于以下问题:C# TextArea类的具体用法?C# TextArea怎么用?C# TextArea使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextArea类属于ICSharpCode.TextEditor命名空间,在下文中一共展示了TextArea类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: IndentLines
/// <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);
}
}
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:30,代码来源:CSharpFormattingStrategy.cs
示例2: AutoIndentLine
/// <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;
}
开发者ID:NexusMods,项目名称:NexusModManager-4.5,代码行数:32,代码来源:XmlFormattingStrategy.cs
示例3: InsertAction
/// <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);
}
开发者ID:scriptord3,项目名称:RagnarokNPCEditor,代码行数:10,代码来源:CodeCompletionProvider.cs
示例4: Execute
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();
}
}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:35,代码来源:Actions.cs
示例5: AddTemplates
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);
}
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:30,代码来源:CtrlSpaceCompletionDataProvider.cs
示例6: GenerateCompletionData
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();
}
开发者ID:cleciusjm,项目名称:db4oanalyzer,代码行数:26,代码来源:CodeCompletionProvider.cs
示例7: 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
示例8: SmartIndentLine
/// <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;
}
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:35,代码来源:CSharpFormattingStrategy.cs
示例9: TextAreaControl
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;
};
}
开发者ID:ArsenShnurkov,项目名称:ospa-texteditor,代码行数:30,代码来源:TextAreaControl.cs
示例10: GutterMargin
public GutterMargin(TextArea textArea)
: base(textArea)
{
numberStringFormat.LineAlignment = StringAlignment.Far;
numberStringFormat.FormatFlags = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.FitBlackBox |
StringFormatFlags.NoWrap | StringFormatFlags.NoClip;
}
开发者ID:umabiel,项目名称:WsdlUI,代码行数:7,代码来源:GutterMargin.cs
示例11: Validate
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);
}
}
开发者ID:FelicePollano,项目名称:Fatica.Labs.XmlEditor,代码行数:32,代码来源:XmlSchemaSquiggleValidator.cs
示例12: Execute
public override void Execute(TextArea services)
{
XmlEditorControl editor = services.MotherTextEditorControl as XmlEditorControl;
if (editor != null) {
editor.ShowCompletionWindow();
}
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:CodeCompletionPopupCommand.cs
示例13: SetupDataProvider
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);
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:34,代码来源:MethodInsightDataProvider.cs
示例14: InsertAction
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);
}
开发者ID:tormaroe,项目名称:Ping-Ring,代码行数:7,代码来源:CodeCompletionProvider.cs
示例15: GenerateCode
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();
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:7,代码来源:CodeGeneratorBase.cs
示例16: Execute
/// <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;
}
}
开发者ID:,项目名称:,代码行数:13,代码来源:
示例17: IndentLine
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));
}
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:8,代码来源:PInvokeCodeGenerator.cs
示例18: GenerateCompletionData
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;
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:8,代码来源:TextCompletionDataProvider.cs
示例19: GenerateCompletionData
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) };
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:8,代码来源:ICSharpCodeCoreTagCompletionDataProvider.cs
示例20: GenerateCompletionData
protected override void GenerateCompletionData(TextArea textArea, char charTyped)
{
preSelection = null;
if (fixedExpression.Expression == null)
GenerateCompletionData(textArea, GetExpression(textArea));
else
GenerateCompletionData(textArea, fixedExpression);
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:8,代码来源:CodeCompletionDataProvider.cs
注:本文中的ICSharpCode.TextEditor.TextArea类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论