本文整理汇总了C#中ICSharpCode.AvalonEdit.Editing.TextArea类的典型用法代码示例。如果您正苦于以下问题:C# TextArea类的具体用法?C# TextArea怎么用?C# TextArea使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextArea类属于ICSharpCode.AvalonEdit.Editing命名空间,在下文中一共展示了TextArea类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateCompletionData
public CompletionData[] GenerateCompletionData(string fileName, TextArea textArea)
{
string name = WordUtilities.FindPreviousWord(textArea);
if (name == null)
return EmptySuggestion(textArea.Caret);
if (name == "specification" || name == "requires" || name == "same_machine_as" || name == "@")
{
return ModulesSuggestions();
}
if (name == "users_per_machine")
{
return NumbersSuggestions(50,100,150,200);
}
else if (name == "min_memory")
{
return NumbersSuggestions(1024,2048,4096,8*1024);
}
else if (name == "min_cpu_count")
{
return NumbersSuggestions(1, 2, 4, 8, 16);
}
return EmptySuggestion(textArea.Caret);
}
示例2: ReplaceSelectionWithText
/// <inheritdoc/>
public override void ReplaceSelectionWithText(TextArea textArea, string newText)
{
if (textArea == null)
throw new ArgumentNullException("textArea");
if (newText == null)
throw new ArgumentNullException("newText");
using (textArea.Document.RunUpdate()) {
if (IsEmpty) {
if (newText.Length > 0) {
if (textArea.ReadOnlySectionProvider.CanInsert(textArea.Caret.Offset)) {
textArea.Document.Insert(textArea.Caret.Offset, newText);
}
}
} else {
ISegment[] segmentsToDelete = textArea.GetDeletableSegments(this);
for (int i = segmentsToDelete.Length - 1; i >= 0; i--) {
if (i == segmentsToDelete.Length - 1) {
textArea.Caret.Offset = segmentsToDelete[i].EndOffset;
textArea.Document.Replace(segmentsToDelete[i], newText);
} else {
textArea.Document.Remove(segmentsToDelete[i]);
}
}
if (segmentsToDelete.Length != 0) {
textArea.Selection = Selection.Empty;
}
}
}
}
示例3: Create
/// <summary>
/// Creates a new <see cref="TextAreaInputHandler"/> for the text area.
/// </summary>
public static TextAreaInputHandler Create(TextArea textArea)
{
TextAreaInputHandler handler = new TextAreaInputHandler(textArea);
handler.CommandBindings.AddRange(CommandBindings);
handler.InputBindings.AddRange(InputBindings);
return handler;
}
示例4: Insert
/// <summary>
/// Inserts the snippet into the text area.
/// </summary>
public void Insert(TextArea textArea)
{
if (textArea == null)
throw new ArgumentNullException("textArea");
ISegment selection = textArea.Selection.SurroundingSegment;
int insertionPosition = textArea.Caret.Offset;
if (selection != null) // if something is selected
// use selection start instead of caret position,
// because caret could be at end of selection or anywhere inside.
// Removal of the selected text causes the caret position to be invalid.
insertionPosition = selection.Offset + TextUtilities.GetWhitespaceAfter(textArea.Document, selection.Offset).Length;
InsertionContext context = new InsertionContext(textArea, insertionPosition);
using (context.Document.RunUpdate()) {
if (selection != null)
textArea.Document.Remove(insertionPosition, selection.EndOffset - insertionPosition);
Insert(context);
// [DIGITALRUNE] Format inserted lines.
int beginLine = textArea.Document.GetLineByOffset(context.StartPosition).LineNumber;
int endLine = textArea.Document.GetLineByOffset(context.InsertionPosition).LineNumber;
textArea.IndentationStrategy?.IndentLines(textArea, beginLine, endLine);
context.RaiseInsertionCompleted(EventArgs.Empty);
}
}
示例5: SetUpFixture
public void SetUpFixture()
{
string python = "class Test:\r\n" +
"\tdef foo(self):\r\n" +
"\t\tpass";
DefaultProjectContent projectContent = new DefaultProjectContent();
PythonParser parser = new PythonParser();
compilationUnit = parser.Parse(projectContent, @"C:\test.py", python);
if (compilationUnit.Classes.Count > 0) {
c = compilationUnit.Classes[0];
if (c.Methods.Count > 0) {
method = c.Methods[0];
}
TextArea textArea = new TextArea();
document = new TextDocument();
textArea.Document = document;
textArea.Document.Text = python;
ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(textArea);
ParseInformation parseInfo = new ParseInformation(compilationUnit);
foldingStrategy.UpdateFoldings(parseInfo);
List<FoldingSection> folds = new List<FoldingSection>(foldingStrategy.FoldingManager.AllFoldings);
if (folds.Count > 0) {
classFold = folds[0];
}
if (folds.Count > 1) {
methodFold = folds[1];
}
}
}
示例6: SearchInputHandler
/// <summary>
/// Creates a new SearchInputHandler and registers the search-related commands.
/// </summary>
public SearchInputHandler(TextArea textArea)
: base(textArea)
{
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Find, ExecuteFind));
this.CommandBindings.Add(new CommandBinding(SearchCommands.FindNext, ExecuteFindNext));
this.CommandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, ExecuteFindPrevious));
}
示例7: SearchInputHandler
/// <summary>
/// Creates a new SearchInputHandler and registers the search-related commands.
/// </summary>
public SearchInputHandler(TextArea textArea)
: base(textArea)
{
RegisterCommands(this.CommandBindings);
panel = new SearchPanel();
panel.Attach(TextArea);
}
示例8: Complete
public virtual void Complete(TextArea textArea, ISegment completionSegment,
EventArgs insertionRequestEventArgs)
{
textArea.Document.Replace(completionSegment, Action == null ? this.Text : Action.Invoke());
if (CaretOffset != 0)
textArea.Caret.Offset += CaretOffset;
}
示例9: TextMarkerService
public TextMarkerService(TextArea area)
{
this.area = area;
markers = new TextSegmentCollection<TextMarker>(area.Document);
this.area.TextView.BackgroundRenderers.Add(this);
this.area.TextView.LineTransformers.Add(this);
}
示例10: Complete
public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
{
if (m_jsonEditorViewModel.IsBetweenQoats)
{
int offset = m_jsonEditorViewModel.Caret.Offset;
List<char> startChars = new List<char> {m_autoCompleteValue.SchemaObject.AutoCompletePathSeperator, '"'};
if (m_autoCompleteValue.SchemaObject.Prefix.Length > 0)
startChars.Add(m_autoCompleteValue.SchemaObject.Prefix.Last());
int indexQuotStart = m_jsonEditorViewModel.TextDocument.Text.LastIndexOfAny(startChars.ToArray(), offset - 1, offset - 1) + 1;
int indexQuatEnd = m_jsonEditorViewModel.TextDocument.Text.IndexOf('"', offset);
int indexLineBreak = m_jsonEditorViewModel.TextDocument.Text.IndexOf('\n', offset);
if (indexQuatEnd >= indexQuotStart && indexQuatEnd < indexLineBreak)
completionSegment = new SelectionSegment(indexQuotStart, indexQuatEnd);
}
int endOffset = completionSegment.Offset + Text.Length;
textArea.Document.Replace(completionSegment, (Text + m_autoCompleteValue.SchemaObject.Suffix).Replace("\\", "\\\\"));
m_jsonEditorViewModel.Caret.Offset = endOffset;
string value = m_autoCompleteValue.SchemaObject.RemovePrefixAndSuffix(m_jsonEditorViewModel.GetCurrentValue());
if (Text.StartsWith(".." + m_autoCompleteValue.SchemaObject.AutoCompletePathSeperator) && value.Any(char.IsLetterOrDigit))
{
value = value.Substring(0, value.Length - 4);
int startIndex = value.LastIndexOf(m_autoCompleteValue.SchemaObject.AutoCompletePathSeperator);
if (startIndex == -1)
startIndex = m_autoCompleteValue.SchemaObject.Prefix.Length;
else
{
startIndex++;
}
m_jsonEditorViewModel.TextDocument.Replace(
m_jsonEditorViewModel.Caret.Offset - 4 - (value.Length - startIndex), (value.Length - startIndex) + 4, "");
}
m_jsonEditorViewModel.UpdateAutoCompletList = true;
}
示例11: SetUpFixture
public void SetUpFixture()
{
string ruby = "class Test\r\n" +
"\tdef initialize\r\n" +
"\t\tputs 'test'\r\n" +
"\tend\r\n" +
"end";
DefaultProjectContent projectContent = new DefaultProjectContent();
RubyParser parser = new RubyParser();
compilationUnit = parser.Parse(projectContent, @"C:\test.rb", ruby);
if (compilationUnit.Classes.Count > 0) {
c = compilationUnit.Classes[0];
if (c.Methods.Count > 0) {
method = c.Methods[0];
}
TextArea textArea = new TextArea();
document = new TextDocument();
textArea.Document = document;
textArea.Document.Text = ruby;
// Get folds.
ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(textArea);
ParseInformation parseInfo = new ParseInformation(compilationUnit);
foldingStrategy.UpdateFoldings(parseInfo);
List<FoldingSection> folds = new List<FoldingSection>(foldingStrategy.FoldingManager.AllFoldings);
if (folds.Count > 1) {
classFold = folds[0];
methodFold = folds[1];
}
}
}
示例12: Execute
public void Execute(object arg)
{
ta = arg as TextArea;
int begin, end, caret;
if ( ta!=null){
if (CanExecute()){
ViSDGlobalCount.UpdLastUsed( cmdf, ta );
caret = ta.Caret.Offset;
while( IsLetter( caret-1 )) caret--;
begin = caret;
while( IsLetter(caret+1)) caret++;
end = caret;
int lenght = end - begin + 1;
ViSDGlobalWordSearch.SearchedWord=ta.Document.GetText( begin, lenght);
if ( begin>0)
ta.Caret.Offset = begin-1;
else
ta.Caret.Offset = ta.Document.TextLength-1;
cmdf.Execute(ta);
}else{
ViSDGlobalCount.ResetAll();
}
}
}
示例13: SharpDevelopCompletionWindow
public SharpDevelopCompletionWindow(ITextEditor editor, TextArea textArea, ICompletionItemList itemList) : base(textArea)
{
if (editor == null)
throw new ArgumentNullException("editor");
if (itemList == null)
throw new ArgumentNullException("itemList");
if (!itemList.ContainsAllAvailableItems) {
// If more items are available (Ctrl+Space wasn't pressed), show this hint
this.EmptyText = StringParser.Parse("${res:ICSharpCode.AvalonEdit.AddIn.SharpDevelopCompletionWindow.EmptyText}");
}
InitializeComponent();
this.Editor = editor;
this.itemList = itemList;
ICompletionItem suggestedItem = itemList.SuggestedItem;
foreach (ICompletionItem item in itemList.Items) {
ICompletionData adapter = new CodeCompletionDataAdapter(this, item);
this.CompletionList.CompletionData.Add(adapter);
if (item == suggestedItem)
this.CompletionList.SelectedItem = adapter;
}
this.StartOffset -= itemList.PreselectionLength;
this.EndOffset += itemList.PostselectionLength;
}
示例14: Execute
public void Execute(object arg)
{
ViSDGlobalCount.ResetAll();
ta = arg as TextArea;
int begin=-1;
int end=-1;
if ( ta!=null ){
double TopLine = ta.TextView.ScrollOffset.Y;
foreach( VisualLine vl in ta.TextView.VisualLines){
if ( begin == -1 ){
if ( vl.VisualTop>=TopLine) {
begin = vl.FirstDocumentLine.LineNumber;
}
} else{
if (((vl.VisualTop +2*vl.Height)>=(TopLine+ta.TextView.ActualHeight))||
((vl.VisualTop +1*vl.Height)>=(ta.TextView.DocumentHeight))) {
end = vl.LastDocumentLine.LineNumber;
break;
}
}
}
if ( (begin >=0)&&( end >=0)){
ta.Caret.Line = begin + (end - begin)/2;
return;
}
}
}
示例15: PythonConsoleCompletionWindow
/// <summary>
/// Creates a new code completion window.
/// </summary>
public PythonConsoleCompletionWindow(TextArea textArea, PythonTextEditor textEditor)
: base(textArea)
{
// keep height automatic
this.completionDataProvider = textEditor.CompletionProvider;
this.textEditor = textEditor;
this.CloseAutomatically = true;
this.SizeToContent = SizeToContent.Height;
this.MaxHeight = 300;
this.Width = 175;
this.Content = completionList;
// prevent user from resizing window to 0x0
this.MinHeight = 15;
this.MinWidth = 30;
toolTip.PlacementTarget = this;
toolTip.Placement = PlacementMode.Right;
toolTip.Closed += toolTip_Closed;
completionList.InsertionRequested += completionList_InsertionRequested;
completionList.SelectionChanged += completionList_SelectionChanged;
AttachEvents();
updateDescription = new DispatcherTimer();
updateDescription.Tick += new EventHandler(completionList_UpdateDescription);
updateDescriptionInterval = TimeSpan.FromSeconds(0.3);
EventInfo eventInfo = typeof(TextView).GetEvent("ScrollOffsetChanged");
Delegate methodDelegate = Delegate.CreateDelegate(eventInfo.EventHandlerType, (this as CompletionWindowBase), "TextViewScrollOffsetChanged");
eventInfo.RemoveEventHandler(this.TextArea.TextView, methodDelegate);
}