diff --git a/exports/atom.coffee b/exports/atom.coffee index b68144665..049d3d9f1 100644 --- a/exports/atom.coffee +++ b/exports/atom.coffee @@ -20,7 +20,8 @@ unless process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE module.exports.$ = $ module.exports.$$ = $$ module.exports.$$$ = $$$ - module.exports.Editor = require '../src/editor' + module.exports.Editor = require '../src/text-editor-view' + module.exports.pathForRepositoryUrl = require('../src/project').pathForRepositoryUrl module.exports.RootView = require '../src/root-view' module.exports.SelectList = require '../src/select-list' module.exports.ScrollView = require '../src/scroll-view' diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index e2c8f5817..1d34730aa 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -1,8 +1,8 @@ -{_, $, $$, fs, Editor, Range, RootView} = require 'atom' +{_, $, $$, fs, TextEditorView, Range, RootView} = require 'atom' path = require 'path' temp = require 'temp' -describe "Editor", -> +describe "TextEditorView", -> [buffer, editor, editSession, cachedLineHeight, cachedCharWidth] = [] beforeEach -> @@ -10,7 +10,7 @@ describe "Editor", -> atom.activatePackage('language-javascript', sync: true) editSession = project.openSync('sample.js') buffer = editSession.buffer - editor = new Editor(editSession) + editor = new TextEditorView(editSession) editor.lineOverdraw = 2 editor.isFocused = true editor.enableKeymap() @@ -33,7 +33,7 @@ describe "Editor", -> cachedCharWidth calcDimensions = -> - editorForMeasurement = new Editor(editSession: project.openSync('sample.js')) + editorForMeasurement = new TextEditorView(editSession: project.openSync('sample.js')) editorForMeasurement.attachToDom() cachedLineHeight = editorForMeasurement.lineHeight cachedCharWidth = editorForMeasurement.charWidth @@ -41,7 +41,7 @@ describe "Editor", -> describe "construction", -> it "throws an error if no edit session is given", -> - expect(-> new Editor).toThrow() + expect(-> new TextEditorView).toThrow() describe "when the editor is attached to the dom", -> it "calculates line height and char width and updates the pixel position of the cursor", -> @@ -325,7 +325,7 @@ describe "Editor", -> expect(editor.charWidth).not.toBe charWidthBefore expect(editor.getCursorView().position()).toEqual { top: 5 * editor.lineHeight, left: 6 * editor.charWidth } - newEditor = new Editor(editor.activeEditSession.copy()) + newEditor = new TextEditorView(editor.activeEditSession.copy()) newEditor.attachToDom() expect(newEditor.css('font-family')).toBe fontFamily @@ -353,7 +353,7 @@ describe "Editor", -> expect(editor.renderedLines.outerHeight()).toBe buffer.getLineCount() * editor.lineHeight expect(editor.verticalScrollbarContent.height()).toBe buffer.getLineCount() * editor.lineHeight - newEditor = new Editor(editor.activeEditSession.copy()) + newEditor = new TextEditorView(editor.activeEditSession.copy()) editor.remove() newEditor.attachToDom() expect(newEditor.css('font-size')).toBe '30px' @@ -1764,7 +1764,7 @@ describe "Editor", -> expect(editor.getCursorScreenPosition()).toEqual [11, 0] it "calls .setWidthInChars() when the editor is attached because now its dimensions are available to calculate it", -> - otherEditor = new Editor(editSession: project.openSync('sample.js')) + otherEditor = new TextEditorView(editSession: project.openSync('sample.js')) spyOn(otherEditor, 'setWidthInChars') otherEditor.activeEditSession.setSoftWrap(true) @@ -1902,19 +1902,19 @@ describe "Editor", -> describe "when the editor is mini", -> it "hides the gutter", -> - miniEditor = new Editor(mini: true) + miniEditor = new TextEditorView(mini: true) miniEditor.attachToDom() expect(miniEditor.gutter).toBeHidden() it "doesn't highlight the only line", -> - miniEditor = new Editor(mini: true) + miniEditor = new TextEditorView(mini: true) miniEditor.attachToDom() expect(miniEditor.getCursorBufferPosition().row).toBe 0 expect(miniEditor.find('.line.cursor-line').length).toBe 0 it "doesn't show the end of line invisible", -> atom.config.set "editor.showInvisibles", true - miniEditor = new Editor(mini: true) + miniEditor = new TextEditorView(mini: true) miniEditor.attachToDom() space = miniEditor.invisibles?.space expect(space).toBeTruthy() @@ -1925,14 +1925,14 @@ describe "Editor", -> it "doesn't show the indent guide", -> atom.config.set "editor.showIndentGuide", true - miniEditor = new Editor(mini: true) + miniEditor = new TextEditorView(mini: true) miniEditor.attachToDom() miniEditor.setText(" and indented line") expect(miniEditor.renderedLines.find('.indent-guide').length).toBe 0 it "lets you set the grammar", -> - miniEditor = new Editor(mini: true) + miniEditor = new TextEditorView(mini: true) miniEditor.setText("var something") previousTokens = miniEditor.lineForScreenRow(0).tokens miniEditor.setGrammar(atom.syntax.selectGrammar('something.js')) diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 0c07dd1af..bd8cc5e75 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -9,7 +9,7 @@ Keymap = require '../src/keymap' Config = require '../src/config' {Point} = require 'telepath' Project = require '../src/project' -Editor = require '../src/editor' +TextEditorView = require '../src/text-editor-view' TokenizedBuffer = require '../src/tokenized-buffer' pathwatcher = require 'pathwatcher' platform = require './spec-helper-platform' @@ -75,7 +75,7 @@ beforeEach -> spyOn(config, 'load') spyOn(config, 'save') config.setDefaults('core', RootView.configDefaults) - config.setDefaults('editor', Editor.configDefaults) + config.setDefaults('editor', TextEditorView.configDefaults) config.set "editor.fontFamily", "Courier" config.set "editor.fontSize", 16 config.set "editor.autoIndent", false @@ -86,7 +86,7 @@ beforeEach -> window.config = config # make editor display updates synchronous - spyOn(Editor.prototype, 'requestDisplayUpdate').andCallFake -> @updateDisplay() + spyOn(TextEditorView.prototype, 'requestDisplayUpdate').andCallFake -> @updateDisplay() spyOn(RootView.prototype, 'setTitle').andCallFake (@title) -> spyOn(window, "setTimeout").andCallFake window.fakeSetTimeout spyOn(window, "clearTimeout").andCallFake window.fakeClearTimeout diff --git a/src/edit-session.coffee b/src/edit-session.coffee index b12628ba0..ef892a187 100644 --- a/src/edit-session.coffee +++ b/src/edit-session.coffee @@ -131,7 +131,7 @@ class EditSession # Private: getViewClass: -> - require './editor' + require './text-editor-view' # Private: destroy: -> diff --git a/src/gutter.coffee b/src/gutter.coffee index a776bf447..1d021b9e4 100644 --- a/src/gutter.coffee +++ b/src/gutter.coffee @@ -2,7 +2,7 @@ {Range} = require 'telepath' _ = require 'underscore-plus' -# Private: Represents the portion of the {Editor} containing row numbers. +# Private: Represents the portion of the {TextEditorView} containing row numbers. # # The gutter also indicates if rows are folded. module.exports = @@ -52,9 +52,9 @@ class Gutter extends View ### Public ### - # Retrieves the containing {Editor}. + # Retrieves the containing {TextEditorView}. # - # Returns an {Editor}. + # Returns an {TextEditorView}. getEditor: -> @parentView diff --git a/src/pane.coffee b/src/pane.coffee index 514e37e93..b91ed926e 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -7,7 +7,7 @@ PaneColumn = require './pane-column' # Public: A container which can contains multiple items to be switched between. # -# Items can be almost anything however most commonly they're {Editor}s. +# Items can be almost anything however most commonly they're {TextEditorView}s. # # Most packages won't need to use this class, unless you're interested in # building a package that deals with switching between panes or tiems. diff --git a/src/root-view.coffee b/src/root-view.coffee index d1d071272..fd8e00b6e 100644 --- a/src/root-view.coffee +++ b/src/root-view.coffee @@ -5,7 +5,7 @@ Q = require 'q' _ = require 'underscore-plus' fs = require 'fs-plus' telepath = require 'telepath' -Editor = require './editor' +TextEditorView = require './text-editor-view' Pane = require './pane' PaneColumn = require './pane-column' PaneRow = require './pane-row' @@ -38,7 +38,7 @@ EditSession = require './edit-session' # module.exports = class RootView extends View - registerDeserializers(this, Pane, PaneRow, PaneColumn, Editor) + registerDeserializers(this, Pane, PaneRow, PaneColumn, TextEditorView) @version: 1 @@ -249,7 +249,7 @@ class RootView extends View setTitle: (title) -> document.title = title - # Private: Returns an Array of all of the application's {Editor}s. + # Private: Returns an Array of all of the application's {TextEditorView}s. getEditors: -> @panes.find('.pane > .item-views > .editor').map(-> $(this).view()).toArray() @@ -308,7 +308,7 @@ class RootView extends View indexOfPane: (pane) -> @panes.indexOfPane(pane) - # Private: Fires a callback on each open {Editor}. + # Private: Fires a callback on each open {TextEditorView}. eachEditor: (callback) -> callback(editor) for editor in @getEditors() attachedCallback = (e, editor) -> callback(editor) diff --git a/src/select-list.coffee b/src/select-list.coffee index 78a305945..aafe2ca58 100644 --- a/src/select-list.coffee +++ b/src/select-list.coffee @@ -1,5 +1,5 @@ {$, View} = require './space-pen-extensions' -Editor = require './editor' +TextEditorView = require './text-editor-view' fuzzyFilter = require('fuzzaldrin').filter # Public: Provides a widget for users to make a selection from a list of @@ -10,7 +10,7 @@ class SelectList extends View # Private: @content: -> @div class: @viewClass(), => - @subview 'miniEditor', new Editor(mini: true) + @subview 'miniEditor', new TextEditorView(mini: true) @div class: 'error-message', outlet: 'error' @div class: 'loading', outlet: 'loadingArea', => @span class: 'loading-message', outlet: 'loading' diff --git a/src/text-buffer.coffee b/src/text-buffer.coffee index 52d494fb0..fa7a4a86a 100644 --- a/src/text-buffer.coffee +++ b/src/text-buffer.coffee @@ -126,7 +126,7 @@ class TextBuffer extends telepath.Model # Identifies if the buffer belongs to multiple editors. # - # For example, if the {Editor} was split. + # For example, if the {TextEditorView} was split. # # Returns a {Boolean}. hasMultipleEditors: -> @refcount > 1 diff --git a/src/editor.coffee b/src/text-editor-view.coffee similarity index 98% rename from src/editor.coffee rename to src/text-editor-view.coffee index ed14e6e9a..9015c94a6 100644 --- a/src/editor.coffee +++ b/src/text-editor-view.coffee @@ -15,9 +15,9 @@ LongLineLength = 1000 # Private: Represents the entire visual pane in Atom. # -# The Editor manages the {EditSession}, which manages the file buffers. +# The TextEditorView manages the {EditSession}, which manages the file buffers. module.exports = -class Editor extends View +class TextEditorView extends View @characterWidthCache: {} @configDefaults: fontSize: 20 @@ -75,7 +75,7 @@ class Editor extends View ### Public ### - # The constructor for setting up an `Editor` instance. + # The constructor for setting up an `TextEditorView` instance. # # editSessionOrOptions - Either an {EditSession}, or an object with one property, `mini`. # If `mini` is `true`, a "miniature" `EditSession` is constructed. @@ -88,7 +88,7 @@ class Editor extends View else {editSession, @mini} = editSessionOrOptions ? {} - @id = Editor.nextEditorId++ + @id = TextEditorView.nextEditorId++ @lineCache = [] @configure() @bindKeys() @@ -1038,7 +1038,7 @@ class Editor extends View pane = @getPane() pane?.splitDown(pane?.copyActiveItem()).activeView - # Retrieve's the `Editor`'s pane. + # Retrieve's the `TextEditorView`'s pane. # # Returns a {Pane}. getPane: -> @@ -1480,9 +1480,9 @@ class Editor extends View eolInvisibles = @getEndOfLineInvisibles(screenLine) htmlEolInvisibles = @buildHtmlEndOfLineInvisibles(screenLine) - indentation = Editor.buildIndentation(screenRow, @activeEditSession) + indentation = TextEditorView.buildIndentation(screenRow, @activeEditSession) - Editor.buildLineHtml({tokens, text, lineEnding, fold, isSoftWrapped, invisibles, eolInvisibles, htmlEolInvisibles, attributes, @showIndentGuide, indentation, @activeEditSession, @mini}) + TextEditorView.buildLineHtml({tokens, text, lineEnding, fold, isSoftWrapped, invisibles, eolInvisibles, htmlEolInvisibles, attributes, @showIndentGuide, indentation, @activeEditSession, @mini}) @buildIndentation: (screenRow, activeEditSession) -> bufferRow = activeEditSession.bufferPositionForScreenPosition([screenRow]).row @@ -1639,7 +1639,7 @@ class Editor extends View getCharacterWidthCache: (scopes, char) -> scopes ?= NoScope - obj = Editor.characterWidthCache + obj = TextEditorView.characterWidthCache for scope in scopes obj = obj[scope] return null unless obj? @@ -1647,14 +1647,14 @@ class Editor extends View setCharacterWidthCache: (scopes, char, val) -> scopes ?= NoScope - obj = Editor.characterWidthCache + obj = TextEditorView.characterWidthCache for scope in scopes obj[scope] ?= {} obj = obj[scope] obj[char] = val clearCharacterWidthCache: -> - Editor.characterWidthCache = {} + TextEditorView.characterWidthCache = {} pixelOffsetForScreenPosition: (position) -> {top, left} = @pixelPositionForScreenPosition(position) @@ -1734,7 +1734,7 @@ class Editor extends View line.push("