本文整理汇总了C#中Gtk.TextBuffer.InsertWithTags方法的典型用法代码示例。如果您正苦于以下问题:C# TextBuffer.InsertWithTags方法的具体用法?C# TextBuffer.InsertWithTags怎么用?C# TextBuffer.InsertWithTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.TextBuffer
的用法示例。
在下文中一共展示了TextBuffer.InsertWithTags方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertLink
// Inserts a piece of text into the buffer, giving it the usual
// appearance of a hyperlink in a web browser: blue and underlined.
// Additionally, attaches some data on the tag, to make it recognizable
// as a link.
void InsertLink (TextBuffer buffer, ref TextIter iter, string text, int page)
{
TextTag tag = new TextTag (null);
tag.Foreground = "blue";
tag.Underline = Pango.Underline.Single;
tag_pages [tag] = page;
buffer.TagTable.Add (tag);
buffer.InsertWithTags (ref iter, text, tag);
}
示例2: AddPadding
public static void AddPadding (TextBuffer buffer, ref TextIter insertAt, string suffix)
{
DocumentTagTable tagTable = (DocumentTagTable) buffer.TagTable;
TextTag tag = tagTable.Lookup ("padding" + suffix);
if (tag == null)
tag = tagTable.CreateDynamicTag ("padding" + suffix);
buffer.InsertWithTags (ref insertAt, " ", tag);
}
示例3: ShowPage
// Fills the buffer with text and interspersed links. In any real
// hypertext app, this method would parse a file to identify the links.
void ShowPage (TextBuffer buffer, int page)
{
buffer.Text = "";
TextIter iter = buffer.StartIter;
if (page == 1) {
buffer.Insert (ref iter, "Some text to show that simple ");
InsertLink (buffer, ref iter, "hypertext", 3);
buffer.Insert (ref iter, " can easily be realized with ");
InsertLink (buffer, ref iter, "tags", 2);
buffer.Insert (ref iter, ".");
} else if (page == 2) {
buffer.Insert (ref iter,
"A tag is an attribute that can be applied to some range of text. " +
"For example, a tag might be called \"bold\" and make the text inside " +
"the tag bold. However, the tag concept is more general than that; " +
"tags don't have to affect appearance. They can instead affect the " +
"behavior of mouse and key presses, \"lock\" a range of text so the " +
"user can't edit it, or countless other things.\n");
InsertLink (buffer, ref iter, "Go back", 1);
} else if (page == 3) {
TextTag tag = buffer.TagTable.Lookup ("bold");
if (tag == null) {
tag = new TextTag ("bold");
tag.Weight = Pango.Weight.Bold;
buffer.TagTable.Add (tag);
}
buffer.InsertWithTags (ref iter, "hypertext:\n", tag);
buffer.Insert (ref iter,
"machine-readable text that is not sequential but is organized " +
"so that related items of information are connected.\n");
InsertLink (buffer, ref iter, "Go back", 1);
}
}
示例4: AddText
public static void AddText (TextBuffer buffer, ref TextIter insertAt, string data, TextTag tag)
{
DocumentTagTable tagTable = (DocumentTagTable) buffer.TagTable;
TextTag textTag = tagTable.Lookup ("significant-whitespace" + "#" + tag.Name);
if (textTag == null)
textTag = tagTable.CreateDynamicTag ("significant-whitespace" + "#" + tag.Name);
string trimData = data.Trim ();
int index = data.IndexOf (trimData);
string startSpace = data.Substring (0, index);
string prefixSpace = String.Empty;
if (!startSpace.Equals (String.Empty)) {
if (startSpace.Length == 1) {
prefixSpace = startSpace;
startSpace = String.Empty;
} else {
prefixSpace = startSpace.Substring (startSpace.Length - 1);
startSpace = startSpace.Substring (0, startSpace.Length - 1);
}
}
string endSpace = data.Substring (index + trimData.Length);
string postSpace = String.Empty;
if (!endSpace.Equals (String.Empty)) {
if (endSpace.Length == 1) {
if (endSpace.Equals (" ")) {
postSpace = endSpace;
endSpace = String.Empty;
}
} else {
if (endSpace.Substring (0, 1).Equals (" ")) {
postSpace = endSpace.Substring (0, 1);
endSpace = endSpace.Substring (1);
}
}
}
buffer.InsertWithTags (ref insertAt, Escape (startSpace), textTag);
buffer.InsertWithTags (ref insertAt, prefixSpace + trimData + postSpace, tag);
buffer.InsertWithTags (ref insertAt, Escape (endSpace), textTag);
}
示例5: AddStub
public static void AddStub (TextBuffer buffer, ref TextIter insertAt, string data, string suffix)
{
DocumentTagTable tagTable = (DocumentTagTable) buffer.TagTable;
TextTag textTag = tagTable.Lookup ("stub" + suffix + "#" + counter);
if (textTag == null)
textTag = tagTable.CreateDynamicTag ("stub" + suffix + "#" + counter);
counter++;
buffer.InsertWithTags (ref insertAt, data, textTag);
}
示例6: DrawPart
private void DrawPart(ContentText text, TextBuffer tb = null)
{
if (tb == null)
{
tb = richTextBox.Buffer;
}
Gtk.TextIter iter = tb.EndIter;
TextTag format = new TextTag(null);
format.FontDesc = DefaultFont;
if (text.Bold)
{
format.Weight = Pango.Weight.Bold;
if (Configuration.Scrollback.UnderlineBold)
{
format.Underline = Pango.Underline.Double;
}
}
if (text.Underline)
{
format.Underline = Pango.Underline.Single;
}
if (text.Italic)
{
format.Style = Pango.Style.Italic;
format.BackgroundGdk = Core.FromColor(text.TextColor);
format.ForegroundGdk = Core.FromColor(Configuration.CurrentSkin.BackgroundColor);
}
if (text.Link != null)
{
format.TextEvent += new TextEventHandler(LinkHandler);
}
else
{
format.TextEvent += new TextEventHandler(LinkRm);
}
format.Data.Add("link", text.Link);
format.Data.Add("identifier", text.Text);
if (!text.Italic)
{
format.ForegroundGdk = Core.FromColor(text.TextColor);
}
tb.TagTable.Add(format);
//format.SizePoints = Configuration.CurrentSkin.FontSize;
tb.InsertWithTags(ref iter, text.Text, format);
}
示例7: DeserializeAttributesNone
private static void DeserializeAttributesNone (TextBuffer buffer, ref TextIter insertAt, XmlTextReader xmlReader, string tagSuffix)
{
string tagName = String.Empty;
string tagPrefix = xmlReader.Name + ":";
DocumentTagTable tagTable = (DocumentTagTable) buffer.TagTable;
while (xmlReader.MoveToNextAttribute ()) {
tagName = tagPrefix + xmlReader.Name + tagSuffix;
TextTag tag = tagTable.Lookup (tagName);
if (tag == null)
tag = tagTable.CreateDynamicTag (tagName);
buffer.InsertWithTags (ref insertAt, xmlReader.Value, tag);
}
#if DEBUG
Console.WriteLine ("Attribute: {0} End: {1}", tagName, insertAt.Offset);
#endif
}
示例8: DeserializeAttributesMemberSignature
private static void DeserializeAttributesMemberSignature (TextBuffer buffer, ref TextIter insertAt, XmlTextReader xmlReader, string tagSuffix)
{
string tagName = String.Empty;
string tagPrefix = xmlReader.Name + ":";
DocumentTagTable tagTable = (DocumentTagTable) buffer.TagTable;
while (xmlReader.MoveToNextAttribute ()) {
tagName = tagPrefix + xmlReader.Name + tagSuffix;
TextTag formatTag = tagTable.Lookup ("format" + tagSuffix);
if (formatTag == null)
formatTag = tagTable.CreateDynamicTag ("format" + tagSuffix);
if (xmlReader.Name == "Language")
buffer.InsertWithTags (ref insertAt, "Member Language: ", formatTag);
if (xmlReader.Name == "Value")
buffer.InsertWithTags (ref insertAt, "Member Signature: ", formatTag);
TextTag tag = tagTable.Lookup (tagName);
if (tag == null)
tag = tagTable.CreateDynamicTag (tagName);
buffer.InsertWithTags (ref insertAt, xmlReader.Value, tag);
DocumentUtils.AddNewLine (buffer, ref insertAt, tagSuffix);
#if DEBUG
Console.WriteLine ("Attribute: {0} End: {1}", tagName, insertAt.Offset);
#endif
}
}