Massive updates

This commit is contained in:
Garen Torikian 2013-04-11 21:11:12 -05:00
parent bb8f5bb40c
commit 7e5b6bf5c4
14 changed files with 50 additions and 7 deletions

View File

@ -25,6 +25,7 @@ class Config
settings: null
configFileHasErrors: null
# Internal:
constructor: ->
@defaultSettings =
core: _.clone(require('root-view').configDefaults)
@ -33,6 +34,7 @@ class Config
@configFilePath = fsUtils.resolve(configDirPath, 'config', ['json', 'cson'])
@configFilePath ?= fsUtils.join(configDirPath, 'config.cson')
# Internal:
initializeConfigDirectory: ->
return if fsUtils.exists(@configDirPath)
@ -52,10 +54,12 @@ class Config
fsUtils.write(configPath, fsUtils.read(path))
fsUtils.traverseTreeSync(bundledThemesDirPath, onThemeDirFile, (path) -> true)
# Internal:
load: ->
@initializeConfigDirectory()
@loadUserConfig()
# Internal:
loadUserConfig: ->
if fsUtils.exists(@configFilePath)
try

View File

@ -12,6 +12,7 @@ class Cursor
visible: true
needsAutoscroll: null
# Internal:
constructor: ({@editSession, @marker}) ->
@updateVisibility()
@editSession.observeMarker @marker, (e) =>
@ -34,6 +35,7 @@ class Cursor
@editSession.trigger 'cursor-moved', movedEvent
@needsAutoscroll = true
# Internal:
destroy: ->
@destroyed = true
@editSession.destroyMarker(@marker)

View File

@ -17,6 +17,7 @@ class EditSession
@version: 1
# Internal:
@deserialize: (state) ->
session = project.buildEditSessionForBuffer(Buffer.deserialize(state.buffer))
if !session?
@ -36,6 +37,7 @@ class EditSession
softTabs: true
softWrap: false
# Internal:
constructor: ({@project, @buffer, tabLength, softTabs, @softWrap }) ->
@softTabs = @buffer.usesSoftTabs() ? softTabs ? true
@languageMode = new LanguageMode(this, @buffer.getExtension())
@ -1051,7 +1053,7 @@ class EditSession
# Public: Moves every cursor to a given screen position.
#
# position - An {Array} of two numbers: the screen row, and the screen column.
# options - An object with properties based on {Cursor#changePosition}
# options - An object with properties based on {Cursor#setScreenPosition}
#
setCursorScreenPosition: (position, options) ->
@moveCursors (cursor) -> cursor.setScreenPosition(position, options)
@ -1071,7 +1073,7 @@ class EditSession
# Public: Moves every cursor to a given buffer position.
#
# position - An {Array} of two numbers: the buffer row, and the buffer column.
# options - An object with properties based on {Cursor#changePosition}
# options - An object with properties based on {Cursor#setBufferPosition}
#
setCursorBufferPosition: (position, options) ->
@moveCursors (cursor) -> cursor.setBufferPosition(position, options)

View File

@ -26,6 +26,7 @@ class Editor extends View
@nextEditorId: 1
# Internal: Establishes the DOM for the editor.
@content: (params) ->
@div class: @classes(params), tabindex: -1, =>
@subview 'gutter', new Gutter
@ -37,6 +38,7 @@ class Editor extends View
@div class: 'vertical-scrollbar', outlet: 'verticalScrollbar', =>
@div outlet: 'verticalScrollbarContent'
# Internal: Defines the classes available to the editor.
@classes: ({mini} = {}) ->
classes = ['editor']
classes.push 'mini' if mini
@ -234,7 +236,7 @@ class Editor extends View
# Public: Sets the cursor based on a given screen position.
#
# position - An {Array} of two numbers: the screen row, and the screen column.
# options - An object with properties based on {Cursor#changePosition}.
# options - An object with properties based on {Cursor#setScreenPosition}.
#
setCursorScreenPosition: (position, options) -> @activeEditSession.setCursorScreenPosition(position, options)
# Public: Duplicates the current line.
@ -248,7 +250,7 @@ class Editor extends View
# Public: Sets the cursor based on a given buffer position.
#
# position - An {Array} of two numbers: the buffer row, and the buffer column.
# options - An object with properties based on {Cursor#changePosition}.
# options - An object with properties based on {Cursor#setBufferPosition}.
#
setCursorBufferPosition: (position, options) -> @activeEditSession.setCursorBufferPosition(position, options)
# Public: Gets the current buffer position.

View File

