本文整理汇总了C#中Gtk.GetSlice方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.GetSlice方法的具体用法?C# Gtk.GetSlice怎么用?C# Gtk.GetSlice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk
的用法示例。
在下文中一共展示了Gtk.GetSlice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyUrlToBlock
void ApplyUrlToBlock (Gtk.TextIter start, Gtk.TextIter end)
{
NoteBuffer.GetBlockExtents (ref start,
ref end,
256 /* max url length */,
Note.TagTable.UrlTag);
Buffer.RemoveTag (Note.TagTable.UrlTag, start, end);
for (Match match = regex.Match (start.GetSlice (end));
match.Success;
match = match.NextMatch ()) {
System.Text.RegularExpressions.Group group = match.Groups [1];
/*
Logger.Log ("Highlighting url: '{0}' at offset {1}",
group,
group.Index);
*/
Gtk.TextIter start_cpy = start;
start_cpy.ForwardChars (group.Index);
end = start_cpy;
end.ForwardChars (group.Length);
Buffer.ApplyTag (Note.TagTable.UrlTag, start_cpy, end);
}
}
示例2: HighlightInBlock
void HighlightInBlock (Gtk.TextIter start, Gtk.TextIter end)
{
IList<TrieHit> hits = Manager.TitleTrie.FindMatches (start.GetSlice (end));
foreach (TrieHit hit in hits) {
DoHighlight (hit, start, end);
}
}
示例3: GetUrl
string GetUrl (Gtk.TextIter start, Gtk.TextIter end)
{
string url = start.GetSlice (end);
// FIXME: Needed because the file match is greedy and
// eats a leading space.
url = url.Trim ();
// Simple url massaging. Add to 'http://' to the front
// of www.foo.com, 'mailto:' to [email protected], 'file://'
// to /home/alex/foo.
if (url.StartsWith ("www."))
url = "http://" + url;
else if (url.StartsWith ("/") &&
url.LastIndexOf ("/") > 1)
url = "file://" + url;
else if (url.StartsWith ("~/"))
url = "file://" +
Path.Combine (Environment.GetEnvironmentVariable ("HOME"),
url.Substring (2));
else if (Regex.IsMatch (url,
@"^(?!(news|mailto|http|https|ftp|file|irc):)[email protected]{2,}$",
RegexOptions.IgnoreCase))
url = "mailto:" + url;
return url;
}