StonehearthEditor.FilePreview.restyleDocument C# (CSharp) Method

restyleDocument() private method

Called whenever a change was made; used to re-style the whole document. Sets indicators.
private restyleDocument ( ) : void
return void
        private void restyleDocument()
        {
            var scintilla = this.textBox;

            // Reset all indicators
            scintilla.IndicatorClearRange(0, scintilla.TextLength);

            // Search for fitting texts
            scintilla.SearchFlags = SearchFlags.Regex | SearchFlags.Posix;

            scintilla.IndicatorCurrent = kI18nIndicator;
            this.indicate(@"i18n\(.+?\)");
            scintilla.IndicatorCurrent = kFileIndicator;
            this.indicate(@"""[^"" ]*?:[^"" ]*?""", this.transformFileNames);
            this.indicate(@"file\(.+?\)", this.transformFileNames);
            this.indicate(@"""[^""]*?/[^""]*?""", this.transformFileNames);

            // Update line number margin width
            // From https://github.com/jacobslusser/ScintillaNET/wiki/Displaying-Line-Numbers
            var maxLineNumberCharLength = scintilla.Lines.Count.ToString().Length;
            if (maxLineNumberCharLength != this.maxLineNumberCharLength)
            {
                const int padding = 2;
                scintilla.Margins[0].Width = scintilla.TextWidth(Style.LineNumber, new string('9', maxLineNumberCharLength + 1)) + padding;
                this.maxLineNumberCharLength = maxLineNumberCharLength;
            }
        }