internal ImageAdornmentManager(IServiceProvider serviceProvider, IWpfTextView view, IEditorFormatMap editorFormatMap)
        {
            View = view;
            this.serviceProvider = serviceProvider;
            AdornmentLayer = View.GetAdornmentLayer(ImageAdornmentLayerName);

            ImagesAdornmentsRepository = new ImageAdornmentRepositoryService(view.TextBuffer);

            // Create the highlight line adornment
            HighlightLineAdornment = new HighlightLineAdornment(view, editorFormatMap);
            AdornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, HighlightLineAdornment,
                                        HighlightLineAdornment.VisualElement, null);

            // Create the preview image adornment
            PreviewImageAdornment = new PreviewImageAdornment();
            AdornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, this,
                                        PreviewImageAdornment.VisualElement, null);

            // Attach to the view events
            View.LayoutChanged += OnLayoutChanged;
            View.TextBuffer.Changed += OnBufferChanged;
            View.Closed += OnViewClosed;

            // Load and initialize the image adornments repository
            ImagesAdornmentsRepository.Load();
            ImagesAdornmentsRepository.Images.ToList().ForEach(image => InitializeImageAdornment(image));
        }
 internal EasyMotionAdornmentController(IEasyMotionUtil easyMotionUtil, IWpfTextView wpfTextview, IEditorFormatMap editorFormatMap, IClassificationFormatMap classificationFormatMap)
 {
     _easyMotionUtil = easyMotionUtil;
     _wpfTextView = wpfTextview;
     _editorFormatMap = editorFormatMap;
     _classificationFormatMap = classificationFormatMap;
 }
        internal HighlightLineAdornment(IWpfTextView view, IEditorFormatMap editorFormatMap)
        {
            this.View = view;
            this.editorFormatMap = editorFormatMap;

            CreateVisualElement();
        }
        internal CommandMarginController(IVimBuffer buffer, FrameworkElement parentVisualElement, CommandMarginControl control, IEditorFormatMap editorFormatMap, IEnumerable<Lazy<IOptionsProviderFactory>> optionsProviderFactory)
        {
            _vimBuffer = buffer;
            _margin = control;
            _parentVisualElement = parentVisualElement;
            _editorFormatMap = editorFormatMap;
            _optionsProviderFactory = optionsProviderFactory.ToList().AsReadOnly();

            _vimBuffer.SwitchedMode += OnSwitchMode;
            _vimBuffer.KeyInputStart += OnKeyInputStart;
            _vimBuffer.KeyInputEnd += OnKeyInputEnd;
            _vimBuffer.StatusMessage += OnStatusMessage;
            _vimBuffer.ErrorMessage += OnErrorMessage;
            _vimBuffer.WarningMessage += OnWarningMessage;
            _vimBuffer.CommandMode.CommandChanged += OnCommandChanged;
            _vimBuffer.Vim.MacroRecorder.RecordingStarted += OnRecordingStarted;
            _vimBuffer.Vim.MacroRecorder.RecordingStopped += OnRecordingStopped;
            _margin.OptionsClicked += OnOptionsClicked;
            _margin.CancelCommandEdition += OnCancelCommandEdition;
            _margin.RunCommandEdition += OnRunCommandEdition;
            _margin.HistoryGoPrevious += OnHistoryGoPrevious;
            _margin.HistoryGoNext += OnHistoryGoNext;
            _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
            UpdateForRecordingChanged();
            UpdateTextColor();
        }
        internal CommandMarginController(IVimBuffer buffer, FrameworkElement parentVisualElement, CommandMarginControl control, IEditorFormatMap editorFormatMap, IFontProperties fontProperties, IEnumerable<Lazy<IOptionsProviderFactory>> optionsProviderFactory)
        {
            _vimBuffer = buffer;
            _margin = control;
            _parentVisualElement = parentVisualElement;
            _editorFormatMap = editorFormatMap;
            _fontProperties = fontProperties;
            _optionsProviderFactory = optionsProviderFactory.ToList().AsReadOnly();

            _vimBuffer.SwitchedMode += OnSwitchMode;
            _vimBuffer.KeyInputStart += OnKeyInputStart;
            _vimBuffer.KeyInputEnd += OnKeyInputEnd;
            _vimBuffer.StatusMessage += OnStatusMessage;
            _vimBuffer.ErrorMessage += OnErrorMessage;
            _vimBuffer.WarningMessage += OnWarningMessage;
            _vimBuffer.CommandMode.CommandChanged += OnCommandChanged;
            _vimBuffer.Vim.MacroRecorder.RecordingStarted += OnRecordingStarted;
            _vimBuffer.Vim.MacroRecorder.RecordingStopped += OnRecordingStopped;
            _margin.Loaded += OnCommandMarginLoaded;
            _margin.Unloaded += OnCommandMarginUnloaded;
            _margin.OptionsButton.Click += OnOptionsClicked;
            _margin.CommandLineTextBox.PreviewKeyDown += OnCommandLineTextBoxPreviewKeyDown;
            _margin.CommandLineTextBox.TextChanged += OnCommandLineTextBoxTextChanged;
            _margin.CommandLineTextBox.SelectionChanged += OnCommandLineTextBoxSelectionChanged;
            _margin.CommandLineTextBox.LostKeyboardFocus += OnCommandLineTextBoxLostKeyboardFocus;
            _margin.CommandLineTextBox.PreviewMouseDown += OnCommandLineTextBoxPreviewMouseDown;
            _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
            UpdateForRecordingChanged();
            UpdateTextColor();
        }
