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


C# TextBuffer.Insert方法代码示例

本文整理汇总了C#中Gtk.TextBuffer.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# TextBuffer.Insert方法的具体用法?C# TextBuffer.Insert怎么用?C# TextBuffer.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gtk.TextBuffer的用法示例。


在下文中一共展示了TextBuffer.Insert方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: LoadIntoBuffer

        public static void LoadIntoBuffer(TextBuffer buffer, TextReader reader)
        {
            buffer.TagTable.Add(new TextTag("header1")
              {
            Weight = Pango.Weight.Bold,
            SizePoints = 18
              });

              buffer.TagTable.Add(new TextTag("header2")
              {
            Weight = Pango.Weight.Bold,
            SizePoints = 14
              });

              buffer.TagTable.Add(new TextTag("header3")
              {
            Weight = Pango.Weight.Bold
              });

              var iter = buffer.StartIter;
              var line = reader.ReadLine();

              while (line != null)
              {
            var textToInsert = string.Format("{0}{1}", line, Environment.NewLine);

            if (Regex.IsMatch(line, "^#[^#]"))
            {
              buffer.InsertWithTagsByName(ref iter, textToInsert.Substring(2), "header1");
            }
            else if (Regex.IsMatch(line, "^##[^#]"))
            {
              buffer.InsertWithTagsByName(ref iter, textToInsert.Substring(3), "header2");
            }
            else if (Regex.IsMatch(line, "^###[^#]"))
            {
              buffer.InsertWithTagsByName(ref iter, textToInsert.Substring(4), "header3");
            }
            else
            {
              buffer.Insert(ref iter, textToInsert);
            }

            line = reader.ReadLine();
              }
        }
开发者ID:synesthesiam,项目名称:nexus,代码行数:46,代码来源:Markdown.cs

