示例#1
0
        public SearchMetadata(int position, [NotNull] string searchText, bool filter,
                              HighlightingMode highlight,
                              bool useRegex,
                              bool ignoreCase,
                              Hue highlightHue,
                              string iconKind,
                              bool isGlobal,
                              bool isExclusion)
        {
            if (searchText == null)
            {
                throw new ArgumentNullException(nameof(searchText));
            }

            Position     = position;
            SearchText   = searchText;
            Filter       = filter;
            Highlight    = highlight;
            UseRegex     = useRegex;
            IgnoreCase   = ignoreCase;
            HighlightHue = highlightHue;
            IconKind     = iconKind;
            IsGlobal     = isGlobal;
            IsExclusion  = isExclusion;
            RegEx        = this.BuildRegEx();
            Predicate    = this.BuildPredicate();
        }
示例#2
0
 /// <summary>
 /// Prints the given text in the chosen highlighting mode on the console
 /// </summary>
 public override void PrintHighlighted(String text, HighlightingMode mode)
 {
     if ((mode & HighlightingMode.Focus) == HighlightingMode.Focus)
     {
         Console.Write("\x1b[1m\x1b[33m\x1b[40m" + text + "\x1b[0m"); // bold, yellow fg, black bg
     }
     else if ((mode & HighlightingMode.FocusSucces) == HighlightingMode.FocusSucces)
     {
         Console.Write("\x1b[1m\x1b[32m\x1b[40m" + text + "\x1b[0m"); // bold, green fg, black bg
     }
     else if ((mode & HighlightingMode.LastSuccess) == HighlightingMode.LastSuccess)
     {
         Console.Write("\x1b[42m" + text + "\x1b[0m"); // green bg
     }
     else if ((mode & HighlightingMode.LastFail) == HighlightingMode.LastFail)
     {
         Console.Write("\x1b[41m" + text + "\x1b[0m"); // red bg
     }
     else if ((mode & HighlightingMode.Breakpoint) == HighlightingMode.Breakpoint)
     {
         Console.Write("\x1b[31m" + text + "\x1b[0m"); // red fg
     }
     else if ((mode & HighlightingMode.Choicepoint) == HighlightingMode.Choicepoint)
     {
         Console.Write("\x1b[35m" + text + "\x1b[0m"); // magenta fg
     }
     else if ((mode & HighlightingMode.SequenceStart) == HighlightingMode.SequenceStart)
     {
         Console.Write("\x1b[34m" + text + "\x1b[0m"); // blue fg
     }
     else if ((mode & HighlightingMode.GrsFile) == HighlightingMode.GrsFile)
     {
         Console.Write("\x1b[31m" + text + "\x1b[0m"); // red fg
     }
     else if ((mode & HighlightingMode.GrsiFile) == HighlightingMode.GrsiFile)
     {
         Console.Write("\x1b[35m" + text + "\x1b[0m"); // magenta fg
     }
     else if ((mode & HighlightingMode.GrgFile) == HighlightingMode.GrgFile)
     {
         Console.Write("\x1b[32m" + text + "\x1b[0m"); // green fg
     }
     else if ((mode & HighlightingMode.GriFile) == HighlightingMode.GriFile)
     {
         Console.Write("\x1b[36m" + text + "\x1b[0m"); // cyan fg
     }
     else if ((mode & HighlightingMode.GmFile) == HighlightingMode.GmFile)
     {
         Console.Write("\x1b[34m" + text + "\x1b[0m"); // blue fg
     }
     else if ((mode & HighlightingMode.Directory) == HighlightingMode.Directory)
     {
         Console.Write("\x1b[43m" + text + "\x1b[0m"); // yellow bg
     }
     else
     {
         Console.Write(text); // normal
     }
 }