Exemple #6
0
        public BlockColoring(IEditorFormatMap formatMap, double width)
        {
            _formatMap = formatMap;
            _width = width;

            formatMap.FormatMappingChanged += this.OnFormatMappingChanged;
            this.OnFormatMappingChanged(null, null);
        }
 public ToastNotificationServiceTest()
 {
     _wpfTextView = CreateTextView();
     _editorFormatMap = CompositionContainer.GetExportedValue<IEditorFormatMapService>().GetEditorFormatMap(_wpfTextView);
     _toastNotificationServiceRaw = new ToastNotificationService(_wpfTextView, _editorFormatMap);
     _toastNotificationService = _toastNotificationServiceRaw;
     _toastControl = _toastNotificationServiceRaw.ToastControl;
 }
Exemple #8
0
 public void Dispose()
 {
     if (_formatMap != null)
     {
         _formatMap.FormatMappingChanged -= this.OnFormatMappingChanged;
         _formatMap = null;
     }
 }
        internal VisualAssistMargin(IVisualAssistUtil visualAssistUtil, IEditorFormatMap editorFormatMap)
        {
            _visualAssistUtil = visualAssistUtil;
            _visualAssistUtil.IsRegistryFixNeededChanged += IsRegistryFixNeededChanged;
            InitializeComponent();

            Background = editorFormatMap.GetBackgroundBrush(EditorFormatDefinitionNames.Margin, MarginFormatDefinition.DefaultColor);
        }
 internal ToastNotificationService(IWpfTextView wpfTextView, IEditorFormatMap editorFormatMap)
 {
     _wpfTextView = wpfTextView;
     _editorFormatMap = editorFormatMap;
     _toastControl = new ToastControl();
     _toastControl.Visibility = Visibility.Collapsed;
     _toastControl.ToastNotificationCollection.CollectionChanged += OnToastControlItemsChanged;
     _editorFormatMap.FormatMappingChanged += OnEditorFormatMappingChanged;
     _wpfTextView.Closed += OnTextViewClosed;
     UpdateTheme();
 }
		void UpdateAppearanceMap() {
			var newMap = editorFormatMapService.GetEditorFormatMap(GetAppearanceCategory());
			if (categoryMap == newMap)
				return;

			if (categoryMap != null)
				categoryMap.FormatMappingChanged -= CategoryMap_FormatMappingChanged;
			categoryMap = newMap;
			categoryMap.FormatMappingChanged += CategoryMap_FormatMappingChanged;
			FormatMappingChanged?.Invoke(this, new FormatItemsEventArgs(new ReadOnlyCollection<string>(viewProps.ToArray())));
		}
        internal ConflictingKeyBindingMargin(IKeyBindingService service, IEditorFormatMap formatMap)
        {
            _keyBindingService = service;
            _control = new ConflictingKeyBindingMarginControl();
            _control.Background = GetBackgroundColor(formatMap);

            _control.ConfigureClick += OnConfigureClick;
            _control.IgnoreClick += OnIgnoreClick;
            _keyBindingService.ConflictingKeyBindingStateChanged += OnStateChanged;

            OnStateChanged(this, EventArgs.Empty);
        }
        private static Brush GetBackgroundColor(IEditorFormatMap map)
        {
            var properties = map.GetProperties(EditorFormatDefinitionNames.ConflictingKeyBindingMargin);
            var key = EditorFormatDefinition.BackgroundColorId;
            var color = ConflictingKeyBindingMarginFormatDefinition.DefaultColor;
            if (properties != null && properties.Contains(key))
            {
                color = (Color)properties[key];
            }

            return new SolidColorBrush(color);
        }
        internal CommandMarginController(IVimBuffer buffer, FrameworkElement parentVisualElement, CommandMarginControl control, IEditorFormatMap editorFormatMap, IClassificationFormatMap classificationFormatMap)
        {
            _vimBuffer = buffer;
            _margin = control;
            _parentVisualElement = parentVisualElement;
            _editorFormatMap = editorFormatMap;
            _classificationFormatMap = classificationFormatMap;

            Connect();
            UpdateForRecordingChanged();
            UpdateTextColor();
        }
Exemple #15
0
        internal PasteController(IVimBuffer vimBuffer, IWpfTextView wpfTextView, IProtectedOperations protectedOperations, IEditorFormatMap editorFormatMap)
        {
            _vimBuffer = vimBuffer;
            _pasteAdornment = new PasteAdornment(
                wpfTextView,
                wpfTextView.GetAdornmentLayer(PasteFactoryService.PasteAdornmentLayerName),
                protectedOperations,
                editorFormatMap);

            _vimBuffer.KeyInputProcessed += OnKeyInputProcessed;
            _vimBuffer.Closed += OnVimBufferClosed;
        }
		public CurrentLineHighlighter(IWpfTextView wpfTextView, IEditorFormatMap editorFormatMap) {
			if (wpfTextView == null)
				throw new ArgumentNullException(nameof(wpfTextView));
			if (editorFormatMap == null)
				throw new ArgumentNullException(nameof(editorFormatMap));
			this.wpfTextView = wpfTextView;
			this.editorFormatMap = editorFormatMap;
			currentLineHighlighterElement = new CurrentLineHighlighterElement();
			wpfTextView.Closed += WpfTextView_Closed;
			wpfTextView.Options.OptionChanged += Options_OptionChanged;
			UpdateEnableState();
		}
        public RainbowTipHighlight(IWpfTextView textView, IEditorFormatMap formatMap)
        {
            this.textView = textView;
              this.formatMap = formatMap;
              this.layer = textView.GetAdornmentLayer(LAYER);

              AddHighlight();
              this.textView.Closed += OnViewClosed;
              this.textView.ViewportWidthChanged += OnViewportSizeChanged;
              this.textView.ViewportHeightChanged += OnViewportSizeChanged;
              this.textView.LayoutChanged += OnLayoutChanged;
        }