示例3: InsertWithMarkup

	void InsertWithMarkup (TextBuffer buffer, ref TextIter iter, string text)
	{
		Match match = markupRegex.Match (text);
		if (!match.Success) {
			buffer.Insert (ref iter, text);
			return;
		}

		int start = 0, len, idx;
		var tags = new List <string> ();
		while (match.Success) {
			len = match.Index - start;
			if (len > 0)
				buffer.InsertWithTagsByName (ref iter, text.Substring (start, len), tags.ToArray ());

			switch (match.Value.ToLowerInvariant ()) {
				case "<i>":
					if (!tags.Contains ("italic"))
						tags.Add ("italic");
					break;

				case "</i>":
					idx = tags.IndexOf ("italic");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<b>":
					if (!tags.Contains ("bold"))
						tags.Add ("bold");
					break;

				case "</b>":
					idx = tags.IndexOf ("bold");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<big>":
					if (!tags.Contains ("big"))
						tags.Add ("big");
					break;

				case "</big>":
					idx = tags.IndexOf ("big");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<s>":
					if (!tags.Contains ("strikethrough"))
						tags.Add ("strikethrough");
					break;

				case "</s>":
					idx = tags.IndexOf ("strikethrough");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<sub>":
					if (!tags.Contains ("sub"))
						tags.Add ("sub");
					break;

				case "</sub>":
					idx = tags.IndexOf ("sub");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<sup>":
					if (!tags.Contains ("sup"))
						tags.Add ("sup");
					break;

				case "</sup>":
					idx = tags.IndexOf ("sup");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<small>":
					if (!tags.Contains ("small"))
						tags.Add ("small");
					break;

				case "</small>":
					idx = tags.IndexOf ("small");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<tt>":
					if (!tags.Contains ("monospace"))
						tags.Add ("monospace");
					break;

				case "</tt>":
					idx = tags.IndexOf ("monospace");
//.........这里部分代码省略.........
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:101,代码来源:MainWindow.cs

示例4: EasterEggCB

		private void EasterEggCB (object o, EventArgs args)
		{
			TextIter insertIter;

			TextBuffer buffer = new TextBuffer (null);
			insertIter = buffer.StartIter;
			buffer.Insert (ref insertIter, "This buffer is shared by a set of nested text views.\n Nested view:\n");
			TextChildAnchor anchor = buffer.CreateChildAnchor (ref insertIter);
			buffer.Insert (ref insertIter, "\nDon't do this in real applications, please.\n");
			TextView view = new TextView (buffer);

			RecursiveAttach (0, view, anchor);

			Gtk.Window window = new Gtk.Window (Gtk.WindowType.Toplevel);
			ScrolledWindow sw = new ScrolledWindow ();
			sw.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);

			window.Add (sw);
			sw.Add (view);

			window.SetDefaultSize (300, 400);
			window.ShowAll ();
		}
开发者ID:ystk,项目名称:debian-gtk-sharp2,代码行数:23,代码来源:DemoTextView.cs

示例5: InsertText

		private void InsertText (TextBuffer buffer)
		{
			Pixbuf pixbuf = Gdk.Pixbuf.LoadFromResource ("gtk-logo-rgb.gif");
			pixbuf = pixbuf.ScaleSimple (32, 32, InterpType.Bilinear);

			// get start of buffer; each insertion will revalidate the
			// iterator to point to just after the inserted text.

			TextIter insertIter = buffer.StartIter;
			buffer.Insert (ref insertIter,
				       "The text widget can display text with all kinds of nifty attributes. It also supports multiple views of the same buffer; this demo is showing the same buffer in two places.\n\n");

			buffer.InsertWithTagsByName (ref insertIter, "Font styles. ", "heading");

			buffer.Insert (ref insertIter, "For example, you can have ");
			buffer.InsertWithTagsByName (ref insertIter, "italic", "italic");
		        buffer.Insert (ref insertIter, ", ");
			buffer.InsertWithTagsByName (ref insertIter, "bold", "bold");
		        buffer.Insert (ref insertIter, ", or ");
			buffer.InsertWithTagsByName (ref insertIter, "monospace (typewriter)", "monospace");
		        buffer.Insert (ref insertIter, ", or  ");
			buffer.InsertWithTagsByName (ref insertIter, "big", "big");
			buffer.Insert (ref insertIter, " text. ");
			buffer.Insert (ref insertIter,
				       "It's best not to hardcode specific text sizes; you can use relative sizes as with CSS, such as ");
			buffer.InsertWithTagsByName (ref insertIter, "xx-small", "xx-small");
		        buffer.Insert (ref insertIter, " or");
			buffer.InsertWithTagsByName (ref insertIter, "x-large", "x-large");
			buffer.Insert (ref insertIter,
				       " to ensure that your program properly adapts if the user changes the default font size.\n\n");

			buffer.InsertWithTagsByName (ref insertIter, "Colors. ", "heading");

			buffer.Insert (ref insertIter, "Colors such as ");
			buffer.InsertWithTagsByName (ref insertIter, "a blue foreground", "blue_foreground");
		        buffer.Insert (ref insertIter, " or ");
			buffer.InsertWithTagsByName (ref insertIter, "a red background", "red_background");
		        buffer.Insert (ref insertIter, " or even ");
			buffer.InsertWithTagsByName (ref insertIter, "a stippled red background",
						     "red_background",
						     "background_stipple");

		        buffer.Insert (ref insertIter, " or ");
                        buffer.InsertWithTagsByName (ref insertIter,
						     "a stippled blue foreground on solid red background",
						     "blue_foreground",
						     "red_background",
						     "foreground_stipple");
		        buffer.Insert (ref insertIter, " (select that to read it) can be used.\n\n");

			buffer.InsertWithTagsByName (ref insertIter, "Underline, strikethrough, and rise. ", "heading");

			buffer.InsertWithTagsByName (ref insertIter, "Strikethrough", "strikethrough");
			buffer.Insert (ref insertIter, ", ");
			buffer.InsertWithTagsByName (ref insertIter, "underline", "underline");
			buffer.Insert (ref insertIter, ", ");
			buffer.InsertWithTagsByName (ref insertIter, "double underline", "double_underline");
			buffer.Insert (ref insertIter, ", ");
			buffer.InsertWithTagsByName (ref insertIter, "superscript", "superscript");
		        buffer.Insert (ref insertIter, ", and ");
			buffer.InsertWithTagsByName (ref insertIter, "subscript", "subscript");
			buffer.Insert (ref insertIter, " are all supported.\n\n");

			buffer.InsertWithTagsByName (ref insertIter, "Images. ", "heading");

			buffer.Insert (ref insertIter, "The buffer can have images in it: ");

			buffer.InsertPixbuf (ref insertIter, pixbuf);
			buffer.InsertPixbuf (ref insertIter, pixbuf);
			buffer.InsertPixbuf (ref insertIter, pixbuf);
			buffer.Insert (ref insertIter, " for example.\n\n");

			buffer.InsertWithTagsByName (ref insertIter, "Spacing. ", "heading");

			buffer.Insert (ref insertIter, "You can adjust the amount of space before each line.\n");
			buffer.InsertWithTagsByName (ref insertIter, "This line has a whole lot of space before it.\n",
						     "big_gap_before_line", "wide_margins");
			buffer.InsertWithTagsByName (ref insertIter, "You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n",
						     "big_gap_after_line", "wide_margins");

			buffer.InsertWithTagsByName (ref insertIter, "You can also adjust the amount of space between wrapped lines; this line has extra space between each wrapped line in the same paragraph. To show off wrapping, some filler text: the quick brown fox jumped over the lazy dog. Blah blah blah blah blah blah blah blah blah.\n",
						     "double_spaced_line", "wide_margins");

			buffer.Insert (ref insertIter, "Also note that those lines have extra-wide margins.\n\n");

			buffer.InsertWithTagsByName (ref insertIter, "Editability. ", "heading");

			buffer.InsertWithTagsByName (ref insertIter, "This line is 'locked down' and can't be edited by the user - just try it! You can't delete this line.\n\n",
						     "not_editable");

			buffer.InsertWithTagsByName (ref insertIter, "Wrapping. ", "heading");

			buffer.Insert (ref insertIter, "This line (and most of the others in this buffer) is word-wrapped, using the proper Unicode algorithm. Word wrap should work in all scripts and languages that GTK+ supports. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n");

			buffer.InsertWithTagsByName (ref insertIter,  "This line has character-based wrapping, and can wrap between any two character glyphs. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n",
						     "char_wrap");

			buffer.InsertWithTagsByName (ref insertIter, "This line has all wrapping turned off, so it makes the horizontal scrollbar appear.\n\n\n",
						     "no_wrap");

//.........这里部分代码省略.........
开发者ID:ystk,项目名称:debian-gtk-sharp2,代码行数:101,代码来源:DemoTextView.cs

示例6: ColorizePacket

    void ColorizePacket(TextBuffer buffer, string text)
    {
        if (!text.StartsWith("Message Type:") && !text.StartsWith("Packet Type:"))
        {
            buffer.Text = text;
            return;
        }

        buffer.Text = string.Empty;
        text = text.Replace("\r", "");
        TextIter iter = buffer.StartIter;

        Regex typesRegex = new Regex(@"\[(?<Type>\w+|\w+\[\])\]|\((?<Enum>.*)\)|\s-- (?<Header>\w+|\w+ \[\]) --\s|(?<BlockSep>\s\*\*\*\s)|(?<Tag>\s<\w+>\s|\s<\/\w+>\s)|(?<BlockCounter>\s\w+\[\d+\]\s)|(?<UUID>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})", RegexOptions.ExplicitCapture);

        MatchCollection matches = typesRegex.Matches(text);
        int pos = 0;

        if (matches.Count == 0)
        {
            buffer.Text = text;
        }

        foreach (Match match in matches)
        {
            string tag = "bold";

            buffer.Insert(ref iter, text.Substring(pos, match.Index - pos));
            pos += match.Index - pos;

            if (!String.IsNullOrEmpty(match.Groups["Type"].Value))
            {
                tag = "type";
            }
            else if (!String.IsNullOrEmpty(match.Groups["Enum"].Value))
            {
                tag = "type";
            }
            else if (!String.IsNullOrEmpty(match.Groups["Header"].Value))
            {
                tag = "header";
            }
            else if (!String.IsNullOrEmpty(match.Groups["BlockSep"].Value))
            {
                tag = "block";
            }
            else if (!String.IsNullOrEmpty(match.Groups["Tag"].Value))
            {
                tag = "tag";
            }
            else if (!String.IsNullOrEmpty(match.Groups["BlockCounter"].Value))
            {
                tag = "counter";
            }
            else if (!String.IsNullOrEmpty(match.Groups["UUID"].Value))
            {
                tag = "UUID";
            }

            buffer.InsertWithTagsByName(ref iter, text.Substring(pos, match.Length), tag);
            pos += match.Length;
        }
    }
开发者ID:nivardus,项目名称:libopenmetaverse,代码行数:62,代码来源:MainWindow.cs

示例7: OnUpdateTimer

        private bool OnUpdateTimer()
        {
            if (!Active)
                return false;
            if(slowMode && slowModeCountdown > 0)
            {
                slowModeCountdown--;
                return true;
            }

            //Обновляем чат
            logger.Info("Обновляем чат...");
            if((QSMain.ConnectionDB as MySqlConnection).State != System.Data.ConnectionState.Open)
            {
                logger.Warn("Соедиение с сервером не открыто.");
                return true;
            }
            string sql = "SELECT datetime, text, users.name as user FROM chat_history " +
                "LEFT JOIN users ON users.id = chat_history.user_id " +
                "WHERE datetime > DATE_SUB(CURDATE(), INTERVAL " + ShowDays.ToString() +" DAY) " +
                "ORDER BY datetime";
            MySqlCommand cmd = new MySqlCommand(sql, (MySqlConnection)QSMain.ConnectionDB);
            TextBuffer tempBuffer = new TextBuffer(textTags);
            TextIter iter = tempBuffer.EndIter;
            NewMessageCount = 0;
            DateTime MaxDate = default(DateTime);
            using (MySqlDataReader rdr = cmd.ExecuteReader())
            {
                while (rdr.Read())
                {
                    DateTime mesDate = rdr.GetDateTime("datetime");
                    if (mesDate.Date != MaxDate.Date)
                    {
                        tempBuffer.InsertWithTagsByName(ref iter, String.Format("\n{0:D}", mesDate.Date), "date");
                    }
                    tempBuffer.InsertWithTagsByName(ref iter, string.Format("\n({0:t}) {1}: ", mesDate, rdr.GetString("user")),
                        QSChatMain.GetUserTag(rdr.GetString("user")));
                    tempBuffer.Insert(ref iter, rdr.GetString("text"));

                    if (isHided && lastShowTime != default(DateTime) && mesDate > lastShowTime)
                        NewMessageCount++;
                    if (mesDate > MaxDate)
                        MaxDate = mesDate;
                }
            }
            if (ActiveCount > uint.MaxValue - 10)
                ActiveCount = 61;
            ActiveCount++;
            if(MaxDate > lastMessageTime)
            {
                ActiveCount = 0;
                textviewChat.Buffer = tempBuffer;
                //Сдвигаем скрол до конца
                TextIter ti = textviewChat.Buffer.GetIterAtLine(textviewChat.Buffer.LineCount-1);
                TextMark tm = textviewChat.Buffer.CreateMark("eot", ti,false);
                textviewChat.ScrollToMark(tm, 0, false, 0, 0);
            }
            lastMessageTime = MaxDate;
            if (slowModeCountdown <= 0)
                slowModeCountdown = 8;
            logger.Info("Ок");
            if (ChatUpdated != null)
                ChatUpdated(this, EventArgs.Empty);
            return true;
        }
开发者ID:QualitySolution,项目名称:QSProjects,代码行数:65,代码来源:Chat.cs

示例8: InsertTextTable

        private void InsertTextTable(TextBuffer buffer)
        {
            Pixbuf pixbuf2 = MainClass.Tools.GetIconFromStock("file-ms.png",IconSize.Menu);

            TextIter insertIter = buffer.StartIter;

            List<Feature> listDif = MainClass.LicencesSystem.GetUserDifferent(featureLicence);

            if(listDif!= null){
                foreach(Feature ftv in listDif){
                    buffer.Insert (ref insertIter," ");
                    buffer.InsertPixbuf (ref insertIter, pixbuf2);
                    buffer.Insert (ref insertIter, String.Format(" {0} \n", ftv.Name));
                }
            }
            buffer.ApplyTag ("word_wrap", buffer.StartIter, buffer.EndIter);
        }
开发者ID:moscrif,项目名称:ide,代码行数:17,代码来源:BuyDialog.cs

示例9: InsertTextHeader

        private void InsertTextHeader(TextBuffer buffer)
        {
            TextIter insertIter = buffer.StartIter;

            string upgradeLicence = "";
            if(featureLicence != null){
                upgradeLicence = featureLicence.Name;
            }

            buffer.InsertWithTagsByName (ref insertIter, String.Format("Moscrif {0} ",upgradeLicence), "heading");
            buffer.Insert (ref insertIter,"\n\n");

            buffer.Insert (ref insertIter,
                           String.Format("The \"{0}\" is available for Moscrif {1} license. Please purchase an upgrade to unlock this Buying Moscrif {1} License you also unlock:\n\n",featureTitle,upgradeLicence));

            buffer.ApplyTag ("word_wrap", buffer.StartIter, buffer.EndIter);
        }
开发者ID:moscrif,项目名称:ide,代码行数:17,代码来源:BuyDialog.cs

示例10: InsertTextFooter

        private void InsertTextFooter(TextBuffer buffer)
        {
            TextIter insertIter = buffer.StartIter;

            buffer.Insert (ref insertIter,"More features area avalable in Pro License. ");
            InsertLink (buffer, ref insertIter, "Buy Pro now!", 1);

            buffer.ApplyTag ("word_justification", buffer.StartIter, buffer.EndIter);
        }
开发者ID:moscrif,项目名称:ide,代码行数:9,代码来源:BuyDialog.cs

示例11: DrawLineToBuffer

 private void DrawLineToBuffer(Line line, TextBuffer tb)
 {
     Gtk.TextIter iter = tb.EndIter;
     lock (line.text)
     {
         foreach (ContentText _text in line.text)
         {
             DrawPart(_text, tb);
         }
     }
     iter = tb.EndIter;
     tb.Insert(ref iter, Environment.NewLine);
 }
开发者ID:JGunning,项目名称:OpenAIM,代码行数:13,代码来源:Data.cs

示例12: InsertEndElement

	private static int InsertEndElement (TextBuffer buffer, int offset, Stack stack, ref int depth)
	{
		TextIter insertAt, applyStart, applyEnd;
		TagStart tagStart = (TagStart) stack.Pop ();
		string suffix =  '#' + depth.ToString ();
		
		#if DEBUG
		Console.WriteLine ("Element: {0}, End: {1}", tagStart.Tag.Name, offset);
		#endif
		
		if (((DocumentTag) tagStart.Tag).IsEditable) {
			if (tagStart.Start + 1 == offset)
				offset = DocumentUtils.AddStub (buffer, offset, "To be added test", suffix);
			
			insertAt = buffer.GetIterAtOffset (offset);
			buffer.Insert (ref insertAt, "]");
			offset += 1;
		} else if (tagStart.Start == offset)
			offset = DocumentUtils.AddPaddingEmpty (buffer, offset, suffix);
		
		applyStart = buffer.GetIterAtOffset (tagStart.Start);
		applyEnd = buffer.GetIterAtOffset (offset);
		buffer.ApplyTag (tagStart.Tag, applyStart, applyEnd);
		offset = FormatEnd (buffer, offset, suffix, tagStart.Name);
		depth--;
		
		#if DEBUG
		Console.WriteLine ("Applied: {0}, Start: {1}, End: {2}", tagStart.Tag.Name, tagStart.Start, offset);
		#endif
		
		// Padding between tag regions
		suffix = "#" + depth;
		offset = DocumentUtils.AddPadding (buffer, offset, suffix);
		
		return offset;
	}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:36,代码来源:DocumentBufferArchiver.cs

示例13: InsertStartElement

	private static int InsertStartElement (TextBuffer buffer, int offset, XmlTextReader xmlReader, Stack stack, ref int depth, ref int count)
	{
		string elementName = xmlReader.Name;
		string suffix = String.Empty;
		DocumentTagTable tagTable = (DocumentTagTable) buffer.TagTable;
		bool emptyElement = xmlReader.IsEmptyElement;
		bool isDynamic = DocumentTagTable.IsDynamic (elementName);
		TextIter insertAt, applyStart, applyEnd;
		depth++;
		
		// We define a suffix so each dynamic tag has an unique name.
		// Suffix has format: #{depth level}
		if (isDynamic)
			suffix = "#" + depth;
		
		// We add any needed string to give format to the document.
		offset = FormatStart (buffer, offset, suffix, elementName);
		
		TagStart tagStart = new TagStart ();
		tagStart.Start = offset;
		tagStart.Name = elementName;
		
		// We first lookup the tag name, if the element is dynamic, we can
		// have three scenarios.
		// 1) The tag is not in the table: So we create it in the spot.
		// 2) Tag is in table but it priority is wrong: We created a new
		// dynamic tag with an extra suffix. Format #{depth level}.{count}
		// 3) Tag is in table with right priority: We reuse it and we don't
		// create a new dymamic tag.
		tagStart.Tag = tagTable.Lookup (elementName + suffix);
		if (isDynamic && tagStart.Tag == null)
			tagStart.Tag = tagTable.CreateDynamicTag (elementName + suffix);
		else if (isDynamic && tagStart.Tag != null &&  tagStart.Tag.Priority < ((TagStart) stack.Peek ()).Tag.Priority) {
			suffix += "." + count;
			tagStart.Tag = tagTable.CreateDynamicTag (elementName + suffix);
			count++;
		}
		
		#if DEBUG
		try {
			Console.WriteLine ("Element: {0} Start: {1}", tagStart.Tag.Name, tagStart.Start);
		} catch (NullReferenceException) {
			Console.WriteLine ("Error: Missing {0} element", xmlReader.Name);
			Environment.Exit (1);
		}
		#endif
		
		// If element has attributes we have to get them and deserialize them.
		if (xmlReader.HasAttributes)
			offset = DeserializeAttributes (buffer, offset, xmlReader, suffix);
		
		// Special case when an elment is empty.
		// Case A: If element is editable a string stub is inserted to allow edition.
		// Case B: If element is not editable then a padding is inserted to handle
		// TextTag behaviour in which zero length ranges are lost.
		if (emptyElement) {
			if (((DocumentTag) tagStart.Tag).IsEditable) {
				insertAt = buffer.GetIterAtOffset (offset);
				buffer.Insert (ref insertAt, "[");
				offset += 1;
				
				offset = DocumentUtils.AddStub (buffer, offset, "Click to Add Documentation", suffix);
				
				insertAt = buffer.GetIterAtOffset (offset);
				buffer.Insert (ref insertAt, "]");
				offset += 1;
			} else
				offset = DocumentUtils.AddPaddingEmpty (buffer, offset, suffix);
			
			applyStart = buffer.GetIterAtOffset (tagStart.Start);
			applyEnd = buffer.GetIterAtOffset (offset);
			buffer.ApplyTag (tagStart.Tag, applyStart, applyEnd);
			offset = FormatEnd (buffer, offset, suffix, elementName);
			
			// Padding between tag regions
			offset = DocumentUtils.AddPadding (buffer, offset, suffix);
			depth--;
			
			#if DEBUG
			Console.WriteLine ("Empty Element: {0}, Start: {1}, End: {2}", tagStart.Tag.Name, tagStart.Start, offset);
			#endif
		} else {
			stack.Push (tagStart);
			
			if (((DocumentTag) tagStart.Tag).IsEditable) {
				insertAt = buffer.GetIterAtOffset (offset);
				buffer.Insert (ref insertAt, "[");
				offset += 1;
			}
		}
		
		return offset;
	}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:93,代码来源:DocumentBufferArchiver.cs

示例14: AppendTextWithoutScroll

		public void AppendTextWithoutScroll (TextBuffer buffer, string text) 
		{
			TextIter iter;
			text = text.Replace("\0","");
			buffer.MoveMark(buf.InsertMark, buffer.EndIter);
			if (text.Equals ("") == false) {				
				iter = buffer.EndIter;
				buffer.Insert (iter, text);
			}
			iter = buffer.EndIter;
			buffer.Insert (iter, "\n");
		}
开发者ID:Zman0169,项目名称:mono,代码行数:12,代码来源:sqlsharpgtk.cs


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