Example #1
0
            static void DisposeTransformer(TextMateColoringTransformer transformer)
            {
                if (transformer == null)
                {
                    return;
                }

                transformer.Dispose();
            }
Example #2
0
            TextMateColoringTransformer GetOrCreateTransformer()
            {
                var transformer = _editor.TextArea.TextView.LineTransformers.OfType <TextMateColoringTransformer>().FirstOrDefault();

                if (transformer is null)
                {
                    transformer = new TextMateColoringTransformer(_editor.TextArea.TextView);

                    _editor.TextArea.TextView.LineTransformers.Add(transformer);
                }

                return(transformer);
            }
Example #3
0
            static void DisposeTMModel(TMModel tmModel, TextMateColoringTransformer transformer)
            {
                if (tmModel == null)
                {
                    return;
                }

                if (transformer != null)
                {
                    tmModel.RemoveModelTokensChangedListener(transformer);
                }

                tmModel.Dispose();
            }
Example #4
0
            void OnEditorOnDocumentChanged(object sender, EventArgs args)
            {
                try
                {
                    DisposeEditorModel(_editorModel);
                    DisposeTMModel(_tmModel);

                    _editorModel = new TextEditorModel(_editor.TextArea.TextView, _editor.Document, _exceptionHandler);
                    _tmModel     = new TMModel(_editorModel);
                    _tmModel.SetGrammar(_grammar);
                    _transformer = GetOrCreateTransformer();
                    _transformer.SetModel(_editor.Document, _tmModel);
                    _tmModel.AddModelTokensChangedListener(_transformer);
                }
                catch (Exception ex)
                {
                    _exceptionHandler?.Invoke(ex);
                }
            }