Exemple #18
0
        public PromptMargin(IWpfTextViewHost wpfTextViewHost, IEditorFormatMap editorFormatMap) {
            _textView = wpfTextViewHost.TextView;
            _editorFormatMap = editorFormatMap;

            _promptProvider = ReplWindow.FromBuffer(_textView.TextBuffer);
            _promptProvider.MarginVisibilityChanged += new Action(OnMarginVisibilityChanged);

            _visualManager = new PromptMarginVisualManager(this, editorFormatMap);
            _visualManager.MarginVisual.IsVisibleChanged += this.OnIsVisibleChanged;

            OnMarginVisibilityChanged();
        }
        internal ConflictingKeyBindingMargin(IKeyBindingService service, IEditorFormatMap formatMap, IVimApplicationSettings vimApplicationSettings)
        {
            _keyBindingService = service;
            _vimApplicationSettings = vimApplicationSettings;
            _control = new ConflictingKeyBindingMarginControl();
            _control.Background = formatMap.GetBackgroundBrush(EditorFormatDefinitionNames.Margin, MarginFormatDefinition.DefaultColor);

            _control.ConfigureClick += OnConfigureClick;
            _control.IgnoreClick += OnIgnoreClick;
            _keyBindingService.ConflictingKeyBindingStateChanged += OnStateChanged;

            OnStateChanged(this, EventArgs.Empty);
        }
 public InlineDiagnosticsTag(string errorType, DiagnosticData diagnostic, IEditorFormatMap editorFormatMap,
                             IClassificationFormatMapService classificationFormatMapService, IClassificationTypeRegistryService classificationTypeRegistryService,
                             InlineDiagnosticsLocations location, INavigateToLinkService navigateToLinkService)
     : base(editorFormatMap)
 {
     ErrorType                          = errorType;
     _diagnostic                        = diagnostic;
     Location                           = location;
     _navigateToLinkService             = navigateToLinkService;
     _editorFormatMap                   = editorFormatMap;
     _classificationFormatMap           = classificationFormatMapService.GetClassificationFormatMap("text");
     _classificationTypeRegistryService = classificationTypeRegistryService;
     _classificationType                = _classificationTypeRegistryService.GetClassificationType("url");
 }
Exemple #21
0
        private StructureAdornmentManager(IWpfTextView view, StructureAdornmentFactory factory)
        {
            _view    = view;
            _factory = factory;
            _layer   = view.GetAdornmentLayer("StructureAdornmentLayer");

            _formatMap = factory.EditorFormatMapService.GetEditorFormatMap(view);

            _view.VisualElement.IsVisibleChanged += this.OnVisibleChanged;
            _view.Closed += this.OnClosed;

            _view.Options.OptionChanged += this.OnOptionChanged;
            this.OnOptionChanged(null, null);
        }
Exemple #22
0
        internal PasteAdornment(
            ITextView textView,
            IAdornmentLayer adornmentLayer,
            IProtectedOperations protectedOperations,
            IEditorFormatMap editorFormatMap)
        {
            _textView = textView;
            _protectedOperations = protectedOperations;
            _editorFormatMap = editorFormatMap;
            _adornmentLayer = adornmentLayer;

            _textView.Caret.PositionChanged += OnChangeEvent;
            _textView.LayoutChanged += OnChangeEvent;
        }
 public InlineDiagnosticsTaggerProvider(
     IThreadingContext threadingContext,
     IDiagnosticService diagnosticService,
     IGlobalOptionService globalOptions,
     IAsynchronousOperationListenerProvider listenerProvider,
     IEditorFormatMapService editorFormatMapService,
     IClassificationFormatMapService classificationFormatMapService,
     IClassificationTypeRegistryService classificationTypeRegistryService)
     : base(threadingContext, diagnosticService, globalOptions, listenerProvider)
 {
     _editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
     _classificationFormatMapService    = classificationFormatMapService;
     _classificationTypeRegistryService = classificationTypeRegistryService;
 }
        internal CommandMarginController(IVimBuffer buffer, FrameworkElement parentVisualElement, CommandMarginControl control, IEditorFormatMap editorFormatMap, IClassificationFormatMap classificationFormatMap, ICommonOperations commonOperations)
        {
            _vimBuffer               = buffer;
            _margin                  = control;
            _parentVisualElement     = parentVisualElement;
            _editorFormatMap         = editorFormatMap;
            _classificationFormatMap = classificationFormatMap;
            _commonOperations        = commonOperations;

            Connect();
            UpdateForRecordingChanged();
            UpdateTextColor();
            UpdateStatusLineVisibility();
        }
