Rename EditSession to TextEditor

This commit is contained in:
probablycorey
2013-11-19 14:56:09 -08:00
parent 89212e599f
commit 955d379e0e
8 changed files with 155 additions and 155 deletions

View File

@@ -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 {EditSession}s and have some metadata attached in the form
# Cursors belong to {TextEditor}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 {EditSession}
# Private: Instantiated by an {TextEditor}
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 {EditSession} to wherever the
# A Boolean which, if `true`, scrolls the {TextEditor} 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 {EditSession} to wherever the
# A Boolean which, if `true`, scrolls the {TextEditor} 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 {EditSession}.
# Public: Identifies if this cursor is the last in the {TextEditor}.
#
# "Last" is defined as the most recently added cursor.
#

View File

@@ -22,9 +22,9 @@ class LanguageMode
### Public ###
# Sets up a `LanguageMode` for the given {EditSession}.
# Sets up a `LanguageMode` for the given {TextEditor}.
#
# editSession - The {EditSession} to associate with
# editSession - The {TextEditor} to associate with
constructor: (@editSession) ->
@buffer = @editSession.buffer

View File

@@ -7,7 +7,7 @@ Q = require 'q'
telepath = require 'telepath'
TextBuffer = require './text-buffer'
EditSession = require './edit-session'
TextEditor = require './text-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
# {EditSession}, showing the file.
# {TextEditor}, showing the file.
#
# * filePath:
# The {String} path of the file to associate with
# * editSessionOptions:
# Options that you can pass to the {EditSession} constructor
# Options that you can pass to the {TextEditor} constructor
#
# Returns a promise that resolves to an {EditSession}.
# Returns a promise that resolves to an {TextEditor}.
open: (filePath, options={}) ->
filePath = @resolve(filePath)
resource = null
@@ -160,18 +160,18 @@ class Project extends telepath.Model
@buildEditSessionForBuffer(@bufferForPathSync(filePath), options)
# Public: Retrieves all {EditSession}s for all open files.
# Public: Retrieves all {TextEditor}s for all open files.
#
# Returns an {Array} of {EditSession}s.
# Returns an {Array} of {TextEditor}s.
getEditSessions: ->
new Array(@editSessions...)
# Public: Add the given {EditSession}.
# Public: Add the given {TextEditor}.
addEditSession: (editSession) ->
@editSessions.push editSession
@emit 'edit-session-created', editSession
# Public: Return and removes the given {EditSession}.
# Public: Return and removes the given {TextEditor}.
removeEditSession: (editSession) ->
_.remove(@editSessions, editSession)
@@ -332,7 +332,7 @@ class Project extends telepath.Model
# Private:
buildEditSessionForBuffer: (buffer, editSessionOptions) ->
editSession = new EditSession(_.extend({buffer}, editSessionOptions))
editSession = new TextEditor(_.extend({buffer}, editSessionOptions))
@addEditSession(editSession)
editSession

View File

@@ -10,7 +10,7 @@ Pane = require './pane'
PaneColumn = require './pane-column'
PaneRow = require './pane-row'
PaneContainer = require './pane-container'
EditSession = require './edit-session'
TextEditor = require './text-editor'
# Public: The container for the entire Atom application.
#
@@ -169,7 +169,7 @@ class RootView extends View
# * options
# + initialLine: The buffer line number to open to.
#
# Returns a promise that resolves to the {EditSession} for the file URI.
# Returns a promise that resolves to the {TextEditor} for the file URI.
open: (filePath, options={}) ->
changeFocus = options.changeFocus ? true
filePath = project.resolve(filePath)
@@ -259,7 +259,7 @@ class RootView extends View
getModifiedBuffers: ->
modifiedBuffers = []
for pane in @getPanes()
for item in pane.getItems() when item instanceof EditSession
for item in pane.getItems() when item instanceof TextEditor
modifiedBuffers.push item.buffer if item.buffer.isModified()
modifiedBuffers
@@ -315,7 +315,7 @@ class RootView extends View
@on('editor:attached', attachedCallback)
off: => @off('editor:attached', attachedCallback)
# Public: Fires a callback on each open {EditSession}.
# Public: Fires a callback on each open {TextEditor}.
eachEditSession: (callback) ->
project.eachEditSession(callback)

