mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
🔫
I screwed up a rebase, this nasty commit is the result.
This commit is contained in:
@@ -20,7 +20,7 @@ unless process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE
|
||||
module.exports.$ = $
|
||||
module.exports.$$ = $$
|
||||
module.exports.$$$ = $$$
|
||||
module.exports.Editor = require '../src/text-editor-view'
|
||||
module.exports.Editor = require '../src/editor-view'
|
||||
module.exports.pathForRepositoryUrl = require('../src/project').pathForRepositoryUrl
|
||||
module.exports.RootView = require '../src/root-view'
|
||||
module.exports.SelectList = require '../src/select-list'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
clipboard = require 'clipboard'
|
||||
|
||||
describe "TextEditor", ->
|
||||
describe "Editor", ->
|
||||
[buffer, editSession, lineLengths] = []
|
||||
|
||||
convertToHardTabs = (buffer) ->
|
||||
@@ -99,7 +99,7 @@ describe "RootView", ->
|
||||
|
||||
describe "when there is an active view", ->
|
||||
it "hands off focus to the active view", ->
|
||||
editor = rootView.getActiveView()
|
||||
editorView = rootView.getActiveView()
|
||||
editorView.isFocused = false
|
||||
rootView.focus()
|
||||
expect(editorView.isFocused).toBeTruthy()
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
TextEditor = require '../src/text-editor'
|
||||
Editor = require '../src/editor'
|
||||
|
||||
describe "Selection", ->
|
||||
[buffer, editSession, selection] = []
|
||||
|
||||
beforeEach ->
|
||||
buffer = project.bufferForPathSync('sample.js')
|
||||
editSession = new TextEditor(buffer: buffer, tabLength: 2)
|
||||
editSession = new Editor(buffer: buffer, tabLength: 2)
|
||||
selection = editSession.getSelection()
|
||||
|
||||
afterEach ->
|
||||
|
||||
@@ -9,7 +9,7 @@ Keymap = require '../src/keymap'
|
||||
Config = require '../src/config'
|
||||
{Point} = require 'telepath'
|
||||
Project = require '../src/project'
|
||||
TextEditorView = require '../src/text-editor-view'
|
||||
EditorView = require '../src/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', TextEditorView.configDefaults)
|
||||
config.setDefaults('editor', EditorView.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(TextEditorView.prototype, 'requestDisplayUpdate').andCallFake -> @updateDisplay()
|
||||
spyOn(EditorView.prototype, 'requestDisplayUpdate').andCallFake -> @updateDisplay()
|
||||
spyOn(RootView.prototype, 'setTitle').andCallFake (@title) ->
|
||||
spyOn(window, "setTimeout").andCallFake window.fakeSetTimeout
|
||||
spyOn(window, "clearTimeout").andCallFake window.fakeClearTimeout
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@ _ = require 'underscore-plus'
|
||||
# Public: The `Cursor` class represents the little blinking line identifying
|
||||
# where text can be inserted.
|
||||
#
|
||||
# Cursors belong to {TextEditor}s and have some metadata attached in the form
|
||||
# Cursors belong to {Editor}s and have some metadata attached in the form
|
||||
# of a {StringMarker}.
|
||||
module.exports =
|
||||
class Cursor
|
||||
@@ -17,7 +17,7 @@ class Cursor
|
||||
visible: true
|
||||
needsAutoscroll: null
|
||||
|
||||
# Private: Instantiated by an {TextEditor}
|
||||
# Private: Instantiated by an {Editor}
|
||||
constructor: ({@editSession, @marker}) ->
|
||||
@updateVisibility()
|
||||
@marker.on 'changed', (e) =>
|
||||
@@ -62,7 +62,7 @@ class Cursor
|
||||
# An {Array} of two numbers: the screen row, and the screen column.
|
||||
# * options:
|
||||
# + autoscroll:
|
||||
# A Boolean which, if `true`, scrolls the {TextEditor} to wherever the
|
||||
# A Boolean which, if `true`, scrolls the {Editor} to wherever the
|
||||
# cursor moves to.
|
||||
setScreenPosition: (screenPosition, options={}) ->
|
||||
@changePosition options, =>
|
||||
@@ -78,7 +78,7 @@ class Cursor
|
||||
# An {Array} of two numbers: the buffer row, and the buffer column.
|
||||
# * options:
|
||||
# + autoscroll:
|
||||
# A Boolean which, if `true`, scrolls the {TextEditor} to wherever the
|
||||
# A Boolean which, if `true`, scrolls the {Editor} to wherever the
|
||||
# cursor moves to.
|
||||
setBufferPosition: (bufferPosition, options={}) ->
|
||||
@changePosition options, =>
|
||||
@@ -118,7 +118,7 @@ class Cursor
|
||||
segments.push("[#{_.escapeRegExp(nonWordCharacters)}]+")
|
||||
new RegExp(segments.join("|"), "g")
|
||||
|
||||
# Public: Identifies if this cursor is the last in the {TextEditor}.
|
||||
# Public: Identifies if this cursor is the last in the {Editor}.
|
||||
#
|
||||
# "Last" is defined as the most recently added cursor.
|
||||
#
|
||||
|
||||
@@ -1721,7 +1721,7 @@ class EditorView extends View
|
||||
# Copies the current file path to the native clipboard.
|
||||
copyPathToPasteboard: ->
|
||||
path = @getPath()
|
||||
pasteboard.write(path) if path?
|
||||
atom.pasteboard.write(path) if path?
|
||||
|
||||
### Internal ###
|
||||
|
||||
|
||||
@@ -12,18 +12,18 @@ TextMateScopeSelector = require('first-mate').ScopeSelector
|
||||
|
||||
# Public: The core model of Atom.
|
||||
#
|
||||
# An {TextEditor} represents a unique view of each document, with it's own
|
||||
# An {Editor} represents a unique view of each document, with it's own
|
||||
# {Cursor}s and scroll position.
|
||||
#
|
||||
# For instance if a user creates a split, Atom creates a second {TextEditor}
|
||||
# but both {TextEditor}s interact with the same buffer underlying buffer. So
|
||||
# For instance if a user creates a split, Atom creates a second {Editor}
|
||||
# but both {Editor}s interact with the same buffer underlying buffer. So
|
||||
# if you type in either buffer it immediately appears in both but if you scroll
|
||||
# in one it doesn't scroll the other.
|
||||
#
|
||||
# Almost all extension will interact primiarily with this class as it provides
|
||||
# access to objects you'll most commonly interact with. To access it you'll
|
||||
# want to register a callback on {RootView} which will be fired once for every
|
||||
# existing {TextEditor} as well as any future {TextEditor}s.
|
||||
# existing {Editor} as well as any future {Editor}s.
|
||||
#
|
||||
# ## Example
|
||||
# ```coffeescript
|
||||
@@ -36,7 +36,7 @@ TextMateScopeSelector = require('first-mate').ScopeSelector
|
||||
# FIXME: Describe how there are both local and remote cursors and selections and
|
||||
# why that is.
|
||||
module.exports =
|
||||
class TextEditor
|
||||
class Editor
|
||||
Emitter.includeInto(this)
|
||||
Subscriber.includeInto(this)
|
||||
|
||||
@@ -47,7 +47,7 @@ class TextEditor
|
||||
@version: 5
|
||||
|
||||
@deserialize: (state) ->
|
||||
new TextEditor(state)
|
||||
new Editor(state)
|
||||
|
||||
id: null
|
||||
languageMode: null
|
||||
@@ -131,7 +131,7 @@ class TextEditor
|
||||
|
||||
# Private:
|
||||
getViewClass: ->
|
||||
require './text-editor-view'
|
||||
require './editor-view'
|
||||
|
||||
# Private:
|
||||
destroy: ->
|
||||
@@ -152,12 +152,12 @@ class TextEditor
|
||||
# Private:
|
||||
getState: -> @state
|
||||
|
||||
# Private: Creates an {TextEditor} with the same initial state
|
||||
# Private: Creates an {Editor} with the same initial state
|
||||
copy: ->
|
||||
tabLength = @getTabLength()
|
||||
displayBuffer = @displayBuffer.copy()
|
||||
softTabs = @getSoftTabs()
|
||||
newEditSession = new TextEditor({@buffer, displayBuffer, tabLength, softTabs, suppressCursorCreation: true})
|
||||
newEditSession = new Editor({@buffer, displayBuffer, tabLength, softTabs, suppressCursorCreation: true})
|
||||
newEditSession.setScrollTop(@getScrollTop())
|
||||
newEditSession.setScrollLeft(@getScrollLeft())
|
||||
for marker in @findMarkers(editSessionId: @id)
|
||||
@@ -190,7 +190,7 @@ class TextEditor
|
||||
else
|
||||
'untitled'
|
||||
|
||||
# Public: Compares two `TextEditor`s to determine equality.
|
||||
# Public: Compares two `Editor`s to determine equality.
|
||||
#
|
||||
# Equality is based on the condition that:
|
||||
#
|
||||
@@ -200,7 +200,7 @@ class TextEditor
|
||||
#
|
||||
# Returns a {Boolean}.
|
||||
isEqual: (other) ->
|
||||
return false unless other instanceof TextEditor
|
||||
return false unless other instanceof Editor
|
||||
@buffer == other.buffer and
|
||||
@getScrollTop() == other.getScrollTop() and
|
||||
@getScrollLeft() == other.getScrollLeft() and
|
||||
@@ -876,7 +876,7 @@ class TextEditor
|
||||
@emit 'cursor-added', cursor
|
||||
cursor
|
||||
|
||||
# Public: Removes and returns a cursor from the `TextEditor`.
|
||||
# Public: Removes and returns a cursor from the `Editor`.
|
||||
removeCursor: (cursor) ->
|
||||
_.remove(@cursors, cursor)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{Range} = require 'telepath'
|
||||
_ = require 'underscore-plus'
|
||||
|
||||
# Private: Represents the portion of the {TextEditorView} containing row numbers.
|
||||
# Private: Represents the portion of the {EditorView} 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 {TextEditorView}.
|
||||
# Retrieves the containing {EditorView}.
|
||||
#
|
||||
# Returns an {TextEditorView}.
|
||||
# Returns an {EditorView}.
|
||||
getEditorView: ->
|
||||
@parentView
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ class LanguageMode
|
||||
|
||||
### Public ###
|
||||
|
||||
# Sets up a `LanguageMode` for the given {TextEditor}.
|
||||
# Sets up a `LanguageMode` for the given {Editor}.
|
||||
#
|
||||
# editSession - The {TextEditor} to associate with
|
||||
# editSession - The {Editor} to associate with
|
||||
constructor: (@editSession) ->
|
||||
@buffer = @editSession.buffer
|
||||
|
||||
|
||||
@@ -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 {TextEditorView}s.
|
||||
# Items can be almost anything however most commonly they're {EditorView}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.
|
||||
|
||||
@@ -7,7 +7,7 @@ Q = require 'q'
|
||||
telepath = require 'telepath'
|
||||
|
||||
TextBuffer = require './text-buffer'
|
||||
TextEditor = require './text-editor'
|
||||
Editor = require './editor'
|
||||
{Emitter} = require 'emissary'
|
||||
Directory = require './directory'
|
||||
Task = require './task'
|
||||
@@ -133,14 +133,14 @@ class Project extends telepath.Model
|
||||
@rootDirectory?.contains(pathToCheck) ? false
|
||||
|
||||
# Public: Given a path to a file, this constructs and associates a new
|
||||
# {TextEditor}, showing the file.
|
||||
# {Editor}, showing the file.
|
||||
#
|
||||
# * filePath:
|
||||
# The {String} path of the file to associate with
|
||||
# * editSessionOptions:
|
||||
# Options that you can pass to the {TextEditor} constructor
|
||||
# Options that you can pass to the {Editor} constructor
|
||||
#
|
||||
# Returns a promise that resolves to an {TextEditor}.
|
||||
# Returns a promise that resolves to an {Editor}.
|
||||
open: (filePath, options={}) ->
|
||||
filePath = @resolve(filePath)
|
||||
resource = null
|
||||
@@ -160,18 +160,18 @@ class Project extends telepath.Model
|
||||
|
||||
@buildEditSessionForBuffer(@bufferForPathSync(filePath), options)
|
||||
|
||||
# Public: Retrieves all {TextEditor}s for all open files.
|
||||
# Public: Retrieves all {Editor}s for all open files.
|
||||
#
|
||||
# Returns an {Array} of {TextEditor}s.
|
||||
# Returns an {Array} of {Editor}s.
|
||||
getEditSessions: ->
|
||||
new Array(@editSessions...)
|
||||
|
||||
# Public: Add the given {TextEditor}.
|
||||
# Public: Add the given {Editor}.
|
||||
addEditSession: (editSession) ->
|
||||
@editSessions.push editSession
|
||||
@emit 'edit-session-created', editSession
|
||||
|
||||
# Public: Return and removes the given {TextEditor}.
|
||||
# Public: Return and removes the given {Editor}.
|
||||
removeEditSession: (editSession) ->
|
||||
_.remove(@editSessions, editSession)
|
||||
|
||||
@@ -332,7 +332,7 @@ class Project extends telepath.Model
|
||||
|
||||
# Private:
|
||||
buildEditSessionForBuffer: (buffer, editSessionOptions) ->
|
||||
editSession = new TextEditor(_.extend({buffer}, editSessionOptions))
|
||||
editSession = new Editor(_.extend({buffer}, editSessionOptions))
|
||||
@addEditSession(editSession)
|
||||
editSession
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@ Q = require 'q'
|
||||
_ = require 'underscore-plus'
|
||||
fs = require 'fs-plus'
|
||||
telepath = require 'telepath'
|
||||
TextEditorView = require './text-editor-view'
|
||||
EditorView = require './editor-view'
|
||||
Pane = require './pane'
|
||||
PaneColumn = require './pane-column'
|
||||
PaneRow = require './pane-row'
|
||||
PaneContainer = require './pane-container'
|
||||
TextEditor = require './text-editor'
|
||||
Editor = require './editor'
|
||||
|
||||
# Public: The container for the entire Atom application.
|
||||
#
|
||||
@@ -38,7 +38,7 @@ TextEditor = require './text-editor'
|
||||
#
|
||||
module.exports =
|
||||
class RootView extends View
|
||||
registerDeserializers(this, Pane, PaneRow, PaneColumn, TextEditorView)
|
||||
registerDeserializers(this, Pane, PaneRow, PaneColumn, EditorView)
|
||||
|
||||
@version: 1
|
||||
|
||||
@@ -169,7 +169,7 @@ class RootView extends View
|
||||
# * options
|
||||
# + initialLine: The buffer line number to open to.
|
||||
#
|
||||
# Returns a promise that resolves to the {TextEditor} for the file URI.
|
||||
# Returns a promise that resolves to the {Editor} for the file URI.
|
||||
open: (filePath, options={}) ->
|
||||
changeFocus = options.changeFocus ? true
|
||||
filePath = project.resolve(filePath)
|
||||
@@ -249,7 +249,7 @@ class RootView extends View
|
||||
setTitle: (title) ->
|
||||
document.title = title
|
||||
|
||||
# Private: Returns an Array of all of the application's {TextEditorView}s.
|
||||
# Private: Returns an Array of all of the application's {EditorView}s.
|
||||
getEditors: ->
|
||||
@panes.find('.pane > .item-views > .editor').map(-> $(this).view()).toArray()
|
||||
|
||||
@@ -259,7 +259,7 @@ class RootView extends View
|
||||
getModifiedBuffers: ->
|
||||
modifiedBuffers = []
|
||||
for pane in @getPanes()
|
||||
for item in pane.getItems() when item instanceof TextEditor
|
||||
for item in pane.getItems() when item instanceof Editor
|
||||
modifiedBuffers.push item.buffer if item.buffer.isModified()
|
||||
modifiedBuffers
|
||||
|
||||
@@ -308,14 +308,14 @@ class RootView extends View
|
||||
indexOfPane: (pane) ->
|
||||
@panes.indexOfPane(pane)
|
||||
|
||||
# Private: Fires a callback on each open {TextEditorView}.
|
||||
# Private: Fires a callback on each open {EditorView}.
|
||||
eachEditor: (callback) ->
|
||||
callback(editor) for editor in @getEditors()
|
||||
attachedCallback = (e, editor) -> callback(editor)
|
||||
@on('editor:attached', attachedCallback)
|
||||
off: => @off('editor:attached', attachedCallback)
|
||||
|
||||
# Public: Fires a callback on each open {TextEditor}.
|
||||
# Public: Fires a callback on each open {Editor}.
|
||||
eachEditSession: (callback) ->
|
||||
project.eachEditSession(callback)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{$, View} = require './space-pen-extensions'
|
||||
TextEditorView = require './text-editor-view'
|
||||
EditorView = require './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 TextEditorView(mini: true)
|
||||
@subview 'miniEditor', new EditorView(mini: true)
|
||||
@div class: 'error-message', outlet: 'error'
|
||||
@div class: 'loading', outlet: 'loadingArea', =>
|
||||
@span class: 'loading-message', outlet: 'loading'
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{Emitter} = require 'emissary'
|
||||
{pick} = require 'underscore-plus'
|
||||
|
||||
# Public: Represents a selection in the {TextEditor}.
|
||||
# Public: Represents a selection in the {Editor}.
|
||||
module.exports =
|
||||
class Selection
|
||||
Emitter.includeInto(this)
|
||||
@@ -79,7 +79,7 @@ class Selection
|
||||
# + preserveFolds:
|
||||
# if `true`, the fold settings are preserved after the selection moves
|
||||
# + autoscroll:
|
||||
# if `true`, the {TextEditor} scrolls to the new selection
|
||||
# if `true`, the {Editor} scrolls to the new selection
|
||||
setBufferRange: (bufferRange, options={}) ->
|
||||
bufferRange = Range.fromObject(bufferRange)
|
||||
@needsAutoscroll = options.autoscroll
|
||||
@@ -361,7 +361,7 @@ class Selection
|
||||
# * options - A hash with one key,
|
||||
# + autoIndent:
|
||||
# If `true`, the indentation is performed appropriately. Otherwise,
|
||||
# {TextEditor.getTabText} is used
|
||||
# {Editor.getTabText} is used
|
||||
indent: ({ autoIndent }={})->
|
||||
{ row, column } = @cursor.getBufferPosition()
|
||||
|
||||
|
||||
@@ -126,12 +126,12 @@ class TextBuffer extends telepath.Model
|
||||
|
||||
# Identifies if the buffer belongs to multiple editors.
|
||||
#
|
||||
# For example, if the {TextEditorView} was split.
|
||||
# For example, if the {EditorView} was split.
|
||||
#
|
||||
# Returns a {Boolean}.
|
||||
hasMultipleEditors: -> @refcount > 1
|
||||
|
||||
# Reloads a file in the {TextEditor}.
|
||||
# Reloads a file in the {Editor}.
|
||||
#
|
||||
# Sets the buffer's content to the cached disk contents
|
||||
reload: ->
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -49,7 +49,7 @@ window.startEditorWindow = ->
|
||||
atom.restoreDimensions()
|
||||
atom.config.load()
|
||||
atom.config.setDefaults('core', require('./root-view').configDefaults)
|
||||
atom.config.setDefaults('editor', require('./text-editor-view').configDefaults)
|
||||
atom.config.setDefaults('editor', require('./editor-view').configDefaults)
|
||||
atom.keymap.loadBundledKeymaps()
|
||||
atom.themes.loadBaseStylesheets()
|
||||
atom.packages.loadPackages()
|
||||
|
||||
7
test.coffee
Normal file
7
test.coffee
Normal file
@@ -0,0 +1,7 @@
|
||||
a = ->
|
||||
if false
|
||||
1
|
||||
else
|
||||
3
|
||||
|
||||
console.log a()
|
||||
Reference in New Issue
Block a user