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


C# TextBuffer.InsertWithTags方法代码示例

本文整理汇总了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);
		}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:13,代码来源:DemoHyperText.cs

示例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);
	}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:9,代码来源:Utils.cs

示例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);
			}
		}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:36,代码来源:DemoHyperText.cs

示例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);
	}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:42,代码来源:Utils.cs

示例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);
	}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:11,代码来源:Utils.cs

示例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);
        }
开发者ID:JGunning,项目名称:OpenAIM,代码行数:53,代码来源:Data.cs

示例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
	}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:20,代码来源:DocumentBufferArchiver.cs

示例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
		}
	}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:31,代码来源:DocumentBufferArchiver.cs


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