示例#1
0
 public HL7ParseResult(ISchema <TSchema> schema, IEntityParser <TSchema> parser, HL7ParserSettings settings, TextCursor cursor)
     : base(settings, cursor.InputText, cursor.CurrentSpan, new LineTextParser())
 {
     Schema  = schema;
     Parser  = parser;
     _cursor = cursor;
 }
示例#2
0
 public TextBox(int x, int y, string id, Window parentWindow, int length = 38)
     : base(x, y, 1, length, parentWindow, id)
 {
     TextCursor = new TextCursor(parentWindow);
     IsSelectable = true;
     Text = "";
 }
示例#3
0
 public X12ParseResult(ISchema <TSchema> schema, IEntityParser <TSchema> parser, X12ParserSettings settings, TextCursor cursor)
     : base(settings, cursor.InputText, cursor.CurrentSpan, settings.SegmentParser)
 {
     Schema  = schema;
     Parser  = parser;
     _cursor = cursor;
 }
示例#4
0
        public async Task Should_be_able_to_parse_lines_asynchronously_from_a_stream_and_split()
        {
            using (var stream = new StringReader(Text))
            {
                var first = await new TextReaderStreamTextReader(stream, Environment.NewLine).Text;

                var        parser = new LineTextParser();
                TextCursor result = await StreamTextCursor.ParseText(first, new TextSpan(0, first.Length), parser);

                while (result.HasCurrent)
                {
                    Console.WriteLine(result.Current);

                    var fields = _toListParser.Parse(result.Current, result.CurrentSpan);

                    Assert.That(fields.HasResult, Is.True);
                    Assert.That(fields.Result.Count, Is.EqualTo(5));

                    if (result.HasNext == false)
                    {
                        break;
                    }

                    result = await result.Next();
                }
            }
        }
示例#5
0
文件: TextBox.cs 项目: 0xCA5E/TextUI
 public TextBox(int x, int y, string id, Window parentWindow, int length = 38)
     : base(x, y, 1, length, parentWindow, id)
 {
     TextCursor   = new TextCursor(parentWindow);
     IsSelectable = true;
     Text         = "";
 }
示例#6
0
        public void GotoLine()
        {
            var cursor = new TextCursor("sfsfsdsf\ndfsfdsf".ToCharArray());

            cursor.GoTo(2, 2);

            Assert.Equal(11, cursor.Position);
        }
示例#7
0
        public void StartPosition()
        {
            var cursor = new TextCursor("sfsfsdsf\ndfsfdsf".ToCharArray());

            Assert.Equal(0, cursor.Position);
            Assert.Equal(1, cursor.LineNumber);
            Assert.Equal(0, cursor.LinePosition);
        }
        public void TestConstructor()
        {
            const string testString = "test";
            TextCursor   cursor     = MakeCursor(testString);

            ValidateContents(cursor, testString);
            ValidateBeginningOfString(cursor);
        }
示例#9
0
        public TextBoxBase()
        {
            cursor = new TextCursor(this);
            cursor.ResetCursorPaintMode();

            BackColor = Color.FromArgb(245, 245, 245);

            Text = "test text \r\nnew line was there";
        }
示例#10
0
        public Result <TextCursor, char> Parse(TextCursor cursor)
        {
            if (cursor.Span.Length > 0 && _condition(cursor.Text[cursor.Span.Start]))
            {
                return(new Success <TextCursor, char>(cursor.Text[cursor.Span.Start], cursor.Skip(1)));
            }

            return(new Unmatched <TextCursor, char>(cursor));
        }
示例#11
0
        public void FindSymbol()
        {
            var cursor = new TextCursor("sfsfsdsf\ndfsfdXf".ToCharArray());

            cursor.FindSymbol('X');
            Assert.Equal(14, cursor.Position);
            Assert.Equal(2, cursor.LineNumber);
            Assert.Equal(5, cursor.LinePosition);
        }
 internal static void ValidateContents(TextCursor cursor, string value, int length)
 {
     if (length < 0)
     {
         length = value.Length;
     }
     Assert.AreEqual(value, cursor.Value, "Cursor Value mismatch");
     Assert.AreEqual(length, cursor.Length, "Cursor Length mismatch");
 }