View File

@@ -2,7 +2,7 @@
{Emitter} = require 'emissary'
{pick} = require 'underscore-plus'
# Public: Represents a selection in the {EditSession}.
# Public: Represents a selection in the {TextEditor}.
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 {EditSession} scrolls to the new selection
# if `true`, the {TextEditor} 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,
# {EditSession.getTabText} is used
# {TextEditor.getTabText} is used
indent: ({ autoIndent }={})->
{ row, column } = @cursor.getBufferPosition()

View File

@@ -131,7 +131,7 @@ class TextBuffer extends telepath.Model
# Returns a {Boolean}.
hasMultipleEditors: -> @refcount > 1
# Reloads a file in the {EditSession}.
# Reloads a file in the {TextEditor}.
#
# Sets the buffer's content to the cached disk contents
reload: ->

View File

@@ -2,7 +2,7 @@
TextBuffer = require './text-buffer'
Gutter = require './gutter'
{Point, Range} = require 'telepath'
EditSession = require './edit-session'
TextEditor = require './text-editor'
CursorView = require './cursor-view'
SelectionView = require './selection-view'
fs = require 'fs-plus'
@@ -15,7 +15,7 @@ LongLineLength = 1000
# Private: Represents the entire visual pane in Atom.
#
# The TextEditorView manages the {EditSession}, which manages the file buffers.
# The TextEditorView manages the {TextEditor}, which manages the file buffers.
module.exports =
class TextEditorView extends View
@characterWidthCache: {}
@@ -77,13 +77,13 @@ class TextEditorView extends View
# 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.
# editSessionOrOptions - Either an {TextEditor}, or an object with one property, `mini`.
# If `mini` is `true`, a "miniature" `TextEditor` is constructed.
# Typically, this is ideal for scenarios where you need an Atom editor,
# but without all the chrome, like scrollbars, gutter, _e.t.c._.
#
initialize: (editSessionOrOptions) ->
if editSessionOrOptions instanceof EditSession
if editSessionOrOptions instanceof TextEditor
editSession = editSessionOrOptions
else
{editSession, @mini} = editSessionOrOptions ? {}
@@ -103,14 +103,14 @@ class TextEditorView extends View
if editSession?
@edit(editSession)
else if @mini
@edit(new EditSession
@edit(new TextEditor
buffer: TextBuffer.createAsRoot()
softWrap: false
tabLength: 2
softTabs: true
)
else
throw new Error("Must supply an EditSession or mini: true")
throw new Error("Must supply an TextEditor or mini: true")
# Internal: Sets up the core Atom commands.
#
@@ -213,294 +213,294 @@ class TextEditorView extends View
do (name, method) =>
@command name, (e) => method.call(this, e); false
# {Delegates to: EditSession.getCursor}
# {Delegates to: TextEditor.getCursor}
getCursor: -> @activeEditSession.getCursor()
# {Delegates to: EditSession.getCursors}
# {Delegates to: TextEditor.getCursors}
getCursors: -> @activeEditSession.getCursors()
# {Delegates to: EditSession.addCursorAtScreenPosition}
# {Delegates to: TextEditor.addCursorAtScreenPosition}
addCursorAtScreenPosition: (screenPosition) -> @activeEditSession.addCursorAtScreenPosition(screenPosition)
# {Delegates to: EditSession.addCursorAtBufferPosition}
# {Delegates to: TextEditor.addCursorAtBufferPosition}
addCursorAtBufferPosition: (bufferPosition) -> @activeEditSession.addCursorAtBufferPosition(bufferPosition)
# {Delegates to: EditSession.moveCursorUp}
# {Delegates to: TextEditor.moveCursorUp}
moveCursorUp: -> @activeEditSession.moveCursorUp()
# {Delegates to: EditSession.moveCursorDown}
# {Delegates to: TextEditor.moveCursorDown}
moveCursorDown: -> @activeEditSession.moveCursorDown()
# {Delegates to: EditSession.moveCursorLeft}
# {Delegates to: TextEditor.moveCursorLeft}
moveCursorLeft: -> @activeEditSession.moveCursorLeft()
# {Delegates to: EditSession.moveCursorRight}
# {Delegates to: TextEditor.moveCursorRight}
moveCursorRight: -> @activeEditSession.moveCursorRight()
# {Delegates to: EditSession.moveCursorToBeginningOfWord}
# {Delegates to: TextEditor.moveCursorToBeginningOfWord}
moveCursorToBeginningOfWord: -> @activeEditSession.moveCursorToBeginningOfWord()
# {Delegates to: EditSession.moveCursorToEndOfWord}
# {Delegates to: TextEditor.moveCursorToEndOfWord}
moveCursorToEndOfWord: -> @activeEditSession.moveCursorToEndOfWord()
# {Delegates to: EditSession.moveCursorToBeginningOfNextWord}
# {Delegates to: TextEditor.moveCursorToBeginningOfNextWord}
moveCursorToBeginningOfNextWord: -> @activeEditSession.moveCursorToBeginningOfNextWord()
# {Delegates to: EditSession.moveCursorToTop}
# {Delegates to: TextEditor.moveCursorToTop}
moveCursorToTop: -> @activeEditSession.moveCursorToTop()
# {Delegates to: EditSession.moveCursorToBottom}
# {Delegates to: TextEditor.moveCursorToBottom}
moveCursorToBottom: -> @activeEditSession.moveCursorToBottom()
# {Delegates to: EditSession.moveCursorToBeginningOfLine}
# {Delegates to: TextEditor.moveCursorToBeginningOfLine}
moveCursorToBeginningOfLine: -> @activeEditSession.moveCursorToBeginningOfLine()
# {Delegates to: EditSession.moveCursorToFirstCharacterOfLine}
# {Delegates to: TextEditor.moveCursorToFirstCharacterOfLine}
moveCursorToFirstCharacterOfLine: -> @activeEditSession.moveCursorToFirstCharacterOfLine()
# {Delegates to: EditSession.moveCursorToPreviousWordBoundary}
# {Delegates to: TextEditor.moveCursorToPreviousWordBoundary}
moveCursorToPreviousWordBoundary: -> @activeEditSession.moveCursorToPreviousWordBoundary()
# {Delegates to: EditSession.moveCursorToNextWordBoundary}
# {Delegates to: TextEditor.moveCursorToNextWordBoundary}
moveCursorToNextWordBoundary: -> @activeEditSession.moveCursorToNextWordBoundary()
# {Delegates to: EditSession.moveCursorToEndOfLine}
# {Delegates to: TextEditor.moveCursorToEndOfLine}
moveCursorToEndOfLine: -> @activeEditSession.moveCursorToEndOfLine()
# {Delegates to: EditSession.moveLineUp}
# {Delegates to: TextEditor.moveLineUp}
moveLineUp: -> @activeEditSession.moveLineUp()
# {Delegates to: EditSession.moveLineDown}
# {Delegates to: TextEditor.moveLineDown}
moveLineDown: -> @activeEditSession.moveLineDown()
# {Delegates to: EditSession.setCursorScreenPosition}
# {Delegates to: TextEditor.setCursorScreenPosition}
setCursorScreenPosition: (position, options) -> @activeEditSession.setCursorScreenPosition(position, options)
# {Delegates to: EditSession.duplicateLine}
# {Delegates to: TextEditor.duplicateLine}
duplicateLine: -> @activeEditSession.duplicateLine()
# {Delegates to: EditSession.joinLine}
# {Delegates to: TextEditor.joinLine}
joinLine: -> @activeEditSession.joinLine()
# {Delegates to: EditSession.getCursorScreenPosition}
# {Delegates to: TextEditor.getCursorScreenPosition}
getCursorScreenPosition: -> @activeEditSession.getCursorScreenPosition()
# {Delegates to: EditSession.getCursorScreenRow}
# {Delegates to: TextEditor.getCursorScreenRow}
getCursorScreenRow: -> @activeEditSession.getCursorScreenRow()
# {Delegates to: EditSession.setCursorBufferPosition}
# {Delegates to: TextEditor.setCursorBufferPosition}
setCursorBufferPosition: (position, options) -> @activeEditSession.setCursorBufferPosition(position, options)
# {Delegates to: EditSession.getCursorBufferPosition}
# {Delegates to: TextEditor.getCursorBufferPosition}
getCursorBufferPosition: -> @activeEditSession.getCursorBufferPosition()
# {Delegates to: EditSession.getCurrentParagraphBufferRange}
# {Delegates to: TextEditor.getCurrentParagraphBufferRange}
getCurrentParagraphBufferRange: -> @activeEditSession.getCurrentParagraphBufferRange()
# {Delegates to: EditSession.getWordUnderCursor}
# {Delegates to: TextEditor.getWordUnderCursor}
getWordUnderCursor: (options) -> @activeEditSession.getWordUnderCursor(options)
# {Delegates to: EditSession.getSelection}
# {Delegates to: TextEditor.getSelection}
getSelection: (index) -> @activeEditSession.getSelection(index)
# {Delegates to: EditSession.getSelections}
# {Delegates to: TextEditor.getSelections}
getSelections: -> @activeEditSession.getSelections()
# {Delegates to: EditSession.getSelectionsOrderedByBufferPosition}
# {Delegates to: TextEditor.getSelectionsOrderedByBufferPosition}
getSelectionsOrderedByBufferPosition: -> @activeEditSession.getSelectionsOrderedByBufferPosition()
# {Delegates to: EditSession.getLastSelectionInBuffer}
# {Delegates to: TextEditor.getLastSelectionInBuffer}
getLastSelectionInBuffer: -> @activeEditSession.getLastSelectionInBuffer()
# {Delegates to: EditSession.getSelectedText}
# {Delegates to: TextEditor.getSelectedText}
getSelectedText: -> @activeEditSession.getSelectedText()
# {Delegates to: EditSession.getSelectedBufferRanges}
# {Delegates to: TextEditor.getSelectedBufferRanges}
getSelectedBufferRanges: -> @activeEditSession.getSelectedBufferRanges()
# {Delegates to: EditSession.getSelectedBufferRange}
# {Delegates to: TextEditor.getSelectedBufferRange}
getSelectedBufferRange: -> @activeEditSession.getSelectedBufferRange()
# {Delegates to: EditSession.setSelectedBufferRange}
# {Delegates to: TextEditor.setSelectedBufferRange}
setSelectedBufferRange: (bufferRange, options) -> @activeEditSession.setSelectedBufferRange(bufferRange, options)
# {Delegates to: EditSession.setSelectedBufferRanges}
# {Delegates to: TextEditor.setSelectedBufferRanges}
setSelectedBufferRanges: (bufferRanges, options) -> @activeEditSession.setSelectedBufferRanges(bufferRanges, options)
# {Delegates to: EditSession.addSelectionForBufferRange}
# {Delegates to: TextEditor.addSelectionForBufferRange}
addSelectionForBufferRange: (bufferRange, options) -> @activeEditSession.addSelectionForBufferRange(bufferRange, options)
# {Delegates to: EditSession.selectRight}
# {Delegates to: TextEditor.selectRight}
selectRight: -> @activeEditSession.selectRight()
# {Delegates to: EditSession.selectLeft}
# {Delegates to: TextEditor.selectLeft}
selectLeft: -> @activeEditSession.selectLeft()
# {Delegates to: EditSession.selectUp}
# {Delegates to: TextEditor.selectUp}
selectUp: -> @activeEditSession.selectUp()
# {Delegates to: EditSession.selectDown}
# {Delegates to: TextEditor.selectDown}
selectDown: -> @activeEditSession.selectDown()
# {Delegates to: EditSession.selectToTop}
# {Delegates to: TextEditor.selectToTop}
selectToTop: -> @activeEditSession.selectToTop()
# {Delegates to: EditSession.selectToBottom}
# {Delegates to: TextEditor.selectToBottom}
selectToBottom: -> @activeEditSession.selectToBottom()
# {Delegates to: EditSession.selectAll}
# {Delegates to: TextEditor.selectAll}
selectAll: -> @activeEditSession.selectAll()
# {Delegates to: EditSession.selectToBeginningOfLine}
# {Delegates to: TextEditor.selectToBeginningOfLine}
selectToBeginningOfLine: -> @activeEditSession.selectToBeginningOfLine()
# {Delegates to: EditSession.selectToFirstCharacterOfLine}
# {Delegates to: TextEditor.selectToFirstCharacterOfLine}
selectToFirstCharacterOfLine: -> @activeEditSession.selectToFirstCharacterOfLine()
# {Delegates to: EditSession.selectToEndOfLine}
# {Delegates to: TextEditor.selectToEndOfLine}
selectToEndOfLine: -> @activeEditSession.selectToEndOfLine()
# {Delegates to: EditSession.selectToPreviousWordBoundary}
# {Delegates to: TextEditor.selectToPreviousWordBoundary}
selectToPreviousWordBoundary: -> @activeEditSession.selectToPreviousWordBoundary()
# {Delegates to: EditSession.selectToNextWordBoundary}
# {Delegates to: TextEditor.selectToNextWordBoundary}
selectToNextWordBoundary: -> @activeEditSession.selectToNextWordBoundary()
# {Delegates to: EditSession.addSelectionBelow}
# {Delegates to: TextEditor.addSelectionBelow}
addSelectionBelow: -> @activeEditSession.addSelectionBelow()
# {Delegates to: EditSession.addSelectionAbove}
# {Delegates to: TextEditor.addSelectionAbove}
addSelectionAbove: -> @activeEditSession.addSelectionAbove()
# {Delegates to: EditSession.selectToBeginningOfWord}
# {Delegates to: TextEditor.selectToBeginningOfWord}
selectToBeginningOfWord: -> @activeEditSession.selectToBeginningOfWord()
# {Delegates to: EditSession.selectToEndOfWord}
# {Delegates to: TextEditor.selectToEndOfWord}
selectToEndOfWord: -> @activeEditSession.selectToEndOfWord()
# {Delegates to: EditSession.selectToBeginningOfNextWord}
# {Delegates to: TextEditor.selectToBeginningOfNextWord}
selectToBeginningOfNextWord: -> @activeEditSession.selectToBeginningOfNextWord()
# {Delegates to: EditSession.selectWord}
# {Delegates to: TextEditor.selectWord}
selectWord: -> @activeEditSession.selectWord()
# {Delegates to: EditSession.selectLine}
# {Delegates to: TextEditor.selectLine}
selectLine: -> @activeEditSession.selectLine()
# {Delegates to: EditSession.selectToScreenPosition}
# {Delegates to: TextEditor.selectToScreenPosition}
selectToScreenPosition: (position) -> @activeEditSession.selectToScreenPosition(position)
# {Delegates to: EditSession.transpose}
# {Delegates to: TextEditor.transpose}
transpose: -> @activeEditSession.transpose()
# {Delegates to: EditSession.upperCase}
# {Delegates to: TextEditor.upperCase}
upperCase: -> @activeEditSession.upperCase()
# {Delegates to: EditSession.lowerCase}
# {Delegates to: TextEditor.lowerCase}
lowerCase: -> @activeEditSession.lowerCase()
# {Delegates to: EditSession.clearSelections}
# {Delegates to: TextEditor.clearSelections}
clearSelections: -> @activeEditSession.clearSelections()
# {Delegates to: EditSession.backspace}
# {Delegates to: TextEditor.backspace}
backspace: -> @activeEditSession.backspace()
# {Delegates to: EditSession.backspaceToBeginningOfWord}
# {Delegates to: TextEditor.backspaceToBeginningOfWord}
backspaceToBeginningOfWord: -> @activeEditSession.backspaceToBeginningOfWord()
# {Delegates to: EditSession.backspaceToBeginningOfLine}
# {Delegates to: TextEditor.backspaceToBeginningOfLine}
backspaceToBeginningOfLine: -> @activeEditSession.backspaceToBeginningOfLine()
# {Delegates to: EditSession.delete}
# {Delegates to: TextEditor.delete}
delete: -> @activeEditSession.delete()
# {Delegates to: EditSession.deleteToEndOfWord}
# {Delegates to: TextEditor.deleteToEndOfWord}
deleteToEndOfWord: -> @activeEditSession.deleteToEndOfWord()
# {Delegates to: EditSession.deleteLine}
# {Delegates to: TextEditor.deleteLine}
deleteLine: -> @activeEditSession.deleteLine()
# {Delegates to: EditSession.cutToEndOfLine}
# {Delegates to: TextEditor.cutToEndOfLine}
cutToEndOfLine: -> @activeEditSession.cutToEndOfLine()
# {Delegates to: EditSession.insertText}
# {Delegates to: TextEditor.insertText}
insertText: (text, options) -> @activeEditSession.insertText(text, options)
# {Delegates to: EditSession.insertNewline}
# {Delegates to: TextEditor.insertNewline}
insertNewline: -> @activeEditSession.insertNewline()
# {Delegates to: EditSession.insertNewlineBelow}
# {Delegates to: TextEditor.insertNewlineBelow}
insertNewlineBelow: -> @activeEditSession.insertNewlineBelow()
# {Delegates to: EditSession.insertNewlineAbove}
# {Delegates to: TextEditor.insertNewlineAbove}
insertNewlineAbove: -> @activeEditSession.insertNewlineAbove()
# {Delegates to: EditSession.indent}
# {Delegates to: TextEditor.indent}
indent: (options) -> @activeEditSession.indent(options)
# {Delegates to: EditSession.autoIndentSelectedRows}
# {Delegates to: TextEditor.autoIndentSelectedRows}
autoIndent: (options) -> @activeEditSession.autoIndentSelectedRows()
# {Delegates to: EditSession.indentSelectedRows}
# {Delegates to: TextEditor.indentSelectedRows}
indentSelectedRows: -> @activeEditSession.indentSelectedRows()
# {Delegates to: EditSession.outdentSelectedRows}
# {Delegates to: TextEditor.outdentSelectedRows}
outdentSelectedRows: -> @activeEditSession.outdentSelectedRows()
# {Delegates to: EditSession.cutSelectedText}
# {Delegates to: TextEditor.cutSelectedText}
cutSelection: -> @activeEditSession.cutSelectedText()
# {Delegates to: EditSession.copySelectedText}
# {Delegates to: TextEditor.copySelectedText}
copySelection: -> @activeEditSession.copySelectedText()
# {Delegates to: EditSession.pasteText}
# {Delegates to: TextEditor.pasteText}
paste: (options) -> @activeEditSession.pasteText(options)
# {Delegates to: EditSession.undo}
# {Delegates to: TextEditor.undo}
undo: -> @activeEditSession.undo()
# {Delegates to: EditSession.redo}
# {Delegates to: TextEditor.redo}
redo: -> @activeEditSession.redo()
# {Delegates to: EditSession.createFold}
# {Delegates to: TextEditor.createFold}
createFold: (startRow, endRow) -> @activeEditSession.createFold(startRow, endRow)
# {Delegates to: EditSession.foldCurrentRow}
# {Delegates to: TextEditor.foldCurrentRow}
foldCurrentRow: -> @activeEditSession.foldCurrentRow()
# {Delegates to: EditSession.unfoldCurrentRow}
# {Delegates to: TextEditor.unfoldCurrentRow}
unfoldCurrentRow: -> @activeEditSession.unfoldCurrentRow()
# {Delegates to: EditSession.foldAll}
# {Delegates to: TextEditor.foldAll}
foldAll: -> @activeEditSession.foldAll()
# {Delegates to: EditSession.unfoldAll}
# {Delegates to: TextEditor.unfoldAll}
unfoldAll: -> @activeEditSession.unfoldAll()
# {Delegates to: EditSession.foldSelection}
# {Delegates to: TextEditor.foldSelection}
foldSelection: -> @activeEditSession.foldSelection()
# {Delegates to: EditSession.destroyFoldsContainingBufferRow}
# {Delegates to: TextEditor.destroyFoldsContainingBufferRow}
destroyFoldsContainingBufferRow: (bufferRow) -> @activeEditSession.destroyFoldsContainingBufferRow(bufferRow)
# {Delegates to: EditSession.isFoldedAtScreenRow}
# {Delegates to: TextEditor.isFoldedAtScreenRow}
isFoldedAtScreenRow: (screenRow) -> @activeEditSession.isFoldedAtScreenRow(screenRow)
# {Delegates to: EditSession.isFoldedAtBufferRow}
# {Delegates to: TextEditor.isFoldedAtBufferRow}
isFoldedAtBufferRow: (bufferRow) -> @activeEditSession.isFoldedAtBufferRow(bufferRow)
# {Delegates to: EditSession.isFoldedAtCursorRow}
# {Delegates to: TextEditor.isFoldedAtCursorRow}
isFoldedAtCursorRow: -> @activeEditSession.isFoldedAtCursorRow()
foldAllAtIndentLevel: (indentLevel) -> @activeEditSession.foldAllAtIndentLevel(indentLevel)
# {Delegates to: EditSession.lineForScreenRow}
# {Delegates to: TextEditor.lineForScreenRow}
lineForScreenRow: (screenRow) -> @activeEditSession.lineForScreenRow(screenRow)
# {Delegates to: EditSession.linesForScreenRows}
# {Delegates to: TextEditor.linesForScreenRows}
linesForScreenRows: (start, end) -> @activeEditSession.linesForScreenRows(start, end)
# {Delegates to: EditSession.getScreenLineCount}
# {Delegates to: TextEditor.getScreenLineCount}
getScreenLineCount: -> @activeEditSession.getScreenLineCount()
# Private:
@@ -508,33 +508,33 @@ class TextEditorView extends View
heightInLines ?= @calculateHeightInLines()
@heightInLines = heightInLines if heightInLines
# {Delegates to: EditSession.setEditorWidthInChars}
# {Delegates to: TextEditor.setEditorWidthInChars}
setWidthInChars: (widthInChars) ->
widthInChars ?= @calculateWidthInChars()
@activeEditSession.setEditorWidthInChars(widthInChars) if widthInChars
# {Delegates to: EditSession.getMaxScreenLineLength}
# {Delegates to: TextEditor.getMaxScreenLineLength}
getMaxScreenLineLength: -> @activeEditSession.getMaxScreenLineLength()
# {Delegates to: EditSession.getLastScreenRow}
# {Delegates to: TextEditor.getLastScreenRow}
getLastScreenRow: -> @activeEditSession.getLastScreenRow()
# {Delegates to: EditSession.clipScreenPosition}
# {Delegates to: TextEditor.clipScreenPosition}
clipScreenPosition: (screenPosition, options={}) -> @activeEditSession.clipScreenPosition(screenPosition, options)
# {Delegates to: EditSession.screenPositionForBufferPosition}
# {Delegates to: TextEditor.screenPositionForBufferPosition}
screenPositionForBufferPosition: (position, options) -> @activeEditSession.screenPositionForBufferPosition(position, options)
# {Delegates to: EditSession.bufferPositionForScreenPosition}
# {Delegates to: TextEditor.bufferPositionForScreenPosition}
bufferPositionForScreenPosition: (position, options) -> @activeEditSession.bufferPositionForScreenPosition(position, options)
# {Delegates to: EditSession.screenRangeForBufferRange}
# {Delegates to: TextEditor.screenRangeForBufferRange}
screenRangeForBufferRange: (range) -> @activeEditSession.screenRangeForBufferRange(range)
# {Delegates to: EditSession.bufferRangeForScreenRange}
# {Delegates to: TextEditor.bufferRangeForScreenRange}
bufferRangeForScreenRange: (range) -> @activeEditSession.bufferRangeForScreenRange(range)
# {Delegates to: EditSession.bufferRowsForScreenRows}
# {Delegates to: TextEditor.bufferRowsForScreenRows}
bufferRowsForScreenRows: (startRow, endRow) -> @activeEditSession.bufferRowsForScreenRows(startRow, endRow)
# Public: Emulates the "page down" key, where the last row of a buffer scrolls to become the first.
@@ -591,13 +591,13 @@ class TextEditorView extends View
if path = @getPath()
atom.project.getRepo()?.checkoutHead(path)
# {Delegates to: EditSession.setText}
# {Delegates to: TextEditor.setText}
setText: (text) -> @activeEditSession.setText(text)
# {Delegates to: EditSession.getText}
# {Delegates to: TextEditor.getText}
getText: -> @activeEditSession.getText()
# {Delegates to: EditSession.getPath}
# {Delegates to: TextEditor.getPath}
getPath: -> @activeEditSession?.getPath()
# {Delegates to: TextBuffer.getLineCount}
@@ -888,7 +888,7 @@ class TextEditorView extends View
### Public ###
# Retrieves the {EditSession}'s buffer.
# Retrieves the {TextEditor}'s buffer.
#
# Returns the current {TextBuffer}.
getBuffer: -> @activeEditSession.buffer
@@ -1701,20 +1701,20 @@ class TextEditorView extends View
else
@highlightedLine = null
# {Delegates to: EditSession.getGrammar}
# {Delegates to: TextEditor.getGrammar}
getGrammar: ->
@activeEditSession.getGrammar()
# {Delegates to: EditSession.setGrammar}
# {Delegates to: TextEditor.setGrammar}
setGrammar: (grammar) ->
throw new Error("Only mini-editors can explicity set their grammar") unless @mini
@activeEditSession.setGrammar(grammar)
# {Delegates to: EditSession.reloadGrammar}
# {Delegates to: TextEditor.reloadGrammar}
reloadGrammar: ->
@activeEditSession.reloadGrammar()
# {Delegates to: EditSession.scopesForBufferPosition}
# {Delegates to: TextEditor.scopesForBufferPosition}
scopesForBufferPosition: (bufferPosition) ->
@activeEditSession.scopesForBufferPosition(bufferPosition)

View File

@@ -12,18 +12,18 @@ TextMateScopeSelector = require('first-mate').ScopeSelector
# Public: The core model of Atom.
#
# An {EditSession} represents a unique view of each document, with it's own
# An {TextEditor} 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 {EditSession}
# but both {EditSession}s interact with the same buffer underlying buffer. So
# 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
# 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 {EditSession} as well as any future {EditSession}s.
# existing {TextEditor} as well as any future {TextEditor}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 EditSession
class TextEditor
Emitter.includeInto(this)
Subscriber.includeInto(this)
@@ -47,7 +47,7 @@ class EditSession
@version: 5
@deserialize: (state) ->
new EditSession(state)
new TextEditor(state)
id: null
languageMode: null
@@ -152,12 +152,12 @@ class EditSession
# Private:
getState: -> @state
# Private: Creates an {EditSession} with the same initial state
# Private: Creates an {TextEditor} with the same initial state
copy: ->
tabLength = @getTabLength()
displayBuffer = @displayBuffer.copy()
softTabs = @getSoftTabs()
newEditSession = new EditSession({@buffer, displayBuffer, tabLength, softTabs, suppressCursorCreation: true})
newEditSession = new TextEditor({@buffer, displayBuffer, tabLength, softTabs, suppressCursorCreation: true})
newEditSession.setScrollTop(@getScrollTop())
newEditSession.setScrollLeft(@getScrollLeft())
for marker in @findMarkers(editSessionId: @id)
@@ -190,7 +190,7 @@ class EditSession
else
'untitled'
# Public: Compares two `EditSession`s to determine equality.
# Public: Compares two `TextEditor`s to determine equality.
#
# Equality is based on the condition that:
#
@@ -200,7 +200,7 @@ class EditSession
#
# Returns a {Boolean}.
isEqual: (other) ->
return false unless other instanceof EditSession
return false unless other instanceof TextEditor
@buffer == other.buffer and
@getScrollTop() == other.getScrollTop() and
@getScrollLeft() == other.getScrollLeft() and
@@ -876,7 +876,7 @@ class EditSession
@emit 'cursor-added', cursor
cursor
# Public: Removes and returns a cursor from the `EditSession`.
# Public: Removes and returns a cursor from the `TextEditor`.
removeCursor: (cursor) ->
_.remove(@cursors, cursor)