本文整理汇总了C#中Mono.TextEditor.Document.GetTextAt方法的典型用法代码示例。如果您正苦于以下问题:C# Document.GetTextAt方法的具体用法?C# Document.GetTextAt怎么用?C# Document.GetTextAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.TextEditor.Document
的用法示例。
在下文中一共展示了Document.GetTextAt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartsWithListMember
static int StartsWithListMember (Document document, List<string> list, int offset)
{
for (int i = 0; i < list.Count; i++) {
string item = list[i];
if (offset + item.Length < document.Length) {
if (document.GetTextAt (offset, item.Length) == item)
return i;
}
}
return -1;
}
示例2: Analyze
public override void Analyze (Document doc, LineSegment line, Chunk startChunk, int startOffset, int endOffset)
{
if (endOffset <= startOffset || startOffset >= doc.Length)
return;
string text = doc.GetTextAt (startOffset, endOffset - startOffset);
int startColumn = startOffset - line.Offset;
line.RemoveMarker (typeof(UrlMarker));
foreach (System.Text.RegularExpressions.Match m in urlRegex.Matches (text)) {
line.AddMarker (new UrlMarker (line, m.Value, UrlType.Url, syntax, startColumn + m.Index, startColumn + m.Index + m.Length));
}
foreach (System.Text.RegularExpressions.Match m in mailRegex.Matches (text)) {
line.AddMarker (new UrlMarker (line, m.Value, UrlType.Email, syntax, startColumn + m.Index, startColumn + m.Index + m.Length));
}
}
示例3: Analyze
public override void Analyze (Document doc, LineSegment line, Chunk startChunk, int startOffset, int endOffset)
{
if (endOffset <= startOffset || startOffset >= doc.Length || inUpdate)
return;
inUpdate = true;
try {
string text = doc.GetTextAt (startOffset, endOffset - startOffset);
int startColumn = startOffset - line.Offset;
var markers = new List <UrlMarker> (line.Markers.Where (m => m is UrlMarker).Cast<UrlMarker> ());
markers.ForEach (m => doc.RemoveMarker (m, false));
foreach (System.Text.RegularExpressions.Match m in urlRegex.Matches (text)) {
doc.AddMarker (line, new UrlMarker (doc, line, m.Value, UrlType.Url, syntax, startColumn + m.Index, startColumn + m.Index + m.Length), false);
}
foreach (System.Text.RegularExpressions.Match m in mailRegex.Matches (text)) {
doc.AddMarker (line, new UrlMarker (doc, line, m.Value, UrlType.Email, syntax, startColumn + m.Index, startColumn + m.Index + m.Length), false);
}
} finally {
inUpdate = false;
}
}
示例4: FormatMessage
internal static string FormatMessage (string msg)
{
StringBuilder sb = new StringBuilder ();
bool wasWs = false;
foreach (char ch in msg) {
if (ch == ' ' || ch == '\t') {
if (!wasWs)
sb.Append (' ');
wasWs = true;
continue;
}
wasWs = false;
sb.Append (ch);
}
Document doc = new Document ();
doc.Text = sb.ToString ();
for (int i = 1; i <= doc.LineCount; i++) {
string text = doc.GetLineText (i).Trim ();
int idx = text.IndexOf (':');
if (text.StartsWith ("*") && idx >= 0 && idx < text.Length - 1) {
int offset = doc.GetLine (i).EndOffset;
msg = text.Substring (idx + 1) + doc.GetTextAt (offset, doc.Length - offset);
break;
}
}
return msg.TrimStart (' ', '\t');
}
示例5: AddIndent
static string AddIndent (string text, string indent)
{
Document doc = new Document ();
doc.Text = text;
StringBuilder result = new StringBuilder ();
foreach (LineSegment line in doc.Lines) {
if (result.Length > 0)
result.Append (indent);
result.Append (doc.GetTextAt (line));
}
return result.ToString ();
}
示例6: GetIndent
static string GetIndent (string text)
{
Mono.TextEditor.Document doc = new Mono.TextEditor.Document ();
doc.Text = text;
StringBuilder result = null;
for (int i = 1; i < doc.LineCount; i++) {
LineSegment line = doc.GetLine (i);
StringBuilder lineIndent = new StringBuilder ();
foreach (char ch in doc.GetTextAt (line)) {
if (!char.IsWhiteSpace (ch))
break;
lineIndent.Append (ch);
}
if (line.EditableLength == lineIndent.Length)
continue;
if (result == null || lineIndent.Length < result.Length)
result = lineIndent;
}
if (result == null)
return "";
return result.ToString ();
}
示例7: GetJumpTypePartSearchResult
static MonoDevelop.Ide.FindInFiles.SearchResult GetJumpTypePartSearchResult (IType part)
{
var provider = new MonoDevelop.Ide.FindInFiles.FileProvider (part.CompilationUnit.FileName);
var doc = new Mono.TextEditor.Document ();
doc.Text = provider.ReadString ();
int position = doc.LocationToOffset (part.Location.Line, part.Location.Column);
while (position + part.Name.Length < doc.Length) {
if (doc.GetTextAt (position, part.Name.Length) == part.Name)
break;
position++;
}
return new MonoDevelop.Ide.FindInFiles.SearchResult (provider, position, part.Name.Length);
}
示例8: GetText
public virtual string GetText (Document doc)
{
return doc.GetTextAt (this);
}
示例9: SetDiffCellData
void SetDiffCellData (Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
{
try {
CellRendererDiff cellRendererDiff = (CellRendererDiff)cell;
Change change = store.GetValue (iter, objColumn) as Change;
cellRendererDiff.Visible = !(bool)store.GetValue (iter, statusVisibleColumn);
if (change == null || !cellRendererDiff.Visible) {
cellRendererDiff.InitCell (treeviewPreview, false, "", "");
return;
}
TextReplaceChange replaceChange = change as TextReplaceChange;
if (replaceChange == null)
return;
Mono.TextEditor.Document doc = new Mono.TextEditor.Document ();
doc.Text = System.IO.File.ReadAllText (replaceChange.FileName);
List<string> before = new List<string> ();
foreach (var line in doc.Lines) {
before.Add (doc.GetTextAt (line.Offset, line.EditableLength));
}
((Mono.TextEditor.IBuffer)doc).Replace (replaceChange.Offset, replaceChange.RemovedChars, replaceChange.InsertedText);
List<string> after = new List<string> ();
foreach (var line in doc.Lines) {
after.Add (doc.GetTextAt (line.Offset, line.EditableLength));
}
Diff diff = new Diff (before.ToArray (), after.ToArray (), true, true);
System.IO.StringWriter w = new System.IO.StringWriter();
UnifiedDiff.WriteUnifiedDiff (diff, w, replaceChange.FileName, replaceChange.FileName, 2);
cellRendererDiff.InitCell (treeviewPreview, true, w.ToString ().Trim (), replaceChange.FileName);
} catch (Exception e) {
Console.WriteLine (e);
}
}