Exemple #25
0
        internal PasteAdornment(
            ITextView textView,
            IAdornmentLayer adornmentLayer,
            IProtectedOperations protectedOperations,
            IEditorFormatMap editorFormatMap)
        {
            _textView            = textView;
            _protectedOperations = protectedOperations;
            _editorFormatMap     = editorFormatMap;
            _adornmentLayer      = adornmentLayer;

            _textView.Caret.PositionChanged += OnChangeEvent;
            _textView.LayoutChanged         += OnChangeEvent;
        }
        /// <summary>
        /// Constructor for the <see cref="CSharpMembersMargin"/>.
        /// </summary>
        /// <param name="textView">ITextView to which this <see cref="CSharpMembersMargin"/> will be attacheded.</param>
        /// <param name="verticalScrollbar">Vertical scrollbar of the ITextViewHost that contains <paramref name="textView"/>.</param>
        public CSharpMembersMargin(IWpfTextView textView, IVerticalScrollBar verticalScrollbar)
        {
            IsHitTestVisible    = false;
            SnapsToDevicePixels = true;
            Width                  = Padding + MarkerSize;
            _MemberMarker          = new MemberMarker(textView, verticalScrollbar, this);
            _SymbolReferenceMarker = new SymbolReferenceMarker(textView, verticalScrollbar, this);
            _FormatMap             = ServicesHelper.Instance.EditorFormatMap.GetEditorFormatMap(textView);
            IsVisibleChanged      += _MemberMarker.OnIsVisibleChanged;
            textView.Closed       += TextView_Closed;

            Config.Updated += Config_Updated;
            Config_Updated(null, new ConfigUpdatedEventArgs(Features.ScrollbarMarkers));
        }
        public InheritanceMarginViewMargin(
            Workspace workspace,
            IWpfTextView textView,
            IThreadingContext threadingContext,
            IStreamingFindUsagesPresenter streamingFindUsagesPresenter,
            IUIThreadOperationExecutor operationExecutor,
            IClassificationFormatMap classificationFormatMap,
            ClassificationTypeMap classificationTypeMap,
            ITagAggregator <InheritanceMarginTag> tagAggregator,
            IEditorFormatMap editorFormatMap,
            IGlobalOptionService globalOptions,
            IAsynchronousOperationListener listener,
            string languageName) : base(threadingContext)
        {
            _textView      = textView;
            _tagAggregator = tagAggregator;
            _globalOptions = globalOptions;
            _languageName  = languageName;
            _mainCanvas    = new Canvas {
                ClipToBounds = true, Width = HeightAndWidthOfMargin
            };
            _grid = new Grid();
            _grid.Children.Add(_mainCanvas);
            _glyphManager = new InheritanceGlyphManager(
                workspace,
                textView,
                threadingContext,
                streamingFindUsagesPresenter,
                classificationFormatMap,
                classificationTypeMap,
                operationExecutor,
                editorFormatMap,
                listener,
                _mainCanvas,
                HeightAndWidthOfMargin);
            _refreshAllGlyphs = true;
            _disposed         = false;

            _tagAggregator.BatchedTagsChanged += OnTagsChanged;
            _textView.LayoutChanged           += OnLayoutChanged;
            _textView.ZoomLevelChanged        += OnZoomLevelChanged;
            _globalOptions.OptionChanged      += OnGlobalOptionChanged;

            _grid.LayoutTransform = new ScaleTransform(
                scaleX: _textView.ZoomLevel / 100,
                scaleY: _textView.ZoomLevel / 100);
            _grid.LayoutTransform.Freeze();
            UpdateMarginVisibility();
        }
        /// <summary>
        /// Get foreground brush from specified <see cref="EditorFormatDefinition"/> type.
        /// </summary>
        /// <typeparam name="T">Type of <see cref="EditorFormatDefinition"/>.</typeparam>
        /// <param name="formatMap">Map that contains format definitions.</param>
        /// <returns>The foreground brush.</returns>
        public static SolidColorBrush GetForeground <T>(this IEditorFormatMap formatMap)
            where T : EditorFormatDefinition
        {
            var attr = typeof(T).GetCustomAttribute <ClassificationTypeAttribute>();

            if (attr == null)
            {
                throw new ArgumentException(string.Format("Type \"{0}\" does not contain \"{1}\" attribute.", typeof(T).FullName, typeof(ClassificationTypeAttribute).FullName));
            }

            ResourceDictionary properties = formatMap.GetProperties(attr.ClassificationTypeNames);
            var brush = (SolidColorBrush)properties[EditorFormatDefinition.ForegroundBrushId];

            return(brush);
        }
Exemple #29
0
        public HighlightWordTagger(IWpfTextView view, IEditorFormatMap format, ITextSearchService searcher, ITextStructureNavigator navigator)
        {
            _view      = view;
            _searcher  = searcher;
            _navigator = navigator;
            _format    = format;

            view.VisualElement.AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new RoutedEventHandler(ViewMouseLeftButtonDown), true);
            view.VisualElement.AddHandler(FrameworkElement.KeyUpEvent, new RoutedEventHandler(ViewKeyUp), true);

            view.Closed += OnViewClosed;
            view.Options.OptionChanged += OnOptionChanged;

            ReloadOptions();
        }
Exemple #30
0
        /// <summary>
        ///     Applies the style.
        /// </summary>
        public static void ApplyStyle(IEditorFormatMap editorFormatMap, TextBox textBlock)
        {
            var typeface = editorFormatMap.GetTypeface();
            var fontSize = editorFormatMap.GetFontSize();

            if (typeface != null)
            {
                //Set format for text block
                textBlock.FontFamily  = typeface.FontFamily;
                textBlock.FontStyle   = typeface.Style;
                textBlock.FontStretch = typeface.Stretch;
                textBlock.FontWeight  = typeface.Weight;
                textBlock.FontSize    = fontSize;
            }
        }
 internal LineSeparatorManager(DocumentView docView, LineSeparatorAdornmentManagerProvider provider, IViewTagAggregatorFactoryService aggregatorService, IEditorFormatMapService editorFormatMapService)
 {
     _textView                = docView.TextView;
     _adornmentLayer          = _textView.GetAdornmentLayer(Constants.LanguageName + "LineSeparator");
     _textView.LayoutChanged += OnLayoutChanged;
     _textView.Closed        += OnClosed;
     _buffer          = docView.TextBuffer;
     _editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
     _editorFormatMap.FormatMappingChanged += FormatMappingChanged;
     _lineSeparatorTag = new LineSeparatorTag(_editorFormatMap);
     if (_buffer.Properties.TryGetProperty(typeof(XSharpClassifier), out _classifier))
     {
         _classifier.LineStateChanged += LineStateChanged;
     }
 }
 public InlineDiagnosticsTaggerProvider(
     IThreadingContext threadingContext,
     IDiagnosticService diagnosticService,
     IGlobalOptionService globalOptions,
     [Import(AllowDefault = true)] ITextBufferVisibilityTracker?visibilityTracker,
     IAsynchronousOperationListenerProvider listenerProvider,
     IEditorFormatMapService editorFormatMapService,
     IClassificationFormatMapService classificationFormatMapService,
     IClassificationTypeRegistryService classificationTypeRegistryService)
     : base(threadingContext, diagnosticService, globalOptions, visibilityTracker, listenerProvider)
 {
     _editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
     _classificationFormatMapService    = classificationFormatMapService;
     _classificationTypeRegistryService = classificationTypeRegistryService;
 }
 internal EasyMotionAdornmentController(IEasyMotionUtil easyMotionUtil, IWpfTextView wpfTextview, IEditorFormatMap editorFormatMap, IClassificationFormatMap classificationFormatMap)
 {
     _easyMotionUtil = easyMotionUtil;
     _wpfTextView = wpfTextview;
     _editorFormatMap = editorFormatMap;
     _classificationFormatMap = classificationFormatMap;
     if (_navigationKeysLong == null)
     {
         _navigationKeysLong = CreateNavigationKeysLong();
     }
     if (_navigationKeysShort == null)
     {
         _navigationKeysShort = CreateNavigationKeysShort();
     }
 }
 internal EasyMotionAdornmentController(IEasyMotionUtil easyMotionUtil, IWpfTextView wpfTextview, IEditorFormatMap editorFormatMap, IClassificationFormatMap classificationFormatMap)
 {
     _easyMotionUtil          = easyMotionUtil;
     _wpfTextView             = wpfTextview;
     _editorFormatMap         = editorFormatMap;
     _classificationFormatMap = classificationFormatMap;
     if (_navigationKeysLong == null)
     {
         _navigationKeysLong = CreateNavigationKeysLong();
     }
     if (_navigationKeysShort == null)
     {
         _navigationKeysShort = CreateNavigationKeysShort();
     }
 }
