コード例 #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
ファイル: TextBox.cs プロジェクト: CaseyMcCordAnderson/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 = "";
 }
コード例 #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
ファイル: TextCursorTest.cs プロジェクト: s-tarasov/JsonMask
        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);
        }
コード例 #8
0
        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
ファイル: TextCursorTest.cs プロジェクト: s-tarasov/JsonMask
        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);
        }
コード例 #12
0
 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
ファイル: TextCursorTest.cs プロジェクト: s-tarasov/JsonMask
        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
ファイル: TextCursorTest.cs プロジェクト: s-tarasov/JsonMask
        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
ファイル: TextCursorTest.cs プロジェクト: s-tarasov/JsonMask
        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);
        }
コード例 #17
0
        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');
        }
コード例 #18
0
        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();
        }
コード例 #20
0
        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);
        }
コード例 #21
0
        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);
            }
        }
コード例 #23
0
 internal static void ValidateEndOfString(TextCursor cursor)
 {
     ValidateCurrentCharacter(cursor, cursor.Length, TextCursor.Nul);
 }
コード例 #24
0
 internal static void ValidateCurrentCharacter(TextCursor cursor, int expectedCurrentIndex, char expectedCurrentCharacter)
 {
     Assert.AreEqual(expectedCurrentCharacter, cursor.Current);
     Assert.AreEqual(expectedCurrentIndex, cursor.Index);
 }
コード例 #25
0
 internal static void ValidateBeginningOfString(TextCursor cursor)
 {
     ValidateCurrentCharacter(cursor, -1, TextCursor.Nul);
 }
コード例 #26
0
 internal char GetNextCharacter(TextCursor cursor)
 {
     Assert.IsTrue(cursor.MoveNext());
     return(cursor.Current);
 }
コード例 #27
0
ファイル: TextBox.cs プロジェクト: erisonliang/monoworks
		/// <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
ファイル: TextBox.cs プロジェクト: erisonliang/monoworks
		/// <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
ファイル: TextBox.cs プロジェクト: erisonliang/monoworks
		/// <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
ファイル: TextBox.cs プロジェクト: erisonliang/monoworks
		/// <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
ファイル: TextBox.cs プロジェクト: erisonliang/monoworks
		/// <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;
			}
		}
コード例 #34
0
 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
ファイル: TextBox.cs プロジェクト: erisonliang/monoworks
		/// <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
ファイル: TextBox.cs プロジェクト: erisonliang/monoworks
		/// <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;
			}
		}