Ejemplo n.º 1
0
        private void SetLanguage(string language)
        {
            if ("ini".Equals(language, StringComparison.OrdinalIgnoreCase))
            {
                // Reset/set all styles and prepare _scintilla for custom lexing
                ActiveDocument.IniLexer = true;
                IniLexer.Init(ActiveDocument.Scintilla);
            }
            else
            {
                // Use a built-in lexer and configuration
                ActiveDocument.IniLexer = false;
                ActiveDocument.Scintilla.ConfigurationManager.Language = language;

                // Smart indenting...
                if ("cs".Equals(language, StringComparison.OrdinalIgnoreCase))
                {
                    ActiveDocument.Scintilla.Indentation.SmartIndentType = SmartIndent.CPP;
                }
                else
                {
                    ActiveDocument.Scintilla.Indentation.SmartIndentType = SmartIndent.None;
                }
            }
        }
Ejemplo n.º 2
0
        public static void StyleNeeded(Scintilla scintilla, Range range)
        {
            // Create an instance of our lexer and bada-bing the line!
            var lexer = new IniLexer(scintilla, range.Start, range.StartingLine.Length);

            lexer.Style();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 设置文件的格式
        /// </summary>
        /// <param name="form"></param>
        private void SetLanguage(DocumentForm form)
        {
            if (form == null)
            {
                return;
            }
            string language = new FileInfo(form.FilePath).Extension.Replace(".", "");

            if ("ini".Equals(language, StringComparison.OrdinalIgnoreCase))
            {
                // Reset/set all styles and prepare _scintilla for custom lexing
                form.IniLexer = true;
                IniLexer.Init(form.Scintilla);
            }
            else
            {
                // Use a built-in lexer and configuration
                form.IniLexer = false;
                form.Scintilla.ConfigurationManager.Language = language;

                // Smart indenting...
                if ("cs".Equals(language, StringComparison.OrdinalIgnoreCase))
                {
                    form.Scintilla.Indentation.SmartIndentType = SmartIndent.CPP;
                }
                else
                {
                    form.Scintilla.Indentation.SmartIndentType = SmartIndent.None;
                }
            }
        }
Ejemplo n.º 4
0
 public static void StyleNeeded(Scintilla scintilla, Range range)
 {
     // Create an instance of our lexer and bada-bing the line!
     IniLexer lexer = new IniLexer(scintilla, range.Start, range.StartingLine.Length);
     lexer.Style();
 }