Exemple #35
0
        /// <summary>
        /// Constructs a new selection Element that is bound to the specified editor canvas
        /// </summary>
        /// <param name="wpfTextView">
        /// The WPF Text View that hosts this caret
        /// </param>
        public SkiaTextCaret(
            SkiaTextView wpfTextView, SkiaTextSelection selection,
            ISmartIndentationService smartIndentationService,
            IEditorFormatMap editorFormatMap,
            //IClassificationFormatMap classificationFormatMap,
            GuardedOperations guardedOperations)
        {
            // Verify
            Debug.Assert(wpfTextView != null);
            _regularBrush = new SKPaint()
            {
                Color = SKColors.Red, Typeface = wpfTextView.Typeface, TextSize = 24, LcdRenderText = true, IsAntialias = true, SubpixelText = true
            };
            _wpfTextView       = wpfTextView;
            _selection         = selection;
            _guardedOperations = guardedOperations;

            _smartIndentationService = smartIndentationService;

            // Set up initial values
            _caretAffinity  = PositionAffinity.Successor;
            _insertionPoint = new VirtualSnapshotPoint(new SnapshotPoint(_wpfTextView.TextSnapshot, 0));

            //// Set the regular caret brush
            //_editorFormatMap = editorFormatMap;

            //// store information related to classifications
            //_classificationFormatMap = classificationFormatMap;

            this.SubscribeEvents();

            this.UpdateDefaultBrushes();
            this.UpdateRegularCaretBrush();
            this.UpdateOverwriteCaretBrush();

            //Set the default values for the caret to be what they should be for a hidden caret that is not in overwrite mode.
            _caretBrush = _regularBrush;

            // Get the caret blink time from the system.  If the caret is set not to flash, the return value
            // will be -1
            _blinkInterval = CaretBlinkTimeManager.GetCaretBlinkTime();
            if (_blinkInterval > 0)
            {
                _blinkTimer = new DispatcherTimer(new TimeSpan(0, 0, 0, 0, _blinkInterval), OnTimerElapsed);
            }

            this.UpdateBlinkTimer();
        }
        void ViewClosed(object sender, EventArgs e)
        {
            _view.LayoutChanged -= OnViewLayoutChanged;
            _view.Closed        -= ViewClosed;
            if (_settingsChanged != null)
            {
                _settingsChanged.PropertyChanged -= SettingsChanged;
                _settingsChanged = null;
            }

            if (_formatMap != null)
            {
                _formatMap.FormatMappingChanged -= FormatMappingChanged;
                _formatMap = null;
            }
        }
Exemple #37
0
 internal BlockCaret(
     IWpfTextView textView,
     string adornmentLayerName,
     IClassificationFormatMap classificationFormatMap,
     IEditorFormatMap formatMap,
     IControlCharUtil controlCharUtil,
     IProtectedOperations protectedOperations) :
     this(
         textView,
         classificationFormatMap,
         formatMap,
         textView.GetAdornmentLayer(adornmentLayerName),
         controlCharUtil,
         protectedOperations)
 {
 }
Exemple #38
0
 internal BlockCaret(
     IVimBufferData vimBufferData,
     string adornmentLayerName,
     IClassificationFormatMap classificationFormatMap,
     IEditorFormatMap formatMap,
     IControlCharUtil controlCharUtil,
     IProtectedOperations protectedOperations) :
     this(
         vimBufferData,
         classificationFormatMap,
         formatMap,
         (vimBufferData.TextView as IWpfTextView).GetAdornmentLayer(adornmentLayerName),
         controlCharUtil,
         protectedOperations)
 {
 }
        internal CharDisplayTaggerSource(
            ITextView textView,
            IEditorFormatMap editorFormatMap,
            IControlCharUtil controlCharUtil,
            IClassificationFormatMap classificationFormatMap)
        {
            _textView                = textView;
            _editorFormatMap         = editorFormatMap;
            _controlCharUtil         = controlCharUtil;
            _classificationFormatMap = classificationFormatMap;
            UpdateBrushes();

            _textView.TextBuffer.Changed                += OnTextBufferChanged;
            _editorFormatMap.FormatMappingChanged       += OnFormatMappingChanged;
            _controlCharUtil.DisplayControlCharsChanged += OnSettingChanged;
        }
