當前位置: 首頁>>代碼示例>>C#>>正文


C# TextEditor.GetTextAt方法代碼示例

本文整理匯總了C#中MonoDevelop.Ide.Gui.TextEditor.GetTextAt方法的典型用法代碼示例。如果您正苦於以下問題:C# TextEditor.GetTextAt方法的具體用法?C# TextEditor.GetTextAt怎麽用?C# TextEditor.GetTextAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MonoDevelop.Ide.Gui.TextEditor的用法示例。


在下文中一共展示了TextEditor.GetTextAt方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: IsMatchAt

		static bool IsMatchAt (TextEditor editor, int offset, string abbrevWord)
		{
			if (offset + abbrevWord.Length >= editor.Length)
				return false;
			if (offset > 0 && IsIdentifierPart (editor.GetCharAt (offset - 1)))
				return false;
			if (offset + abbrevWord.Length < editor.Length && !IsIdentifierPart (editor.GetCharAt (offset + abbrevWord.Length)))
				return false;
			return editor.GetTextAt (offset, abbrevWord.Length) == abbrevWord;
		}
開發者ID:pabloescribanoloza,項目名稱:monodevelop,代碼行數:10,代碼來源:DynamicAbbrevHandler.cs

示例2: GetSymbolInfoAsync

		public static Task<RefactoringSymbolInfo> GetSymbolInfoAsync (DocumentContext document, TextEditor editor, CancellationToken cancellationToken = default (CancellationToken))
		{
			if (editor.IsSomethingSelected) {
				var selectionRange = editor.SelectionRange;
				if (editor.GetTextAt (selectionRange).Any (ch => !char.IsLetterOrDigit (ch) && ch !='_')) {
					return Task.FromResult (RefactoringSymbolInfo.Empty);
				}
				return GetSymbolInfoAsync (document, selectionRange.Offset, cancellationToken);
			}
			return GetSymbolInfoAsync (document, editor.CaretOffset, cancellationToken);
		}
開發者ID:sushihangover,項目名稱:monodevelop,代碼行數:11,代碼來源:RefactoringSymbolInfo.cs

示例3: GetItem

		public override async Task<TooltipItem> GetItem (TextEditor editor, DocumentContext ctx, int offset, CancellationToken token = default(CancellationToken))
		{
			if (offset >= editor.Length)
				return null;

			if (!DebuggingService.IsDebugging || DebuggingService.IsRunning)
				return null;

			StackFrame frame = DebuggingService.CurrentFrame;
			if (frame == null)
				return null;

			var ed = CompileErrorTooltipProvider.GetExtensibleTextEditor (editor);
			if (ed == null)
				return null;
			string expression = null;
			int startOffset;

			if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) {
				startOffset = ed.SelectionRange.Offset;
				expression = ed.SelectedText;
			} else {
				var doc = ctx;
				if (doc == null || doc.ParsedDocument == null)
					return null;

				var resolver = doc.GetContent<IDebuggerExpressionResolver> ();
				var data = doc.GetContent<SourceEditorView> ();

				if (resolver != null) {
					var result = await resolver.ResolveExpressionAsync (editor, doc, offset, token);
					expression = result.Text;
					startOffset = result.Span.Start;
				} else {
					int endOffset = data.GetTextEditorData ().FindCurrentWordEnd (offset);
					startOffset = data.GetTextEditorData ().FindCurrentWordStart (offset);

					expression = editor.GetTextAt (startOffset, endOffset - startOffset);
				}
			}
			
			if (string.IsNullOrEmpty (expression))
				return null;

			var options = DebuggingService.DebuggerSession.EvaluationOptions.Clone ();
			options.AllowMethodEvaluation = true;
			options.AllowTargetInvoke = true;

			var val = frame.GetExpressionValue (expression, options);

			if (val == null || val.IsUnknown || val.IsNotSupported)
				return null;
			
			val.Name = expression;
			
			return new TooltipItem (val, startOffset, expression.Length);
		}
開發者ID:gAdrev,項目名稱:monodevelop,代碼行數:57,代碼來源:DebugValueTooltipProvider.cs

示例4: ChangeForeColor

            public void ChangeForeColor(TextEditor editor, Chunk chunk, ref Cairo.Color color)
            {
                if (chunk.Length < 1)
                    return;

                switch (chunk.Style)
                {
                    case "Plain Text":
                    case "Plain Texta":
                        if (!hasEvaluatedBackgroundBrightness)
                        {
                            hasEvaluatedBackgroundBrightness = true;
                            IsDarkBackground = HslColor.Brightness(editor.ColorStyle.PlainText.Background) < 0.5;
                        }

                        color = DiffbasedHighlighting.GetColor(editor.GetTextAt(chunk).Trim());
                        if (IsDarkBackground)
                            color = new Cairo.Color(1.0 - color.R, 1.0 - color.G, 1.0 - color.B, color.A);
                        break;
                    case "String":
                        color = new Cairo.Color(0.8, 0, 0);
                        break;
                    default:
                        if (chunk.Style.StartsWith("Keyword"))
                            chunk.Style = "Plain Text";
                        break;
                }
            }
開發者ID:foerdi,項目名稱:Mono-D,代碼行數:28,代碼來源:DSyntaxMode.cs


注:本文中的MonoDevelop.Ide.Gui.TextEditor.GetTextAt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。