Beispiel #1
0
        //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;
 }
Beispiel #3
0
        //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
        }
Beispiel #4
0
        public WordInfo(string text, WordKind kind, object data)
        {
            this.Text = text;
            WDataList = new List <WordData>();
            WordData wdata = new WordData(kind, data);

            WDataList.Add(wdata);
        }
Beispiel #5
0
		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);
		}
Beispiel #6
0
        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));
        }
Beispiel #7
0
 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);
 }
Beispiel #8
0
 public bool HasKind(WordKind kind)
 {
     foreach (WordData wd in this.WDataList)
     {
         if (wd.WKind == kind)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #9
0
		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);
			}
		}
Beispiel #10
0
		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);
			}
		}
Beispiel #11
0
            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));
        }
Beispiel #13
0
        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);
        }
Beispiel #15
0
            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);
            }
Beispiel #16
0
        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));
                }
            }
        }
Beispiel #17
0
        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));
                }
            }
        }
Beispiel #18
0
        //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));
        }
Beispiel #19
0
 public BreakBounds(int startIndex, int length, WordKind kind)
 {
     this.startIndex = startIndex;
     this.length     = length;
     this.kind       = kind;
 }
Beispiel #20
0
        internal static ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind)
        {
            var textView = EditorUtil.FactoryService.TextEditorFactory.CreateTextView(textBuffer);

            return(CreateTextStructureNavigator(textView, kind));
        }
Beispiel #21
0
 internal static ITextStructureNavigator CreateTextStructureNavigator(ITextView textView, WordKind kind)
 {
     return(GetWordUtil(textView).CreateTextStructureNavigator(kind));
 }
Beispiel #22
0
 public WordInfo(string text, WordKind kind) :
     this(text, kind, null)
 {
 }
Beispiel #23
0
        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);
            }
        }
Beispiel #24
0
 public static SnapshotSpan GetWordSpan(SnapshotPoint currentPosition, out WordKind kind)
 {
     kind = GetWordKind(currentPosition);
     return(GetWordSpan(currentPosition, kind));
 }
Beispiel #25
0
 internal void AddWordBreakAtCurrentIndex(WordKind wordKind = WordKind.Text)
 {
     AddWordBreakAt(this.CurrentIndex, wordKind);
 }
Beispiel #26
0
 private IEnumerable <string> GetWordsInText(WordKind wordKind, SearchPath searchPath, string text) =>
 _wordUtil
 .GetWordSpansInText(wordKind, searchPath, text)
 .Select(span => text.Substring(span.Start, span.Length))
 .ToArray();
Beispiel #27
0
        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("");
        }
Beispiel #28
0
 public BreakAtInfo(int breakAt, WordKind w)
 {
     this.breakAt  = breakAt;
     this.wordKind = w;
 }
Beispiel #29
0
 public WordData(WordKind kind, Object data)
 {
     WKind = kind;
     Data  = data;
 }
Beispiel #30
0
 protected ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind)
 {
     return WordUtilFactory.GetWordUtil(textBuffer).CreateTextStructureNavigator(kind);
 }
Beispiel #31
0
 internal void AddWordBreak_AndSetCurrentIndex(int index, WordKind wordKind)
 {
     AddWordBreakAt(index, wordKind);
     SetCurrentIndex(LatestBreakAt);
 }
Beispiel #32
0
 protected ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind)
 {
     return(WordUtilFactory.GetWordUtil(textBuffer).CreateTextStructureNavigator(kind));
 }
Beispiel #33
0
		public static SnapshotSpan GetWordSpan(SnapshotPoint currentPosition, out WordKind kind) {
			kind = GetWordKind(currentPosition);
			return GetWordSpan(currentPosition, kind);
		}
Beispiel #34
0
 protected ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind)
 {
     return WordUtil.CreateTextStructureNavigator(kind, textBuffer.ContentType);
 }
Beispiel #35
0
        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);
            }
        }
Beispiel #36
0
 protected ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind)
 {
     return(WordUtil.CreateTextStructureNavigator(kind, textBuffer.ContentType));
 }
Beispiel #37
0
        internal static ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind)
        {
            var navigator = CreateTextStructureNavigator(textBuffer);

            return(TssUtil.CreateTextStructureNavigator(kind, navigator));
        }