示例#13
0
        public void FindSymbol()
        {
            var cursor = new TextCursor("sfsfsdsf\ndfsfdsf".ToCharArray());

            cursor.GoTo(2, 0);

            cursor.FindSymbol('s');

            Assert.Equal(11, cursor.Position);
        }
示例#14
0
        public void GoToLastLineSymbol()
        {
            var cursor = new TextCursor(" \r\n \t sfs".ToCharArray());

            cursor.GoToLastLineSymbol();

            Assert.Equal(1, cursor.Position);
            Assert.Equal(1, cursor.LineNumber);
            Assert.Equal(1, cursor.LinePosition);
        }
示例#15
0
        public void GoToNotWhiteSpaceSymbol()
        {
            var cursor = new TextCursor("\r\n \t sfs".ToCharArray());

            cursor.GoToNotWhiteSpaceSymbol();

            Assert.Equal(5, cursor.Position);
            Assert.Equal(2, cursor.LineNumber);
            Assert.Equal(3, cursor.LinePosition);
        }
示例#16
0
        public void NextGotoLine()
        {
            var cursor = new TextCursor("sfsfsdsf\ndfsfdsf".ToCharArray());

            cursor.GoTo(2, 2);

            cursor.GoTo(2, 4);

            Assert.Equal(13, cursor.Position);
            Assert.Equal(2, cursor.LineNumber);
            Assert.Equal(4, cursor.LinePosition);
        }
        public void TestMove_NextPrevious()
        {
            TextCursor cursor = MakeCursor("test");

            ValidateBeginningOfString(cursor);
            Assert.True(cursor.Move(2), "Move(2)");
            ValidateCurrentCharacter(cursor, 2, 's');
            Assert.True(cursor.MovePrevious(), "MovePrevious()");
            ValidateCurrentCharacter(cursor, 1, 'e');
            Assert.True(cursor.MoveNext(), "MoveNext()");
            ValidateCurrentCharacter(cursor, 2, 's');
        }
        public void TestMove_invalid()
        {
            TextCursor cursor = MakeCursor("test");

            ValidateBeginningOfString(cursor);
            Assert.False(cursor.Move(-1000));
            ValidateBeginningOfString(cursor);
            Assert.False(cursor.Move(1000));
            ValidateEndOfString(cursor);
            Assert.False(cursor.Move(-1000));
            ValidateBeginningOfString(cursor);
        }
示例#19
0
        protected override void Setup()
        {
            if (IsSetup)
            {
                return;
            }

            // Initialise the video panel.
            playerPanel = new FLCPlayer()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Middle,
                Size         = new Vector2(320, 200),
                BottomMargin = 13
            };
            NativePanel.Components.Add(playerPanel);

            // Start video playing.
            playerPanel.Load(daedraSummoned.vidFile);
            if (playerPanel.FLCFile.ReadyToPlay)
            {
                playerPanel.Start();
            }

            // Add text message area.
            messageLabel = new MultiFormatTextLabel()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Bottom,
                ExtraLeading        = 3,
            };
            playerPanel.Components.Add(messageLabel);
            playerPanel.OnMouseClick += PlayerPanel_OnMouseClick;

            textCursor         = new TextCursor();
            textCursor.Enabled = false;
            playerPanel.Components.Add(textCursor);

            // Initialise message to display,
            if (daedraQuest != null)
            {   // with the quest offer message.
                Message message = daedraQuest.GetMessage((int)QuestMachine.QuestMessages.QuestorOffer);
                messageTokens = message.GetTextTokens();
            }
            else
            {   // with the textId message evaluated with mcp provided.
                messageTokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(textId);
                MacroHelper.ExpandMacros(ref messageTokens, mcp);
            }
            idx = 0;
            DisplayNextTextChunk();
        }
        public TextBoxBase()
        {
            BackColor = Color.FromArgb(245, 245, 245);

            cursor = new TextCursor(this);
            cursor.ResetCursorPaintMode();

            vscroll          = new VScrollBar();
            vscroll.Anchor   = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
            vscroll.Location = new Point(Width - vscroll.Width, 0);
            vscroll.Height   = Height;

            Controls.Add(vscroll);
        }
        public void TestMove()
        {
            TextCursor cursor = MakeCursor("test");

            ValidateBeginningOfString(cursor);
            Assert.True(cursor.Move(0));
            ValidateCurrentCharacter(cursor, 0, 't');
            Assert.True(cursor.Move(1));
            ValidateCurrentCharacter(cursor, 1, 'e');
            Assert.True(cursor.Move(2));
            ValidateCurrentCharacter(cursor, 2, 's');
            Assert.True(cursor.Move(3));
            ValidateCurrentCharacter(cursor, 3, 't');
            Assert.False(cursor.Move(4));
            ValidateEndOfString(cursor);
        }