Exemple #40
0
 public LineSeparatorTaggerProvider(
     IThreadingContext threadingContext,
     IEditorFormatMapService editorFormatMapService,
     IForegroundNotificationService notificationService,
     IAsynchronousOperationListenerProvider listenerProvider
     )
     : base(
         threadingContext,
         listenerProvider.GetListener(FeatureAttribute.LineSeparators),
         notificationService
         )
 {
     _editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
     _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
     _lineSeparatorTag = new LineSeparatorTag(_editorFormatMap);
 }
Exemple #41
0
        public LineNumberMargin(IWpfTextView textView, IVerticalScrollBar scrollBar)
        {
            _TextView = textView;

            IsHitTestVisible = false;

            _ScrollBar       = scrollBar;
            _EditorFormatMap = ServicesHelper.Instance.EditorFormatMap.GetEditorFormatMap(textView);

            Width = 0;

            Visibility      = Config.Instance.MarkerOptions.MatchFlags(MarkerOptions.LineNumber) ? Visibility.Visible : Visibility.Collapsed;
            Config.Updated += Config_Updated;
            Setup();
            _TextView.Closed += (s, args) => Dispose();
        }
Exemple #42
0
        public GlyphMargin(
            IWpfTextView textView,
            IGlyphFactory <TGlyphTag> glyphFactory,
            Grid marginGrid,
            IViewTagAggregatorFactoryService tagAggregatorFactory,
            IEditorFormatMap editorFormatMap,
            string marginPropertiesName)
        {
            this.textView             = textView;
            this.marginGrid           = marginGrid;
            this.tagAggregatorFactory = tagAggregatorFactory;
            visualManager             = new GlyphMarginVisualManager <TGlyphTag>(textView, glyphFactory, marginGrid, editorFormatMap, marginPropertiesName);

            // Initialize when first visible
            visibleSubscription = marginGrid.WhenAnyValue(x => x.IsVisible).Distinct().Where(x => x).Subscribe(_ => Initialize());
        }
Exemple #43
0
            private static Brush GetBrush(IEditorFormatMap map, string name, string resource = EditorFormatDefinition.BackgroundBrushId)
            {
                var formatProperties = map.GetProperties(name);

                if (formatProperties != null && formatProperties.Contains(resource))
                {
                    var brushValue = formatProperties[resource] as Brush;
                    if (brushValue != null)
                    {
                        Debug.Assert(brushValue.IsFrozen);

                        return(brushValue);
                    }
                }

                return(null);
            }
Exemple #44
0
        internal BlockCaret(ITextView view, IEditorFormatMap formatMap, IAdornmentLayer layer)
        {
            _view = view;
            _formatMap = formatMap;
            _layer = layer;

            _view.LayoutChanged += OnLayoutChanged;
            _view.Caret.PositionChanged += OnCaretChanged;

            var caretBlinkTime = NativeMethods.GetCaretBlinkTime();
            var caretBlinkTimeSpan = new TimeSpan(0, 0, 0, 0, caretBlinkTime);
            _blinkTimer = new DispatcherTimer(
                caretBlinkTimeSpan,
                DispatcherPriority.Normal,
                OnCaretBlinkTimer,
                Dispatcher.CurrentDispatcher);
        }
Exemple #45
0
        /// <summary>
        /// Creates editor column guidelines
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        /// <param name="settings">The guideline settings.</param>
        /// <param name="editorFormatMap">The editor format map used to discover formatting options (guideline color).</param>
        public ColumnGuide(IWpfTextView view, ITextEditorGuidesSettings settings, IEditorFormatMap editorFormatMap)
        {
            _view      = view;
            _formatMap = editorFormatMap;

            InitializeGuidelines(settings);

            _view.LayoutChanged += OnViewLayoutChanged;
            _settingsChanged     = settings as INotifyPropertyChanged;
            if (_settingsChanged != null)
            {
                _settingsChanged.PropertyChanged += SettingsChanged;
            }

            _formatMap.FormatMappingChanged += FormatMappingChanged;
            _view.Closed += ViewClosed;
        }
Exemple #46
0
        internal GitDiffMargin(IWpfTextView textView, MarginFactory factory)
        {
            _textView = textView;
            _classificationFormatMap = factory.ClassificationFormatMapService.GetClassificationFormatMap(textView);
            _editorFormatMap         = factory.EditorFormatMapService.GetEditorFormatMap(textView);

            _editorFormatMap.FormatMappingChanged += HandleFormatMappingChanged;
            _textView.Closed += (sender, e) => _editorFormatMap.FormatMappingChanged -= HandleFormatMappingChanged;
            UpdateBrushes();

            _textView.Options.OptionChanged += HandleOptionChanged;

            _gitDiffBarControl             = new DiffMarginControl();
            _viewModel                     = new DiffMarginViewModel(this, _textView, factory.TextDocumentFactoryService, new GitCommands(factory.ServiceProvider));
            _gitDiffBarControl.DataContext = _viewModel;
            _gitDiffBarControl.Width       = MarginWidth;
        }
Exemple #47
0
        internal BlockCaret(ITextView textView, IClassificationFormatMap classificationFormatMap, IEditorFormatMap formatMap, IAdornmentLayer layer, IControlCharUtil controlCharUtil, IProtectedOperations protectedOperations)
        {
            _textView = textView;
            _editorFormatMap = formatMap;
            _adornmentLayer = layer;
            _protectedOperations = protectedOperations;
            _classificationFormatMap = classificationFormatMap;
            _controlCharUtil = controlCharUtil;

            _textView.LayoutChanged += OnCaretEvent;
            _textView.GotAggregateFocus += OnCaretEvent;
            _textView.LostAggregateFocus += OnCaretEvent;
            _textView.Caret.PositionChanged += OnCaretPositionChanged;
            _textView.Closed += OnTextViewClosed;

            _blinkTimer = CreateBlinkTimer(protectedOperations, OnCaretBlinkTimer);
        }
