diff --git a/src/app/atom-theme.coffee b/src/app/atom-theme.coffee index 832bbf0ab..10015a1eb 100644 --- a/src/app/atom-theme.coffee +++ b/src/app/atom-theme.coffee @@ -5,13 +5,13 @@ Theme = require 'theme' module.exports = class AtomTheme extends Theme - # Internal: Given a path, this loads it as a stylesheet. + # Given a path, this loads it as a stylesheet. # # stylesheetPath - A {String} to a stylesheet loadStylesheet: (stylesheetPath)-> @stylesheets[stylesheetPath] = window.loadStylesheet(stylesheetPath) - # Internal: Loads the stylesheets found in a `package.cson` file. + # Loads the stylesheets found in a `package.cson` file. load: -> if fsUtils.extension(@path) in ['.css', '.less'] @loadStylesheet(@path) diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index fc0f97fea..bcb11b9a7 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -232,7 +232,7 @@ class EditSession newIndentString = @buildIndentString(newLevel) @buffer.change([[bufferRow, 0], [bufferRow, currentIndentString.length]], newIndentString) - # Internal: Given a line, this gets the indentation level. + # Given a line, this retrieves the indentation level. # # line - A {String} in the current {Buffer}. # @@ -246,7 +246,7 @@ class EditSession else 0 - # Internal: Constructs the string used for tabs. + # Constructs the string used for tabs. buildIndentString: (number) -> if @softTabs _.multiplyString(" ", number * @getTabLength()) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index a7ee69b1e..177d3c390 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -353,7 +353,7 @@ class Editor extends View # {Delegates to: EditSession.selectToScreenPosition} selectToScreenPosition: (position) -> @activeEditSession.selectToScreenPosition(position) - + # {Delegates to: EditSession.transpose} transpose: -> @activeEditSession.transpose() @@ -681,7 +681,6 @@ class Editor extends View @activeEditSession.finalizeSelections() @syncCursorAnimations() - afterAttach: (onDom) -> return unless onDom @redraw() if @redrawOnReattach @@ -820,43 +819,6 @@ class Editor extends View @scrollVertically(pixelPosition, options) @scrollHorizontally(pixelPosition) - # Internal: Scrolls the editor vertically to a given position. - scrollVertically: (pixelPosition, {center}={}) -> - scrollViewHeight = @scrollView.height() - scrollTop = @scrollTop() - scrollBottom = scrollTop + scrollViewHeight - - if center - unless scrollTop < pixelPosition.top < scrollBottom - @scrollTop(pixelPosition.top - (scrollViewHeight / 2)) - else - linesInView = @scrollView.height() / @lineHeight - maxScrollMargin = Math.floor((linesInView - 1) / 2) - scrollMargin = Math.min(@vScrollMargin, maxScrollMargin) - margin = scrollMargin * @lineHeight - desiredTop = pixelPosition.top - margin - desiredBottom = pixelPosition.top + @lineHeight + margin - if desiredBottom > scrollBottom - @scrollTop(desiredBottom - scrollViewHeight) - else if desiredTop < scrollTop - @scrollTop(desiredTop) - - # Internal: Scrolls the editor horizontally to a given position. - scrollHorizontally: (pixelPosition) -> - return if @activeEditSession.getSoftWrap() - - charsInView = @scrollView.width() / @charWidth - maxScrollMargin = Math.floor((charsInView - 1) / 2) - scrollMargin = Math.min(@hScrollMargin, maxScrollMargin) - margin = scrollMargin * @charWidth - desiredRight = pixelPosition.left + @charWidth + margin - desiredLeft = pixelPosition.left - margin - - if desiredRight > @scrollView.scrollRight() - @scrollView.scrollRight(desiredRight) - else if desiredLeft < @scrollView.scrollLeft() - @scrollView.scrollLeft(desiredLeft) - # Given a buffer range, this highlights all the folds within that range # # "Highlighting" essentially just adds the `selected` class to the line @@ -1043,6 +1005,44 @@ class Editor extends View ### Internal ### + + # Scrolls the editor vertically to a given position. + scrollVertically: (pixelPosition, {center}={}) -> + scrollViewHeight = @scrollView.height() + scrollTop = @scrollTop() + scrollBottom = scrollTop + scrollViewHeight + + if center + unless scrollTop < pixelPosition.top < scrollBottom + @scrollTop(pixelPosition.top - (scrollViewHeight / 2)) + else + linesInView = @scrollView.height() / @lineHeight + maxScrollMargin = Math.floor((linesInView - 1) / 2) + scrollMargin = Math.min(@vScrollMargin, maxScrollMargin) + margin = scrollMargin * @lineHeight + desiredTop = pixelPosition.top - margin + desiredBottom = pixelPosition.top + @lineHeight + margin + if desiredBottom > scrollBottom + @scrollTop(desiredBottom - scrollViewHeight) + else if desiredTop < scrollTop + @scrollTop(desiredTop) + + # Scrolls the editor horizontally to a given position. + scrollHorizontally: (pixelPosition) -> + return if @activeEditSession.getSoftWrap() + + charsInView = @scrollView.width() / @charWidth + maxScrollMargin = Math.floor((charsInView - 1) / 2) + scrollMargin = Math.min(@hScrollMargin, maxScrollMargin) + margin = scrollMargin * @charWidth + desiredRight = pixelPosition.left + @charWidth + margin + desiredLeft = pixelPosition.left - margin + + if desiredRight > @scrollView.scrollRight() + @scrollView.scrollRight(desiredRight) + else if desiredLeft < @scrollView.scrollLeft() + @scrollView.scrollLeft(desiredLeft) + calculateDimensions: -> fragment = $('
') @renderedLines.append(fragment) @@ -1526,7 +1526,7 @@ class Editor extends View pasteboard.write(path) if path? ### Internal ### - + bindToKeyedEvent: (key, event, callback) -> binding = {} binding[key] = event diff --git a/src/app/line-map.coffee b/src/app/line-map.coffee index 33e76edf9..4b6dd15bd 100644 --- a/src/app/line-map.coffee +++ b/src/app/line-map.coffee @@ -7,8 +7,6 @@ module.exports = class LineMap maxScreenLineLength: 0 - ### Internal ### - constructor: -> @screenLines = [] diff --git a/src/app/pasteboard.coffee b/src/app/pasteboard.coffee index 7a3384905..e940977f1 100644 --- a/src/app/pasteboard.coffee +++ b/src/app/pasteboard.coffee @@ -5,7 +5,7 @@ module.exports = class Pasteboard signatureForMetadata: null - # Internal: Creates an `md5` hash of some text. + # Creates an `md5` hash of some text. # # text - A {String} to encrypt. # diff --git a/src/app/point.coffee b/src/app/point.coffee index aafaa3230..cf1329e05 100644 --- a/src/app/point.coffee +++ b/src/app/point.coffee @@ -94,7 +94,7 @@ class Point [new Point(0, column), new Point(@row, rightColumn)] - # Internal: Compares two `Point`s. + # Compares two `Point`s. # # other - The {Point} to compare against #