Example #1
0
        public NitraTextEditor()
        {
            SyntaxHighlighting = new StubHighlightingDefinition();
            TextArea.DefaultInputHandler.NestedInputHandlers.Add(new NitraSearchInputHandler(TextArea));

            this.WhenActivated(disposables => {
                _popup = new IntelliSensePopup(ViewModel.IntelliSensePopup);

                AddVisualChild(_popup);

                this.OneWayBind(ViewModel, vm => vm.IntelliSensePopup, v => v._popup.ViewModel)
                .AddTo(disposables);

                this.WhenAnyValue(vm => vm.ViewModel.Selection)
                .Subscribe(span => {
                    if (span.HasValue)
                    {
                        Select(span.Value.StartPos, span.Value.Length);
                    }
                })
                .AddTo(disposables);

                this.WhenAnyValue(vm => vm.ViewModel.ScrollPosition)
                .Where(pos => pos != null)
                .Subscribe(scrollPos => ScrollTo(scrollPos.Line, scrollPos.Column))
                .AddTo(disposables);

                ViewModel.WhenAnyValue(vm => vm.IntelliSensePopup.IsVisible)
                .Where(popupVisible => popupVisible)
                .Do(_ => UpdatePopupOffset())
                .Subscribe(visible => _popup.List.Focus())
                .AddTo(disposables);

                ViewModel.WhenAnyValue(vm => vm.IntelliSensePopup.IsVisible)
                .Where(popupVisible => !popupVisible)
                .Subscribe(visible => TextArea.Focus())
                .AddTo(disposables);

                TextArea.SelectionChanged += (sender, args) => {
                    var selection = TextArea.Selection;
                    var span      = selection.Segments.FirstOrDefault();

                    if (span != null)
                    {
                        ViewModel.Selection = new NSpan(span.StartOffset, span.EndOffset);
                    }
                    else
                    {
                        ViewModel.Selection = null;
                    }
                };

                TextArea.Caret.PositionChanged += (sender, args) => {
                    ViewModel.CaretOffset = CaretOffset;
                    ViewModel.CaretLine   = TextArea.Caret.Line;
                    ViewModel.CaretColumn = TextArea.Caret.Column;
                };
            });
        }
Example #2
0
 public NitraTextEditor()
 {
     SyntaxHighlighting = new StubHighlightingDefinition();
 }
Example #3
0
 public NitraTextEditor()
 {
     SyntaxHighlighting = new StubHighlightingDefinition();
 }
Example #4
0
 public NitraTextEditor()
 {
     SyntaxHighlighting = new StubHighlightingDefinition();
     TextArea.DefaultInputHandler.NestedInputHandlers.Add(new NitraSearchInputHandler(TextArea));
 }
Example #5
0
 public NitraTextEditor()
 {
   SyntaxHighlighting = new StubHighlightingDefinition();
   TextArea.DefaultInputHandler.NestedInputHandlers.Add(new NitraSearchInputHandler(TextArea));
 }