Exemple #48
0
        internal BlockCaret(ITextView textView, IClassificationFormatMap classificationFormatMap, IEditorFormatMap formatMap, IAdornmentLayer layer, IControlCharUtil controlCharUtil, IProtectedOperations protectedOperations)
        {
            _textView                = textView;
            _editorFormatMap         = formatMap;
            _adornmentLayer          = layer;
            _protectedOperations     = protectedOperations;
            _classificationFormatMap = classificationFormatMap;
            _controlCharUtil         = controlCharUtil;

            _textView.LayoutChanged         += OnCaretEvent;
            _textView.GotAggregateFocus     += OnCaretEvent;
            _textView.LostAggregateFocus    += OnCaretEvent;
            _textView.Caret.PositionChanged += OnCaretPositionChanged;
            _textView.Closed += OnTextViewClosed;

            _blinkTimer = CreateBlinkTimer(protectedOperations, OnCaretBlinkTimer);
        }
Exemple #49
0
        void UpdateAppearanceMap()
        {
            var newMap = editorFormatMapService.GetEditorFormatMap(GetAppearanceCategory());

            if (categoryMap == newMap)
            {
                return;
            }

            if (categoryMap != null)
            {
                categoryMap.FormatMappingChanged -= CategoryMap_FormatMappingChanged;
            }
            categoryMap = newMap;
            categoryMap.FormatMappingChanged += CategoryMap_FormatMappingChanged;
            FormatMappingChanged?.Invoke(this, new FormatItemsEventArgs(new ReadOnlyCollection <string>(viewProps.ToArray())));
        }
Exemple #50
0
 public CurrentLineHighlighter(IWpfTextView wpfTextView, IEditorFormatMap editorFormatMap)
 {
     if (wpfTextView == null)
     {
         throw new ArgumentNullException(nameof(wpfTextView));
     }
     if (editorFormatMap == null)
     {
         throw new ArgumentNullException(nameof(editorFormatMap));
     }
     this.wpfTextView                   = wpfTextView;
     this.editorFormatMap               = editorFormatMap;
     currentLineHighlighterElement      = new CurrentLineHighlighterElement();
     wpfTextView.Closed                += WpfTextView_Closed;
     wpfTextView.Options.OptionChanged += Options_OptionChanged;
     UpdateEnableState();
 }
        internal GitDiffMargin(IWpfTextView textView, MarginFactory factory)
        {
            _textView = textView;
            _classificationFormatMap = factory.ClassificationFormatMapService.GetClassificationFormatMap(textView);
            _editorFormatMap = factory.EditorFormatMapService.GetEditorFormatMap(textView);

            _editorFormatMap.FormatMappingChanged += HandleFormatMappingChanged;
            _textView.Closed += (sender, e) => _editorFormatMap.FormatMappingChanged -= HandleFormatMappingChanged;
            UpdateBrushes();

            _textView.Options.OptionChanged += HandleOptionChanged;

            _gitDiffBarControl = new DiffMarginControl();
            _viewModel = new DiffMarginViewModel(this, _textView, factory.TextDocumentFactoryService, new GitCommands(factory.ServiceProvider));
            _gitDiffBarControl.DataContext = _viewModel;
            _gitDiffBarControl.Width = MarginWidth;
        }
Exemple #52
0
 void Initialize()
 {
     if (mouseProcessorCollection != null)
     {
         return;
     }
     iconCanvas = new Canvas {
         Background = Brushes.Transparent
     };
     Children.Add(iconCanvas);
     mouseProcessorCollection = new MouseProcessorCollection(VisualElement, null, new DefaultMouseProcessor(), CreateMouseProcessors(), null);
     wpfTextViewHost.TextView.TextDataModel.ContentTypeChanged += TextDataModel_ContentTypeChanged;
     lineInfos       = new Dictionary <object, LineInfo>();
     tagAggregator   = viewTagAggregatorFactoryService.CreateTagAggregator <IGlyphTag>(wpfTextViewHost.TextView);
     editorFormatMap = editorFormatMapService.GetEditorFormatMap(wpfTextViewHost.TextView);
     InitializeGlyphFactories(null, wpfTextViewHost.TextView.TextDataModel.ContentType);
 }
		public TextSelectionLayer(TextSelection textSelection, IAdornmentLayer layer, IEditorFormatMap editorFormatMap) {
			if (textSelection == null)
				throw new ArgumentNullException(nameof(textSelection));
			if (layer == null)
				throw new ArgumentNullException(nameof(layer));
			if (editorFormatMap == null)
				throw new ArgumentNullException(nameof(editorFormatMap));
			markerElementRemovedCallBack = (tag, element) => OnMarkerElementRemoved();
			this.textSelection = textSelection;
			this.layer = layer;
			this.editorFormatMap = editorFormatMap;
			textSelection.TextView.Options.OptionChanged += Options_OptionChanged;
			textSelection.SelectionChanged += TextSelection_SelectionChanged;
			textSelection.TextView.LayoutChanged += TextView_LayoutChanged;
			editorFormatMap.FormatMappingChanged += EditorFormatMap_FormatMappingChanged;
			UpdateUseReducedOpacityForHighContrastOption();
			UpdateBackgroundBrush();
		}
Exemple #54
0
        public MarginCore(IWpfTextView textView, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService)
        {
            _textView = textView;

            _classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(textView);

            _editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView);
            _editorFormatMap.FormatMappingChanged += HandleFormatMappingChanged;

            _textView.Options.OptionChanged += HandleOptionChanged;

            _textView.Closed += (sender, e) =>
            {
                _editorFormatMap.FormatMappingChanged -= HandleFormatMappingChanged;
            };

            UpdateBrushes();
        }
