/// <summary> /// Updates the foldings using the current <see cref="FoldingStrategy"/>. /// </summary> /// <remarks> /// If a <see cref="FoldingStrategy"/> is set, this method is automatically called periodically /// (see <see cref="FoldingUpdateInterval"/>). This method can also be called manually to /// update the foldings. /// </remarks> public void UpdateFoldings() { if (FoldingManager == null) { return; } Debug.Assert(EnableFolding, "Folding manager should be null if folding is disabled."); if (_foldingValid) { return; } if (FoldingStrategy != null) { FoldingStrategy.UpdateFoldings(FoldingManager, Document); } else if (FoldingManager.AllFoldings.Any()) { FoldingManager.Clear(); } _foldingValid = true; }
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); } } }
private void SyntaxModeCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { Language language = (Language)_syntaxModeCombo.SelectedItem; if (_foldingManager != null) { _foldingManager.Clear(); FoldingManager.Uninstall(_foldingManager); } string scopeName = _registryOptions.GetScopeByLanguageId(language.Id); _textMateInstallation.SetGrammar(null); _textEditor.Document = new TextDocument(ResourceLoader.LoadSampleFile(scopeName)); _textMateInstallation.SetGrammar(scopeName); if (language.Id == "xml") { _foldingManager = FoldingManager.Install(_textEditor.TextArea); var strategy = new XmlFoldingStrategy(); strategy.UpdateFoldings(_foldingManager, _textEditor.Document); return; } }
internal void EnableFolding(bool enableFolding) { if (enableFolding) { switch (innerType) { case Enumerations.WebResourceType.Script: case Enumerations.WebResourceType.Css: { if (!foldingManagerInstalled) { foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManagerInstalled = true; } foldingManager.UpdateFoldings(CreateBraceFoldings(textEditor.Document), -1); } break; case Enumerations.WebResourceType.WebPage: { if (!foldingManagerInstalled) { foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManagerInstalled = true; } htmlFoldingStrategy = new HtmlFoldingStrategy(); htmlFoldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } break; case Enumerations.WebResourceType.Data: case Enumerations.WebResourceType.Xsl: { if (!foldingManagerInstalled) { foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManagerInstalled = true; } xmlFoldingStrategy = new XmlFoldingStrategy(); xmlFoldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } break; } FoldingEnabled = true; } else { if (foldingManager != null) { foldingManager.Clear(); } FoldingEnabled = false; } }
/// <summary> /// Restores the state of the foldings in the current text editor. /// </summary> /// <param name="foldings">The object representing the state of the foldings.</param> public void RestoreFoldings(object foldings) { var list = foldings as IEnumerable <NewFolding>; if (list == null) { return; } EnableFolding = true; FoldingManager.Clear(); FoldingManager.UpdateFoldings(list, -1); }
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; } } } } }
public void EnableFolding(bool enableFolding) { if (enableFolding) { switch (item.Type) { case CodeItemType.JavaScript: case CodeItemType.Style: { if (!foldingManagerInstalled) { foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManagerInstalled = true; } foldingManager.UpdateFoldings(CreateBraceFoldings(textEditor.Document), -1); } break; case CodeItemType.LiquidTemplate: { if (!foldingManagerInstalled) { foldingManager = FoldingManager.Install(textEditor.TextArea); foldingManagerInstalled = true; } htmlFoldingStrategy = new HtmlFoldingStrategy(); htmlFoldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } break; } FoldingEnabled = true; } else { if (foldingManager != null) { foldingManager.Clear(); } FoldingEnabled = false; } }
private void UpdateFoldings() { if (Foldings == null) { return; } if (_foldingManager == null) { return; } _foldingManager.Clear(); foreach (var folding in Foldings) { var foldingSection = _foldingManager.CreateFolding(folding.StartOffset, folding.EndOffset); foldingSection.Title = folding.Name; foldingSection.IsFolded = folding.IsFolded; } }
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); } } } }
protected void updateFoldings() { if (foldingManager == null) { Log.Debug("foldingManager is null"); return; } switch (schema) { case ColorSchema.MSBuildTargets: { if (xmlFoldingStrategy == null) { xmlFoldingStrategy = new XmlFoldingStrategy(); } xmlFoldingStrategy.UpdateFoldings(foldingManager, _.Document); return; } case ColorSchema.InterpreterMode: case ColorSchema.ScriptMode: case ColorSchema.SBEScripts: case ColorSchema.CppLang: case ColorSchema.CSharpLang: { if (braceFoldingStrategy == null) { braceFoldingStrategy = new BraceFoldingStrategy(); } braceFoldingStrategy.UpdateFoldings(foldingManager, _.Document); return; } } foldingManager.Clear(); }