Example #1
0
        dynamic HandleCursorUpDown(dynamic self, dynamic args)
        {
            var isUp = (bool)args [0];

            var pos = CursorPosition;

            var historyEvent = new NavigateReplHistoryEvent(this, pos, isUp);

            EventsObserver.OnNext(historyEvent);
            if (historyEvent.Handled)
            {
                return(true);
            }

            if (isUp && pos.Line == 0)
            {
                EventsObserver.OnNext(new FocusSiblingEditorEvent(
                                          this,
                                          FocusSiblingEditorEvent.WhichEditor.Previous));
                return(true);
            }

            if (!isUp && pos.Line == codeEditor.getLastLineIndex())
            {
                EventsObserver.OnNext(new FocusSiblingEditorEvent(
                                          this,
                                          FocusSiblingEditorEvent.WhichEditor.Next));
                return(true);
            }

            return(false);
        }
            dynamic HandleCursorUpDown(dynamic self, dynamic args)
            {
                var isUp = (bool)args [0];
                // var isMod = (bool)args [1];

                FocusSiblingEditorEvent evnt = null;

                if (isUp && proseMirror.shouldFocusPreviousEditor())
                {
                    evnt = new FocusSiblingEditorEvent(
                        this,
                        FocusSiblingEditorEvent.WhichEditor.Previous);
                }
                else if (!isUp && proseMirror.shouldFocusNextEditor())
                {
                    evnt = new FocusSiblingEditorEvent(
                        this,
                        FocusSiblingEditorEvent.WhichEditor.Next);
                }

                if (evnt == null)
                {
                    return(false);
                }

                EventsObserver.OnNext(evnt);
                return(true);
            }
Example #3
0
 protected override void Dispose(bool disposing)
 {
     ((CodeCell)Cell).CodeAnalysisBuffer.TextChanged -= HandleBufferTextChanged;
     EventsObserver.OnNext(new DeleteCellEvent <CodeCell> ((CodeCell)Cell));
     preferenceSubscription.Dispose();
     codeEditor.dispose();
 }
Example #4
0
 public void EvaluateViaKeyPress()
 {
     if (!String.IsNullOrWhiteSpace(Cell.Buffer.Value))
     {
         EventsObserver.OnNext(new EvaluateCodeCellEvent(this, CursorPosition));
     }
 }
        void HandleChange(dynamic self, dynamic args)
        {
            Cell.Buffer.Value = codeEditor.getText();

            // WorkbookCodeEditorChangeEvent
            var changeEvent = args [0];
            var text        = changeEvent.text?.ToString() ?? "";

            EventsObserver.OnNext(new ChangeEvent(this, text));

            UpdateDiagnosticsAsync().Forget();
        }
Example #6
0
        dynamic HandleEnter(dynamic self, dynamic args)
        {
            var isShift = (bool)args [0];
            var isMeta  = (bool)args [1];
            var isCtrl  = (bool)args [2];

            var isMod = InteractiveInstallation.Default.IsMac ? isMeta : isCtrl;

            // Shift+Mod+Enter: new markdown cell
            if (isShift && isMod)
            {
                EventsObserver.OnNext(
                    new InsertCellEvent <MarkdownCell> (Cell));
                return(true);
            }

            // Mod+Enter: evaluate
            if (isMod)
            {
                EvaluateViaKeyPress();
                return(true);
            }

            // Shift+Enter: regular newline+indent
            if (isShift)
            {
                return(false);
            }

            // Regular enter: evaluate if cell submission complete
            var shouldSubmit =
                Prefs.Submissions.ReturnAtEndOfBufferExecutes.GetValue() &&
                !codeEditor.isSomethingSelected() &&
                codeEditor.isCursorAtEnd();

            var workspace  = state.CompilationWorkspace;
            var documentId = state.DocumentId;

            if (shouldSubmit &&
                !String.IsNullOrWhiteSpace(Cell.Buffer.Value) &&
                workspace != null &&
                documentId != null &&
                workspace.IsDocumentSubmissionComplete(documentId))
            {
                EventsObserver.OnNext(new EvaluateCodeCellEvent(this, CursorPosition));
                return(true);
            }

            return(false);
        }
Example #7
0
        void HandleChange(dynamic self, dynamic args)
        {
            settingBufferValue = true;
            Cell.Buffer.Value  = codeEditor.getText();
            settingBufferValue = false;

            // WorkbookCodeEditorChangeEvent
            var     changeEvent       = args [0];
            var     text              = changeEvent.text?.ToString() ?? "";
            dynamic newCursorPosition = changeEvent.newCursorPosition;

            var linePosition = MonacoExtensions.FromMonacoPosition(newCursorPosition);

            EventsObserver.OnNext(new ChangeEvent(this, linePosition, text));

            UpdateDiagnosticsAsync().Forget();
        }
 protected override void Dispose(bool isDisposing)
 {
     proseMirror.dispose();
     EventsObserver.OnNext(new DeleteCellEvent <MarkdownCell> ((MarkdownCell)Cell));
 }
 void HandleFocus(dynamic self, dynamic args)
 => EventsObserver.OnNext(new FocusEvent(this));
 void HandleChange(dynamic self, dynamic args)
 => EventsObserver.OnNext(new ChangeEvent(this));
 void HandleModEnter(dynamic self, dynamic args)
 => EventsObserver.OnNext(
     new InsertCellEvent <CodeCell> (Cell));
 protected override void Dispose(bool disposing)
 {
     EventsObserver.OnNext(new DeleteCellEvent <CodeCell> ((CodeCell)Cell));
     preferenceSubscription.Dispose();
     codeEditor.dispose();
 }