Module: ko/editor

The editor SDK

Author:
  • ActiveState
License:
  • Mozilla Public License v. 2.0

Methods


require("ko/editor")._posFormat(positions, format)

Convert the given position(s) into the given format, regardless of what format the input is in

Parameters:
Name Type Description
positions Array | Object | Int

Either a single position or an array of positions

format String
Returns:

Returns a single position or an array of positions if the input was an array

Type
Array | Object | Int

require("ko/editor")._posToAbsolute(pos)

Converts a relative position to an absolute position

Parameters:
Name Type Description
pos Object

{line, ch}

Returns:
Type
Int

require("ko/editor")._posToRelative(abs)

Converts an absolute position to a relative position

Parameters:
Name Type Description
abs Int
Returns:

{line, ch}

Type
Object

require("ko/editor").available()

Checks whether scintilla is available for the current editor

Returns:
Type
Boolean

require("ko/editor").bookmarkExists(line)

Check if there is already a bookmark set on a given line

Parameters:
Name Type Description
line number

number, defaults to current line


require("ko/editor").clearSelection()

Clear the current selection

Returns:
Type
Void

require("ko/editor").copy()

Copy current selection to clipboard

Returns:
Type
Void

require("ko/editor").cut()

Cut current selection to clipboard

Returns:
Type
Void

require("ko/editor").defaultTextHeight()

Get the default line height (all lines are currently the same height)

Returns:

Height in pixels

Type
Int

require("ko/editor").delCharAfter()

Delete the character after the cursor.


require("ko/editor").delCharBefore()

Delete the character before the cursor.


require("ko/editor").deleteLine()

Deletes the whole line under the cursor, including newline at the end


require("ko/editor").deleteRange(start, length)

Delete the given range of characters

Parameters:
Name Type Description
start Object | Int

Position

length Int
Returns:
Type
Void

require("ko/editor").delLineLeft()

Delete the part of the line before the cursor


require("ko/editor").delLineRight()

Delete the part of the line after the cursor


require("ko/editor").delWordAfter()

Delete up to the end of the word after the cursor.


require("ko/editor").delWordBefore()

Delete up to the start of the word before the cursor.


require("ko/editor").editor(sci, scm)

Returns the editor SDK for a custom scintilla instance

Parameters:
Name Type Description
sci Object

Scintilla

scm Object

Scimoz

Returns:
Type
sdkEditor

require("ko/editor").emptyUndoBuffer()

Empty the undo buffer.

Returns:
Type
Void

require("ko/editor").findString(text, startPos, maxResults)

Find a string in the current buffer

Parameters:
Name Type Description
text String

String of text to find

startPos Object | Int

Start position (optional)

maxResults Int

Maximum number of results, -1 for unlimited (optional)

Returns:

Returns an array of relative positions

Type
Array

require("ko/editor").focus()

Set focus on the editor


require("ko/editor").getAllMarks(type)

Get all registered bookmarks

Parameters:
Name Type Description
type Long

See legacy.markers

Returns:
Type
Array

require("ko/editor").getBookmarkLineFromHandle(markerid,)

Retrieve the line a bookmark is at by handle

Parameters:
Name Type Description
markerid, number

Default is current line.

Returns:

line number

Type
number

require("ko/editor").getColumnNumber()

Get the current column (character | ch) number

Returns:
Type
Int

require("ko/editor").getCursorPosition(format)

Get the position of the cursor

Parameters:
Name Type Description
format String

absolute | relative (default)

Returns:

Absolute: Int, Relative: {line, ch, absolute}

Type
Object | Int

require("ko/editor").getCursorWindowPosition()

Get the position of the cursor relative to the Komodo window

Returns:

{x: .., y: ..}

Type
Object

require("ko/editor").getLanguage()

Get the current programming language used

Returns:
Type
string

require("ko/editor").getLength()

Get the character length of the current buffer

Returns:
Type
Int

require("ko/editor").getLine(line)

Get the contents of the given line

Parameters:
Name Type Description
line Int | Undefined
Returns:
Type
String

require("ko/editor").getLineEndPos()

Get the given line end position

Returns:
Type
Int

require("ko/editor").getLineFromMousePosition(x, y)

Get the line number from the given x/y position

Parameters:
Name Type Description
x int

relative to scimoz view

y int

relative to scimoz view

Returns:

Line number

Type
int

require("ko/editor").getLineNumber(position)

Get the current line number

Parameters:
Name Type Description
position Null | Object | Int

relative/absolute position to look from, leave empty to use current cursor position.

Returns:
Type
Int

require("ko/editor").getLineSize(line)

Get the size of the line

Parameters:
Name Type Description
line Int
Returns:
Type
Int

require("ko/editor").getLineStartPos()

Get the given line start position

Returns:
Type
Int

require("ko/editor").getMarginFromMousePosition(x, y)

Get margin number relative to x/y position

Parameters:
Name Type Description
x int

