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


C# TextBuffer类代码示例

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


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

示例1: DrawMenu

        public void DrawMenu(TextBuffer GUIText)
        {
            ValidateSelected();
            Widget[] Entries = MenuEntries.ToArray();

            // Separator
            int Width = MenuTitle.Length + 5;
            int Height = 3;

            for (int i = 0; i < Entries.Length; i++) {
                Width = Math.Max(Width, Entries[i].Width + 3);
                Height += Entries[i].Height;
            }

            int X = GUIText.BufferWidth / 2 - Width / 2 - 1;
            int Y = GUIText.BufferHeight / 2 - Height / 2 - 1;

            //DrawBox(GUIText, Width, 0, 0, GUIText.BufferHeight - 1);

            // Outline
            for (int x = 0; x < Width; x++)
                for (int y = 0; y < Height; y++)
                    GUIText[X + x, Y + y] = 0;
            GUIText.DrawBox(X, Y, Width, Height);
            GUIText.Print(X + 2, Y, "[" + MenuTitle + "]");

            // Entries
            int YOff = 0;
            for (int i = 0; i < Entries.Length; i++) {
                Entries[i].Draw(GUIText, X + 2, Y + 2 + YOff, i == Selected);
                YOff += Entries[i].Height;
            }
            /*GUIText.Print(X + 2, Y + i + 2, Entries[i],
                i == Selected ? Color.Black : ConsoleColor.Gray.ToColor(), i == Selected ? Color.White : Color.Black);*/
        }
开发者ID:cartman300,项目名称:Tetraquark,代码行数:35,代码来源:MenuEntry.cs

示例2: Setup

 public void Setup()
 {
     textBuffer = new TextBuffer(
         "    var a = 12.34;\n" +
         "    var b = 56.78;\n" +
         "    var c = 90.11;\n" +
         "    var d = 12345;\n" +
         "    var e = 67890;\n");
 }
开发者ID:samuto,项目名称:designscript,代码行数:9,代码来源:TextBufferMultilineTests.cs

