示例#1
0
        public void TestRemoveItalicStyleTag()
        {
            string expected  = "text";
            string formatted = CStringUtils.I(expected);

            Assert.AreEqual(expected, CStringUtils.RemoveRichTextTags(formatted));
        }
示例#2
0
        public void TestRemoveColorTag()
        {
            string expected  = "text";
            string formatted = CStringUtils.C(expected, CColorCode.Clear);

            Assert.AreEqual(expected, CStringUtils.RemoveRichTextTags(formatted));
        }
        private static string GetNewLine(string line, string[] suggestions)
        {
            if (suggestions.Length == 0)
            {
                return(null);
            }

            string token = GetToken(line);

            if (token == null)
            {
                return(null);
            }

            if (suggestions.Length == 1)
            {
                return(ReplaceToken(line, token, CStringUtils.RemoveRichTextTags(suggestions[0])) + " ");
            }

            string suggestion = CStringUtils.GetSuggestedText(token, suggestions, true);

            if (suggestion == null || suggestion.Equals(token))
            {
                return(null);
            }

            return(ReplaceToken(line, token, suggestion));
        }
示例#4
0
        private static string[] getSuggestedArgs(IList <string> values, string token)
        {
            // we need to keep suggested values in a sorted order
            List <string> sortedValues = new List <string>(values.Count);

            for (int i = 0; i < values.Count; ++i)
            {
                if (token.Length == 0 || CStringUtils.StartsWithIgnoreCase(CStringUtils.RemoveRichTextTags(values[i]), token))
                {
                    sortedValues.Add(CStringUtils.RemoveRichTextTags(values[i]));
                }
            }

            if (sortedValues.Count == 0)
            {
                return(EMPTY_SUGGESTIONS);
            }

            if (sortedValues.Count > 1)
            {
                sortedValues.Sort();
                return(sortedValues.ToArray());
            }

            return(singleSuggestion(sortedValues[0]));
        }
示例#5
0
        private void AssertSuggestions(String line, params String[] expected)
        {
            int index = line.IndexOf('¶');

            Assert.IsTrue(index != -1);

            String[] actual = CStringUtils.RemoveRichTextTags(CCommandAutocompletion.getSuggestions(line.Replace("¶", ""), index));
            Assert.AreEqual(actual, expected);
        }
示例#6
0
        public void TestRemoveColorMultipleInnerStyleTags()
        {
            string expected  = "red green blue";
            string formatted = CStringUtils.B(string.Format("{0} {1} {2}",
                                                            CStringUtils.C("red", CColorCode.Clear),
                                                            CStringUtils.C("green", CColorCode.Error),
                                                            CStringUtils.C("blue", CColorCode.LevelDebug)
                                                            ));

            Assert.AreEqual(expected, CStringUtils.RemoveRichTextTags(formatted));
        }
示例#7
0
        //////////////////////////////////////////////////////////////////////////////

        #region IConsoleDelegate implementation

        public void OnConsoleEntryAdded(CAbstractConsole console, ref CConsoleViewCellEntry entry)
        {
            if (entry.IsTable)
            {
                string[] table = entry.Table;
                foreach (string item in table)
                {
                    terminalTableOutput.Add(CStringUtils.RemoveRichTextTags(item));
                }
            }
        }
示例#8
0
        public void GetText(StringBuilder buffer, int fromLine, int length)
        {
            if (fromLine < Entries.HeadIndex)
            {
                throw new ArgumentOutOfRangeException("From line is out of range");
            }

            int toLine = fromLine + length;

            if (toLine > Entries.Length)
            {
                throw new ArgumentOutOfRangeException("To line is out of range");
            }

            for (int i = fromLine; i < toLine;)
            {
                buffer.Append(CStringUtils.RemoveRichTextTags(Entries[i++].value));
                if (i < toLine)
                {
                    buffer.Append('\n');
                }
            }
        }
示例#9
0
        //////////////////////////////////////////////////////////////////////////////

        #region Helpers

        protected void AddResult(string format, params object[] args)
        {
            this.Result.Add(CStringUtils.RemoveRichTextTags(string.Format(format, args)));
        }