{"action":"created","comment":{"url":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/comments/89606898","pull_request_review_id":10151176,"id":89606898,"diff_hunk":"@@ -0,0 +1,637 @@\n+// Copyright (c) Jupyter Development Team.\n+// Distributed under the terms of the Modified BSD License.\n+\n+import {\n+  IDisposable\n+} from 'phosphor/lib/core/disposable';\n+\n+import {\n+  find\n+} from 'phosphor/lib/algorithm/searching';\n+\n+import {\n+  Message\n+} from 'phosphor/lib/core/messaging';\n+\n+import {\n+  ISignal, clearSignalData, defineSignal\n+} from 'phosphor/lib/core/signaling';\n+\n+import {\n+  Widget\n+} from 'phosphor/lib/ui/widget';\n+\n+import {\n+  IChangedArgs\n+} from '../common/interfaces';\n+\n+import {\n+  ObservableVector\n+} from '../common/observablevector';\n+\n+import {\n+  JSONObject\n+} from 'phosphor/lib/algorithm/json';\n+\n+\n+/**\n+ * A namespace for code editors.\n+ */\n+export\n+namespace CodeEditor {\n+  /**\n+   * A zero-based position in the editor.\n+   */\n+  export\n+  interface IPosition {\n+    /**\n+     * The cursor line number.\n+     */\n+    line: number;\n+\n+    /**\n+     * The cursor column number.\n+     */\n+    column: number;\n+  }\n+\n+  /**\n+   * An interface describing editor state coordinates.\n+   */\n+  export\n+  interface ICoords {\n+    /**\n+     * The left coordinate value.\n+     */\n+    readonly left: number;\n+\n+    /**\n+     * The right coordinate value.\n+     */\n+    readonly right: number;\n+\n+    /**\n+     * The top coordinate value.\n+     */\n+    readonly top: number;\n+\n+    /**\n+     * The bottom coordinate value.\n+     */\n+    readonly bottom: number;\n+  }\n+\n+  /**\n+   * A text selection.\n+   */\n+  export\n+  interface ITextSelection {\n+    /**\n+     * The index to the first character in the current selection.\n+     *\n+     * #### Notes\n+     * If this position is greater than [end] then the selection is considered\n+     * to be backward.\n+     */\n+    start: number;\n+\n+    /**\n+     * The index to the last character in the current selection.\n+     *\n+     * #### Notes\n+     * If this position is less than [start] then the selection is considered\n+     * to be backward.\n+     */\n+    end: number;\n+\n+    /**\n+     * The uuid of the text selection owner.\n+     */\n+    uuid: string;\n+\n+    /**\n+     * A class name added to the text selection.\n+     */\n+    className?: string;\n+  }\n+\n+  /**\n+   * An editor model.\n+   */\n+  export\n+  interface IModel extends IDisposable {\n+    /**\n+     * A signal emitted when the value changes.\n+     */\n+    valueChanged: ISignal<IModel, IChangedArgs<string>>;\n+\n+    /**\n+     * A signal emitted when a property changes.\n+     */\n+    mimeTypeChanged: ISignal<IModel, IChangedArgs<string>>;\n+\n+    /**\n+     * The text stored in the model.\n+     */\n+    value: string;  // TODO: this should be an iobservablestring.\n+\n+    /**\n+     * A mime type of the model.\n+     */\n+    mimeType: string;\n+\n+    /**\n+     * Get the number of lines in the model.\n+     */\n+    readonly lineCount: number;\n+\n+    /**\n+     * The currently selected code.\n+     *\n+     * @returns A read-only copy of the text selections.\n+     */\n+    readonly selections: ObservableVector<ITextSelection>;","path":"src/codeeditor/editor.ts","position":153,"original_position":153,"commit_id":"4c58a4953b20d589d58e0e5122160994ff6a694b","original_commit_id":"4c58a4953b20d589d58e0e5122160994ff6a694b","user":{"login":"akosyakov","id":3082655,"avatar_url":"https://avatars.githubusercontent.com/u/3082655?v=3","gravatar_id":"","url":"https://api.github.com/users/akosyakov","html_url":"https://github.com/akosyakov","followers_url":"https://api.github.com/users/akosyakov/followers","following_url":"https://api.github.com/users/akosyakov/following{/other_user}","gists_url":"https://api.github.com/users/akosyakov/gists{/gist_id}","starred_url":"https://api.github.com/users/akosyakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akosyakov/subscriptions","organizations_url":"https://api.github.com/users/akosyakov/orgs","repos_url":"https://api.github.com/users/akosyakov/repos","events_url":"https://api.github.com/users/akosyakov/events{/privacy}","received_events_url":"https://api.github.com/users/akosyakov/received_events","type":"User","site_admin":false},"body":"@blink1073 I've prototyped a bit with selections and have the following suggestions:\r\n- remove `uuid` from `ITextSelection`\r\n- introduce `IModelOwner`:\r\n```ts \r\n  /**\r\n   * An editor model owner.\r\n   */\r\n  export\r\n  interface IModelOwner {\r\n    /**\r\n     * The uuid of the owner.\r\n     */\r\n    readonly uuid: string;\r\n    /**\r\n     * The selections for all the cursors.\r\n     * Cursors will be removed or added, as necessary.\r\n     */\r\n    readonly selections: ObservableVector<ITextSelection>;\r\n    /**\r\n     * Set the primary position of the cursor. This will remove any secondary cursors.\r\n     */\r\n    setPosition(position: IPosition): void;\r\n    /**\r\n     * Returns the primary position of the cursor.\r\n     */\r\n    getPosition(): IPosition;\r\n    /**\r\n     * Set the primary selection. This will remove any secondary cursors.\r\n     */\r\n    setSelection(selection: ITextSelection): void;\r\n    /**\r\n     * Returns the primary selection.\r\n     */\r\n    getSelection(): ITextSelection;\r\n  }\r\n```\r\n- replace `IModel.selections` property with `IModel.owners`:\r\n```ts\r\n/**\r\n * The owners of the current model.\r\n */\r\nreadonly owners: ObservableVector<IModelOwner>;\r\n```\r\n- Provide a default impl `IModelOwner` which just a wrapper around `selections` - `ModelOwner`\r\n- Make `IEditor` extends `IModelOwner`\r\n- Implementations of IEditor should:\r\n  - create an instance of `ModelOwner` and add as an owner to `IModel.owners`\r\n  - implement `IModelOwner` by delegating to an instance of `ModelOwner`\r\n  - subscribe to changes of owners and changes of their selections and manage cursors based on it\r\n- to add foreign cursors or selections one can create an instance of `ModelOwner` and add it to `IModel.owners`\r\n\r\nWhat do you think?","created_at":"2016-11-25T11:52:03Z","updated_at":"2016-11-25T11:52:03Z","html_url":"https://github.com/jupyterlab/jupyterlab/pull/1140#discussion_r89606898","pull_request_url":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/1140","_links":{"self":{"href":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/comments/89606898"},"html":{"href":"https://github.com/jupyterlab/jupyterlab/pull/1140#discussion_r89606898"},"pull_request":{"href":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/1140"}}},"pull_request":{"url":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/1140","id":90449993,"html_url":"https://github.com/jupyterlab/jupyterlab/pull/1140","diff_url":"https://github.com/jupyterlab/jupyterlab/pull/1140.diff","patch_url":"https://github.com/jupyterlab/jupyterlab/pull/1140.patch","issue_url":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/1140","number":1140,"state":"open","locked":false,"title":"Abstract Editor Redux","user":{"login":"blink1073","id":2096628,"avatar_url":"https://avatars.githubusercontent.com/u/2096628?v=3","gravatar_id":"","url":"https://api.github.com/users/blink1073","html_url":"https://github.com/blink1073","followers_url":"https://api.github.com/users/blink1073/followers","following_url":"https://api.github.com/users/blink1073/following{/other_user}","gists_url":"https://api.github.com/users/blink1073/gists{/gist_id}","starred_url":"https://api.github.com/users/blink1073/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blink1073/subscriptions","organizations_url":"https://api.github.com/users/blink1073/orgs","repos_url":"https://api.github.com/users/blink1073/repos","events_url":"https://api.github.com/users/blink1073/events{/privacy}","received_events_url":"https://api.github.com/users/blink1073/received_events","type":"User","site_admin":false},"body":"This is a continuation of the work started by @akosyakov in #890.  We have made some significant changes that would have made rebasing difficult (specifically the code mirror widget is completely rewritten).\n- Adds some extra items to the configuration and editor interfaces based on usage in the notebook.\n- The configuration options were modeled after [Sublime](http://www.sublimetext.com/docs/file-type-preferences).\n- Also shows a minimal implementation using an HTML [text area](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-wrap).\n\nOnce we agree on the interface, I can bring forward the rest of the changes from #890.\n\ncc @afshin @ellisonbg @jasongrout \n","created_at":"2016-10-21T21:51:37Z","updated_at":"2016-11-25T11:52:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b4ff226fd7a0274067b1b346bf6b26801a5da660","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/1140/commits","review_comments_url":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/1140/comments","review_comment_url":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/1140/comments","statuses_url":"https://api.github.com/repos/jupyterlab/jupyterlab/statuses/4c58a4953b20d589d58e0e5122160994ff6a694b","head":{"label":"blink1073:code-editor","ref":"code-editor","sha":"4c58a4953b20d589d58e0e5122160994ff6a694b","user":{"login":"blink1073","id":2096628,"avatar_url":"https://avatars.githubusercontent.com/u/2096628?v=3","gravatar_id":"","url":"https://api.github.com/users/blink1073","html_url":"https://github.com/blink1073","followers_url":"https://api.github.com/users/blink1073/followers","following_url":"https://api.github.com/users/blink1073/following{/other_user}","gists_url":"https://api.github.com/users/blink1073/gists{/gist_id}","starred_url":"https://api.github.com/users/blink1073/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blink1073/subscriptions","organizations_url":"https://api.github.com/users/blink1073/orgs","repos_url":"https://api.github.com/users/blink1073/repos","events_url":"https://api.github.com/users/blink1073/events{/privacy}","received_events_url":"https://api.github.com/users/blink1073/received_events","type":"User","site_admin":false},"repo":{"id":60405847,"name":"jupyterlab","full_name":"blink1073/jupyterlab","owner":{"login":"blink1073","id":2096628,"avatar_url":"https://avatars.githubusercontent.com/u/2096628?v=3","gravatar_id":"","url":"https://api.github.com/users/blink1073","html_url":"https://github.com/blink1073","followers_url":"https://api.github.com/users/blink1073/followers","following_url":"https://api.github.com/users/blink1073/following{/other_user}","gists_url":"https://api.github.com/users/blink1073/gists{/gist_id}","starred_url":"https://api.github.com/users/blink1073/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blink1073/subscriptions","organizations_url":"https://api.github.com/users/blink1073/orgs","repos_url":"https://api.github.com/users/blink1073/repos","events_url":"https://api.github.com/users/blink1073/events{/privacy}","received_events_url":"https://api.github.com/users/blink1073/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/blink1073/jupyterlab","description":"JupyterLab computational environment","fork":true,"url":"https://api.github.com/repos/blink1073/jupyterlab","forks_url":"https://api.github.com/repos/blink1073/jupyterlab/forks","keys_url":"https://api.github.com/repos/blink1073/jupyterlab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/blink1073/jupyterlab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/blink1073/jupyterlab/teams","hooks_url":"https://api.github.com/repos/blink1073/jupyterlab/hooks","issue_events_url":"https://api.github.com/repos/blink1073/jupyterlab/issues/events{/number}","events_url":"https://api.github.com/repos/blink1073/jupyterlab/events","assignees_url":"https://api.github.com/repos/blink1073/jupyterlab/assignees{/user}","branches_url":"https://api.github.com/repos/blink1073/jupyterlab/branches{/branch}","tags_url":"https://api.github.com/repos/blink1073/jupyterlab/tags","blobs_url":"https://api.github.com/repos/blink1073/jupyterlab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/blink1073/jupyterlab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/blink1073/jupyterlab/git/refs{/sha}","trees_url":"https://api.github.com/repos/blink1073/jupyterlab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/blink1073/jupyterlab/statuses/{sha}","languages_url":"https://api.github.com/repos/blink1073/jupyterlab/languages","stargazers_url":"https://api.github.com/repos/blink1073/jupyterlab/stargazers","contributors_url":"https://api.github.com/repos/blink1073/jupyterlab/contributors","subscribers_url":"https://api.github.com/repos/blink1073/jupyterlab/subscribers","subscription_url":"https://api.github.com/repos/blink1073/jupyterlab/subscription","commits_url":"https://api.github.com/repos/blink1073/jupyterlab/commits{/sha}","git_commits_url":"https://api.github.com/repos/blink1073/jupyterlab/git/commits{/sha}","comments_url":"https://api.github.com/repos/blink1073/jupyterlab/comments{/number}","issue_comment_url":"https://api.github.com/repos/blink1073/jupyterlab/issues/comments{/number}","contents_url":"https://api.github.com/repos/blink1073/jupyterlab/contents/{+path}","compare_url":"https://api.github.com/repos/blink1073/jupyterlab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/blink1073/jupyterlab/merges","archive_url":"https://api.github.com/repos/blink1073/jupyterlab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/blink1073/jupyterlab/downloads","issues_url":"https://api.github.com/repos/blink1073/jupyterlab/issues{/number}","pulls_url":"https://api.github.com/repos/blink1073/jupyterlab/pulls{/number}","milestones_url":"https://api.github.com/repos/blink1073/jupyterlab/milestones{/number}","notifications_url":"https://api.github.com/repos/blink1073/jupyterlab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/blink1073/jupyterlab/labels{/name}","releases_url":"https://api.github.com/repos/blink1073/jupyterlab/releases{/id}","deployments_url":"https://api.github.com/repos/blink1073/jupyterlab/deployments","created_at":"2016-06-04T10:50:30Z","updated_at":"2016-06-04T10:50:33Z","pushed_at":"2016-11-23T01:43:26Z","git_url":"git://github.com/blink1073/jupyterlab.git","ssh_url":"git@github.com:blink1073/jupyterlab.git","clone_url":"https://github.com/blink1073/jupyterlab.git","svn_url":"https://github.com/blink1073/jupyterlab","homepage":null,"size":42019,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jupyterlab:master","ref":"master","sha":"1961c84332a9ec2b052afcfff0522dc795a4c82e","user":{"login":"jupyterlab","id":22800682,"avatar_url":"https://avatars.githubusercontent.com/u/22800682?v=3","gravatar_id":"","url":"https://api.github.com/users/jupyterlab","html_url":"https://github.com/jupyterlab","followers_url":"https://api.github.com/users/jupyterlab/followers","following_url":"https://api.github.com/users/jupyterlab/following{/other_user}","gists_url":"https://api.github.com/users/jupyterlab/gists{/gist_id}","starred_url":"https://api.github.com/users/jupyterlab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jupyterlab/subscriptions","organizations_url":"https://api.github.com/users/jupyterlab/orgs","repos_url":"https://api.github.com/users/jupyterlab/repos","events_url":"https://api.github.com/users/jupyterlab/events{/privacy}","received_events_url":"https://api.github.com/users/jupyterlab/received_events","type":"Organization","site_admin":false},"repo":{"id":60374819,"name":"jupyterlab","full_name":"jupyterlab/jupyterlab","owner":{"login":"jupyterlab","id":22800682,"avatar_url":"https://avatars.githubusercontent.com/u/22800682?v=3","gravatar_id":"","url":"https://api.github.com/users/jupyterlab","html_url":"https://github.com/jupyterlab","followers_url":"https://api.github.com/users/jupyterlab/followers","following_url":"https://api.github.com/users/jupyterlab/following{/other_user}","gists_url":"https://api.github.com/users/jupyterlab/gists{/gist_id}","starred_url":"https://api.github.com/users/jupyterlab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jupyterlab/subscriptions","organizations_url":"https://api.github.com/users/jupyterlab/orgs","repos_url":"https://api.github.com/users/jupyterlab/repos","events_url":"https://api.github.com/users/jupyterlab/events{/privacy}","received_events_url":"https://api.github.com/users/jupyterlab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jupyterlab/jupyterlab","description":"JupyterLab computational environment. This is a very early preview, and is not suitable for general usage yet.","fork":false,"url":"https://api.github.com/repos/jupyterlab/jupyterlab","forks_url":"https://api.github.com/repos/jupyterlab/jupyterlab/forks","keys_url":"https://api.github.com/repos/jupyterlab/jupyterlab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jupyterlab/jupyterlab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jupyterlab/jupyterlab/teams","hooks_url":"https://api.github.com/repos/jupyterlab/jupyterlab/hooks","issue_events_url":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/events{/number}","events_url":"https://api.github.com/repos/jupyterlab/jupyterlab/events","assignees_url":"https://api.github.com/repos/jupyterlab/jupyterlab/assignees{/user}","branches_url":"https://api.github.com/repos/jupyterlab/jupyterlab/branches{/branch}","tags_url":"https://api.github.com/repos/jupyterlab/jupyterlab/tags","blobs_url":"https://api.github.com/repos/jupyterlab/jupyterlab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jupyterlab/jupyterlab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jupyterlab/jupyterlab/git/refs{/sha}","trees_url":"https://api.github.com/repos/jupyterlab/jupyterlab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jupyterlab/jupyterlab/statuses/{sha}","languages_url":"https://api.github.com/repos/jupyterlab/jupyterlab/languages","stargazers_url":"https://api.github.com/repos/jupyterlab/jupyterlab/stargazers","contributors_url":"https://api.github.com/repos/jupyterlab/jupyterlab/contributors","subscribers_url":"https://api.github.com/repos/jupyterlab/jupyterlab/subscribers","subscription_url":"https://api.github.com/repos/jupyterlab/jupyterlab/subscription","commits_url":"https://api.github.com/repos/jupyterlab/jupyterlab/commits{/sha}","git_commits_url":"https://api.github.com/repos/jupyterlab/jupyterlab/git/commits{/sha}","comments_url":"https://api.github.com/repos/jupyterlab/jupyterlab/comments{/number}","issue_comment_url":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/comments{/number}","contents_url":"https://api.github.com/repos/jupyterlab/jupyterlab/contents/{+path}","compare_url":"https://api.github.com/repos/jupyterlab/jupyterlab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jupyterlab/jupyterlab/merges","archive_url":"https://api.github.com/repos/jupyterlab/jupyterlab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jupyterlab/jupyterlab/downloads","issues_url":"https://api.github.com/repos/jupyterlab/jupyterlab/issues{/number}","pulls_url":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls{/number}","milestones_url":"https://api.github.com/repos/jupyterlab/jupyterlab/milestones{/number}","notifications_url":"https://api.github.com/repos/jupyterlab/jupyterlab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jupyterlab/jupyterlab/labels{/name}","releases_url":"https://api.github.com/repos/jupyterlab/jupyterlab/releases{/id}","deployments_url":"https://api.github.com/repos/jupyterlab/jupyterlab/deployments","created_at":"2016-06-03T20:09:17Z","updated_at":"2016-11-24T23:22:07Z","pushed_at":"2016-11-25T10:00:19Z","git_url":"git://github.com/jupyterlab/jupyterlab.git","ssh_url":"git@github.com:jupyterlab/jupyterlab.git","clone_url":"https://github.com/jupyterlab/jupyterlab.git","svn_url":"https://github.com/jupyterlab/jupyterlab","homepage":"","size":38462,"stargazers_count":1332,"watchers_count":1332,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":193,"mirror_url":null,"open_issues_count":197,"forks":193,"open_issues":197,"watchers":1332,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/1140"},"html":{"href":"https://github.com/jupyterlab/jupyterlab/pull/1140"},"issue":{"href":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/1140"},"comments":{"href":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/1140/comments"},"review_comments":{"href":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/1140/comments"},"review_comment":{"href":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jupyterlab/jupyterlab/pulls/1140/commits"},"statuses":{"href":"https://api.github.com/repos/jupyterlab/jupyterlab/statuses/4c58a4953b20d589d58e0e5122160994ff6a694b"}}}}
{"actor":{"display_login":"akosyakov"}}