////////////////////////////////////////////////////////////////////////// private void FillWordFileEntry(int Order, WordFileItem Item) { Item.Order = Order; Item.Name = "WME Script"; Item.Lines.Clear(); // language definition string LangLine = ""; LangLine += "/L" + Order.ToString() + "\"WME Script\""; LangLine += " Line Comment = //"; LangLine += " Block Comment On = /* Block Comment Off = */ NestBlockComments"; LangLine += " Line Comment = //"; LangLine += " Escape Char = ~ String Chars = \""; string[] Extensions = ParentForm.GetExtensions(); LangLine += " File Extensions ="; foreach (string Ext in Extensions) { LangLine += " " + Ext; } Item.Lines.Add(LangLine); Item.Lines.Add("/Delimiters = ~!@%^&*()-+=|\\/{}[]:;\"'<> , .?"); Item.Lines.Add("/Function String = \"%[ ^t]++function^(*(*)^)\""); Item.Lines.Add("/Function String 1 = \"%[ ^t]++method^(*(*)^)\""); Item.Lines.Add("/Indent Strings = \"{\" \"else\""); Item.Lines.Add("/Unindent Strings = \"}\""); Item.Lines.Add("/Open Brace Strings = \"{\" \"(\" \"[\" \"<\""); Item.Lines.Add("/Close Brace Strings = \"}\" \")\" \"]\" \">\""); Item.Lines.Add("/Open Fold Strings = \"{\" \"#region\""); Item.Lines.Add("/Close Fold Strings = \"}\" \"#endregion\""); WordHolder wh = new WordHolder(); // keywords Item.Lines.Add("/C1\"Keywords\" STYLE_KEYWORD"); foreach (string Keyword in ScriptTokenizer.Keywords) { wh.AddWord(Keyword); } Item.Lines.Add(wh.GetWords()); // read XML docs ScriptInfo Info = new ScriptInfo(); Info.ReadXml(WmeUtils.XmlDocsPath); // methods Item.Lines.Add("/C2\"Methods\" STYLE_METHOD"); wh = new WordHolder(); foreach (ScriptObject Obj in Info.Objects) { foreach (ScriptMethod Method in Obj.Methods) { //if (Method.IsGlobal) continue; foreach (string Header in Method.Headers) { int Brace = Header.IndexOf("("); if (Brace >= 0) { wh.AddWord(Header.Substring(0, Brace).Trim()); } } } } Item.Lines.Add(wh.GetWords()); // attributes Item.Lines.Add("/C3\"Properties\" STYLE_ATTRIBUTE"); wh = new WordHolder(); foreach (ScriptObject Obj in Info.Objects) { foreach (ScriptAttribute Attr in Obj.Attributes) { if (Attr.Name.StartsWith("[")) { continue; } wh.AddWord(Attr.Name); } } Item.Lines.Add(wh.GetWords()); // preprocessor Item.Lines.Add("/C4\"Preprocessor\" STYLE_EXTENSION"); Item.Lines.Add("#endregion #include #region"); }
////////////////////////////////////////////////////////////////////////// private void OnIntegrate(object sender, EventArgs e) { string ScitePath = Path.Combine(WmeUtils.ToolsPath, "scite"); if (!Directory.Exists(ScitePath)) { Directory.CreateDirectory(ScitePath); } string[] Extensions = ParentForm.GetExtensions(); string Extensions2 = ""; foreach (string Ext in Extensions) { if (Extensions2 != "") { Extensions2 += ";"; } Extensions2 += "*." + Ext; } // generate syntax file try { // read XML docs ScriptInfo Info = new ScriptInfo(); Info.ReadXml(WmeUtils.XmlDocsPath); string KwdFile = Path.Combine(ScitePath, "wme_kwd.properties"); using (StreamWriter sw = new StreamWriter(KwdFile, false, Encoding.Default)) { sw.WriteLine(FileHeader); sw.WriteLine("file.patterns.script=" + Extensions2); sw.WriteLine("filter.script=WME Scripts|$(file.patterns.script)|"); sw.WriteLine(); WordHolder wh; // keywords sw.WriteLine("keywords.$(file.patterns.script)=\\"); wh = new WordHolder(); foreach (string Keyword in ScriptTokenizer.Keywords) { wh.AddWord(Keyword); } sw.WriteLine(wh.GetWords()); // methods sw.WriteLine("keywords2.$(file.patterns.script)=\\"); wh = new WordHolder(); foreach (ScriptObject Obj in Info.Objects) { foreach (ScriptMethod Method in Obj.Methods) { foreach (string Header in Method.Headers) { int Brace = Header.IndexOf("("); if (Brace >= 0) { wh.AddWord(Header.Substring(0, Brace).Trim()); } } } } sw.WriteLine(wh.GetWords()); // attributes sw.WriteLine("keywords4.$(file.patterns.script)=\\"); wh = new WordHolder(); foreach (ScriptObject Obj in Info.Objects) { foreach (ScriptAttribute Attr in Obj.Attributes) { if (Attr.Name.StartsWith("[")) { continue; } wh.AddWord(Attr.Name); } } sw.WriteLine(wh.GetWords()); } // tools string ToolsFile = Path.Combine(ScitePath, "wme_tools.properties"); using (StreamWriter sw = new StreamWriter(ToolsFile, false, Encoding.Default)) { sw.WriteLine(FileHeader); sw.WriteLine("command.compile.$(file.patterns.script)=\"" + WmeUtils.CompilerPath + "\" -script \"$(FilePath)\" -format scite"); sw.WriteLine("command.help.$(file.patterns.script)=reference!" + Path.Combine(WmeUtils.ToolsPath, "wme.chm")); sw.WriteLine("command.help.subsystem.$(file.patterns.script)=4"); sw.WriteLine("api.$(file.patterns.script)=" + Path.Combine(WmeUtils.ToolsPath, "SciTE\\wme.api")); } // api string ApiFile = Path.Combine(ScitePath, "wme.api"); using (StreamWriter sw = new StreamWriter(ApiFile, false, Encoding.Default)) { WordHolder wh; wh = new WordHolder(); foreach (ScriptObject Obj in Info.Objects) { foreach (ScriptMethod Method in Obj.Methods) { foreach (string Header in Method.Headers) { wh.AddWord(Header + Method.Desc); } } } foreach (ScriptObject Obj in Info.Objects) { foreach (ScriptAttribute Attr in Obj.Attributes) { if (Attr.Name.StartsWith("[")) { continue; } wh.AddWord(Attr.Name); } } sw.WriteLine(wh.GetWordsApi()); } } catch { } }
////////////////////////////////////////////////////////////////////////// private void OnAddLanguage(object sender, EventArgs e) { if (!File.Exists(PsPadIni)) { return; } //File.Exists(ParentForm.TxtProjectFile.Text while (NativeMethods.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "TfPSPad", null) != IntPtr.Zero) { DialogResult Res = MessageBox.Show("Please close PSPad first.", ParentForm.Text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); if (Res == DialogResult.Abort) { return; } else if (Res == DialogResult.Ignore) { break; } } if (DialogResult.Yes != MessageBox.Show("Do you really want to replace '" + ListLanguages.SelectedItem.ToString() + "' with WME scripts?", ParentForm.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } IniFile Ini = new IniFile(PsPadIni); string Suffix = ""; if (ListLanguages.SelectedIndex > 0) { Suffix = ListLanguages.SelectedIndex.ToString(); } Ini.WriteString("Config", "UserHighLighterName" + Suffix, "WME Script"); Ini.WriteString("Highlighters", "General" + Suffix, "1"); string[] Extensions = ParentForm.GetExtensions(); string Extensions2 = ""; foreach (string Ext in Extensions) { if (Extensions2 != "") { Extensions2 += ";"; } Extensions2 += "*." + Ext; } // language section Ini.WriteString("WME Script", "Filter", "WME Script (" + Extensions2 + ")|" + Extensions2); Ini.WriteString("WME Script", "HLTabWidth", "4"); Ini.WriteString("WME Script", "IndentChar", "{"); Ini.WriteString("WME Script", "UnIndentChar", "}"); Ini.WriteString("WME Script", "Comment", "000080001FFFFFFF010"); Ini.WriteString("WME Script", "Identifier", "1FFFFFFF1FFFFFFF000"); Ini.WriteString("WME Script", "Key", "00FF00001FFFFFFF100"); Ini.WriteString("WME Script", "Key words 2", "000000801FFFFFFF100"); Ini.WriteString("WME Script", "Key words 3", "008080001FFFFFFF100"); Ini.WriteString("WME Script", "Label", "000000FF1FFFFFFF000"); Ini.WriteString("WME Script", "Number", "000000FF1FFFFFFF000"); Ini.WriteString("WME Script", "Preprocessor", "008000801FFFFFFF010"); Ini.WriteString("WME Script", "Reserved Word", "000000801FFFFFFF100"); Ini.WriteString("WME Script", "Space", "008080001FFFFFFF000"); Ini.WriteString("WME Script", "String", "008080801FFFFFFF000"); Ini.WriteString("WME Script", "Symbol", "1FFFFFFF1FFFFFFF000"); // compiler settings Ini.WriteString("WME Script", "Compilator File", WmeUtils.CompilerPath); string CompParams = "-script |%File%|"; if (File.Exists(ParentForm.TxtProjectFile.Text)) { CompParams += " -project |" + ParentForm.TxtProjectFile.Text + "|"; } Ini.WriteString("WME Script", "Compilator Param", CompParams); Ini.WriteString("WME Script", "Compilator LOG", ""); Ini.WriteString("WME Script", "Compilator Run", ""); Ini.WriteString("WME Script", "Compilator Help", Path.Combine(WmeUtils.ToolsPath, "wme.chm")); Ini.WriteString("WME Script", "Compilator SaveAll", "0"); Ini.WriteString("WME Script", "Compilator ParsLog", "%F,%L:%E"); Ini.WriteString("WME Script", "Compilator Capture", "1"); Ini.WriteString("WME Script", "Compilator HideOutput", "1"); Ini.WriteString("WME Script", "Compilator DefaultDir", ""); // generate syntax file try { string SyntaxFilePath = Path.Combine(TxtPsPadInstallDir.Text, "Syntax"); if (!Directory.Exists(SyntaxFilePath)) { Directory.CreateDirectory(SyntaxFilePath); } SyntaxFilePath = Path.Combine(SyntaxFilePath, "WME Script.ini"); using (StreamWriter sw = new StreamWriter(SyntaxFilePath, false, Encoding.Default)) { sw.WriteLine("; PSPad HighLighter definition file for WME Scripts"); sw.WriteLine("; Generated automatically by WME Integrator"); sw.WriteLine("; Do not modify this file"); sw.WriteLine("[Settings]"); sw.WriteLine("Name=WME Script"); sw.WriteLine("HTMLGroup=0"); sw.WriteLine("Label=1"); sw.WriteLine("FileType=" + Extensions2.Replace(";", ",")); sw.WriteLine("CommentString="); sw.WriteLine("SlashComment=1"); sw.WriteLine("CComment=1"); sw.WriteLine("SlashComment=1"); sw.WriteLine("Preprocessors=1"); sw.WriteLine("IndentChar={"); sw.WriteLine("UnIndentChar=}"); sw.WriteLine("TabWidth=4"); sw.WriteLine("CaseSensitive=1"); sw.WriteLine("DoubleQuote=1"); sw.WriteLine("KeyWordChars=_"); sw.WriteLine("CodeExplorer=ftJS"); WordHolder wh; // keywords sw.WriteLine("[KeyWords]"); wh = new WordHolder(); foreach (string Keyword in ScriptTokenizer.Keywords) { wh.AddWord(Keyword); } sw.WriteLine(wh.GetWords()); // read XML docs ScriptInfo Info = new ScriptInfo(); Info.ReadXml(WmeUtils.XmlDocsPath); // methods sw.WriteLine("[KeyWords2]"); wh = new WordHolder(); foreach (ScriptObject Obj in Info.Objects) { foreach (ScriptMethod Method in Obj.Methods) { foreach (string Header in Method.Headers) { int Brace = Header.IndexOf("("); if (Brace >= 0) { wh.AddWord(Header.Substring(0, Brace).Trim()); } } } } sw.WriteLine(wh.GetWords()); // attributes sw.WriteLine("[KeyWords3]"); wh = new WordHolder(); foreach (ScriptObject Obj in Info.Objects) { foreach (ScriptAttribute Attr in Obj.Attributes) { if (Attr.Name.StartsWith("[")) { continue; } wh.AddWord(Attr.Name); } } sw.WriteLine(wh.GetWords()); } } catch { } LoadInfo(); }