示例#3
0
        private static void PrintSequenceBreakpointable(Sequence seq, Sequence parent, PrintSequenceContext context)
        {
            if (context.bpPosCounter >= 0)
            {
                PrintBreak((SequenceSpecial)seq, context);
                Console.Write(seq.Symbol);
                ++context.bpPosCounter;
                return;
            }

            if (context.cpPosCounter >= 0 && seq is SequenceRandomChoice &&
                ((SequenceRandomChoice)seq).Random)
            {
                PrintChoice((SequenceRandomChoice)seq, context);
                Console.Write(seq.Symbol);
                ++context.cpPosCounter;
                return;
            }

            HighlightingMode mode = HighlightingMode.None;

            if (seq == context.highlightSeq)
            {
                if (context.choice)
                {
                    mode |= HighlightingMode.Choicepoint;
                }
                else if (context.success)
                {
                    mode |= HighlightingMode.FocusSucces;
                }
                else
                {
                    mode |= HighlightingMode.Focus;
                }
            }
            if (seq.ExecutionState == SequenceExecutionState.Success)
            {
                mode |= HighlightingMode.LastSuccess;
            }
            if (seq.ExecutionState == SequenceExecutionState.Fail)
            {
                mode |= HighlightingMode.LastFail;
            }
            if (context.sequences != null && context.sequences.Contains(seq))
            {
                if (context.matches != null && context.matches[context.sequences.IndexOf(seq)].Count > 0)
                {
                    mode |= HighlightingMode.FocusSucces;
                }
            }
            WorkaroundManager.Workaround.PrintHighlighted(seq.Symbol, mode);
        }
示例#4
0
        private static void PrintSequenceDefinitionInterpreted(SequenceDefinitionInterpreted seqDef, Sequence parent, PrintSequenceContext context)
        {
            HighlightingMode mode = HighlightingMode.None;

            if (seqDef.ExecutionState == SequenceExecutionState.Success)
            {
                mode = HighlightingMode.LastSuccess;
            }
            if (seqDef.ExecutionState == SequenceExecutionState.Fail)
            {
                mode = HighlightingMode.LastFail;
            }
            WorkaroundManager.Workaround.PrintHighlighted(seqDef.Symbol + ": ", mode);
            PrintSequence(seqDef.Seq, seqDef.Seq, context);
        }
示例#5
0
 public SearchState(string text, int position, bool useRegEx, HighlightingMode highlight, bool filter, bool alert,
                    bool ignoreCase, string swatch, string icon, string hue, bool isExclusion)
 {
     Text        = text;
     Position    = position;
     UseRegEx    = useRegEx;
     Highlight   = highlight;
     Filter      = filter;
     Alert       = alert;
     IgnoreCase  = ignoreCase;
     Swatch      = swatch;
     Icon        = icon;
     Hue         = hue;
     IsExclusion = isExclusion;
 }
示例#6
0
        /// <summary>
        /// Loads the opacity multiplier
        /// </summary>
        /// <param name="store">The writable settings store</param>
        /// <returns>The opacity multiplier or if not found, the default opacity multiplier</returns>
        public static HighlightingMode LoadHighlightingMode(this WritableSettingsStore store)
        {
            HighlightingMode highlightingMode = DefaultRainbowIndentOptions.defaultHighlightingMode;

            if (store == null)
            {
                return(highlightingMode);
            }
            if (!store.PropertyExists(CollectionName, HighlightingModePropertyName))
            {
                store.SaveHighlightingMode(highlightingMode);
            }
            else
            {
                highlightingMode = (HighlightingMode)Enum.Parse(typeof(HighlightingMode),
                                                                store.GetString(CollectionName, HighlightingModePropertyName));
            }
            return(highlightingMode);
        }
示例#7
0
        /// <summary>
        /// Prints the given text in the chosen highlighting mode on the console
        /// </summary>
        public void PrintHighlighted(String text, HighlightingMode mode)
        {
            if (mode == HighlightingMode.None)
            {
                Console.Write(text);
                return;
            }

            ConsoleColor oldForegroundColor = Console.ForegroundColor;
            ConsoleColor oldBackgroundColor = Console.BackgroundColor;

            if ((mode & HighlightingMode.Focus) == HighlightingMode.Focus)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
            }
            if ((mode & HighlightingMode.FocusSucces) == HighlightingMode.FocusSucces)
            {
                Console.ForegroundColor = ConsoleColor.Green;
            }
            if ((mode & HighlightingMode.LastSuccess) == HighlightingMode.LastSuccess)
            {
                Console.BackgroundColor = ConsoleColor.DarkGreen;
            }
            if ((mode & HighlightingMode.LastFail) == HighlightingMode.LastFail)
            {
                Console.BackgroundColor = ConsoleColor.DarkRed;
            }
            if ((mode & HighlightingMode.Focus) == HighlightingMode.Focus || (mode & HighlightingMode.FocusSucces) == HighlightingMode.FocusSucces)
            {
                Console.BackgroundColor = ConsoleColor.Black;
            }
            if ((mode & HighlightingMode.Breakpoint) == HighlightingMode.Breakpoint)
            {
                Console.ForegroundColor = ConsoleColor.Red;
            }
            if ((mode & HighlightingMode.Choicepoint) == HighlightingMode.Choicepoint)
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
            }
            if ((mode & HighlightingMode.SequenceStart) == HighlightingMode.SequenceStart)
            {
                Console.ForegroundColor = ConsoleColor.Blue;
            }
            if ((mode & HighlightingMode.GrsFile) == HighlightingMode.GrsFile)
            {
                Console.ForegroundColor = ConsoleColor.Red;
            }
            if ((mode & HighlightingMode.GrsiFile) == HighlightingMode.GrsiFile)
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
            }
            if ((mode & HighlightingMode.GrgFile) == HighlightingMode.GrgFile)
            {
                Console.ForegroundColor = ConsoleColor.Green;
            }
            if ((mode & HighlightingMode.GriFile) == HighlightingMode.GriFile)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
            }
            if ((mode & HighlightingMode.GmFile) == HighlightingMode.GmFile)
            {
                Console.ForegroundColor = ConsoleColor.Blue;
            }
            if ((mode & HighlightingMode.Directory) == HighlightingMode.Directory)
            {
                Console.BackgroundColor = ConsoleColor.DarkYellow;
            }
            Console.Write(text);
            Console.ForegroundColor = oldForegroundColor;
            Console.BackgroundColor = oldBackgroundColor;
        }
