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; }
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 = ""; }
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; }
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(); } } }
public void GotoLine() { var cursor = new TextCursor("sfsfsdsf\ndfsfdsf".ToCharArray()); cursor.GoTo(2, 2); Assert.Equal(11, cursor.Position); }
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); }
public TextBoxBase() { cursor = new TextCursor(this); cursor.ResetCursorPaintMode(); BackColor = Color.FromArgb(245, 245, 245); Text = "test text \r\nnew line was there"; }
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)); }
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"); }
public void FindSymbol() { var cursor = new TextCursor("sfsfsdsf\ndfsfdsf".ToCharArray()); cursor.GoTo(2, 0); cursor.FindSymbol('s'); Assert.Equal(11, cursor.Position); }
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); }
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); }
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); }
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); }
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); }
/// <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; } }
public HL7ParsedSlice(ISchema <TSchema> schema, HL7Settings settings, TextCursor cursor) : base(settings, cursor.SourceText, cursor.Span, new LineParser()) { _schema = schema; _cursor = cursor; }
/// <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(); } }
/// <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; } } }
private void ShowCursor() { var paddedText = Text + " "; TextCursor.PlaceCursor(Origin.X + CursorPostion - _offset + 1, Origin.Y, paddedText[CursorPostion], TEXT_COLOR, BACKGROUND_COLOR); }
/// <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; } } }
/// <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); }
public StreamTextSubCursor(TextCursor cursor, TextSpan span, int count) { _cursor = cursor; _span = span; _count = count; }
/// <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; } }
private void RemoveCursor() { TextCursor.RemoveCursor(); }
/// <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; } }