//int dbugAddSteps; #endif internal void AddWordBreakAt(int index, WordKind wordKind) { #if DEBUG //dbugAddSteps++; //if (dbugAddSteps >= 57) //{ //} if (index == _latestBreakAt) { throw new NotSupportedException(); } #endif LatestSpanLen = (ushort)(index - LatestBreakAt); LatestSpanStartAt = _latestBreakAt; _latestBreakAt = index; this.LatestWordKind = wordKind; _newWordBreakHandler(this); #if DEBUG dbugBreakAtList.Add(new BreakAtInfo(index, wordKind)); #endif }
public TextPrinterLineSegment(int startAt, int len, WordKind wordKind, SpanBreakInfo breakInfo) { _startAt = startAt; _len = (ushort)len; //*** WordKind = wordKind; BreakInfo = breakInfo; }
//int dbugAddSteps; #endif internal void AddWordBreakAt(int index, WordKind wordKind) { #if DEBUG //dbugAddSteps++; //if (dbugAddSteps >= 57) //{ //} if (index == _latestBreakAt) { throw new NotSupportedException(); } #endif LatestSpanLen = (ushort)(index - LatestBreakAt); LatestSpanStartAt = _latestBreakAt; LatestWordKind = wordKind; _latestBreakAt = index;//** OnBreak(); //#if DEBUG // if (dbugCollectBreakAtList) // { // dbugBreakAtList.Add(new BreakAtInfo(index, wordKind)); // } //#endif }
public WordInfo(string text, WordKind kind, object data) { this.Text = text; WDataList = new List <WordData>(); WordData wdata = new WordData(kind, data); WDataList.Add(wdata); }
static SnapshotSpan GetWordSpan(SnapshotPoint currentPosition, WordKind kind) { Debug.Assert(GetWordKind(currentPosition) == kind); var line = currentPosition.GetContainingLine(); int column = currentPosition.Position - line.Start.Position; var start = GetStartSpanBefore(line, column, kind); var end = GetEndSpanAfter(line, column, kind); return new SnapshotSpan(start, end); }
static SnapshotSpan GetWordSpan(SnapshotPoint currentPosition, WordKind kind) { Debug.Assert(GetWordKind(currentPosition) == kind); var line = currentPosition.GetContainingLine(); int column = currentPosition.Position - line.Start.Position; var start = GetStartSpanBefore(line, column, kind); var end = GetEndSpanAfter(line, column, kind); return(new SnapshotSpan(start, end)); }
private void AssertWordSpans(string input, WordKind kind, params string[] expected) { var wordsForward = TextUtil.GetWordSpans(kind, SearchPath.Forward, input).Select(x => input.Substring(x.Start, x.Length)).ToList(); Assert.Equal( expected, wordsForward); var wordsBackward = TextUtil.GetWordSpans(kind, SearchPath.Backward, input).Select(x => input.Substring(x.Start, x.Length)).ToList(); Assert.Equal( expected.Reverse(), wordsBackward); }
public bool HasKind(WordKind kind) { foreach (WordData wd in this.WDataList) { if (wd.WKind == kind) { return(true); } } return(false); }
static SnapshotPoint GetStartSpanBefore(ITextSnapshotLine line, int column, WordKind kind) { int position = line.Start.Position + column; var snapshot = line.Snapshot; for (;;) { if (position == line.Start.Position) return line.Start; position--; if (GetWordKind(snapshot[position]) != kind) return new SnapshotPoint(snapshot, position + 1); } }
static SnapshotPoint GetEndSpanAfter(ITextSnapshotLine line, int column, WordKind kind) { int position = line.Start.Position + column; var snapshot = line.Snapshot; for (;;) { if (position + 1 >= line.End.Position) return new SnapshotPoint(snapshot, line.End.Position); position++; if (GetWordKind(snapshot[position]) != kind) return new SnapshotPoint(snapshot, position); } }
private void AssertFullWord(WordKind wordKind, string text, int index, string expected) { var span = _wordUtil.GetFullWordSpanInText(wordKind, text, index).Value; var found = text.Substring(span.Start, span.Length); Assert.Equal(expected, found); _textBuffer.SetTextContent(text); var snapshotSpan = _wordUtil.GetFullWordSpan(wordKind, _textBuffer.GetPoint(index)).Value; Assert.Equal(expected, snapshotSpan.GetText()); }
public void AddWordBreakAt(int index, WordKind wordKind) { #if DEBUG if (index == latestBreakAt) { throw new NotSupportedException(); } #endif this.latestBreakAt = index; breakAtList.Add(new BreakAtInfo(index, wordKind)); }
private void AssertWordSpans(string input, WordKind kind, params string[] expected) { var wordsForward = TextUtil.GetWordSpans(kind, Path.Forward, input).Select(x => input.Substring(x.Start, x.Length)).ToList(); CollectionAssert.AreEquivalent( expected, wordsForward); var wordsBackward = TextUtil.GetWordSpans(kind, Path.Backward, input).Select(x => input.Substring(x.Start, x.Length)).ToList(); CollectionAssert.AreEquivalent( expected.Reverse(), wordsForward); }
private bool HandlePasteSpecial(KeyInput keyInput, WordKind wordKind) { Debug.Assert(InPasteWait); if (!_vimBuffer.Process(keyInput).IsAnyHandled) { return(false); } var currentWord = _vimBuffer.MotionUtil.GetMotion(Motion.NewInnerWord(wordKind), new MotionArgument(MotionContext.AfterOperator)); string pasteText = currentWord.IsSome() ? currentWord.Value.Span.GetText(): string.Empty; EndPasteWait(pasteText); return(true); }
private void AssertWordSpans(WordKind wordKind, string text, string[] expected) { var textWordsForward = GetWordsInText(wordKind, SearchPath.Forward, text); Assert.Equal(expected, textWordsForward); var textWordsBackward = GetWordsInText(wordKind, SearchPath.Forward, text).Reverse(); Assert.Equal(expected.Reverse(), textWordsBackward); _textBuffer.SetTextContent(text); var bufferWordsForward = _wordUtil.GetWordSpans(wordKind, SearchPath.Forward, _textBuffer.GetStartPoint()).Select(x => x.GetText()); Assert.Equal(expected, bufferWordsForward); var bufferWordsBackward = _wordUtil.GetWordSpans(wordKind, SearchPath.Backward, _textBuffer.GetEndPoint()).Select(x => x.GetText()); Assert.Equal(expected.Reverse(), bufferWordsBackward); }
static SnapshotPoint GetEndSpanAfter(ITextSnapshotLine line, int column, WordKind kind) { int position = line.Start.Position + column; var snapshot = line.Snapshot; for (;;) { if (position + 1 >= line.End.Position) { return(new SnapshotPoint(snapshot, line.End.Position)); } position++; if (GetWordKind(snapshot[position]) != kind) { return(new SnapshotPoint(snapshot, position)); } } }
static SnapshotPoint GetStartSpanBefore(ITextSnapshotLine line, int column, WordKind kind) { int position = line.Start.Position + column; var snapshot = line.Snapshot; for (;;) { if (position == line.Start.Position) { return(line.Start); } position--; if (GetWordKind(snapshot[position]) != kind) { return(new SnapshotPoint(snapshot, position + 1)); } } }
//int dbugAddSteps; #endif public void AddWordBreakAt(int index, WordKind wordKind) { #if DEBUG //dbugAddSteps++; //if (dbugAddSteps >= 57) //{ //} if (index == _latestBreakAt) { throw new NotSupportedException(); } #endif this._latestBreakAt = index; _breakAtList.Add(new BreakAtInfo(index, wordKind)); }
public BreakBounds(int startIndex, int length, WordKind kind) { this.startIndex = startIndex; this.length = length; this.kind = kind; }
internal static ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind) { var textView = EditorUtil.FactoryService.TextEditorFactory.CreateTextView(textBuffer); return(CreateTextStructureNavigator(textView, kind)); }
internal static ITextStructureNavigator CreateTextStructureNavigator(ITextView textView, WordKind kind) { return(GetWordUtil(textView).CreateTextStructureNavigator(kind)); }
public WordInfo(string text, WordKind kind) : this(text, kind, null) { }
public String toDL_Simple(String A, WordKind k) { if (A.Length > 0 && char.IsDigit(A[0])) { return(A); } if (k == WordKind.SimplePast) { if (A == "was") { return("was"); } else if (sp.ContainsKey(A)) { return(sp[A]); } else { if (A.EndsWith("ed") && A.Length != 2) { return(A.Substring(0, A.Length - 2)); } else if (A.EndsWith("d") && A.Length != 1) { return(A.Substring(0, A.Length - 1)); } else { return(A); } } } else if (k == WordKind.PastParticiple) { if (pp.ContainsKey(A)) { return(pp[A]); } else { if (A == "was") { return("was"); } else if (A == "is" || A == "are") { return("be"); } else if (A.EndsWith("s") && A.Length != 1) { return(A.Substring(0, A.Length - 1)); } else { return(A); } } } else if (k == WordKind.PluralFormNoun) { if (pl.ContainsKey(A)) { return(pl[A]); } else { if (A.EndsWith("s") && A.Length != 1) { return(A.Substring(0, A.Length - 1)); } else { return(A); } } } else if (k == WordKind.PluralFormVerb) { if (A == "was") { return("was"); } else if (A == "are" || A == "is") { return("be"); } else { return(A); } } else { return(A); } }
public static SnapshotSpan GetWordSpan(SnapshotPoint currentPosition, out WordKind kind) { kind = GetWordKind(currentPosition); return(GetWordSpan(currentPosition, kind)); }
internal void AddWordBreakAtCurrentIndex(WordKind wordKind = WordKind.Text) { AddWordBreakAt(this.CurrentIndex, wordKind); }
private IEnumerable <string> GetWordsInText(WordKind wordKind, SearchPath searchPath, string text) => _wordUtil .GetWordSpansInText(wordKind, searchPath, text) .Select(span => text.Substring(span.Start, span.Length)) .ToArray();
public static string GetStringPostfix(this int value, WordKind kind) { var rest = value % 10; if (kind == WordKind.Man) { if (value > 10 && value < 20) { return("ов"); } else if (rest == 0 || rest >= 5) { return("ов"); } else if (rest == 1) { return(""); } else { return("а"); } } if (kind == WordKind.Woman) { if (value > 10 && value < 20) { return(""); } else if (rest == 0 || rest >= 5) { return(""); } else if (rest == 1) { return("а"); } else { return("ы"); } } if (kind == WordKind.Day) { if (value > 10 && value < 20) { return("дней"); } else if (rest == 0 || rest >= 5) { return("дней"); } else if (rest == 1) { return("день"); } else { return("дня"); } } if (kind == WordKind.Minute) { if (value > 10 && value < 20) { return("минут"); } else if (rest == 0 || rest >= 5) { return("минут"); } else if (rest == 1) { return("минута"); } else { return("минуты"); } } return(""); }
public BreakAtInfo(int breakAt, WordKind w) { this.breakAt = breakAt; this.wordKind = w; }
public WordData(WordKind kind, Object data) { WKind = kind; Data = data; }
protected ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind) { return WordUtilFactory.GetWordUtil(textBuffer).CreateTextStructureNavigator(kind); }
internal void AddWordBreak_AndSetCurrentIndex(int index, WordKind wordKind) { AddWordBreakAt(index, wordKind); SetCurrentIndex(LatestBreakAt); }
protected ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind) { return(WordUtilFactory.GetWordUtil(textBuffer).CreateTextStructureNavigator(kind)); }
public static SnapshotSpan GetWordSpan(SnapshotPoint currentPosition, out WordKind kind) { kind = GetWordKind(currentPosition); return GetWordSpan(currentPosition, kind); }
protected ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind) { return WordUtil.CreateTextStructureNavigator(kind, textBuffer.ContentType); }
public String toN_Simple(String A, WordKind k) { if (A.Length > 0 && char.IsDigit(A[0])) { return(A); } if (k == WordKind.SimplePast) { if (i_sp.ContainsKey(A)) { return(i_sp[A]); } if (A == "was") { return("was"); } else if (A == "be") { return("is"); } else { if (A.EndsWith("e") && A.Length != 1) { return(A + "d"); } else { return(A + "ed"); } } } else if (k == WordKind.PastParticiple) { if (i_pp.ContainsKey(A)) { return(i_pp[A]); } else if (A == "was") { return("was"); } else if (A == "be") { return("is"); } else { return(A + "s"); } } else if (k == WordKind.PluralFormNoun) { if (i_pl.ContainsKey(A)) { return(i_pl[A]); } else { return(A + "s"); } } else if (k == WordKind.PluralFormVerb) { if (A == "was") { return("was"); } else if (A == "be") { return("are"); } else { return(A); } } else { return(A); } }
protected ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind) { return(WordUtil.CreateTextStructureNavigator(kind, textBuffer.ContentType)); }
internal static ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind) { var navigator = CreateTextStructureNavigator(textBuffer); return(TssUtil.CreateTextStructureNavigator(kind, navigator)); }