示例#8
0
 public abstract void PrintHighlighted(String text, HighlightingMode mode);
示例#9
0
        /// <summary>
        /// Prints the given text in the chosen highlighting mode on the console
        /// </summary>
        public void PrintHighlighted(String text, HighlightingMode mode)
        {
            if(mode == HighlightingMode.None)
            {
                Console.Write(text);
                return;
            }

            ConsoleColor oldForegroundColor = Console.ForegroundColor;
            ConsoleColor oldBackgroundColor = Console.BackgroundColor;
            if((mode & HighlightingMode.Focus) == HighlightingMode.Focus) Console.ForegroundColor = ConsoleColor.Yellow;
            if((mode & HighlightingMode.FocusSucces) == HighlightingMode.FocusSucces) Console.ForegroundColor = ConsoleColor.Green;
            if((mode & HighlightingMode.LastSuccess) == HighlightingMode.LastSuccess) Console.BackgroundColor = ConsoleColor.DarkGreen;
            if((mode & HighlightingMode.LastFail) == HighlightingMode.LastFail) Console.BackgroundColor = ConsoleColor.DarkRed;
            if((mode & HighlightingMode.Focus) == HighlightingMode.Focus || (mode & HighlightingMode.FocusSucces) == HighlightingMode.FocusSucces) Console.BackgroundColor = ConsoleColor.Black;
            if((mode & HighlightingMode.Breakpoint) == HighlightingMode.Breakpoint) Console.ForegroundColor = ConsoleColor.Red;
            if((mode & HighlightingMode.Choicepoint) == HighlightingMode.Choicepoint) Console.ForegroundColor = ConsoleColor.Magenta;
            if((mode & HighlightingMode.SequenceStart) == HighlightingMode.SequenceStart) Console.ForegroundColor = ConsoleColor.Blue;
            if((mode & HighlightingMode.GrsFile) == HighlightingMode.GrsFile) Console.ForegroundColor = ConsoleColor.Red;
            if((mode & HighlightingMode.GrsiFile) == HighlightingMode.GrsiFile) Console.ForegroundColor = ConsoleColor.Magenta;
            if((mode & HighlightingMode.GrgFile) == HighlightingMode.GrgFile) Console.ForegroundColor = ConsoleColor.Green;
            if((mode & HighlightingMode.GriFile) == HighlightingMode.GriFile) Console.ForegroundColor = ConsoleColor.Cyan;
            if((mode & HighlightingMode.GmFile) == HighlightingMode.GmFile) Console.ForegroundColor = ConsoleColor.Blue;
            if((mode & HighlightingMode.Directory) == HighlightingMode.Directory) Console.BackgroundColor = ConsoleColor.DarkYellow;
            Console.Write(text);
            Console.ForegroundColor = oldForegroundColor;
            Console.BackgroundColor = oldBackgroundColor;
        }
