返回介绍

Selection

发布于 2019-12-03 22:56:32 字数 24763 浏览 1070 评论 0 收藏 0

Contains the cursor position and the text selection of an edit session.

The row/columns used in the selection are in document coordinates representing the coordinates as they appear in the document before applying soft wrap and folding.

Constructors

Creates a new Selection object.

sessionEditSessionRequired. The session to use

Events

  • Selection.on("changeCursor", function())

Emitted when the cursor position changes.

  • Selection.on("changeSelection", function())

Emitted when the cursor selection changes.

Methods

Adds a range to a selection by entering multiselect mode, if necessary.

rangeRangeRequired. The new range to add
$blockChangeEventsBooleanRequired. Whether or not to block changing events
  • Selection.clearSelection()

Empties the selection (by de-selecting it). This function also emits the 'changeSelection' event.

  • Selection.detach()
  • Undocumented
  • Selection.fromOrientedRange()
  • Undocumented
  • Selection.getAllRanges()
  • 返回值: Array

Returns a concatenation of all the ranges.

  • Selection.getCursor()
  • 返回值: Number

Gets the current position of the cursor.

  • Selection.getLineRange()
  • Undocumented
  • Selection.getRange()
  • 返回值: Range

Returns the Range for the selected text.

  • Selection.getSelectionAnchor()
  • 返回值: Object

Returns an object containing the row and column of the calling selection anchor.

  • Selection.getSelectionLead()
  • 返回值: Object

Returns an object containing the row and column of the calling selection lead.

Moves the selection to highlight the entire word.

rowObjectRequired.
columnObjectRequired.
  • Selection.isBackwards()
  • 返回值: Boolean

Returns true if the selection is going backwards in the document.

  • Selection.isEmpty()
  • 返回值: Boolean

Returns true if the selection is empty.

  • Selection.isMultiLine()
  • 返回值: Boolean

Returns true if the selection is a multi-line.

  • Selection.mergeOverlappingRanges()

Merges overlapping ranges ensuring consistency after changes

Moves the cursor to position indicated by the parameters. Negative numbers move the cursor backwards in the document.

rowsNumberRequired. The number of rows to move by
charsNumberRequired. The number of characters to move by
  • Selection.moveCursorDown()

Moves the cursor down one row.

  • Selection.moveCursorFileEnd()

Moves the cursor to the end of the file.

  • Selection.moveCursorFileStart()

Moves the cursor to the start of the file.

  • Selection.moveCursorLeft()

Moves the cursor left one column.

  • Selection.moveCursorLineEnd()

Moves the cursor to the end of the line.

  • Selection.moveCursorLineStart()

Moves the cursor to the start of the line.

  • Selection.moveCursorLongWordLeft()

Moves the cursor to the word on the left.

  • Selection.moveCursorLongWordRight()

Moves the cursor to the word on the right.

  • Selection.moveCursorRight()

Moves the cursor right one column.

  • Selection.moveCursorShortWordLeft()
  • Undocumented
  • Selection.moveCursorShortWordRight()
  • Undocumented

Moves the cursor to the row and column provided. If preventUpdateDesiredColumn is true, then the cursor stays in the same column position as its original point.

rowNumberRequired. The row to move to
columnNumberRequired. The column to move to
keepDesiredColumnBooleanRequired. If true, the cursor move does not respect the previous column
  • Selection.moveCursorToPosition(Object position)

Moves the selection to the position indicated by its row and column.

positionObjectRequired. The position to move to

Moves the cursor to the screen position indicated by row and column. If preventUpdateDesiredColumn is true, then the cursor stays in the same column position as its original point.

rowNumberRequired. The row to move to
columnNumberRequired. The column to move to
keepDesiredColumnBooleanRequired. If true, the cursor move does not respect the previous column
  • Selection.moveCursorUp()

Moves the cursor up one row.

  • Selection.moveCursorWordLeft()
  • Undocumented
  • Selection.moveCursorWordRight()
  • Undocumented

Gets list of ranges composing rectangular block on the screen

screenCursorCursorRequired. The cursor to use
screenAnchorAnchorRequired. The anchor to use
includeEmptyLinesBooleanRequired. If true, this includes ranges inside the block which are empty due to clipping
  • Selection.selectAll()

Selects all the text in the document.

  • Selection.selectAWord()

Selects a word, including its right whitespace.

  • Selection.selectDown()

Moves the selection down one row.

  • Selection.selectFileEnd()

Moves the selection to the end of the file.

  • Selection.selectFileStart()

Moves the selection to the start of the file.

  • Selection.selectLeft()

Moves the selection left one column.

  • Selection.selectLine()

Selects the entire line.

  • Selection.selectLineEnd()

Moves the selection to the end of the current line.

  • Selection.selectLineStart()

Moves the selection to the beginning of the current line.

  • Selection.selectRight()

Moves the selection right one column.

Moves the selection cursor to the indicated row and column.

rowNumberRequired. The row to select to
columnNumberRequired. The column to select to
  • Selection.selectToPosition(Object pos)

Moves the selection cursor to the row and column indicated by pos.

posObjectRequired. An object containing the row and column
  • Selection.selectUp()

Moves the selection up one row.

  • Selection.selectWord()

Selects an entire word boundary.

  • Selection.selectWordLeft()

Moves the selection to the first word on the left.

  • Selection.selectWordRight()

Moves the selection to the first word on the right.

Sets the row and column position of the anchor. This function also emits the 'changeSelection' event.

rowNumberRequired. The new row
columnNumberRequired. The new column

Sets the selection to the provided range.

rangeRangeRequired. The range of text to select
reverseBooleanRequired. Indicates if the range should go backwards (true) or not
  • Selection.shiftSelection(Number columns)

Shifts the selection up (or down, if isBackwards() is true) the given number of columns.

columnsNumberRequired. The number of columns to shift by
  • Selection.splitIntoLines()

Splits all the ranges into lines.

  • Selection.substractPoint(Range pos)

Removes a Range containing pos (if it exists).

posRangeRequired. The position to remove, as a {row, column} object
  • Selection.toggleBlockSelection()
  • Undocumented
  • Selection.toOrientedRange()
  • Undocumented
  • Selection.toSingleRange()
  • Undocumented

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文