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


C# TextEditor.GetTextEditorData方法代码示例

本文整理汇总了C#中TextEditor.GetTextEditorData方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.GetTextEditorData方法的具体用法?C# TextEditor.GetTextEditorData怎么用?C# TextEditor.GetTextEditorData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextEditor的用法示例。


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

示例1: InsertNewLine

		public void InsertNewLine (TextEditor editor, NewLineInsertion insertion, ref int offset)
		{
			string str = null;
			switch (insertion) {
			case NewLineInsertion.Eol:
				str = editor.GetTextEditorData ().EolMarker;
				break;
			case NewLineInsertion.BlankLine:
				str = editor.GetTextEditorData ().EolMarker + editor.GetTextEditorData ().EolMarker;
				break;
			default:
				return;
			}
			
			offset += editor.Insert (offset, str);
		}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:16,代码来源:InsertionCursorEditMode.cs

示例2: CreateInsertionPoint

		string CreateInsertionPoint (string input, string text, NewLineInsertion before, NewLineInsertion after)
		{
			int idx = input.IndexOf ('$');
			Assert.Greater (idx, -1);
			TextEditor editor = new TextEditor ();
			editor.Document.Text = input.Substring (0, idx) + input.Substring (idx + 1);
			InsertionPoint point = new InsertionPoint (editor.Document.OffsetToLocation (idx), before, after);
			point.Insert (editor.GetTextEditorData (), text);
			return editor.Document.Text;
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:10,代码来源:InsertionModeTests.cs

示例3: Insert

		public void Insert (TextEditor editor, string text)
		{
			int offset = editor.Document.LocationToOffset (Location);
			editor.Document.BeginAtomicUndo ();
			text = editor.GetTextEditorData ().FormatString (Location, text);
			
			LineSegment line = editor.Document.GetLineByOffset (offset);
			
			int insertionOffset = line.Offset;
			offset = insertionOffset;
			InsertNewLine (editor, LineBefore, ref offset);
			
			offset += editor.Insert (offset, text);
			InsertNewLine (editor, LineAfter, ref offset);
			editor.Document.EndAtomicUndo ();
		}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:16,代码来源:InsertionCursorEditMode.cs

示例4: TextViewMargin

		public TextViewMargin (TextEditor textEditor)
		{
			if (textEditor == null)
				throw new ArgumentNullException ("textEditor");
			this.textEditor = textEditor;

			textEditor.Document.TextReplaced += HandleTextReplaced;
			base.cursor = xtermCursor;
			textEditor.HighlightSearchPatternChanged += delegate {
				selectedRegions.Clear ();
				RefreshSearchMarker ();
			};
			textEditor.Document.LineChanged += TextEditorDocumentLineChanged;
			textEditor.GetTextEditorData ().SearchChanged += HandleSearchChanged;
			markerLayout = PangoUtil.CreateLayout (textEditor);
			defaultLayout = PangoUtil.CreateLayout (textEditor);

			textEditor.Document.EndUndo += HandleEndUndo;
			textEditor.SelectionChanged += UpdateBracketHighlighting;
			textEditor.Document.Undone += HandleUndone; 
			textEditor.Document.Redone += HandleUndone;
			textEditor.TextArea.FocusInEvent += HandleFocusInEvent;
			textEditor.TextArea.FocusOutEvent += HandleFocusOutEvent;
			Caret.PositionChanged += UpdateBracketHighlighting;
			textEditor.VScroll += HandleVAdjustmentValueChanged;
		}
开发者ID:OnorioCatenacci,项目名称:monodevelop,代码行数:26,代码来源:TextViewMargin.cs

示例5: TextViewMargin

		public TextViewMargin (TextEditor textEditor)
		{
			if (textEditor == null)
				throw new ArgumentNullException ("textEditor");
			this.textEditor = textEditor;
			
			textEditor.Document.TextReplaced += delegate(object sender, ReplaceEventArgs e) {
				if (mouseSelectionMode == MouseSelectionMode.Word && e.Offset < mouseWordStart) {
					int delta = -e.Count;
					if (!string.IsNullOrEmpty (e.Value))
						delta += e.Value.Length;
					mouseWordStart += delta;
					mouseWordEnd += delta;
				}
			};
			base.cursor = xtermCursor;
			textEditor.HighlightSearchPatternChanged += delegate { 
				selectedRegions.Clear (); 
				RefreshSearchMarker ();
			};
			//			textEditor.SelectionChanged += delegate { DisposeLayoutDict (); };
			textEditor.Document.TextReplaced += delegate(object sender, ReplaceEventArgs e) {
				if (selectedRegions.Count == 0)
					return;
				List<ISegment> newRegions = new List<ISegment> (this.selectedRegions);
				Document.UpdateSegments (newRegions, e);
				this.selectedRegions = newRegions;
				RefreshSearchMarker ();
			};
			textEditor.Document.LineChanged += TextEditorDocumentLineChanged;
			textEditor.GetTextEditorData ().SearchChanged += HandleSearchChanged;
			markerLayout = PangoUtil.CreateLayout (textEditor);
			
			textEditor.Document.EndUndo += UpdateBracketHighlighting;
			textEditor.SelectionChanged += UpdateBracketHighlighting;
			textEditor.Document.Undone += delegate {
				UpdateBracketHighlighting (this, EventArgs.Empty);
			};
			textEditor.Document.Redone += delegate {
				UpdateBracketHighlighting (this, EventArgs.Empty);
			};
			Caret.PositionChanged += UpdateBracketHighlighting;
			textEditor.VScroll += HandleVAdjustmentValueChanged;
		}
开发者ID:natosha,项目名称:monodevelop,代码行数:44,代码来源:TextViewMargin.cs

示例6: SetRevision

		public void SetRevision (TextEditor toEditor, Revision rev)
		{
			BackgroundWorker worker = new BackgroundWorker ();
			worker.DoWork += delegate(object sender, DoWorkEventArgs e) {
				Revision workingRevision = (Revision)e.Argument;
				string text = null;
				try {
					text = info.Item.Repository.GetTextAtRevision (info.VersionInfo.LocalPath, workingRevision);
				} catch (Exception ex) {
					text = string.Format (GettextCatalog.GetString ("Error while getting the text of revision {0}:\n{1}"), workingRevision, ex.ToString ());
					MessageService.ShowError (text);
				}
				e.Result = new KeyValuePair<Revision, string> (workingRevision, text);
			};
			
			worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) {
				Application.Invoke (delegate {
					var result = (KeyValuePair<Revision, string>)e.Result;
					var box = toEditor == editors[0] ? diffComboBox : originalComboBox;
					RemoveLocal (toEditor.GetTextEditorData ());
					box.SetItem (string.Format (GettextCatalog.GetString ("Revision {0}\t{1}\t{2}"), result.Key, result.Key.Time, result.Key.Author), null, result.Key);
					toEditor.Text = result.Value;
					IdeApp.Workbench.StatusBar.AutoPulse = false;
					IdeApp.Workbench.StatusBar.EndProgress ();
					box.Sensitive = true;
					UpdateDiff ();
				});
			};
			
			worker.RunWorkerAsync (rev);
			IdeApp.Workbench.StatusBar.BeginProgress (string.Format (GettextCatalog.GetString ("Retrieving revision {0}..."), rev.ToString ()));
			IdeApp.Workbench.StatusBar.AutoPulse = true;
			
			if (toEditor == editors[0]) {
				diffRevision = rev;
			} else {
				originalRevision = rev;
			}
	
			var box2 = toEditor == editors[0] ? diffComboBox : originalComboBox;
			box2.Sensitive = false;
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:42,代码来源:ComparisonWidget.cs

示例7: DomLocation

        //MonoDevelop.Ide.Gui.Document document)
        /// <summary>
        /// Don't use this unless you're implementing ICodeTemplateWidget. Use Insert instead.
        /// </summary>
        /*		public TemplateResult InsertTemplateContents (TextEditor editor)//(MonoDevelop.Ide.Gui.Document document)
        {
            //ProjectDom dom = document.Dom;
            //ParsedDocument doc = document.ParsedDocument ?? MonoDevelop.Projects.Dom.Parser.ProjectDomService.GetParsedDocument (dom, document.FileName);
            //MonoDevelop.Ide.Gui.TextEditor editor = document.TextEditor;

            Mono.TextEditor.TextEditorData data = editor.GetTextEditorData();

            int offset = data.Caret.Offset;
            int line, col;
            editor.GetLineColumnFromPosition (offset, out line, out col);
        //			string leadingWhiteSpace = GetLeadingWhiteSpace (editor, editor.CursorLine);

            TemplateContext context = new TemplateContext {
                Template = this,
                //Document = document,
                //ProjectDom = dom,
                //ParsedDocument = doc,
                InsertPosition = new DomLocation (line, col),
                LineIndent = GetIndent (editor, line, 0),
                TemplateCode = IndentCode (Code, document.TextEditorData.EolMarker, GetIndent (editor, line, 0))
            };

            if (data.IsSomethingSelected) {
                int start = data.SelectionRange.Offset;
                while (Char.IsWhiteSpace (data.Document.GetCharAt (start))) {
                    start++;
                }
                int end = data.SelectionRange.EndOffset;
                while (Char.IsWhiteSpace (data.Document.GetCharAt (end - 1))) {
                    end--;
                }
                context.LineIndent = GetIndent (editor, data.Document.OffsetToLineNumber (start) + 1, 0);
                context.SelectedText = RemoveIndent (data.Document.GetTextBetween (start, end), context.LineIndent);
                data.Remove (start, end - start);
                offset = start;
            } else {
                string word = GetWordBeforeCaret (editor).Trim ();
                if (word.Length > 0)
                    offset = DeleteWordBeforeCaret (editor);
            }

            TemplateResult template = FillVariables (context);
            template.InsertPosition = offset;
            document.TextEditorData.Insert (offset, template.Code);

            if (template.CaretEndOffset >= 0) {
                data.Caret.Offset = offset + template.CaretEndOffset;
            } else {
                data.Caret.Offset= offset + template.Code.Length;
            }
            return template;
        }*/
        public CodeTemplate.TemplateResult InsertTemplateContents(TextEditor editor)
        {
            //ProjectDom dom = document.Dom;
            //ParsedDocument doc = document.ParsedDocument ?? MonoDevelop.Projects.Dom.Parser.ProjectDomService.GetParsedDocument (dom, document.FileName);
            //Mono.TextEditor.TextEditorData data = document.Editor;
            Mono.TextEditor.TextEditorData data = editor.GetTextEditorData();

            int offset = data.Caret.Offset;
            //			string leadingWhiteSpace = GetLeadingWhiteSpace (editor, editor.CursorLine);

            TemplateContext context = new TemplateContext {
                Template = this,
                Document = data,
                //ProjectDom = dom,
                //ParsedDocument = doc,
                InsertPosition = data.Caret.Location,
                LineIndent = data.Document.GetLineIndent (data.Caret.Line),
                TemplateCode = Code
            };
            if (editor.IsSomethingSelected) {//data.IsSomethingSelected
                int start = data.SelectionRange.Offset;
                while (Char.IsWhiteSpace (data.Document.GetCharAt (start))) {
                    start++;
                }
                int end = data.SelectionRange.EndOffset;
                while (Char.IsWhiteSpace (data.Document.GetCharAt (end - 1))) {
                    end--;
                }
                context.LineIndent = data.Document.GetLineIndent (data.Document.OffsetToLineNumber (start));
                context.SelectedText = RemoveIndent (data.Document.GetTextBetween (start, end), context.LineIndent);
                data.Remove (start, end - start);
                offset = start;
            } else {
                string word = GetWordBeforeCaret (editor).Trim ();
                if (word.Length > 0)
                    offset = DeleteWordBeforeCaret (editor);
            }

            TemplateResult template = FillVariables (context);
            template.InsertPosition = offset;
            data.Insert (offset, template.Code);

            int newoffset;
//.........这里部分代码省略.........
开发者ID:moscrif,项目名称:ide,代码行数:101,代码来源:CodeTemplate.cs


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