From 0c5e38680dbce00231a156a5f530eb536bc9be59 Mon Sep 17 00:00:00 2001 From: Garen Torikian Date: Fri, 12 Apr 2013 14:37:21 -0500 Subject: [PATCH] Internalize a bunch of methods --- src/app/cursor-view.coffee | 1 + src/app/display-buffer-marker.coffee | 1 + src/app/display-buffer.coffee | 1 + src/app/edit-session.coffee | 2 ++ src/app/gutter.coffee | 6 ++++++ src/app/image-edit-session.coffee | 12 ++++++++++++ src/app/image-view.coffee | 3 +++ src/app/pane-column.coffee | 3 +++ src/app/pane-container.coffee | 3 +++ src/app/pane.coffee | 3 +++ src/app/range.coffee | 9 +++++++++ src/app/select-list.coffee | 2 ++ src/app/selection-view.coffee | 2 ++ src/app/syntax.coffee | 1 + src/app/tokenized-buffer.coffee | 6 ++++++ src/app/undo-manager.coffee | 1 + 16 files changed, 56 insertions(+) diff --git a/src/app/cursor-view.coffee b/src/app/cursor-view.coffee index 03fae93de..3cef15ba2 100644 --- a/src/app/cursor-view.coffee +++ b/src/app/cursor-view.coffee @@ -5,6 +5,7 @@ _ = require 'underscore' module.exports = class CursorView extends View + # Internal: @content: -> @pre class: 'cursor idle', => @raw ' ' diff --git a/src/app/display-buffer-marker.coffee b/src/app/display-buffer-marker.coffee index c8ed1648a..e794af009 100644 --- a/src/app/display-buffer-marker.coffee +++ b/src/app/display-buffer-marker.coffee @@ -9,6 +9,7 @@ class DisplayBufferMarker tailScreenPosition: null valid: true + # Internal: constructor: ({@id, @displayBuffer}) -> @buffer = @displayBuffer.buffer diff --git a/src/app/display-buffer.coffee b/src/app/display-buffer.coffee index d123e791b..b0166d3f2 100644 --- a/src/app/display-buffer.coffee +++ b/src/app/display-buffer.coffee @@ -19,6 +19,7 @@ class DisplayBuffer foldsById: null markers: null + # Internal: constructor: (@buffer, options={}) -> @id = @constructor.idCounter++ @languageMode = options.languageMode diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 1770e3b5f..99eb3621b 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -68,6 +68,8 @@ class EditSession # Public: Retrieves the filename of the open file. # + # This is `'untitled'` if the file is new and not saved to the disk. + # # Returns a {String}. getTitle: -> if path = @getPath() diff --git a/src/app/gutter.coffee b/src/app/gutter.coffee index 76bf22cad..9b16710e7 100644 --- a/src/app/gutter.coffee +++ b/src/app/gutter.coffee @@ -5,6 +5,8 @@ _ = require 'underscore' module.exports = class Gutter extends View + + # Internal: @content: -> @div class: 'gutter', => @div outlet: 'lineNumbers', class: 'line-numbers' @@ -22,9 +24,13 @@ class Gutter extends View @getEditor().on 'selection:changed', highlightLines @on 'mousedown', (e) => @handleMouseEvents(e) + # Public: Retrieves the containing {Editor}. + # + # Returns an {Editor}. getEditor: -> @parentView + # Internal: beforeRemove: -> $(document).off(".gutter-#{@getEditor().id}") diff --git a/src/app/image-edit-session.coffee b/src/app/image-edit-session.coffee index 32ab2c867..14607e84f 100644 --- a/src/app/image-edit-session.coffee +++ b/src/app/image-edit-session.coffee @@ -5,6 +5,11 @@ module.exports= class ImageEditSession registerDeserializer(this) + # Public: Identifies if a path can be opened by the image viewer. + # + # path - The {String} name of the path to check + # + # Returns a {Boolean}. @canOpen: (path) -> _.indexOf([ '.gif' @@ -23,13 +28,20 @@ class ImageEditSession # Internal: Establishes a new image viewer. constructor: (@path) -> + # Internal: serialize: -> deserializer: 'ImageEditSession' path: @path + # Internal: getViewClass: -> require 'image-view' + # Public: Retrieves the filename of the open file. + # + # This is `'untitled'` if the file is new and not saved to the disk. + # + # Returns a {String}. getTitle: -> if path = @getPath() fsUtils.base(path) diff --git a/src/app/image-view.coffee b/src/app/image-view.coffee index 0db56b20a..ff1e2cc99 100644 --- a/src/app/image-view.coffee +++ b/src/app/image-view.coffee @@ -4,10 +4,13 @@ $ = require 'jquery' module.exports = class ImageView extends ScrollView + + # Internal: @content: -> @div class: 'image-view', tabindex: -1, => @img outlet: 'image' + # Internal: initialize: (imageEditSession) -> super diff --git a/src/app/pane-column.coffee b/src/app/pane-column.coffee index 43ba40cbb..d795e0cb7 100644 --- a/src/app/pane-column.coffee +++ b/src/app/pane-column.coffee @@ -4,9 +4,12 @@ PaneAxis = require 'pane-axis' module.exports = class PaneColumn extends PaneAxis + + # Internal: @content: -> @div class: 'column' + # Internal: className: -> "PaneColumn" diff --git a/src/app/pane-container.coffee b/src/app/pane-container.coffee index c0a0c4315..06db6890d 100644 --- a/src/app/pane-container.coffee +++ b/src/app/pane-container.coffee @@ -13,12 +13,15 @@ class PaneContainer extends View container.removeEmptyPanes() container + # Internal: The DOM of the pane container. @content: -> @div id: 'panes' + # Internal: initialize: -> @destroyedItemStates = [] + # Internal: serialize: -> deserializer: 'PaneContainer' root: @getRoot()?.serialize() diff --git a/src/app/pane.coffee b/src/app/pane.coffee index 166fd7e90..56e550787 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -6,10 +6,13 @@ PaneColumn = require 'pane-column' module.exports = class Pane extends View + + # Internal: Defines the pane's DOM. @content: (wrappedView) -> @div class: 'pane', => @div class: 'item-views', outlet: 'itemViews' + # Internal: @deserialize: ({items, focused, activeItemUri}) -> deserializedItems = _.compact(items.map((item) -> deserialize(item))) pane = new Pane(deserializedItems...) diff --git a/src/app/range.coffee b/src/app/range.coffee index 1aac76c70..2b82cc3bd 100644 --- a/src/app/range.coffee +++ b/src/app/range.coffee @@ -98,6 +98,15 @@ class Range add: (point) -> new Range(@start.add(point), @end.add(point)) + # Public: Moves a `Range`. + # + # In other words, the starting and ending `row` values, and the starting and ending + # `column` values, are added to each other. + # + # startPoint - The {Point} to move the `Range`s `start` by + # endPoint - The {Point} to move the `Range`s `end` by + # + # Returns the new {Range}. translate: (startPoint, endPoint=startPoint) -> new Range(@start.translate(startPoint), @end.translate(endPoint)) diff --git a/src/app/select-list.coffee b/src/app/select-list.coffee index e5ac69970..30e42a894 100644 --- a/src/app/select-list.coffee +++ b/src/app/select-list.coffee @@ -5,6 +5,8 @@ fuzzyFilter = require 'fuzzy-filter' module.exports = class SelectList extends View + + # Internal: Establishes the DOM for the selection list. @content: -> @div class: @viewClass(), => @subview 'miniEditor', new Editor(mini: true) diff --git a/src/app/selection-view.coffee b/src/app/selection-view.coffee index 4b66e3d97..2adcf7627 100644 --- a/src/app/selection-view.coffee +++ b/src/app/selection-view.coffee @@ -4,6 +4,8 @@ Range = require 'range' module.exports = class SelectionView extends View + + # Internal: Establishes the DOM for the selection view. @content: -> @div class: 'selection' diff --git a/src/app/syntax.coffee b/src/app/syntax.coffee index 3aebccbb8..d952ab84f 100644 --- a/src/app/syntax.coffee +++ b/src/app/syntax.coffee @@ -10,6 +10,7 @@ module.exports = class Syntax registerDeserializer(this) + # Internal: @deserialize: ({grammarOverridesByPath}) -> syntax = new Syntax() syntax.grammarOverridesByPath = grammarOverridesByPath diff --git a/src/app/tokenized-buffer.coffee b/src/app/tokenized-buffer.coffee index f35c94680..d84973c59 100644 --- a/src/app/tokenized-buffer.coffee +++ b/src/app/tokenized-buffer.coffee @@ -156,6 +156,7 @@ class TokenizedBuffer token = @screenLines[position.row].tokenAtBufferColumn(position.column) token.scopes + # Internal: destroy: -> @buffer.off ".tokenized-buffer#{@id}" @@ -219,14 +220,19 @@ class TokenizedBuffer stop() position + # Public: Gets the row number of the last line. + # + # Returns a {Number}. getLastRow: -> @buffer.getLastRow() + # Internal: logLines: (start=0, end=@buffer.getLastRow()) -> for row in [start..end] line = @lineForScreenRow(row).text console.log row, line, line.length + # Internal: getDebugSnapshot: -> lines = ["Tokenized Buffer:"] for screenLine, row in @linesForScreenRows(0, @getLastRow()) diff --git a/src/app/undo-manager.coffee b/src/app/undo-manager.coffee index fc5b73e00..d8aaaa70b 100644 --- a/src/app/undo-manager.coffee +++ b/src/app/undo-manager.coffee @@ -7,6 +7,7 @@ class UndoManager redoHistory: null currentTransaction: null + # Internal: constructor: -> @clear()