# Range

This object is used in various places to indicate a region within the editor. To better visualize how this works, imagine a rectangle. Each quadrant of the rectangle is analogus to a range, as ranges contain a starting row and starting column, and an ending row, and ending column.

### Constructors

- - new Range(Number startRow, Number startColumn, Number endRow, Number endColumn)

Creates a new `Range` object with the given starting and ending row and column points.

Creates a new `Range` object with the given starting and ending row and column points.

#### Arguments

startRow | Number | Required. The starting row
startColumn | Number | Required. The starting column
endRow | Number | Required. The ending row
endColumn | Number | Required. The ending column

### Methods

- - Range.clipRows(Number firstRow, Number lastRow)
  - - Range

Returns the part of the current `Range` that occurs within the boundaries of `firstRow` and `lastRow` as a new `Range` object.

Returns the part of the current `Range` that occurs within the boundaries of `firstRow` and `lastRow` as a new `Range` object.

#### Arguments

firstRow | Number | Required. The starting row
lastRow | Number | Required. The ending row

- - Range.clone()
  - - Range

Returns a duplicate of the calling range.

Returns a duplicate of the calling range.

- - Range.collapseRows()
  - - Range

Returns a range containing the starting and ending rows of the original range, but with a column value of `0`.

Returns a range containing the starting and ending rows of the original range, but with a column value of `0`.

- - Range.compare(Number row, Number column)
  - - Number

Checks the row and column points with the row and column points of the calling range.

Checks the row and column points with the row and column points of the calling range.

#### Arguments

row | Number | Required. A row point to compare with
column | Number | Required. A column point to compare with

- - Range.compareEnd(Number row, Number column)
  - - Number

Checks the row and column points with the row and column points of the calling range.

Checks the row and column points with the row and column points of the calling range.

#### Arguments

row | Number | Required. A row point to compare with
column | Number | Required. A column point to compare with

- - Range.compareInside(Number row, Number column)
  - - Number

Checks the row and column points with the row and column points of the calling range.

Checks the row and column points with the row and column points of the calling range.

#### Arguments

row | Number | Required. A row point to compare with
column | Number | Required. A column point to compare with

- - Range.comparePoint(Range p)
  - - Number

Checks the row and column points of `p` with the row and column points of the calling range.

Checks the row and column points of `p` with the row and column points of the calling range.

#### Arguments

p | Range | Required. A point to compare with

- - Range.compareRange(Range range)
  - - Number

Compares `this` range (A) with another range (B).

Compares `this` range (A) with another range (B).

#### Arguments

range | Range | Required. A range to compare with

- - Range.compareStart(Number row, Number column)
  - - Number

Checks the row and column points with the row and column points of the calling range.

Checks the row and column points with the row and column points of the calling range.

#### Arguments

row | Number | Required. A row point to compare with
column | Number | Required. A column point to compare with

- - Range.contains(Number row, Number column)
  - - Boolean

Returns `true` if the `row` and `column` provided are within the given range. This can better be expressed as returning `true` if:

       this.start.row <= row <= this.end.row &&
       this.start.column <= column <= this.end.column

Returns `true` if the `row` and `column` provided are within the given range. This can better be expressed as returning `true` if:

       this.start.row <= row <= this.end.row &&
       this.start.column <= column <= this.end.column

#### Arguments

row | Number | Required. A row to check for
column | Number | Required. A column to check for

- - Range.containsRange(Range range)
  - - Boolean

Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range.

Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range.

#### Arguments

range | Range | Required. A range to compare with

- - Range.extend(Number row, Number column)
  - - Range

Changes the row and column points for the calling range for both the starting and ending points.

Changes the row and column points for the calling range for both the starting and ending points.

#### Arguments

row | Number | Required. A new row to extend to
column | Number | Required. A new column to extend to

- - Range.fromPoints(Range start, Range end)
  - - Range

Creates and returns a new `Range` based on the row and column of the given parameters.

Creates and returns a new `Range` based on the row and column of the given parameters.

#### Arguments

start | Range | Required. A starting point to use
end | Range | Required. An ending point to use

- - Range.inside(Number row, Number column)
  - - Boolean

Returns `true` if the `row` and `column` are within the given range.

Returns `true` if the `row` and `column` are within the given range.

#### Arguments

row | Number | Required. A row point to compare with
column | Number | Required. A column point to compare with

- - Range.insideEnd(Number row, Number column)
  - - Boolean

Returns `true` if the `row` and `column` are within the given range's ending points.

Returns `true` if the `row` and `column` are within the given range's ending points.

#### Arguments

row | Number | Required. A row point to compare with
column | Number | Required. A column point to compare with

- - Range.insideStart(Number row, Number column)
  - - Boolean

Returns `true` if the `row` and `column` are within the given range's starting points.

Returns `true` if the `row` and `column` are within the given range's starting points.

#### Arguments

row | Number | Required. A row point to compare with
column | Number | Required. A column point to compare with

- - Range.intersects(Range range)
  - - Boolean

Returns `true` if passed in `range` intersects with the one calling this method.

Returns `true` if passed in `range` intersects with the one calling this method.

#### Arguments

range | Range | Required. A range to compare with

- - Range.isEmpty()
  - Undocumented

- - Range.isEnd(Number row, Number column)
  - - Boolean

Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`.

Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`.

#### Arguments

row | Number | Required. A row point to compare with
column | Number | Required. A column point to compare with

- - Range.isEqual(Range range)
  - - Boolean

Returns `true` if and only if the starting row and column, and ending row and column, are equivalent to those given by `range`.

Returns `true` if and only if the starting row and column, and ending row and column, are equivalent to those given by `range`.

#### Arguments

range | Range | Required. A range to check against

- - Range.isMultiLine()
  - - Boolean

Returns `true` if the range spans across multiple lines.

Returns `true` if the range spans across multiple lines.

- - Range.isStart(Number row, Number column)
  - - Boolean

Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`.

Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`.

#### Arguments

row | Number | Required. A row point to compare with
column | Number | Required. A column point to compare with

- - Range.setEnd(Number row, Number column)

Sets the starting row and column for the range.

Sets the starting row and column for the range.

#### Arguments

row | Number | Required. A row point to set
column | Number | Required. A column point to set

- - Range.setStart(Number row, Number column)

Sets the starting row and column for the range.

Sets the starting row and column for the range.

#### Arguments

row | Number | Required. A row point to set
column | Number | Required. A column point to set

- - Range.toScreenRange(EditSession session)
  - - Range

Given the current `Range`, this function converts those starting and ending points into screen positions, and then returns a new `Range` object.

Given the current `Range`, this function converts those starting and ending points into screen positions, and then returns a new `Range` object.

#### Arguments

session | EditSession | Required. The `EditSession` to retrieve coordinates from

- - Range.toString()
  - - String

Returns a string containing the range's row and column information, given like this:

       [start.row/start.column] -> [end.row/end.column]

Returns a string containing the range's row and column information, given like this:

       [start.row/start.column] -> [end.row/end.column]