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; } } }
/// <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; } } }