diff --git a/src/app/cursor.coffee b/src/app/cursor.coffee index 3f5785fbc..985ac2ebc 100644 --- a/src/app/cursor.coffee +++ b/src/app/cursor.coffee @@ -364,6 +364,9 @@ class Cursor isAtEndOfLine: -> @getBufferPosition().isEqual(@getCurrentLineBufferRange().end) + # Public: Retrieves the grammar's token scopes for the line. + # + # Returns an {Array} of {String}s. getScopes: -> @editSession.scopesForBufferPosition(@getBufferPosition()) diff --git a/src/app/display-buffer.coffee b/src/app/display-buffer.coffee index 9855c53f6..9a420b0f2 100644 --- a/src/app/display-buffer.coffee +++ b/src/app/display-buffer.coffee @@ -34,6 +34,7 @@ class DisplayBuffer setVisible: (visible) -> @tokenizedBuffer.setVisible(visible) + # Internal: buildLineMap: -> @lineMap = new LineMap @lineMap.insertAtScreenRow 0, @buildLinesForBufferRows(0, @buffer.getLastRow()) @@ -45,6 +46,9 @@ class DisplayBuffer @trigger 'changed', eventProperties @resumeMarkerObservers() + # Public: Defines the limit at which the buffer begins to soft wrap text. + # + # softWrapColumn - A {Number} defining the soft wrap limit. setSoftWrapColumn: (@softWrapColumn) -> start = 0 end = @getLastRow() @@ -52,13 +56,27 @@ class DisplayBuffer screenDelta = @getLastRow() - end bufferDelta = 0 @triggerChanged({ start, end, screenDelta, bufferDelta }) - + + # Public: Gets the line for the given screen row. + # + # screenRow - A {Number} indicating the screen row. + # + # Returns a {String}. lineForRow: (row) -> @lineMap.lineForScreenRow(row) + # Public: Gets the lines for the given screen row boundaries. + # + # startRow - A {Number} indicating the beginning screen row. + # endRow - A {Number} indicating the ending screen row. + # + # Returns an {Array} of {String}s. linesForRows: (startRow, endRow) -> @lineMap.linesForScreenRows(startRow, endRow) + # Public: Gets the lines in the buffer. + # + # Returns an {Array} of {String}s. getLines: -> @lineMap.linesForScreenRows(0, @lineMap.lastScreenRow()) @@ -123,6 +141,8 @@ class DisplayBuffer # # startRow - The row {Number} to start folding at # endRow - The row {Number} to end the fold + # + # Returns the new {Fold}. createFold: (startRow, endRow) -> return fold if fold = @foldFor(startRow, endRow) fold = new Fold(this, startRow, endRow) @@ -256,6 +276,9 @@ class DisplayBuffer bufferRangeForScreenRange: (screenRange) -> @lineMap.bufferRangeForScreenRange(screenRange) + # Public: Gets the number of lines in the buffer. + # + # Returns a {Number}. lineCount: -> @lineMap.screenLineCount() @@ -265,6 +288,9 @@ class DisplayBuffer getLastRow: -> @lineCount() - 1 + # Public: Gets the length of the longest screen line. + # + # Returns a {Number}. maxLineLength: -> @lineMap.maxScreenLineLength @@ -286,7 +312,12 @@ class DisplayBuffer # Returns a {Point}. bufferPositionForScreenPosition: (position, options) -> @lineMap.bufferPositionForScreenPosition(position, options) - + + # Public: Retrieves the grammar's token scopes for a buffer position. + # + # bufferPosition - A {Point} in the {Buffer} + # + # Returns an {Array} of {String}s. scopesForBufferPosition: (bufferPosition) -> @tokenizedBuffer.scopesForPosition(bufferPosition) @@ -490,13 +521,16 @@ class DisplayBuffer for marker in @getMarkers() marker.notifyObservers(bufferChanged: false) + # Internal: destroy: -> @tokenizedBuffer.destroy() @buffer.off 'markers-updated', @handleMarkersUpdated + # Internal: logLines: (start, end) -> @lineMap.logLines(start, end) + # Internal: getDebugSnapshot: -> lines = ["Display Buffer:"] for screenLine, row in @lineMap.linesForScreenRows(0, @getLastRow()) diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 5369a1e34..d19bca65d 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -10,7 +10,7 @@ Range = require 'range' _ = require 'underscore' fsUtils = require 'fs-utils' -# Public: `EditSession`s manage the states between file {Buffer}s, and the project as a whole. +# Public: An `EditSession` manages the states between {Editor}s, {Buffer}s, and the project as a whole. module.exports = class EditSession registerDeserializer(this) @@ -250,6 +250,9 @@ class EditSession # # Returns a {String}. getBuffer: -> @buffer + # Public: Retrieves the current buffer's URI. + # + # Returns a {String}. getUri: -> @getPath() # Public: Given a buffer row, identifies if it is blank. # @@ -291,7 +294,17 @@ class EditSession # # Returns a {Number}. lineLengthForBufferRow: (row) -> @buffer.lineLengthForRow(row) + # Public: Scans for text in the buffer, calling a function on each match. + # + # regex - A {RegExp} representing the text to find + # range - A {Range} in the buffer to search within + # iterator - A {Function} that's called on each match scanInBufferRange: (args...) -> @buffer.scanInRange(args...) + # Public: Scans for text in the buffer _backwards_, calling a function on each match. + # + # regex - A {RegExp} representing the text to find + # range - A {Range} in the buffer to search within + # iterator - A {Function} that's called on each match backwardsScanInBufferRange: (args...) -> @buffer.backwardsScanInRange(args...) # Public: Identifies if the {Buffer} is modified (and not saved). # @@ -365,8 +378,17 @@ class EditSession # # Returns an {Array} of {Range}s. bufferRowsForScreenRows: (startRow, endRow) -> @displayBuffer.bufferRowsForScreenRows(startRow, endRow) + # Public: Retrieves the grammar's token scopes for a buffer position. + # + # bufferPosition - A {Point} in the {Buffer} + # + # Returns an {Array} of {String}s. scopesForBufferPosition: (bufferPosition) -> @displayBuffer.scopesForBufferPosition(bufferPosition) + # Public: Retrieves the grammar's token scopes for the line with the most recently added cursor. + # + # Returns an {Array} of {String}s. getCursorScopes: -> @getCursor().getScopes() + # Internal: logScreenLines: (start, end) -> @displayBuffer.logLines(start, end) # Public: Determines whether the {Editor} will auto indent rows. @@ -565,6 +587,8 @@ class EditSession # # startRow - The row {Number} to start folding at # endRow - The row {Number} to end the fold + # + # Returns the new {Fold}. createFold: (startRow, endRow) -> @displayBuffer.createFold(startRow, endRow) @@ -675,6 +699,8 @@ class EditSession # # startRow - The row {Number} to start at # endRow - The row {Number} to end at + # + # Returns an {Array} of the commented {Ranges}. toggleLineCommentsForBufferRows: (start, end) -> @languageMode.toggleLineCommentsForBufferRows(start, end) @@ -1334,6 +1360,7 @@ class EditSession markersForBufferPosition: (bufferPosition) -> @buffer.markersForPosition(bufferPosition) + # Internal: mergeCursors: -> positions = [] for cursor in @getCursors() diff --git a/src/app/editor.coffee b/src/app/editor.coffee index c58a49554..7092fddf0 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -431,6 +431,12 @@ class Editor extends View transact: (fn) -> @activeEditSession.transact(fn) commit: -> @activeEditSession.commit() abort: -> @activeEditSession.abort() + # Public: Creates a new fold between two row numbers. + # + # startRow - The row {Number} to start folding at + # endRow - The row {Number} to end the fold + # + # Returns the new {Fold}. createFold: (startRow, endRow) -> @activeEditSession.createFold(startRow, endRow) # Public: Folds the current row. foldCurrentRow: -> @activeEditSession.foldCurrentRow() @@ -636,7 +642,17 @@ class Editor extends View # # Returns a {Range}. rangeForBufferRow: (row) -> @getBuffer().rangeForRow(row) + # Public: Scans for text in the buffer, calling a function on each match. + # + # regex - A {RegExp} representing the text to find + # range - A {Range} in the buffer to search within + # iterator - A {Function} that's called on each match scanInBufferRange: (args...) -> @getBuffer().scanInRange(args...) + # Public: Scans for text in the buffer _backwards_, calling a function on each match. + # + # regex - A {RegExp} representing the text to find + # range - A {Range} in the buffer to search within + # iterator - A {Function} that's called on each match backwardsScanInBufferRange: (args...) -> @getBuffer().backwardsScanInRange(args...) # Internal: @@ -1090,6 +1106,7 @@ class Editor extends View appendToLinesView: (view) -> @overlayer.append(view) + # Internal: calculateDimensions: -> fragment = $('