/// <summary> /// Xshdファイルを書き込みます /// </summary> /// <param name="def">書き込み対象のDefinitionインスタンス</param> /// <returns>true:成功, false:失敗</returns> private bool WriteXshdFile(XshdSyntaxDefinition def) { Logger.Info(CLASS_NAME, "WriteXshdFile", "start"); if (def == null) { Logger.Error(CLASS_NAME, "WriteXshdFile", "def is null!"); return(false); } using (XmlTextWriter writer = new XmlTextWriter(_xshdFilePath, System.Text.Encoding.UTF8)) { writer.Formatting = Formatting.Indented; SaveXshdVisitor visitor = new SaveXshdVisitor(writer); // 実装側でどう処理しているか調査終えるまで、念のためtry-catchしておく try { visitor.WriteDefinition(def); } catch (Exception e) { Logger.Fatal(CLASS_NAME, "WriteXshdFile", e.ToString()); return(false); } finally { writer.Close(); } } return(true); }
public void HighlightingDefinitionCanBeLoadedFromXmlViaMemoryStream() { using (XmlTextReader reader = new XmlTextReader(predefinedManifestResourceStream)) { XshdSyntaxDefinition xshd = HighlightingLoader.LoadXshd(reader); Assert.AreEqual("BAT", xshd.Name); } }
void UpdatePreview() { XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem; if (xshd != null) { var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name); CustomizableHighlightingColorizer.ApplyCustomizationsToDefaultElements(textEditor, customizationsForCurrentLanguage); ApplyToFolding(textEditor, customizationsForCurrentLanguage); var item = (IHighlightingItem)listBox.SelectedItem; TextView textView = textEditor.TextArea.TextView; foldingManager.Clear(); textView.LineTransformers.Remove(colorizer); colorizer = null; if (item != null) { if (item.ParentDefinition != null) { colorizer = new CustomizableHighlightingColorizer(item.ParentDefinition.MainRuleSet, customizationsForCurrentLanguage); textView.LineTransformers.Add(colorizer); } textEditor.Select(0, 0); bracketHighlighter.SetHighlight(null); item.ShowExample(textEditor.TextArea); } } }
/// <summary> /// Class constructor from highlighting theme definition resolver /// and highlighting definition (and resolver) /// </summary> /// <param name="xshd"></param> /// <param name="resolver"></param> /// <param name="themedHighlights"></param> public XmlHighlightingDefinition(SyntaxDefinition themedHighlights, XshdSyntaxDefinition xshd, IHighlightingDefinitionReferenceResolver resolver) { _themedHighlights = themedHighlights; InitializeDefinitions(xshd, resolver); }
public MainWindow() { InitializeComponent(); DataContext = this; cmbFontStyle.ItemsSource = new FontStyle[] { FontStyles.Italic, FontStyles.Normal, FontStyles.Oblique }; cmbFontWeight.ItemsSource = new FontWeight[] { FontWeights.Black, FontWeights.Bold, FontWeights.DemiBold, FontWeights.ExtraBlack, FontWeights.ExtraBold, FontWeights.ExtraLight, FontWeights.Heavy, FontWeights.Light, FontWeights.Medium, FontWeights.Normal, FontWeights.Regular, FontWeights.SemiBold, FontWeights.Thin, FontWeights.UltraBlack, FontWeights.UltraBold, FontWeights.UltraLight }; try { using (XmlTextReader reader = new XmlTextReader(App.XSHDFile)) { xshd = HighlightingLoader.LoadXshd(reader); //XshdColor x; } colors = xshd.Elements.OfType <XshdColor>().ToList(); /*using (XmlTextWriter writer = new XmlTextWriter("output.xshd", System.Text.Encoding.UTF8)) * { * writer.Formatting = Formatting.Indented; * new SaveXshdVisitor(writer).WriteDefinition(xshd); * }*/ } catch (Exception) { MessageBox.Show("Error: Couldn't load syntax definition file." + Environment.NewLine + "Usage: XSHDEditor myfile.xshd", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }
/// <summary> /// Creates a highlighting definition from the XSHD file. /// </summary> public static IHighlightingDefinition Load(XshdSyntaxDefinition syntaxDefinition, IHighlightingDefinitionReferenceResolver resolver) { if (syntaxDefinition == null) { throw new ArgumentNullException("syntaxDefinition"); } return(new XmlHighlightingDefinition(syntaxDefinition, resolver)); }
public object VisitImport(XshdImport import) { if (import.RuleSetReference.InlineElement != null) { return(import.RuleSetReference.AcceptVisitor(this)); } XshdSyntaxDefinition definition = allSyntaxDefinitions.SingleOrDefault(def => def.Name == import.RuleSetReference.ReferencedDefinition); if (definition != null && visitedDefinitons.Add(definition)) { foundColors.AddRange(definition.Elements.OfType <XshdColor>()); } return(null); }
public XshdSyntaxDefinition LoadXshd() { using (XmlReader reader = CreateXmlReader()) { XshdSyntaxDefinition xshd = HighlightingLoader.LoadXshd(reader); if (xshd.Name != this.Name) { throw new InvalidOperationException("Loaded XSHD has name '" + xshd.Name + "', but expected was '" + this.Name + "'."); } if (!Enumerable.SequenceEqual(xshd.Extensions, this.Extensions)) { throw new InvalidOperationException("Loaded XSHD has extensions '" + string.Join(";", xshd.Extensions) + "', but expected was '" + string.Join(";", this.Extensions) + "'."); } return(xshd); } }
void LanguageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { listBox.ItemsSource = null; XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem; if (xshd != null) { IHighlightingItem defaultText; ObservableCollection <IHighlightingItem> list = new ObservableCollection <IHighlightingItem>(); CreateDefaultEntries(languageComboBox.SelectedIndex == 0 ? null : xshd.Name, out defaultText, list); listBox.ItemsSource = list; if (languageComboBox.SelectedIndex > 0) { // Create entries for all customizable colors in the syntax highlighting definition // (but don't do this for the "All languages" pseudo-entry) IHighlightingDefinition def = HighlightingManager.Instance.GetDefinition(xshd.Name); if (def == null) { throw new InvalidOperationException("Expected that all XSHDs are registered in default highlighting manager; but highlighting definition was not found"); } else { var visitor = new ColorVisitor(allSyntaxDefinitions); xshd.AcceptElements(visitor); foreach (XshdColor namedColor in visitor.foundColors) { if (namedColor.ExampleText != null) { IHighlightingItem item = new NamedColorHighlightingItem(defaultText, namedColor) { ParentDefinition = def }; item = new CustomizedHighlightingItem(customizationList, item, xshd.Name); list.Add(item); item.PropertyChanged += item_PropertyChanged; } } } } if (listBox.Items.Count > 0) { listBox.SelectedIndex = 0; } } }
void UpdatePreview() { XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem; if (xshd != null) { var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name); CustomizableHighlightingColorizer.ApplyCustomizationsToDefaultElements(textEditor, customizationsForCurrentLanguage); ApplyToRendering(textEditor, customizationsForCurrentLanguage); var item = (IHighlightingItem)listBox.SelectedItem; TextView textView = textEditor.TextArea.TextView; foldingManager.Clear(); textMarkerService.RemoveAll(m => true); marker = null; textView.LineTransformers.Remove(colorizer); colorizer = null; if (item != null) { if (item.ParentDefinition != null) { colorizer = new CustomizableHighlightingColorizer(item.ParentDefinition.MainRuleSet, customizationsForCurrentLanguage); textView.LineTransformers.Add(colorizer); } textEditor.Select(0, 0); bracketHighlighter.SetHighlight(null); item.ShowExample(textEditor.TextArea); if (marker != null) { switch (item.Name) { case ErrorPainter.ErrorColorName: case ErrorPainter.WarningColorName: case ErrorPainter.MessageColorName: marker.MarkerType = TextMarkerType.SquigglyUnderline; marker.MarkerColor = item.Foreground; break; default: marker.MarkerType = TextMarkerType.None; marker.MarkerColor = Colors.Transparent; break; } } } } }
static XshdSyntaxDefinition ParseDefinition(XmlReader reader) { Debug.Assert(reader.LocalName == "SyntaxDefinition"); XshdSyntaxDefinition def = new XshdSyntaxDefinition(); def.Name = reader.GetAttribute("name"); string extensions = reader.GetAttribute("extensions"); if (extensions != null) { def.Extensions.AddRange(extensions.Split(';')); } ParseElements(def.Elements, reader); Debug.Assert(reader.NodeType == XmlNodeType.EndElement); Debug.Assert(reader.LocalName == "SyntaxDefinition"); return(def); }
public SettingsManager() { RootFolder = DesignerProperties.GetIsInDesignMode(new DependencyObject()) ? ProjectRootFolder() : Directory.GetCurrentDirectory(); Config = Toml.ReadFile <Config>($"{RootFolder}/{ConfigFile}"); Keymap = Toml.ReadFile <Keymap>($"{RootFolder}/{KeymapFolder}/{Config.Keymap}.toml"); Theme = Toml.ReadFile <Theme>($"{RootFolder}/{ThemeFolder}/{Config.Theme}.toml"); using (XmlTextReader reader = new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("FasmCode.Syntax.Fasm.xshd"))) { XshdSyntaxDefinition syntax = HighlightingLoader.LoadXshd(reader); foreach (var element in syntax.Elements) { if (element is XshdColor) { var xshdColor = element as XshdColor; switch (xshdColor.Name) { case "Comment": break; case "String": break; case "Number": break; case "SizeOperator": break; case "Register": /*var c = (Color)ColorConverter.ConvertFromString("#FFFFFF00"); * xshdColor.Background = new SimpleHighlightingBrush(c Color.FromScRgb(1.0f, 0.9f, 0.9f, 0.3f));*/ break; case "Instruction": break; default: break; } } } Highlighting = HighlightingLoader.Load(syntax, HighlightingManager.Instance); } }
private IHighlightingDefinition LoadHighlightingDefinition() { HighlightingManager highlightingManager = HighlightingManager.Instance; if (!string.IsNullOrEmpty(CustomSyntaxHighlightingFileName)) { using var reader = new XmlTextReader(OpenStream(CustomSyntaxHighlightingFileName)); _syntaxDefinition = HighlightingLoader.LoadXshd(reader); } if (_syntaxDefinition != null) { var highlightingDefinition = HighlightingLoader.Load(_syntaxDefinition, highlightingManager); highlightingManager.RegisterHighlighting(_syntaxDefinition.Name, _syntaxDefinition.Extensions.ToArray(), highlightingDefinition); } return(highlightingManager.GetDefinition(Name)); }
private void InitializeDefinitions(XshdSyntaxDefinition xshd, IHighlightingDefinitionReferenceResolver resolver) { this.Name = xshd.Name; // Create HighlightingRuleSet instances var rnev = new RegisterNamedElementsVisitor(this); xshd.AcceptElements(rnev); // Assign MainRuleSet so that references can be resolved foreach (XshdElement element in xshd.Elements) { XshdRuleSet xrs = element as XshdRuleSet; if (xrs != null && xrs.Name == null) { if (MainRuleSet != null) { throw Error(element, "Duplicate main RuleSet. There must be only one nameless RuleSet!"); } else { MainRuleSet = rnev.ruleSets[xrs]; } } } if (MainRuleSet == null) { throw new HighlightingDefinitionInvalidException("Could not find main RuleSet."); } // Translate elements within the rulesets (resolving references and processing imports) xshd.AcceptElements(new TranslateElementVisitor(this, rnev.ruleSets, resolver)); foreach (var p in xshd.Elements.OfType <XshdProperty>()) { propDict.Add(p.Name, p.Value); } }
void UpdatePreview() { XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem; if (xshd != null) { var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name); CustomizingHighlighter.ApplyCustomizationsToDefaultElements(textEditor, customizationsForCurrentLanguage); ApplyToRendering(textEditor, customizationsForCurrentLanguage); var item = (IHighlightingItem)listBox.SelectedItem; TextView textView = textEditor.TextArea.TextView; foldingManager.Clear(); textMarkerService.RemoveAll(m => true); textView.LineTransformers.Remove(colorizer); colorizer = null; if (item != null) { if (item.ParentDefinition != null) { var highlighter = new CustomizingHighlighter( new DocumentHighlighter(textView.Document, item.ParentDefinition), customizationsForCurrentLanguage ); colorizer = new HighlightingColorizer(highlighter); textView.LineTransformers.Add(colorizer); } textEditor.Select(0, 0); bracketHighlighter.SetHighlight(null); textEditor.Options.HighlightCurrentLine = false; item.ShowExample(textEditor.TextArea); ITextMarker m = textMarkerService.TextMarkers.SingleOrDefault(); if (m != null && m.Tag != null) { ((Action <IHighlightingItem, ITextMarker>)m.Tag)(item, m); } } } }
public static void Init() { if (Table == null) { var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("QueryDesk.Resources.Table_748.png"); PngBitmapDecoder decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); Table = decoder.Frames[0]; } if (Field == null) { var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("QueryDesk.Resources.Template_514.png"); PngBitmapDecoder decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); Field = decoder.Frames[0]; } if (SQLHighlighter == null) { var reader = XmlReader.Create(Assembly.GetExecutingAssembly().GetManifestResourceStream("QueryDesk.Resources.SQL.xshd")); SQLHighlighter = HighlightingLoader.LoadXshd(reader); SQLSyntaxHiglighting = HighlightingLoader.Load(SQLHighlighter, HighlightingManager.Instance); } }
public XmlHighlightingDefinition(XshdSyntaxDefinition xshd, IHighlightingDefinitionReferenceResolver resolver) { InitializeDefinitions(xshd, resolver); }
void CreateDefaultEntries(string language, out IHighlightingItem defaultText) { // Create entry for "default text/background" defaultText = new SimpleHighlightingItem(CustomizableHighlightingColorizer.DefaultTextAndBackground, ta => ta.Document.Text = "Normal text") { Foreground = SystemColors.WindowTextColor, Background = SystemColors.WindowColor }; defaultText = new CustomizedHighlightingItem(customizationList, defaultText, null, canSetFont: false); if (language != null) { defaultText = new CustomizedHighlightingItem(customizationList, defaultText, language, canSetFont: false); } defaultText.PropertyChanged += item_PropertyChanged; listBox.Items.Add(defaultText); // Create entry for "Selected text" IHighlightingItem selectedText = new SimpleHighlightingItem( CustomizableHighlightingColorizer.SelectedText, ta => { ta.Document.Text = "Selected text"; ta.Selection = Selection.Create(ta, 0, 13); }) { Foreground = SystemColors.HighlightTextColor, Background = SystemColors.HighlightColor }; selectedText = new CustomizedHighlightingItem(customizationList, selectedText, null, canSetFont: false); if (language != null) { selectedText = new CustomizedHighlightingItem(customizationList, selectedText, language, canSetFont: false); } selectedText.PropertyChanged += item_PropertyChanged; listBox.Items.Add(selectedText); // Create entry for "Non-printable characters" IHighlightingItem nonPrintChars = new SimpleHighlightingItem( CustomizableHighlightingColorizer.NonPrintableCharacters, ta => { ta.Document.Text = " \r \r\n \n"; }) { Foreground = Colors.LightGray }; nonPrintChars = new CustomizedHighlightingItem(customizationList, nonPrintChars, null, canSetFont: false, canSetBackground: false); if (language != null) { nonPrintChars = new CustomizedHighlightingItem(customizationList, nonPrintChars, language, canSetFont: false); } nonPrintChars.PropertyChanged += item_PropertyChanged; listBox.Items.Add(nonPrintChars); // Create entry for "Line numbers" IHighlightingItem lineNumbers = new SimpleHighlightingItem( CustomizableHighlightingColorizer.LineNumbers, ta => { ta.Document.Text = "These are just" + Environment.NewLine + "multiple" + Environment.NewLine + "lines of" + Environment.NewLine + "text"; }) { Foreground = Colors.Gray }; lineNumbers = new CustomizedHighlightingItem(customizationList, lineNumbers, null, canSetFont: false, canSetBackground: false); if (language != null) { lineNumbers = new CustomizedHighlightingItem(customizationList, lineNumbers, language, canSetFont: false); } lineNumbers.PropertyChanged += item_PropertyChanged; listBox.Items.Add(lineNumbers); // Create entry for "Bracket highlight" IHighlightingItem bracketHighlight = new SimpleHighlightingItem( BracketHighlightRenderer.BracketHighlight, ta => { ta.Document.Text = "(simple) example"; XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem; if (xshd == null) { return; } var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name); BracketHighlightRenderer.ApplyCustomizationsToRendering(bracketHighlighter, customizationsForCurrentLanguage); bracketHighlighter.SetHighlight(new BracketSearchResult(0, 1, 7, 1)); }) { Foreground = BracketHighlightRenderer.DefaultBorder, Background = BracketHighlightRenderer.DefaultBackground }; bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, null, canSetFont: false); if (language != null) { bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, language, canSetFont: false); } bracketHighlight.PropertyChanged += item_PropertyChanged; listBox.Items.Add(bracketHighlight); // Create entry for "Folding controls" IHighlightingItem foldingControls = new SimpleHighlightingItem( FoldingControls, ta => { ta.Document.Text = "This" + Environment.NewLine + "is a folding" + Environment.NewLine + "example"; foldingManager.CreateFolding(0, 10); }) { Foreground = Colors.Gray, Background = Colors.White }; foldingControls = new CustomizedHighlightingItem(customizationList, foldingControls, null, canSetFont: false); if (language != null) { foldingControls = new CustomizedHighlightingItem(customizationList, foldingControls, language, canSetFont: false); } foldingControls.PropertyChanged += item_PropertyChanged; listBox.Items.Add(foldingControls); // Create entry for "Selected folding controls" IHighlightingItem selectedFoldingControls = new SimpleHighlightingItem( FoldingSelectedControls, ta => { ta.Document.Text = "This" + Environment.NewLine + "is a folding" + Environment.NewLine + "example"; foldingManager.CreateFolding(0, 10); }) { Foreground = Colors.Black, Background = Colors.White }; selectedFoldingControls = new CustomizedHighlightingItem(customizationList, selectedFoldingControls, null, canSetFont: false); if (language != null) { selectedFoldingControls = new CustomizedHighlightingItem(customizationList, selectedFoldingControls, language, canSetFont: false); } selectedFoldingControls.PropertyChanged += item_PropertyChanged; listBox.Items.Add(selectedFoldingControls); // Create entry for "Folding text markers" IHighlightingItem foldingTextMarker = new SimpleHighlightingItem( FoldingTextMarkers, ta => { ta.Document.Text = "This" + Environment.NewLine + "is a folding" + Environment.NewLine + "example"; foldingManager.CreateFolding(0, 10).IsFolded = true; }) { Foreground = Colors.Gray }; foldingTextMarker = new CustomizedHighlightingItem(customizationList, foldingTextMarker, null, canSetFont: false, canSetBackground: false); if (language != null) { foldingControls = new CustomizedHighlightingItem(customizationList, foldingTextMarker, language, canSetFont: false, canSetBackground: false); } foldingTextMarker.PropertyChanged += item_PropertyChanged; listBox.Items.Add(foldingTextMarker); }
/// <summary> /// 保持しているInfoに従い、Xshdファイルを生成します /// </summary> /// <returns>true:成功, false:失敗</returns> private bool CreateXshdFile() { Logger.Info(CLASS_NAME, "CreateXshdFile", "start"); XshdSyntaxDefinition def = new XshdSyntaxDefinition(); def.Name = "TXT"; def.Extensions.Add(".txt"); // .txtファイルのみ対象としているので、将来拡張するならここをいじる必要がある // keywordは勝手に正規表現で前後に改行コードが含まれてしまうため、見出し文字列等以外には適さない // ★設定で回避できる? 要調査、現状は動くことを優先して下記設定とする // そのため、日本語文章を対象としていることから、類語・検索語はXshdRuleSetに登録する XshdRuleSet xshdRuleSet = new XshdRuleSet(); int i = 0; foreach (TextHighlightInfo info in _infos) { if (IsInfoCorrect(info) == false) { Logger.Error(CLASS_NAME, "CreateXshdFile", $"info is null or incorrect! index:[{i}]"); continue; } XshdColor color = new XshdColor { // Name = "keywordColor", // 別に名前は何でもいい Foreground = info.ForeGround, Background = info.BackGrouond, // 検索結果表示を太字にする //todo:設定で持たせるべきかもしれない FontWeight = System.Windows.FontWeights.Bold, //FontStyle = System.Windows.FontStyles.Italic これは斜体になる }; string colorName = "keyword"; // 文字毎に異なる背景色を設定したいため、ここでColorおよびColorRefのNameを紐付ける必要がある // 大量にあることを想定し、StringBuilderで結合する StringBuilder sb = new StringBuilder(colorName); sb.Append(i.ToString()); color.Name = sb.ToString(); XshdReference <XshdColor> colorRef = new XshdReference <XshdColor>(null, color.Name); string target = info.TargetWord; if (string.IsNullOrEmpty(target)) { Logger.Error(CLASS_NAME, "CreateXshdFile", $"target is null! target:[{target}]"); continue; } XshdRule rule = new XshdRule { ColorReference = colorRef, Regex = target // 正規表現で持たせる必要があるが、文字単位なのでそのまま渡して問題ない }; xshdRuleSet.Elements.Add(rule); // 追加したいモノは追加した def.Elements.Add(color); System.Threading.Interlocked.Increment(ref i); } def.Elements.Add(xshdRuleSet); return(WriteXshdFile(def)); }
void CreateDefaultEntries(string language, out IHighlightingItem defaultText, IList <IHighlightingItem> items) { // Create entry for "default text/background" defaultText = new SimpleHighlightingItem(CustomizingHighlighter.DefaultTextAndBackground, ta => ta.Document.Text = "Normal text") { Foreground = SystemColors.WindowTextColor, Background = SystemColors.WindowColor }; defaultText = new CustomizedHighlightingItem(customizationList, defaultText, language, canSetFont: false); defaultText.PropertyChanged += item_PropertyChanged; items.Add(defaultText); // Create entry for "Selected text" IHighlightingItem selectedText = new SimpleHighlightingItem( CustomizingHighlighter.SelectedText, ta => { ta.Document.Text = "Selected text"; ta.Selection = Selection.Create(ta, 0, 13); }) { Foreground = SystemColors.HighlightTextColor, Background = SystemColors.HighlightColor }; selectedText = new CustomizedHighlightingItem(customizationList, selectedText, language, canSetFont: false); selectedText.PropertyChanged += item_PropertyChanged; items.Add(selectedText); // Create entry for "Non-printable characters" IHighlightingItem nonPrintChars = new SimpleHighlightingItem( CustomizingHighlighter.NonPrintableCharacters, ta => { ta.Document.Text = " \r \r\n \n"; }) { Foreground = Colors.LightGray }; nonPrintChars = new CustomizedHighlightingItem(customizationList, nonPrintChars, language, canSetFont: false, canSetBackground: false); nonPrintChars.PropertyChanged += item_PropertyChanged; items.Add(nonPrintChars); // Create entry for "Line numbers" IHighlightingItem lineNumbers = new SimpleHighlightingItem( CustomizingHighlighter.LineNumbers, ta => { ta.Document.Text = "These are just" + Environment.NewLine + "multiple" + Environment.NewLine + "lines of" + Environment.NewLine + "text"; }) { Foreground = Colors.Gray }; lineNumbers = new CustomizedHighlightingItem(customizationList, lineNumbers, language, canSetFont: false, canSetBackground: false); lineNumbers.PropertyChanged += item_PropertyChanged; items.Add(lineNumbers); // Create entry for "Bracket highlight" IHighlightingItem bracketHighlight = new SimpleHighlightingItem( BracketHighlightRenderer.BracketHighlight, ta => { ta.Document.Text = "(simple) example"; XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem; if (xshd == null) { return; } var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name); BracketHighlightRenderer.ApplyCustomizationsToRendering(bracketHighlighter, customizationsForCurrentLanguage); bracketHighlighter.SetHighlight(new BracketSearchResult(0, 1, 7, 1)); }) { Foreground = BracketHighlightRenderer.DefaultBorder, Background = BracketHighlightRenderer.DefaultBackground }; bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, language, canSetFont: false); bracketHighlight.PropertyChanged += item_PropertyChanged; items.Add(bracketHighlight); // Create entry for "Current Line highlight" IHighlightingItem currentLineHighlight = new SimpleHighlightingItem( CustomizingHighlighter.CurrentLineHighlighter, ta => { ta.Document.Text = "example text line"; ta.TextView.Options.HighlightCurrentLine = true; }) { Foreground = Color.FromArgb(52, 0, 255, 110), Background = Color.FromArgb(22, 20, 220, 224) }; currentLineHighlight = new CustomizedHighlightingItem(customizationList, currentLineHighlight, language, canSetFont: false); currentLineHighlight.PropertyChanged += item_PropertyChanged; items.Add(currentLineHighlight); // Create entry for "Folding controls" IHighlightingItem foldingControls = new SimpleHighlightingItem( FoldingControls, ta => { ta.Document.Text = "This" + Environment.NewLine + "is a folding" + Environment.NewLine + "example"; foldingManager.CreateFolding(0, 10); }) { Foreground = Colors.Gray, Background = Colors.White }; foldingControls = new CustomizedHighlightingItem(customizationList, foldingControls, language, canSetFont: false); foldingControls.PropertyChanged += item_PropertyChanged; items.Add(foldingControls); // Create entry for "Selected folding controls" IHighlightingItem selectedFoldingControls = new SimpleHighlightingItem( FoldingSelectedControls, ta => { ta.Document.Text = "This" + Environment.NewLine + "is a folding" + Environment.NewLine + "example"; foldingManager.CreateFolding(0, 10); }) { Foreground = Colors.Black, Background = Colors.White }; selectedFoldingControls = new CustomizedHighlightingItem(customizationList, selectedFoldingControls, language, canSetFont: false); selectedFoldingControls.PropertyChanged += item_PropertyChanged; items.Add(selectedFoldingControls); // Create entry for "Folding text markers" IHighlightingItem foldingTextMarker = new SimpleHighlightingItem( FoldingTextMarkers, ta => { ta.Document.Text = "This" + Environment.NewLine + "is a folding" + Environment.NewLine + "example"; foldingManager.CreateFolding(0, 10).IsFolded = true; }) { Foreground = Colors.Gray }; foldingTextMarker = new CustomizedHighlightingItem(customizationList, foldingTextMarker, language, canSetFont: false, canSetBackground: false); foldingTextMarker.PropertyChanged += item_PropertyChanged; items.Add(foldingTextMarker); IHighlightingItem linkText = new SimpleHighlightingItem( CustomizingHighlighter.LinkText, ta => { ta.Document.Text = "http://icsharpcode.net" + Environment.NewLine + "*****@*****.**"; }) { Foreground = Colors.Blue, Background = Colors.Transparent }; linkText = new CustomizedHighlightingItem(customizationList, linkText, language, canSetFont: false); linkText.PropertyChanged += item_PropertyChanged; items.Add(linkText); IHighlightingItem errorMarker = new SimpleHighlightingItem( ErrorPainter.ErrorColorName, ta => { ta.Document.Text = "some error"; ITextMarker marker = textMarkerService.Create(0, 5); marker.Tag = (Action <IHighlightingItem, ITextMarker>) delegate(IHighlightingItem item, ITextMarker m) { m.MarkerTypes = TextMarkerTypes.SquigglyUnderline; m.MarkerColor = item.Foreground; }; }) { Foreground = Colors.Red }; errorMarker = new CustomizedHighlightingItem(customizationList, errorMarker, language, canSetFont: false, canSetBackground: false); errorMarker.PropertyChanged += item_PropertyChanged; items.Add(errorMarker); IHighlightingItem warningMarker = new SimpleHighlightingItem( ErrorPainter.WarningColorName, ta => { ta.Document.Text = "some warning"; ITextMarker marker = textMarkerService.Create(0, 5); marker.Tag = (Action <IHighlightingItem, ITextMarker>) delegate(IHighlightingItem item, ITextMarker m) { m.MarkerTypes = TextMarkerTypes.SquigglyUnderline; m.MarkerColor = item.Foreground; }; }) { Foreground = Colors.Orange }; warningMarker = new CustomizedHighlightingItem(customizationList, warningMarker, language, canSetFont: false, canSetBackground: false); warningMarker.PropertyChanged += item_PropertyChanged; items.Add(warningMarker); IHighlightingItem messageMarker = new SimpleHighlightingItem( ErrorPainter.MessageColorName, ta => { ta.Document.Text = "some message"; ITextMarker marker = textMarkerService.Create(0, 5); marker.Tag = (Action <IHighlightingItem, ITextMarker>) delegate(IHighlightingItem item, ITextMarker m) { m.MarkerTypes = TextMarkerTypes.SquigglyUnderline; m.MarkerColor = item.Foreground; }; }) { Foreground = Colors.Blue }; messageMarker = new CustomizedHighlightingItem(customizationList, messageMarker, language, canSetFont: false, canSetBackground: false); messageMarker.PropertyChanged += item_PropertyChanged; items.Add(messageMarker); IHighlightingItem breakpointMarker = new SimpleHighlightingItem( BookmarkBase.BreakpointMarkerName, ta => { ta.Document.Text = "some code with a breakpoint"; ITextMarker marker = textMarkerService.Create(0, ta.Document.TextLength); marker.Tag = (Action <IHighlightingItem, ITextMarker>) delegate(IHighlightingItem item, ITextMarker m) { m.BackgroundColor = item.Background; m.ForegroundColor = item.Foreground; }; }) { Background = BookmarkBase.BreakpointDefaultBackground, Foreground = BookmarkBase.BreakpointDefaultForeground }; breakpointMarker = new CustomizedHighlightingItem(customizationList, breakpointMarker, language, canSetFont: false); breakpointMarker.PropertyChanged += item_PropertyChanged; items.Add(breakpointMarker); IHighlightingItem currentStatementMarker = new SimpleHighlightingItem( BookmarkBase.CurrentLineBookmarkName, ta => { ta.Document.Text = "current statement line"; ITextMarker marker = textMarkerService.Create(0, ta.Document.TextLength); marker.Tag = (Action <IHighlightingItem, ITextMarker>) delegate(IHighlightingItem item, ITextMarker m) { m.BackgroundColor = item.Background; m.ForegroundColor = item.Foreground; }; }) { Background = BookmarkBase.CurrentLineDefaultBackground, Foreground = BookmarkBase.CurrentLineDefaultForeground }; currentStatementMarker = new CustomizedHighlightingItem(customizationList, currentStatementMarker, language, canSetFont: false); currentStatementMarker.PropertyChanged += item_PropertyChanged; items.Add(currentStatementMarker); IHighlightingItem columnRuler = new SimpleHighlightingItem( CustomizingHighlighter.ColumnRuler, ta => { ta.Document.Text = "some line with a lot of text"; ta.TextView.Options.ColumnRulerPosition = 15; ta.TextView.Options.ShowColumnRuler = true; }) { Foreground = Colors.LightGray }; columnRuler = new CustomizedHighlightingItem(customizationList, columnRuler, language, canSetFont: false, canSetBackground: false); columnRuler.PropertyChanged += item_PropertyChanged; items.Add(columnRuler); }
public static IList <string> GetExtensions(this XshdSyntaxDefinition self) => (self.Extensions?.Select(e =>
public DefaultLanguageDefinition(XshdSyntaxDefinition syntaxDefinition) : this(syntaxDefinition.Name, syntaxDefinition.Extensions) { _syntaxDefinition = syntaxDefinition; }