示例#22
0
文件: Tests.cs 项目: ahives/Machete
        public async Task Should_parse_a_file_line_by_line_async()
        {
            const string fileContent = @"Line 1.
Line 2.
Line 3.
Line 4.
Line 5.
Line 6.
Line 7.
Line 8.";

            using (var stream = new StringReader(fileContent))
            {
                var first = await new TextReaderStreamTextReader(stream, Environment.NewLine).Text;

                var        parser = new LineParser();
                TextCursor result = await StreamTextCursor.ParseText(first, new TextSpan(0, first.Length), parser);

                while (result.HasValue)
                {
                    Console.WriteLine(result.Text);

                    if (result.HasNext == false)
                    {
                        break;
                    }

                    result = await result.Next();
                }


//                var span = await new ReadLineStreamTextSpanProvider(stream, Environment.NewLine).TextSpan;
//                while (span.CanExtend)
//                    span = await span.Extend();
//
//                Console.WriteLine(span.Text);
            }
        }
 internal static void ValidateEndOfString(TextCursor cursor)
 {
     ValidateCurrentCharacter(cursor, cursor.Length, TextCursor.Nul);
 }
 internal static void ValidateCurrentCharacter(TextCursor cursor, int expectedCurrentIndex, char expectedCurrentCharacter)
 {
     Assert.AreEqual(expectedCurrentCharacter, cursor.Current);
     Assert.AreEqual(expectedCurrentIndex, cursor.Index);
 }
 internal static void ValidateBeginningOfString(TextCursor cursor)
 {
     ValidateCurrentCharacter(cursor, -1, TextCursor.Nul);
 }
 internal char GetNextCharacter(TextCursor cursor)
 {
     Assert.IsTrue(cursor.MoveNext());
     return(cursor.Current);
 }
示例#27
0
		/// <summary>
		/// Moves the cursor to the end of the current line.
		/// </summary>
		public virtual void CursorEnd()
		{
			if (Anchor != null)
				Anchor = null;
			
			if (Cursor == null)
			{
				Cursor = new TextCursor() {
					Column = 0,
					Row = 0,
					IsDirty = true
				};
			}
			else
			{
				Cursor.Column = CurrentLine.Length;
				Cursor.IsDirty = true;
			}
		}
示例#28
0
 public HL7ParsedSlice(ISchema <TSchema> schema, HL7Settings settings, TextCursor cursor)
     : base(settings, cursor.SourceText, cursor.Span, new LineParser())
 {
     _schema = schema;
     _cursor = cursor;
 }
示例#29
0
		/// <summary>
		/// Inserts the given string at the current cursor position.
		/// </summary>
		public virtual void Insert(string val)
		{
			DeleteSelection();
			if (Cursor == null)
			{
				Body = val;
				Cursor = new TextCursor();
				Cursor.Column = val.Length;
			}
			else if (Cursor.Row == 0 && Cursor.Column == 0)
			{
				Body = val + Body;
				Cursor.Column = val.Length;
				Cursor.IsDirty = true;
			}
			else if (Cursor.Row == Lines.Length - 1 && 
			         Cursor.Column == Lines[Lines.Length - 1].Length - 1)
			{
				Body = Body + val;
				Cursor.IsDirty = true;
			}
			else // somewhere in the middle
			{
				CurrentLine = CurrentLine.Insert(Cursor.Column, val);
				Cursor.Column++;
				SetBodyFromLines();
			}
		}