示例3: ClassificationSpan

		/// <summary>
		/// Initializes a new instance of the <see cref="ClassificationSpan"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException"><para><paramref name="classification"/> is <see langword="null"/>.</para></exception>
		public ClassificationSpan(TextBuffer buffer, Int32 start, Int32 length, String classification)
			: base(buffer, start, length)
		{
			if (classification == null)
			{
				throw new ArgumentNullException("classification");
			}
			_classification = classification;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:13,代码来源:ClassificationSpan.cs

示例4: TestFindAllOccurences03

        public void TestFindAllOccurences03()
        {
            string initialContent = "First line\nSecond line\nThird line\nFourth line";
            TextBuffer localBuffer = new TextBuffer(initialContent);
            Assert.AreEqual(4, localBuffer.GetLineCount());
            localBuffer.FindReplace("design", null, FindOptions.ReplaceOnce);
            List<FindPosition> findResults = new List<FindPosition>();
            localBuffer.GetSearchResults(ref findResults);

            Assert.AreEqual(0, findResults.Count);
        }
开发者ID:samuto,项目名称:designscript,代码行数:11,代码来源:TextBufferTests.cs

示例5: ReplaceFirst

 public static int ReplaceFirst(Matcher m,Substitution substitution,TextBuffer dest)
 {
     int c=0;
     if(m.Find()) {
         if(m.Start>0) m.Group(Matcher.PREFIX,dest);
         substitution.AppendSubstitution(m,dest);
         c++;
         m.SetTarget(m,Matcher.SUFFIX);
     }
     m.Group(Matcher.TARGET,dest);
     return c;
 }
开发者ID:olabini,项目名称:nregex,代码行数:12,代码来源:Replacer.cs

示例6: TextWithGroupRuby

 public void TextWithGroupRuby(UString baseText, UString rubyText)
 {
     var baseBuffer = new TextBuffer(_zwSize, _wordWrap, _advancing, _latinMetric, 64);
     var rubyBuffer = new TextBuffer(_rubyZwSize, _wordWrap, _advancing, _latinMetric, 128);
     _buffer.MoveLastLetterStateTo(baseBuffer);
     baseBuffer.Append(baseText);
     rubyBuffer.Append(rubyText);
     _buffer.AppendObject(new GroupRuby(baseBuffer.ToArray(), rubyBuffer.ToArray()));
     baseBuffer.MoveLastLetterStateTo(_buffer);
     baseBuffer.Clear();
     rubyBuffer.Clear();
 }
开发者ID:karak,项目名称:Geovanni,代码行数:12,代码来源:ParagraphBuilder.cs

示例7: VersionedTextSpan

		/// <summary>
		/// Initializes a new instance of the <see cref="VersionedTextSpan"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="buffer"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="span"/> is <see langword="null"/>.</para>
		/// </exception>
		public VersionedTextSpan(TextBuffer buffer, Span span)
		{
			if (buffer == null)
			{
				throw new ArgumentNullException("buffer");
			}
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}
			this.Construct(buffer, buffer.Version, span.Start, span.Length, SpanTrackingMode.EdgeExclusive);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:20,代码来源:VersionedTextSpan.cs

示例8: Draw

 public override void Draw(TextBuffer TBuffer, int X, int Y, bool IsSelected)
 {
     Color Fg = ConsoleColor.Gray.ToColor();
     Color Bg = Color.Black;
     if (IsSelected) {
         Fg = Color.Black;
         if (Enabled)
             Bg = Color.White;
         else
             Bg = ConsoleColor.DarkGray.ToColor();
     }
     TBuffer.Print(X, Y, Txt, Fg, Bg);
 }
开发者ID:cartman300,项目名称:Tetraquark,代码行数:13,代码来源:Widgets.cs

示例9: GetView

	public override Widget GetView ()
	{
		if (scrolled_window != null)
			return scrolled_window;

		buffer = new TextBuffer (new TextTagTable ());
		buffer.Text = Text;
		view = new TextView (buffer);
		
		scrolled_window = new ScrolledWindow ();
		scrolled_window.Add (view);
		
		return scrolled_window;
	}
开发者ID:dfr0,项目名称:moon,代码行数:14,代码来源:View.cs

示例10: Replace

 public static int Replace(Matcher m,Substitution substitution,TextBuffer dest)
 {
     bool firstPass=true;
     int c=0;
     while(m.Find()) {
         if(m.End==0 && !firstPass) continue;  //allow to Replace at "^"
         if(m.Start>0) m.Group(Matcher.PREFIX,dest);
         substitution.AppendSubstitution(m,dest);
         c++;
         m.SetTarget(m,Matcher.SUFFIX);
         firstPass=false;
     }
     m.Group(Matcher.TARGET,dest);
     return c;
 }
开发者ID:olabini,项目名称:nregex,代码行数:15,代码来源:Replacer.cs

示例11: Format

      /// <summary>Formats the input BPL object into the output XML document.</summary>
      public override bool Format(BplObject input) {
         if (!PrepareFormatter(input)) return false;

         _output = new TextBuffer(this);
         try {
            _serializeObject(null, Input);
            _injectMapping(NSMapping);
            Output = _output.ToString();
         } catch (Exception e) {
            AddException(e);
         }
         _output = null;

         return Success;
      }
开发者ID:borkaborka,项目名称:gmit,代码行数:16,代码来源:BplJsonFormatter.cs

示例12: MenuState

        public MenuState()
        {
            GUIText = new TextBuffer(80, 30);
            GUIText.SetFontTexture(ResourceMgr.Get<Texture>("font"));
            GUIText.Sprite.Scale = Renderer.Screen.Size.ToVec2f().Divide(GUIText.Sprite.Texture.Size.ToVec2f());
            GUIText.Sprite.Position = Renderer.Screen.Texture.Size.ToVec2f() / 2;
            GUIText.Sprite.Origin = GUIText.Sprite.Texture.Size.ToVec2f() / 2;

            AAA = new RenderSprite(Renderer.Screen.Size);
            BBB = new RenderSprite(Renderer.Screen.Size);
            CRT = new RenderSprite(Renderer.Screen.Size);

            MainMenu = new MenuEntry("Main Menu");
            if (Renderer.CountStates() > 0)
                MainMenu.Add(new WidgetButton("Continue Universe", () => Renderer.PopState()));

            MainMenu
                .Add(new WidgetButton("Create Universe", () => Renderer.PushState(new GameState())))
                .Add(new WidgetButton("Load Universe", () => CurrentMenu = LoadUniverse).Disable())
                .Add(new WidgetButton("Universal Constants", () => CurrentMenu = Constants))
                .Add(new WidgetButton("Terminate", () => Program.Running = false));

            Action BackToMainMenu = () => {
                GUIText.Clear();
                CurrentMenu = MainMenu;
            };

            LoadUniverse = new MenuEntry("Load Universe")
                .Add(new WidgetButton("Back", BackToMainMenu));

            Constants = new MenuEntry("Universal Constants")
                .Add(new WidgetTextbox("Resolution X", Program.ResX.ToString(), 6, (S) => {
                    if (S.Length > 0)
                        Program.ResX = int.Parse(S);
                    GUIText.Print(0, 0, "Restart required for changes to take effect");
                }, char.IsNumber))
                .Add(new WidgetTextbox("Resolution Y", Program.ResY.ToString(), 6, (S) => {
                    if (S.Length > 0)
                        Program.ResY = int.Parse(S);
                    GUIText.Print(0, 0, "Restart required for changes to take effect");
                }, char.IsNumber))
                .Add(new WidgetCheckbox("Debug", Program.Debug, (B) => Program.Debug = B))
                            .Add(new WidgetCheckbox("Border", Program.Border, (B) => Program.Border = B))
                .Add(new WidgetButton("Back", BackToMainMenu));

            CurrentMenu = MainMenu;
            CurrentMenu.DrawMenu(GUIText);
        }
开发者ID:cartman300,项目名称:Tetraquark,代码行数:48,代码来源:MenuState.cs

示例13: TestFindAllOccurences02

        public void TestFindAllOccurences02()
        {
            string initialContent = "First line design\nSecond line\nThird line\nFourth design design";
            TextBuffer localBuffer = new TextBuffer(initialContent);
            Assert.AreEqual(4, localBuffer.GetLineCount());
            localBuffer.FindReplace("design", null, FindOptions.ReplaceOnce);
            List<FindPosition> findResults = new List<FindPosition>();
            localBuffer.GetSearchResults(ref findResults);

            Assert.AreEqual(new Point(11, 0), findResults[0].startPoint);
            Assert.AreEqual(new Point(16, 0), findResults[0].endPoint);
            Assert.AreEqual(new Point(7, 3), findResults[1].startPoint);
            Assert.AreEqual(new Point(12, 3), findResults[1].endPoint);
            Assert.AreEqual(new Point(14, 3), findResults[2].startPoint);
            Assert.AreEqual(new Point(19, 3), findResults[2].endPoint);
        }
开发者ID:samuto,项目名称:designscript,代码行数:16,代码来源:TextBufferTests.cs

示例14: TextFormattingSource

		public TextFormattingSource(
			TextBuffer textBuffer
			, IClassificationFormatMap classificationFormatMap
			, Int32 startIndex
			, Int32 length
			, IList<ClassificationSpan> classificationSpans
			, IList<SpaceNegotiation> spaceNegotiations
			)
		{
			List<SpaceNegotiation> list = null;
			if (spaceNegotiations != null)
			{
				list = new List<SpaceNegotiation>(spaceNegotiations);
				list.Sort(new Comparison<SpaceNegotiation>(this.Comparison));
			}
			String text = textBuffer.GetText(startIndex, length);
			_normalizedSpanManager = new NormalizedSpanManager(text, startIndex, classificationSpans, list, classificationFormatMap);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:18,代码来源:TextFormattingSource.cs

示例15: BasicTest

        public void BasicTest()
        {
            var str = "Test1Test2Test3";
            var text = new TextBuffer();
            var reader = text.GetReader();

            var evt = new AutoResetEvent(false);

            Action a = () =>
            {
                evt.WaitOne();
                text.Write(str);
                evt.WaitOne();
                text.Write(str);
            };

            var t = new Thread(new ThreadStart(a));
            t.Start();
            char[] buffer = new char[0x1000];
            var task = reader.ReadAsync(buffer, 0, 1000);
            evt.Set();
            task.Wait();
            var s = task.Result;
            log.WriteLine(s.ToString());

            task = reader.ReadAsync(buffer, 0, 1000);

            var reader2 = text.GetReader();

            evt.Set();

            var task2 = reader2.ReadToEndAsync();

            task.Wait();
            task2.Wait();
            s = task.Result;
            var s2 = task2.Result;
            Assert.True(!string.IsNullOrEmpty(s2));
            log.WriteLine(s.ToString());
            log.WriteLine(s2.ToString());

            t.Join();
        }
开发者ID:MarkPflug,项目名称:AspNetScriptConsole,代码行数:43,代码来源:TextBufferTests.cs


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