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


C# TextArea类代码示例

本文整理汇总了C#中TextArea的典型用法代码示例。如果您正苦于以下问题:C# TextArea类的具体用法?C# TextArea怎么用?C# TextArea使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Execute

        public override void Execute(TextArea textArea)
        {
            Point position = textArea.Caret.Position;
            List<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldedFoldingsWithEnd(position.Y);
            FoldMarker justBeforeCaret = null;
            foreach (FoldMarker fm in foldings) {
                if (fm.EndColumn == position.X) {
                    justBeforeCaret = fm;
                    break; // the first folding found is the folding with the smallest Startposition
                }
            }

            if (justBeforeCaret != null) {
                position.Y = justBeforeCaret.StartLine;
                position.X = justBeforeCaret.StartColumn;
            } else {
                if (position.X > 0) {
                    --position.X;
                } else if (position.Y  > 0) {
                    LineSegment lineAbove = textArea.Document.GetLineSegment(position.Y - 1);
                    position = new Point(lineAbove.Length, position.Y - 1);
                }
            }

            textArea.Caret.Position = position;
            textArea.SetDesiredColumn();
        }
开发者ID:jumpinjackie,项目名称:fdotoolbox,代码行数:27,代码来源:CaretActions.cs

示例2: SmartIndentLine

    /// <summary>
    /// Indents the specified 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;
      CSharpIndentationReformatter r = new CSharpIndentationReformatter();

      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:Finarch,项目名称:DigitalRune.Windows.TextEditor,代码行数:38,代码来源:HlslFormattingStrategy.cs

示例3: Execute

 public override void Execute(TextArea textArea)
 {
     foreach (FoldMarker fm in  textArea.Document.FoldingManager.FoldMarker) {
         fm.IsFolded = fm.FoldType == FoldType.MemberBody || fm.FoldType == FoldType.Region;
     }
     //textArea.Refresh();
 }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:7,代码来源:FoldActions.cs

示例4: GenerateCompletionData

		public ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped) {
			List<ICompletionData> completionData = new List<ICompletionData>();

			int column = Math.Max(0, textArea.Caret.Column - 1);
			LineSegment line = textArea.Document.GetLineSegment(textArea.Caret.Line);
			TextWord word = line.GetWord(column);

			string itemText = (word != null ? word.Word : "") + char.ToLower(charTyped);

			if (mScriptContent.CommandsFlat.ContainsKey(itemText) != false) {
				foreach (string key in mScriptContent.CommandsFlat[itemText]) {
					completionData.Add(new ScriptCompletionData(mScriptContent.Commands[key].Name, mScriptContent.Commands[key].Description, 0));
				}
			}
			if (mScriptContent.ConstantsFlat.ContainsKey(itemText) != false) {
				foreach (string key in mScriptContent.ConstantsFlat[itemText]) {
					completionData.Add(new ScriptCompletionData(mScriptContent.Constants[key].Name, mScriptContent.Constants[key].Description, 0));
				}
			}
			if (mScriptContent.Maps.ContainsKey(itemText) != false) {
				foreach (string key in mScriptContent.Maps[itemText]) {
					completionData.Add(new ScriptCompletionData(key, key, 0));
				}
			}

			return completionData.ToArray();
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:27,代码来源:ScriptCompletionProvider.cs

示例5: Execute

 public override void Execute(TextArea textArea)
 {
     List<FoldMarker> foldMarkers = textArea.Document.FoldingManager.GetFoldingsWithStart(textArea.Caret.Line);
     if (foldMarkers.Count != 0)
     {
         foreach (FoldMarker fm in foldMarkers)
             fm.IsFolded = !fm.IsFolded;
     }
     else
     {
         foldMarkers = textArea.Document.FoldingManager.GetFoldingsContainsLineNumber(textArea.Caret.Line);
         if (foldMarkers.Count != 0)
         {
             FoldMarker innerMost = foldMarkers[0];
             for (int i = 1; i < foldMarkers.Count; i++)
             {
                 if (new TextLocation(foldMarkers[i].StartColumn, foldMarkers[i].StartLine) >
                         new TextLocation(innerMost.StartColumn, innerMost.StartLine))
                 {
                     innerMost = foldMarkers[i];
                 }
             }
             innerMost.IsFolded = !innerMost.IsFolded;
         }
     }
     textArea.Document.FoldingManager.NotifyFoldingsChanged(EventArgs.Empty);
 }
开发者ID:KindDragon,项目名称:ICSharpCode.TextEditor.V4,代码行数:27,代码来源:FoldActions.cs

示例6: IndentLines

    /// <summary>
    /// This function sets the indentation level in a range of lines.
    /// </summary>
    /// <param name="textArea">The text area.</param>
    /// <param name="begin">The begin.</param>
    /// <param name="end">The end.</param>
    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);
      CSharpIndentationReformatter r = new CSharpIndentationReformatter();
      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:Finarch,项目名称:DigitalRune.Windows.TextEditor,代码行数:36,代码来源:HlslFormattingStrategy.cs

