Browse Source

Merge pull request #199 from afshin/edge-requested

Switch to using string literal type instead of enum.
Steven Silvester 9 years ago
parent
commit
e14906b840
2 changed files with 10 additions and 17 deletions
  1. 7 14
      src/notebook/editor/model.ts
  2. 3 3
      src/notebook/editor/widget.ts

+ 7 - 14
src/notebook/editor/model.ts

@@ -15,18 +15,11 @@ import {
 } from 'phosphor-signaling';
 
 
+/**
+ * The location of requested edges.
+ */
 export
-enum EdgeFlag {
-  /**
-   * The bottom edge of the editor.
-   */
-  Bottom = 0x1,
-
-  /**
-   * The top edge of the editor.
-   */
-  Top = 0x2
-}
+type EdgeLocation = 'top' | 'bottom';
 
 
 /**
@@ -42,7 +35,7 @@ interface IEditorModel extends IDisposable {
   /**
    * A signal emitted when either the top or bottom edge is requested.
    */
-  edgeRequested: ISignal<IEditorModel, EdgeFlag>;
+  edgeRequested: ISignal<IEditorModel, EdgeLocation>;
 
   /**
    * The text in the text editor.
@@ -155,7 +148,7 @@ class EditorModel implements IEditorModel {
  /**
    * A signal emitted when either the top or bottom edge is requested.
    */
-  get edgeRequested(): ISignal<EditorModel, EdgeFlag> {
+  get edgeRequested(): ISignal<EditorModel, EdgeLocation> {
     return EditorModelPrivate.edgeRequestedSignal.bind(this);
   }
 
@@ -318,7 +311,7 @@ namespace EditorModelPrivate {
    * A signal emitted when either the top or bottom edge is requested.
    */
   export
-  const edgeRequestedSignal = new Signal<EditorModel, EdgeFlag>();
+  const edgeRequestedSignal = new Signal<EditorModel, EdgeLocation>();
 
   /**
    * Initialize an editor view model from an options object.

+ 3 - 3
src/notebook/editor/widget.ts

@@ -29,7 +29,7 @@ import {
 } from 'phosphor-widget';
 
 import {
-  IEditorModel, EdgeFlag
+  IEditorModel
 } from './model';
 
 
@@ -113,13 +113,13 @@ class CodeMirrorWidget extends Widget implements IEditorWidget {
       let line = cursor.line;
       let ch = cursor.ch;
       if (line === 0 && ch === 0 && event.keyCode === UP_ARROW) {
-        this._model.edgeRequested.emit(EdgeFlag.Top);
+        this._model.edgeRequested.emit('top');
         return
       }
       let lastLine = doc.lastLine();
       let lastCh = doc.getLineHandle(lastLine).text.length;
       if (line === lastLine && ch === lastCh && event.keyCode === DOWN_ARROW) {
-        this._model.edgeRequested.emit(EdgeFlag.Bottom);
+        this._model.edgeRequested.emit('bottom');
         return
       }
     });