relative to scimoz view

y int

relative to scimoz view

Returns:

Margin number, see ISciMoz.template.idl

Type
int

require("ko/editor").getRange(from, to)

Retrieve the given range of text

Parameters:
Name Type Description
from Object | Int

Absolute or relative position

to Object | Int

Absolute or relative position

Returns:
Type
String

require("ko/editor").getSelection()

Get the currently selected text

Returns:
Type
String

require("ko/editor").getSelectionRange(format)

Get the current selection range

Parameters:
Name Type Description
format String

absolute | relative (default)

Returns:

{start: formattedPost, end: formattedPos}

Type
Object

require("ko/editor").getValue()

Get the current buffer's content

Returns:
Type
String

require("ko/editor").getWindowPosition()

Get the window position of the given character

Returns:

{x: .., y: ..}

Type
Object

require("ko/editor").getWord(pos, match)

Get word to the left of the given position

Parameters:
Name Type Description
pos Null | Int | Object | Regexp

Absolute or relative position, if value is regex then this will be used as the match. Leave empty to use current cursor position.

match Null | RegExp

The regex to match the word agains


require("ko/editor").goCharLeft()

Move the cursor one character left, going to the previous line when hitting the start of line.


require("ko/editor").goCharRight()

Move the cursor one character right, going to the next line when hitting the end of line.


require("ko/editor").goColumnLeft()

Move the cursor one character left, but don't cross line boundaries.


require("ko/editor").goColumnRight()

Move the cursor one character right, don't cross line boundaries.


require("ko/editor").goDocEnd()

Move the cursor to the end of the document.


require("ko/editor").goDocStart()

Move the cursor to the start of the document


require("ko/editor").goLineDown()

Move down one line.


require("ko/editor").goLineEnd()

Move the cursor to the end of the line.


require("ko/editor").goLineLeft()

Move the cursor to the left side of the visual line it is on. If this line is wrapped, that may not be the start of the line.


require("ko/editor").goLineRight()

Move the cursor to the right side of the visual line it is on.


require("ko/editor").goLineStart()

Move the cursor to the start of the line.


require("ko/editor").goLineStartSmart()

Move to the start of the text on the line, or if we are already there, to the actual start of the line (including whitespace).


require("ko/editor").goLineUp()

Move the cursor up one line.


require("ko/editor").goPageDown()

Move the cursor down one screen, and scroll down by the same distance.


require("ko/editor").goPageUp()

Move the cursor up one screen, and scroll up by the same distance.


require("ko/editor").gotoLine((number))

Move cursor to a specific line

Parameters:
Name Type Description
(number)

line number


require("ko/editor").goWordLeft()

Move the cursor to the start of the previous word.


require("ko/editor").goWordRight()

Move the cursor to the end of the next word.


require("ko/editor").insert(text)

Insert text at the current cursor position

Any existing selections will be replaced with the given text

Parameters:
Name Type Description
text String
Returns:
Type
Void

require("ko/editor").lineCount()

Get the number of lines in the current buffer

Returns:
Type
Int

require("ko/editor").paste()

Replace current selection with the clipboard contents

Returns:
Type
Void

require("ko/editor").replaceSelection(replacement, select)

Replace the current selection with the given text

Parameters:
Name Type Description
replacement String
select Object

What to select after insertion

                           - around: select inserted text
                           - start: set cursor to start of insertion
                           - {undefined}: set cursor at end of insertion
Returns:
Type
Void

require("ko/editor").selectAll()

Select all the text in the buffer

Returns:
Type
Void

require("ko/editor").setBookmark(line, Optional)

Create a bookmark at a given line if one doesn't exist.

Parameters:
Name Type Description
line number

number. Default is current line. Line is decremented when passed in.

Optional number

type of bookmark. See legacy.markers.

Returns:

ID of marker according to Scimoz

Type
number

require("ko/editor").setCursor(pos)

Set the position of the cursor

Parameters:
Name Type Description
pos Int | Object

relative or absolute position

Returns:
Type
Void

require("ko/editor").setSelection(start, end)

Set the selection

Parameters:
Name Type Description
start Object

{line, ch}

end Object

{line, ch}

Returns:
Type
Void

require("ko/editor").setValue(value)

Set the current buffer's content

Parameters:
Name Type Description
value String
Returns:
Type
Void

require("ko/editor").toggleBookmark(line)

Toggle a bookmark on a given line

Parameters:
Name Type Description
line number

number. default is current line Line number is decremented by one if passed in to match scimoz lines starting from 0.


require("ko/editor").undo()

Undo the last action

Returns:
Type
Void

require("ko/editor").unsetBookmarkByHandle(A)

Unset breakpoint by Marker handle

Parameters:
Name Type Description
A number

marker handle


require("ko/editor").unsetBookmarkByLine(line)

Remove a bookmark at a given line

Parameters:
Name Type Description
line number

number. default is current line Note, if using this