예제 #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);
        }
예제 #2
0
            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);
            }
예제 #3
0
 protected override void Dispose(bool disposing)
 {
     ((CodeCell)Cell).CodeAnalysisBuffer.TextChanged -= HandleBufferTextChanged;
     EventsObserver.OnNext(new DeleteCellEvent <CodeCell> ((CodeCell)Cell));
     preferenceSubscription.Dispose();
     codeEditor.dispose();
 }
예제 #4
0
 public void EvaluateViaKeyPress()
 {
     if (!String.IsNullOrWhiteSpace(Cell.Buffer.Value))
     {
         EventsObserver.OnNext(new EvaluateCodeCellEvent(this, CursorPosition));
     }
 }
예제 #5
0
        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();
        }
예제 #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);
        }
예제 #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();
        }
예제 #8
0
 protected override void Dispose(bool isDisposing)
 {
     proseMirror.dispose();
     EventsObserver.OnNext(new DeleteCellEvent <MarkdownCell> ((MarkdownCell)Cell));
 }
예제 #9
0
 void HandleFocus(dynamic self, dynamic args)
 => EventsObserver.OnNext(new FocusEvent(this));
예제 #10
0
 void HandleChange(dynamic self, dynamic args)
 => EventsObserver.OnNext(new ChangeEvent(this));
예제 #11
0
 void HandleModEnter(dynamic self, dynamic args)
 => EventsObserver.OnNext(
     new InsertCellEvent <CodeCell> (Cell));
예제 #12
0
 protected override void Dispose(bool disposing)
 {
     EventsObserver.OnNext(new DeleteCellEvent <CodeCell> ((CodeCell)Cell));
     preferenceSubscription.Dispose();
     codeEditor.dispose();
 }