private static IVsFontsAndColorsInformation TryGetFontAndColorInfo(IVsFontsAndColorsInformationService service) { var guidTextFileType = new Guid(2184822468u, 61063, 4560, 140, 152, 0, 192, 79, 194, 171, 34); var fonts = new FontsAndColorsCategory( guidTextFileType, DefGuidList.guidTextEditorFontCategory, DefGuidList.guidTextEditorFontCategory); return(service?.GetFontAndColorInformation(fonts)); }
void FixFormatMap() { if (_view == null || _view.IsClosed) { return; } var bufferAdapter = _adaptersService.GetBufferAdapter(_view.TextBuffer); if (bufferAdapter == null) { return; } Guid fontCategory = DefGuidList.guidTextEditorFontCategory; Guid languageService; if (0 != bufferAdapter.GetLanguageServiceID(out languageService)) { return; } FontsAndColorsCategory category = new FontsAndColorsCategory(languageService, fontCategory, fontCategory); var info = _fcService.GetFontAndColorInformation(category); if (info == null) { return; } // This is pretty dirty. IVsFontsAndColorsInformation doesn't give you a count, and I don't really want // to go through the ugly of finding the eventual colorable items provider to ask for its count, so this nasty // little loop will go until an index past the count (at which point it returns null). HashSet <IClassificationType> types = new HashSet <IClassificationType>(_formatMap.CurrentPriorityOrder); for (int i = 1; i < 1000; i++) { var type = info.GetClassificationType(i); if (type == null) { break; } types.Add(type); } FixFormatMap(types); }
void FixFormatMap() { if (_view == null || _view.IsClosed) return; var bufferAdapter = _adaptersService.GetBufferAdapter(_view.TextBuffer); if (bufferAdapter == null) return; Guid fontCategory = DefGuidList.guidTextEditorFontCategory; Guid languageService; if (0 != bufferAdapter.GetLanguageServiceID(out languageService)) return; FontsAndColorsCategory category = new FontsAndColorsCategory(languageService, fontCategory, fontCategory); var info = _fcService.GetFontAndColorInformation(category); if (info == null) return; // This is pretty dirty. IVsFontsAndColorsInformation doesn't give you a count, and I don't really want // to go through the ugly of finding the eventual colorable items provider to ask for its count, so this nasty // little loop will go until an index past the count (at which point it returns null). HashSet<IClassificationType> types = new HashSet<IClassificationType>(_formatMap.CurrentPriorityOrder); for (int i = 1; i < 1000; i++) { var type = info.GetClassificationType(i); if (type == null) break; types.Add(type); } FixFormatMap(types); }