From 7e5b6bf5c47b29d7f67e41b730247ff91346f15f Mon Sep 17 00:00:00 2001 From: Garen Torikian Date: Thu, 11 Apr 2013 21:11:12 -0500 Subject: [PATCH] Massive updates --- src/app/config.coffee | 4 ++++ src/app/cursor.coffee | 2 ++ src/app/edit-session.coffee | 6 ++++-- src/app/editor.coffee | 6 ++++-- src/app/git.coffee | 5 +++++ src/app/image-edit-session.coffee | 4 +++- src/app/language-mode.coffee | 6 +++++- src/app/pane-container.coffee | 1 + src/app/pane-row.coffee | 3 +++ src/app/project.coffee | 6 ++++++ src/app/range.coffee | 4 ++++ src/app/root-view.coffee | 6 +++++- src/app/select-list.coffee | 1 + src/app/text-buffer.coffee | 3 +++ 14 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/app/config.coffee b/src/app/config.coffee index dee2052a5..336b00f4f 100644 --- a/src/app/config.coffee +++ b/src/app/config.coffee @@ -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 diff --git a/src/app/cursor.coffee b/src/app/cursor.coffee index 56c0f117f..bbf8895ca 100644 --- a/src/app/cursor.coffee +++ b/src/app/cursor.coffee @@ -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) diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index c51d5095e..1770e3b5f 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -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) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index c717dba0b..67164e833 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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. diff --git a/src/app/git.coffee b/src/app/git.coffee index 7edcbaed1..740901760 100644 --- a/src/app/git.coffee +++ b/src/app/git.coffee @@ -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? diff --git a/src/app/image-edit-session.coffee b/src/app/image-edit-session.coffee index f0e25318a..32ab2c867 100644 --- a/src/app/image-edit-session.coffee +++ b/src/app/image-edit-session.coffee @@ -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: -> diff --git a/src/app/language-mode.coffee b/src/app/language-mode.coffee index ac82579ed..870334aa3 100644 --- a/src/app/language-mode.coffee +++ b/src/app/language-mode.coffee @@ -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() diff --git a/src/app/pane-container.coffee b/src/app/pane-container.coffee index 8bcaa45fb..c0a0c4315 100644 --- a/src/app/pane-container.coffee +++ b/src/app/pane-container.coffee @@ -6,6 +6,7 @@ module.exports = class PaneContainer extends View registerDeserializer(this) + # Internal: @deserialize: ({root}) -> container = new PaneContainer container.append(deserialize(root)) if root diff --git a/src/app/pane-row.coffee b/src/app/pane-row.coffee index ce7a09f82..1db337994 100644 --- a/src/app/pane-row.coffee +++ b/src/app/pane-row.coffee @@ -7,6 +7,9 @@ class PaneRow extends PaneAxis @content: -> @div class: 'row' + # Public: Retrieves the pane class name. + # + # Returns a {String}. className: -> "PaneRow" diff --git a/src/app/project.coffee b/src/app/project.coffee index cf1f2a230..747ab3222 100644 --- a/src/app/project.coffee +++ b/src/app/project.coffee @@ -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() diff --git a/src/app/range.coffee b/src/app/range.coffee index 6847dd6da..1aac76c70 100644 --- a/src/app/range.coffee +++ b/src/app/range.coffee @@ -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) diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 6b4bf73bb..188f07f5d 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -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' diff --git a/src/app/select-list.coffee b/src/app/select-list.coffee index 9dbbd077a..e5ac69970 100644 --- a/src/app/select-list.coffee +++ b/src/app/select-list.coffee @@ -19,6 +19,7 @@ class SelectList extends View inputThrottle: 50 cancelling: false + # Internal: initialize: -> requireStylesheet 'select-list' diff --git a/src/app/text-buffer.coffee b/src/app/text-buffer.coffee index 8a8dc75b5..90f5b4ba1 100644 --- a/src/app/text-buffer.coffee +++ b/src/app/text-buffer.coffee @@ -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()