本文整理汇总了C#中Mono.TextEditor.TextDocument.GetTextAt方法的典型用法代码示例。如果您正苦于以下问题:C# TextDocument.GetTextAt方法的具体用法?C# TextDocument.GetTextAt怎么用?C# TextDocument.GetTextAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.TextEditor.TextDocument
的用法示例。
在下文中一共展示了TextDocument.GetTextAt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
protected override void Run (object dataItem)
{
base.Run (dataItem);
if (IdeApp.Workspace == null) return;
if (IdeApp.Workbench.ActiveDocument == null || IdeApp.Workbench.ActiveDocument.FileName == FilePath.Null) return;
var document = IdeApp.Workbench.ActiveDocument;
ResolveResult resolveResult = null;
object item = CurrentRefactoryOperationsHandler.GetItem (document, out resolveResult);
IMethod method = item as IMethod;
if (method == null)
return;
ISearchProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor(true, true);
ThreadPool.QueueUserWorkItem((data) =>
{
try
{
ImplementationsFinder.Find(method, implementation =>
{
FileProvider fileProvider = new FileProvider(implementation.Region.FileName);
TextDocument doc = new TextDocument();
doc.Text = fileProvider.ReadString();
int offset = doc.LocationToOffset(implementation.Region.BeginLine, implementation.Region.BeginColumn);
while ((offset + implementation.Name.Length) < doc.TextLength)
{
if (doc.GetTextAt(offset, implementation.Name.Length) == implementation.Name)
{
break;
}
offset++;
}
monitor.ReportResult (new MonoDevelop.Ide.FindInFiles.SearchResult(fileProvider, offset, implementation.Name.Length));
});
}
catch (Exception exception)
{
if (monitor != null)
{
monitor.ReportError("Error finding references", exception);
}
else
{
LoggingService.LogError("Error finding references", exception);
}
}
finally
{
if (monitor != null)
{
monitor.Dispose();
}
}
});
}
示例2: StartsWithListMember
static int StartsWithListMember (TextDocument document, List<string> list, int offset)
{
for (int i = 0; i < list.Count; i++) {
string item = list[i];
if (offset + item.Length < document.TextLength) {
if (document.GetTextAt (offset, item.Length) == item)
return i;
}
}
return -1;
}
示例3: Analyze
public override void Analyze (TextDocument doc, DocumentLine line, Chunk startChunk, int startOffset, int endOffset)
{
if (endOffset <= startOffset || startOffset >= doc.TextLength || 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: Analyze
public override void Analyze (TextDocument doc, DocumentLine line, Chunk startChunk, int startOffset, int endOffset)
{
if (endOffset <= startOffset || startOffset >= doc.TextLength || inUpdate)
return;
if (startChunk.Style != Highlighting.ColorScheme.CommentsSingleLineKey && startChunk.Style != Highlighting.ColorScheme.CommentsBlockKey)
return;
inUpdate = true;
try {
string text = doc.GetTextAt (startOffset, System.Math.Min (endOffset, doc.TextLength) - startOffset);
int startColumn = startOffset - line.Offset;
var markers = new List <UrlMarker> (line.Markers.OfType<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;
}
}
示例5: CreateFileContent
public override System.IO.Stream CreateFileContent(SolutionItem policyParent, Project project, string language, string fileName, string identifier)
{
if (Outer.FormatCode)
{
return base.CreateFileContent(policyParent, project, language, fileName, identifier);
}
var model = GetTagModel (policyParent, project, language, identifier, fileName);
string text = CreateContent (project, model.OverrideTags, language);
text = ProcessContent (text, model);
var memoryStream = new MemoryStream ();
byte[] preamble = Encoding.UTF8.GetPreamble ();
memoryStream.Write (preamble, 0, preamble.Length);
if (AddStandardHeader) {
string header = StandardHeaderService.GetHeader (policyParent, fileName, true);
byte[] bytes = Encoding.UTF8.GetBytes (header);
memoryStream.Write (bytes, 0, bytes.Length);
}
var textDocument = new TextDocument ();
textDocument.Text = text;
var textStylePolicy = (policyParent == null) ? PolicyService.GetDefaultPolicy<TextStylePolicy> ("text/plain") : policyParent.Policies.Get<TextStylePolicy> ("text/plain");
string eolMarker = TextStylePolicy.GetEolMarker (textStylePolicy.EolMarker);
byte[] eol = Encoding.UTF8.GetBytes (eolMarker);
string indent = (!textStylePolicy.TabsToSpaces) ? null : new string (' ', textStylePolicy.TabWidth);
foreach (DocumentLine current in textDocument.Lines) {
string line = textDocument.GetTextAt (current.Offset, current.Length);
if (indent != null) {
line = line.Replace (" ", indent);
}
byte[] bytes = Encoding.UTF8.GetBytes (line);
memoryStream.Write (bytes, 0, bytes.Length);
memoryStream.Write (eol, 0, eol.Length);
}
memoryStream.Position = 0;
return memoryStream;
}
示例6: GetJumpTypePartSearchResult
static MonoDevelop.Ide.FindInFiles.SearchResult GetJumpTypePartSearchResult (IUnresolvedTypeDefinition part)
{
var provider = new MonoDevelop.Ide.FindInFiles.FileProvider (part.Region.FileName);
var doc = new Mono.TextEditor.TextDocument ();
doc.Text = provider.ReadString ();
int position = doc.LocationToOffset (part.Region.BeginLine, part.Region.BeginColumn);
while (position + part.Name.Length < doc.TextLength) {
if (doc.GetTextAt (position, part.Name.Length) == part.Name)
break;
position++;
}
return new MonoDevelop.Ide.FindInFiles.SearchResult (provider, position, part.Name.Length);
}
示例7: Reindent
string Reindent (string text, string indent)
{
var doc = new TextDocument ();
doc.Text = text;
var result = new StringBuilder ();
foreach (DocumentLine line in doc.Lines) {
if (result.Length > 0)
result.Append (indent);
result.Append (doc.GetTextAt (line));
}
return result.ToString ();
}
示例8: 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);
}
var doc = new TextDocument ();
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).EndOffsetIncludingDelimiter;
msg = text.Substring (idx + 1) + doc.GetTextAt (offset, doc.TextLength - offset);
break;
}
}
return msg.TrimStart (' ', '\t');
}