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


C# TextBuffer.Insert方法代码示例

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


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

示例1: PrintTitle

            private void PrintTitle(TextBuffer buffer,
						 ref TextIter iter)
            {
                if (game == null)
                    return;
                string title = String.Format ("{0} vs {1}",
                                  game.White,
                                  game.Black);

                buffer.CreateMark ("-1", iter, true);
                buffer.InsertWithTagsByName (ref iter, title,
                                 HEADING_TAG);
                buffer.Insert (ref iter, "\n");

                Widget tagdetails = GetTagDetailsWidget ();
                TextChildAnchor anchor =
                    buffer.CreateChildAnchor (ref iter);
                view.AddChildAtAnchor (tagdetails, anchor);
                buffer.Insert (ref iter, "\n\n");
            }
开发者ID:BackupTheBerlios,项目名称:csboard-svn,代码行数:20,代码来源:ChessGameView.cs

示例2: TextTree

		// Constructor.
		public TextTree(TextBuffer buffer, TextLayout layout)
				{
					// set the buffer for this text tree
					this.buffer = buffer;

					// set the layout for this text tree
					this.layout = layout;

					// set the root for this text tree
					root = new TextGroup();

					// insert a new line into the buffer
					buffer.Insert(0, '\n');

					// create the first line
					TextLine line = new TextLine
						(buffer.MarkPosition(0, true),
						 buffer.MarkPosition(1, true));

					// insert the first line into the tree
					root.InsertChild(null, line);

					// update the metrics information
					root.UpdateMetrics(layout, true);

					// create the caret position
					caret = buffer.MarkPosition(0, false);

					// create the selection position
					selection = buffer.MarkPosition(0, false);
				}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:32,代码来源:TextBoxBase.cs

示例3: UpdateGameDetails

            private void UpdateGameDetails(TextBuffer buffer,
							ref TextIter iter)
            {
                PrintTitle (buffer, ref iter);
                if (game == null)
                    return;

                if (game.Comment != null)
                  {
                      buffer.InsertWithTags (ref
                                 iter,
                                 game.Comment,
                                 commentTag);
                      buffer.Insert (ref iter, "\n");
                  }

                int i = 0;
                int moveno = 1;
                foreach (PGNChessMove move in game.Moves)
                {
                    if (i % 2 == 0)
                      {
                          buffer.InsertWithTags (ref
                                     iter,
                                     moveno.
                                     ToString
                                     (),
                                     movenumberTag);
                          moveno++;
                          buffer.Insert (ref iter,
                                 ". ");
                      }

                    string markstr = i.ToString ();
                    string text = move.DetailedMove;
                    buffer.CreateMark (markstr, iter, true);	// left gravity
                    TextTag link_tag = new TextTag (null);
                    tag_links[link_tag] = i;
                    taglinks.Add (link_tag);
                    buffer.TagTable.Add (link_tag);
                    buffer.InsertWithTags (ref iter, text,
                                   moveTag,
                                   link_tag);
                    marks[markstr] = text.Length;
                    buffer.Insert (ref iter, " ");

                    if (move.comment != null)
                      {
                          buffer.Insert (ref iter,
                                 "\n");
                          buffer.InsertWithTags (ref
                                     iter,
                                     FormatComment
                                     (move.
                                      comment),
                                     commentTag);
                          buffer.Insert (ref iter,
                                 "\n");
                      }
                    i++;
                }
            }
开发者ID:BackupTheBerlios,项目名称:csboard-svn,代码行数:62,代码来源:ChessGameView.cs

示例4:

			// Update after a removal.
			public static bool RemovalUpdate
						(TextTree tree, TextBuffer buffer,
						 int offset, int length)
					{
						// NOTE: this is here to keep the method calls down to
						//       a minimum... technically, this belongs in the
						//       tree, but it's more efficient to do this here,
						//       where we can access the line/node fields
						//       directly

						// set the default return value
						bool retval = false;

						// declare the start offset of the found lines
						int garbage;

						// get the first line affected by the removal
						TextLine startLine = tree.FindLineByCharOffset
							(offset, out garbage);

						// get the last line affected by the removal
						TextLine endLine = tree.FindLineByCharOffset
							((offset + length + 1), out garbage);

						// handle end of buffer case
						if(endLine == null)
						{
							// get the character count of the buffer
							int bufCount = buffer.CharCount;

							// insert an extra line at the end of the buffer
							buffer.Insert(bufCount, '\n');

							// find the last line of the tree
							endLine = tree.root.LastLine;

							// create the new line node
							TextLine newLine = new TextLine
								(buffer.MarkPosition(bufCount, true),
								 buffer.MarkPosition((bufCount + 1), true));

							// add the new line to the last line's parent
							endLine.parent.InsertChild(endLine, newLine);

							// rebalance the parent
							endLine.parent.Rebalance(tree);

							// set the end line to the new line
							endLine = newLine;

							// flag that an insertion was performed
							retval = true;
						}

						// handle single line case
						if(startLine == endLine)
						{
							// force a character count update for the line
							startLine.UpdateCharCount();

							// invalidate the line
							startLine.Invalidate();

							// we're done
							return retval;
						}

						// merge the content of the two lines into the first
						startLine.end.Move(endLine.EndOffset);

						// get the start line's next sibling
						TextNode first = startLine.next;

						// set the current line to the start's next sibling
						TextLine currLine = (TextLine)first;

						// get the start line's parent
						TextNode startParent = startLine.parent;

						// get the end line's parent
						TextNode endParent = endLine.parent;

						// handle single parent case
						if(startParent == endParent)
						{
							// set the default removal count
							int rmCount = 1;

							// delete the end line's start position
							endLine.start.Delete();

							// delete the end line's end position
							endLine.end.Delete();

							// count and delete the lines to be removed
							while(currLine != endLine)
							{
								// delete the current line's start position
								currLine.start.Delete();
//.........这里部分代码省略.........
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:101,代码来源:TextBoxBase.cs


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