示例#10
0
 /// <summary>
 /// Prints the given text in the chosen highlighting mode on the console
 /// </summary>
 public override void PrintHighlighted(String text, HighlightingMode mode)
 {
     if((mode & HighlightingMode.Focus) == HighlightingMode.Focus)
         Console.Write("\x1b[1m\x1b[33m\x1b[40m" + text + "\x1b[0m"); // bold, yellow fg, black bg
     else if((mode & HighlightingMode.FocusSucces) == HighlightingMode.FocusSucces)
         Console.Write("\x1b[1m\x1b[32m\x1b[40m" + text + "\x1b[0m"); // bold, green fg, black bg
     else if((mode & HighlightingMode.LastSuccess) == HighlightingMode.LastSuccess)
         Console.Write("\x1b[42m" + text + "\x1b[0m"); // green bg
     else if((mode & HighlightingMode.LastFail) == HighlightingMode.LastFail)
         Console.Write("\x1b[41m" + text + "\x1b[0m"); // red bg
     else if((mode & HighlightingMode.Breakpoint) == HighlightingMode.Breakpoint)
         Console.Write("\x1b[31m" + text + "\x1b[0m"); // red fg
     else if((mode & HighlightingMode.Choicepoint) == HighlightingMode.Choicepoint)
         Console.Write("\x1b[35m" + text + "\x1b[0m"); // magenta fg
     else if((mode & HighlightingMode.SequenceStart) == HighlightingMode.SequenceStart)
         Console.Write("\x1b[34m" + text + "\x1b[0m"); // blue fg
     else if((mode & HighlightingMode.GrsFile) == HighlightingMode.GrsFile)
         Console.Write("\x1b[31m" + text + "\x1b[0m"); // red fg
     else if((mode & HighlightingMode.GrsiFile) == HighlightingMode.GrsiFile)
         Console.Write("\x1b[35m" + text + "\x1b[0m"); // magenta fg
     else if((mode & HighlightingMode.GrgFile) == HighlightingMode.GrgFile)
         Console.Write("\x1b[32m" + text + "\x1b[0m"); // green fg
     else if((mode & HighlightingMode.GriFile) == HighlightingMode.GriFile)
         Console.Write("\x1b[36m" + text + "\x1b[0m"); // cyan fg
     else if((mode & HighlightingMode.GmFile) == HighlightingMode.GmFile)
         Console.Write("\x1b[34m" + text + "\x1b[0m"); // blue fg
     else if((mode & HighlightingMode.Directory) == HighlightingMode.Directory)
         Console.Write("\x1b[43m" + text + "\x1b[0m"); // yellow bg
     else
         Console.Write(text); // normal
 }
示例#11
0
 public abstract void PrintHighlighted(String text, HighlightingMode mode);
示例#12
0
        /// <summary>
        /// Saves the settings to the settings store
        /// </summary>
        /// <param name="indentSize">The indent size specifiyng the number of spaces for indentation detection</param>
        /// <param name="colors">The colors as string</param>
        public static void SaveSettings(int indentSize, string fileExtensionsString, string colors, double opacityMultiplier, HighlightingMode highlightingmode, string errorColor, bool detectError)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            WritableSettingsStore settingsStore = GetWritableSettingsStore();

            settingsStore.SaveIndentSize(indentSize);
            settingsStore.SaveFileExtensionsIndentSizes(fileExtensionsString);
            settingsStore.SaveColors(colors);
            settingsStore.SaveOpacityMultiplier(opacityMultiplier);
            settingsStore.SaveHighlightingMode(highlightingmode);
            settingsStore.SaveDetectErrorsFlag(detectError);
            settingsStore.SaveErrorColor(errorColor);

            OptionsManager.indentSize.Set(indentSize);
            OptionsManager.fileExtensionsString.Set(fileExtensionsString);
            fileExtensionsDictionary.Set(LanguageParser.CreateDictionaryFromString(fileExtensionsString));
            OptionsManager.colors.Set(colors);
            brushes.Set(ColorParser.ConvertStringToBrushArray(colors, opacityMultiplier));
            OptionsManager.opacityMultiplier.Set(opacityMultiplier);
            OptionsManager.highlightingMode.Set(highlightingmode);
            OptionsManager.errorColor.Set(errorColor);
            detectErrors.Set(detectError);
            errorBrush.Set(ColorParser.ConvertStringToBrush(errorColor, opacityMultiplier));
        }
示例#13
0
 /// <summary>
 /// Saves the highlightingMode
 /// </summary>
 /// <param name="store">The writable settings store</param>
 /// <param name="highlightingMode">The highlightingmode to  save</param>
 public static void SaveHighlightingMode(this WritableSettingsStore store, HighlightingMode highlightingMode)
 {
     store?.SetString(CollectionName, HighlightingModePropertyName, highlightingMode.ToString());
 }