示例#30
0
		/// <summary>
		/// Moves the cursor one or more characters to the left, depending on the modifier.
		/// </summary>
		public virtual void CursorLeft(InteractionModifier modifier)
		{
			if (Anchor != null && modifier != InteractionModifier.Shift)
				Anchor = null;
			else if (Anchor == null && modifier == InteractionModifier.Shift)
				Anchor = Cursor.Copy();
			
			// make sure there is a cursor
			if (Cursor == null)
			{
				Cursor = new TextCursor() {
					Column = 0,
					Row = 0,
					IsDirty = true
				};
			}
			else
			{
				if (Cursor.Column > 0)
				{
					Cursor.Column--;
					Cursor.IsDirty = true;
				}
				else if (Cursor.Row > 0)
				{
					Cursor.Row--;
					Cursor.Column = CurrentLine.Length;
					Cursor.IsDirty = true;
				}
			}
		}
示例#31
0
文件: TextBox.cs 项目: 0xCA5E/TextUI
        private void ShowCursor()
        {
            var paddedText = Text + " ";

            TextCursor.PlaceCursor(Origin.X + CursorPostion - _offset + 1, Origin.Y, paddedText[CursorPostion], TEXT_COLOR, BACKGROUND_COLOR);
        }
示例#32
0
		/// <summary>
		/// Moves the cursor one or more characters to the right, depending on the modifier.
		/// </summary>
		public virtual void CursorRight(InteractionModifier modifier)
		{
			if (Anchor != null && modifier != InteractionModifier.Shift)
				Anchor = null;
			else if (Anchor == null && modifier == InteractionModifier.Shift)
				Anchor = Cursor.Copy();
			
			if (Cursor == null)
			{
				Cursor = new TextCursor() {
					Column = 0,
					Row = 0,
					IsDirty = true
				};
			}
			else
			{
				if (Cursor.Column < CurrentLine.Length )
				{
					Cursor.Column++;
					Cursor.IsDirty = true;
				}
				else if (Cursor.Row < Lines.Length - 1)
				{
					Cursor.Row++;
					Cursor.Column = 0;
					Cursor.IsDirty = true;
				}
			}
		}
示例#33
0
		/// <summary>
		/// Moves the cursor down or more lines up, depending on the modifier.
		/// </summary>
		public virtual void CursorDown(InteractionModifier modifier)
		{
			if (Anchor != null)
				Anchor = null;
			
			if (Cursor == null)
			{
				Cursor = new TextCursor() {
					Column = 0,
					Row = NumLines - 1,
					IsDirty = true
				};
			}
			else if (Cursor.Row < NumLines - 1 )
			{
				Cursor.Row++;
				Cursor.IsDirty = true;
			}
		}
 internal static void ValidateContents(TextCursor cursor, string value)
 {
     ValidateContents(cursor, value, -1);
 }
示例#35
0
 public StreamTextSubCursor(TextCursor cursor, TextSpan span, int count)
 {
     _cursor = cursor;
     _span   = span;
     _count  = count;
 }
示例#36
0
		/// <summary>
		/// Moves the cursor to the beginning of the current line.
		/// </summary>
		public virtual void CursorHome()
		{
			if (Anchor != null)
				Anchor = null;
			
			if (Cursor == null)
			{
				Cursor = new TextCursor() {
					Column = 0,
					Row = 0,
					IsDirty = true
				};
			}
			else
			{
				Cursor.Column = 0;
				Cursor.IsDirty = true;
			}
		}
示例#37
0
文件: TextBox.cs 项目: 0xCA5E/TextUI
 private void RemoveCursor()
 {
     TextCursor.RemoveCursor();
 }
示例#38
0
		/// <summary>
		/// Moves the cursor one or more lines up, depending on the modifier.
		/// </summary>
		public virtual void CursorUp(InteractionModifier modifier)
		{
			if (Anchor != null)
				Anchor = null;
			
			if (Cursor == null)
			{
				Cursor = new TextCursor() {
					Column = 0,
					Row = 0,
					IsDirty = true
				};
			}
			else if (Cursor.Row > 0 )
			{
				Cursor.Row--;
				Cursor.IsDirty = true;
			}
		}