Exemple #55
0
        public LineNumberMargin(IWpfTextView textView, IVerticalScrollBar scrollBar)
        {
            _TextView = textView;

            IsHitTestVisible = false;

            _ScrollBar       = scrollBar;
            _Tags            = textView.Properties.GetOrCreateSingletonProperty(() => new TaggerResult());
            _EditorFormatMap = ServicesHelper.Instance.EditorFormatMap.GetEditorFormatMap(textView);

            Width = 0;

            Visibility      = Config.Instance.MarkerOptions.MatchFlags(MarkerOptions.LineNumber) ? Visibility.Visible : Visibility.Collapsed;
            Config.Updated += Config_Updated;
            _TextView.TextBuffer.Changed += TextView_TextBufferChanged;
            _ScrollBar.TrackSpanChanged  += OnMappingChanged;
            _TextView.Closed             += (s, args) => Dispose();
        }
Exemple #56
0
        /// <summary>
        /// Constructor for the StructureMarginElement.
        /// </summary>
        /// <param name="textView">ITextView to which this StructureMargenElement will be attacheded.</param>
        /// <param name="verticalScrollbar">Vertical scrollbar of the ITextViewHost that contains <paramref name="textView"/>.</param>
        /// <param name="factory">MEF tag factory.</param>
        public StructureMarginElement(IWpfTextView textView, IVerticalScrollBar verticalScrollbar, StructureMarginFactory factory)
        {
            _textView  = textView;
            _scrollBar = verticalScrollbar;
            _factory   = factory;

            _formatMap = factory.EditorFormatMapService.GetEditorFormatMap(textView);

            this.IsHitTestVisible    = false;
            this.SnapsToDevicePixels = true;
            this.Width = marginWidth;

            textView.Options.OptionChanged += this.OnOptionChanged;

            this.IsVisibleChanged += this.OnIsVisibleChanged;

            this.OnOptionChanged(null, null);
        }
		public CategoryEditorFormatMapUpdater(IThemeService themeService, ITextAppearanceCategory textAppearanceCategory, IEditorFormatDefinitionService editorFormatDefinitionService, IEditorFormatMap editorFormatMap) {
			if (themeService == null)
				throw new ArgumentNullException(nameof(themeService));
			if (textAppearanceCategory == null)
				throw new ArgumentNullException(nameof(textAppearanceCategory));
			if (editorFormatDefinitionService == null)
				throw new ArgumentNullException(nameof(editorFormatDefinitionService));
			if (editorFormatMap == null)
				throw new ArgumentNullException(nameof(editorFormatMap));
			this.themeService = themeService;
			this.textAppearanceCategory = textAppearanceCategory;
			this.editorFormatDefinitionService = editorFormatDefinitionService;
			this.editorFormatMap = editorFormatMap;

			themeService.ThemeChangedHighPriority += ThemeService_ThemeChangedHighPriority;
			textAppearanceCategory.SettingsChanged += TextAppearanceCategory_SettingsChanged;
			InitializeAll();
		}
        public FormatMapWatcher(IWpfTextView view, IEditorFormatMap formatMap)
        {
            this.formatMap = formatMap;
            this.view = view;

            this.SetAppropriateBrush();

            formatMap.FormatMappingChanged += (sender, args) => SetAppropriateBrush();

            // Track the rich client option changing, to set and clear the gradient brush
            view.Options.OptionChanged += (sender, args) =>
            {
                if (args.OptionId == DefaultWpfViewOptions.EnableSimpleGraphicsId.Name)
                {
                    SetAppropriateBrush();
                }
            };
            view.VisualElement.IsVisibleChanged += (sender, args) => this.SetAppropriateBrush();
        }
        public HistorySelectionTextAdornment(IWpfTextView textView, IEditorFormatMapService editorFormatMapService, IRHistoryProvider historyProvider) {
            _textView = textView;
            _layer = textView.GetAdornmentLayer("HistorySelectionTextAdornment");

            _editorFormatMap = editorFormatMapService.GetEditorFormatMap(_textView);
            _history = historyProvider.GetAssociatedRHistory(_textView);

            // Advise to events
            _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
            _textView.VisualElement.GotKeyboardFocus += OnGotKeyboardFocus;
            _textView.VisualElement.LostKeyboardFocus += OnLostKeyboardFocus;
            _textView.LayoutChanged += OnLayoutChanged;
            _textView.Closed += OnClosed;
            _history.SelectionChanged += OnSelectionChanged;

            _activeVisualToolset = CreateVisualToolset(ActiveSelectionPropertiesName, SystemColors.HighlightColor);
            _inactiveVisualToolset = CreateVisualToolset(InactiveSelectionPropertiesName, SystemColors.GrayTextColor);
            Redraw();
        }
        internal CommandMarginController(IVimBuffer buffer, CommandMarginControl control, IEditorFormatMap editorFormatMap, IEnumerable<Lazy<IOptionsProviderFactory>> optionsProviderFactory)
        {
            _buffer = buffer;
            _margin = control;
            _editorFormatMap = editorFormatMap;
            _optionsProviderFactory = optionsProviderFactory.ToList().AsReadOnly();

            _buffer.SwitchedMode += OnSwitchMode;
            _buffer.KeyInputStart += OnKeyInputStart;
            _buffer.KeyInputEnd += OnKeyInputEnd;
            _buffer.StatusMessage += OnStatusMessage;
            _buffer.ErrorMessage += OnErrorMessage;
            _buffer.WarningMessage += OnWarningMessage;
            _buffer.Vim.MacroRecorder.RecordingStarted += OnRecordingStarted;
            _buffer.Vim.MacroRecorder.RecordingStopped += OnRecordingStopped;
            _margin.OptionsClicked += OnOptionsClicked;
            _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
            UpdateForRecordingChanged();
            UpdateTextColor();
        }