示例7: Execute

        /// <summary>
        /// Executes the action on a certain <see cref="TextArea"/>.
        /// </summary>
        /// <param name="textArea">The text area on which to execute the action.</param>
        public override void Execute(TextArea textArea)
        {
            foreach (Fold fold in textArea.Document.FoldingManager.Folds)
            fold.IsFolded = _predicate(fold);

              textArea.Document.FoldingManager.NotifyFoldingChanged(EventArgs.Empty);
        }
开发者ID:cavaliercoder,项目名称:expression-lab,代码行数:11,代码来源:FoldActions.cs

示例8: Execute

 public override void Execute(TextArea textArea)
 {
     if (textArea.Caret.Line != 0 || textArea.Caret.Column != 0) {
         textArea.Caret.Position = new Point(0, 0);
         textArea.SetDesiredColumn();
     }
 }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:7,代码来源:HomeEndActions.cs

示例9: GetIndentationSmart

		/// <summary>
		/// Description
		/// </summary>
		private string GetIndentationSmart(TextArea textArea, int lineNumber) {
			if (lineNumber < 0 || lineNumber > textArea.Document.TotalNumberOfLines) {
				throw new ArgumentOutOfRangeException("lineNumber");
			}

			//! TODO:
			//			- search backward the last symbol
			//			- on { or ), indend by \t
			//			- think about more indentation style
			//			- remember last ) and set next indentation -1

			LineSegment lastLine = textArea.Document.GetLineSegment(lineNumber);
			if (lastLine == null || lastLine.Words.Count == 0) {
				// No text in the last line
				return "";
			}

			// Fetch leading space of last line
			string lastLeading = GetIndentation(textArea, lineNumber);
			TextWord lastWord = lastLine.Words[lastLine.Words.Count - 1];
			if (lastWord.Type != TextWordType.Word) {
				return lastLeading;
			}
			if (mIndentationChars.Contains(lastWord.Word.Trim()) == false) {
				return lastLeading;
			}

			return lastLeading + "\t";
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:32,代码来源:ScrptFormattingStrategy.cs

示例10: Execute

        /// <remarks>
        /// Executes this edit action
        /// </remarks>
        /// <param name="textArea">The <see cref="ItextArea"/> which is used for callback purposes</param>
        public override void Execute(TextArea textArea)
        {
            if (textArea.SelectionManager.HasSomethingSelected) {
                Delete.DeleteSelection(textArea);
            } else {
                if (textArea.Caret.Offset > 0 && !textArea.IsReadOnly(textArea.Caret.Offset - 1)) {
                    textArea.BeginUpdate();
                    int curLineNr     = textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset);
                    int curLineOffset = textArea.Document.GetLineSegment(curLineNr).Offset;

                    if (curLineOffset == textArea.Caret.Offset) {
                        LineSegment line = textArea.Document.GetLineSegment(curLineNr - 1);
                        int lineEndOffset = line.Offset + line.Length;
                        int lineLength = line.Length;
                        textArea.Document.Remove(lineEndOffset, curLineOffset - lineEndOffset);
                        textArea.Caret.Position = new TextLocation(lineLength, curLineNr - 1);
                        textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new TextLocation(0, curLineNr - 1)));
                    } else {
                        int caretOffset = textArea.Caret.Offset - 1;
                        textArea.Caret.Position = textArea.Document.OffsetToPosition(caretOffset);
                        textArea.Document.Remove(caretOffset, 1);

                        textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToLineEnd, new TextLocation(textArea.Caret.Offset - textArea.Document.GetLineSegment(curLineNr).Offset, curLineNr)));
                    }
                    textArea.EndUpdate();
                }
            }
        }
开发者ID:umabiel,项目名称:WsdlUI,代码行数:32,代码来源:MiscActions.cs

