/// <summary> /// Set the editor to use the specified resource name to syntax highlighting /// </summary> /// <param name="resourceName">The name of the resource</param> public void SetSyntaxHighlighter(string resourceName) { ResourceSyntaxModeProvider fsmProvider; // Provider fsmProvider = new ResourceSyntaxModeProvider(resourceName); // Create new provider with the highlighting directory. HighlightingManager.Manager.AddSyntaxModeFileProvider(fsmProvider); // Attach to the text editor. TextBox.SetHighlighting(resourceName); // Activate the highlighting, use the name from the SyntaxDefinition node. }
void FillLists() { builtinList.Items.Clear(); userList.Items.Clear(); string uPath = Path.Combine(PropertyService.ConfigDirectory, "modes"); List<string> uCol; if (Directory.Exists(uPath)) { uCol = FileUtility.SearchDirectory(uPath, "*.xshd", true); } else { Directory.CreateDirectory(uPath); uCol = new List<string>(); } foreach(string str in uCol) { SchemeNode node = LoadFile(new XmlTextReader(str), true, Path.GetFileNameWithoutExtension(str)); if (node == null) continue; userList.Items.Add(new HighlightItem(null, str, node)); } ISyntaxModeFileProvider modeProvider; modeProvider = new ResourceSyntaxModeProvider(); foreach(SyntaxMode mode in modeProvider.SyntaxModes) { SchemeNode node = LoadFile(modeProvider.GetSyntaxModeFile(mode), false, mode.Name); if (node == null) continue; builtinList.Items.Add(new HighlightItem(mode, null, node)); } modeProvider = new ICSharpCode.SharpDevelop.DefaultEditor.Codons.AddInTreeSyntaxModeProvider(); foreach(SyntaxMode mode in modeProvider.SyntaxModes) { SchemeNode node = LoadFile(modeProvider.GetSyntaxModeFile(mode), false, mode.Name); if (node == null) continue; builtinList.Items.Add(new HighlightItem(mode, null, node)); } if (builtinList.Items.Count > 0) builtinList.SelectedIndex = 0; if (userList.Items.Count > 0) userList.SelectedIndex = 0; }