@ -28,6 +28,11 @@ class Git
upstream: null
statusTask: null
# Internal: Creates a new `Git` object.
#
# path - The {String} representing the path to your git working directory
# options - A hash with the following keys:
# :refreshOnWindowFocus - If `true`, {#refreshIndex} and {#refreshStatus} are called on focus
constructor: (path, options={}) ->
@repo = GitUtils.open(path)
unless @repo?

View File

@ -12,13 +12,15 @@ class ImageEditSession
'.jpg'
'.png'
], fsUtils.extension(path), true) >= 0
# Internal:
@deserialize: (state) ->
if fsUtils.exists(state.path)
project.buildEditSession(state.path)
else
console.warn "Could not build edit session for path '#{state.path}' because that file no longer exists"
# Internal: Establishes a new image viewer.
constructor: (@path) ->
serialize: ->

View File

@ -12,13 +12,17 @@ class LanguageMode
editSession = null
currentGrammarScore: null
# Public: Sets up a `LanguageMode` for the given {EditSession}.
#
# editSession - The {EditSession} to associate with
constructor: (@editSession) ->
@buffer = @editSession.buffer
@reloadGrammar()
@subscribe syntax, 'grammar-added', (grammar) =>
newScore = grammar.getScore(@buffer.getPath(), @buffer.getText())
@setGrammar(grammar, newScore) if newScore > @currentGrammarScore
# Internal:
destroy: ->
@unsubscribe()

View File

@ -6,6 +6,7 @@ module.exports =
class PaneContainer extends View
registerDeserializer(this)
# Internal:
@deserialize: ({root}) ->
container = new PaneContainer
container.append(deserialize(root)) if root

View File

@ -7,6 +7,9 @@ class PaneRow extends PaneAxis
@content: ->
@div class: 'row'
# Public: Retrieves the pane class name.
#
# Returns a {String}.
className: ->
"PaneRow"

View File

@ -17,6 +17,7 @@ module.exports =
class Project
registerDeserializer(this)
# Internal:
@deserialize: (state) ->
new Project(state.path)
@ -27,15 +28,20 @@ class Project
editSessions: null
ignoredPathRegexes: null
# Public: Establishes a new project at a given path.
#
# path - The {String} name of the path
constructor: (path) ->
@setPath(path)
@editSessions = []
@buffers = []
# Internal:
serialize: ->
deserializer: 'Project'
path: @getPath()
# Internal:
destroy: ->
editSession.destroy() for editSession in @getEditSessions()

View File

@ -35,6 +35,10 @@ class Range
pointB = new Point(point.row + rowDelta, point.column + columnDelta)
new Range(pointA, pointB)
# Public: Creates a new `Range` object based on two {Point}s.
#
# pointA - The first {Point} (default: `0, 0`)
# pointB - The second {Point} (default: `0, 0`)
constructor: (pointA = new Point(0, 0), pointB = new Point(0, 0)) ->
pointA = Point.fromObject(pointA)
pointB = Point.fromObject(pointB)

View File

@ -23,16 +23,19 @@ class RootView extends View
ignoredNames: [".git", ".svn", ".DS_Store"]
disabledPackages: []
# Internal:
@content: ({panes}={}) ->
@div id: 'root-view', =>
@div id: 'horizontal', outlet: 'horizontal', =>
@div id: 'vertical', outlet: 'vertical', =>
@subview 'panes', panes ? new PaneContainer
# Internal:
@deserialize: ({ panes }) ->
panes = deserialize(panes) if panes?.deserializer is 'PaneContainer'
new RootView({panes})
# Internal:
initialize: ->
@command 'toggle-dev-tools', => atom.toggleDevTools()
@on 'focus', (e) => @handleFocus(e)
@ -69,6 +72,7 @@ class RootView extends View
@command 'pane:reopen-closed-item', =>
@panes.reopenItem()
# Internal:
serialize: ->
version: RootView.version
deserializer: 'RootView'

View File

@ -19,6 +19,7 @@ class SelectList extends View
inputThrottle: 50
cancelling: false
# Internal:
initialize: ->
requireStylesheet 'select-list'

View File

@ -29,6 +29,7 @@ class Buffer
invalidMarkers: null
refcount: 0
# Internal:
@deserialize: ({path, text}) ->
project.bufferForPath(path, text)
@ -58,6 +59,7 @@ class Buffer
@undoManager = new UndoManager(this)
# Internal:
destroy: ->
throw new Error("Destroying buffer twice with path '#{@getPath()}'") if @destroyed
@file?.off()
@ -73,6 +75,7 @@ class Buffer
@destroy() if @refcount <= 0
this
# Internal:
serialize: ->
deserializer: 'TextBuffer'
path: @getPath()