示例11: GenerateRtf

		public static string GenerateRtf(TextArea textArea)
		{
			try {
				colors = new Hashtable();
				colorNum = 0;
				colorString = new StringBuilder();
				
				
				StringBuilder rtf = new StringBuilder();
				
				rtf.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1031");
				BuildFontTable(textArea.Document, rtf);
				rtf.Append('\n');
				
				string fileContent = BuildFileContent(textArea);
				BuildColorTable(textArea.Document, rtf);
				rtf.Append('\n');
				rtf.Append(@"\viewkind4\uc1\pard");
				rtf.Append(fileContent);
				rtf.Append("}");
				return rtf.ToString();
			} catch (Exception e) {
				Console.WriteLine(e.ToString());
			}
			return null;
		}
开发者ID:tangxuehua,项目名称:DataStructure,代码行数:26,代码来源:RtfWriter.cs

示例12: Initialize

        public override void Initialize()
        {
            base.Initialize();

            TextArea loveletter = new TextArea("Hello, World!", 1, 20);
            AddComponent(loveletter, 20, 200);
        }
开发者ID:Syderis,项目名称:CellSDK-Tutorials,代码行数:7,代码来源:MainScreen.cs

示例13: Execute

		/// <remarks>
		/// Executes this edit action
		/// </remarks>
		/// <param name="textArea">The <see cref="ItextArea"/> which is used for callback purposes</param>
		public override void Execute(TextArea textArea)
		{
			if (textArea.Document.ReadOnly) {
				return;
			}
			textArea.Document.UndoStack.StartUndoGroup();
			if (textArea.SelectionManager.HasSomethingSelected) {
				foreach (ISelection selection in textArea.SelectionManager.SelectionCollection) {
					int startLine = selection.StartPosition.Y;
					int endLine   = selection.EndPosition.Y;
					if (startLine != endLine) {
						textArea.BeginUpdate();
						InsertTabs(textArea.Document, selection, startLine, endLine);
						textArea.Document.UpdateQueue.Clear();
						textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, startLine, endLine));
                        textArea.EndUpdate();
					} else {
						InsertTabAtCaretPosition(textArea);
						break;
					}
				}
				textArea.Document.CommitUpdate();
				textArea.AutoClearSelection = false;
			} else {
				InsertTabAtCaretPosition(textArea);
			}
			textArea.Document.UndoStack.EndUndoGroup();
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:32,代码来源:MiscActions.cs

示例14: Execute

        /// <summary>
        /// Executes the action on a certain <see cref="TextArea"/>.
        /// </summary>
        /// <param name="textArea">The text area on which to execute the action.</param>
        public override void Execute(TextArea textArea)
        {
            if (textArea.Document.ReadOnly)
            return;

              textArea.ClipboardHandler.Paste();
        }
开发者ID:cavaliercoder,项目名称:expression-lab,代码行数:11,代码来源:ClipBoardActions.cs

示例15: Execute

        /// <remarks>
        /// Executes this edit action
        /// </remarks>
        /// <param name="textArea">The <see cref="ItextArea"/> which is used for callback purposes</param>
        public override void Execute(TextArea textArea)
        {
            if (textArea.Document.ReadOnly) {
                return;
            }
            if (textArea.SelectionManager.HasSomethingSelected) {
                textArea.BeginUpdate();
                textArea.Caret.Position = textArea.SelectionManager.SelectionCollection[0].StartPosition;
                textArea.SelectionManager.RemoveSelectedText();
                textArea.ScrollToCaret();
                textArea.EndUpdate();
            } else {

                if (textArea.Caret.Offset < textArea.Document.TextLength) {
                    textArea.BeginUpdate();
                    int curLineNr   = textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset);
                    LineSegment curLine = textArea.Document.GetLineSegment(curLineNr);

                    if (curLine.Offset + curLine.Length == textArea.Caret.Offset) {
                        if (curLineNr + 1 < textArea.Document.TotalNumberOfLines) {
                            LineSegment nextLine = textArea.Document.GetLineSegment(curLineNr + 1);

                            textArea.Document.Remove(textArea.Caret.Offset, nextLine.Offset - textArea.Caret.Offset);
                            textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new Point(0, curLineNr)));
                        }
                    } else {
                        textArea.Document.Remove(textArea.Caret.Offset, 1);
            //						textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToLineEnd, new Point(textArea.Caret.Offset - textArea.Document.GetLineSegment(curLineNr).Offset, curLineNr)));
                    }
                    textArea.UpdateMatchingBracket();
                    textArea.EndUpdate();
                }
            }
        }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:38,代码来源:MiscActions.cs


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