text_action_context.js

The TextActionContext class (and what you’ll probably use more often, the textContext object) exposes numerous aspects of the global context object to Javascript manipulation without needing JSCocoa methods.

Exports

TextActionContext (class)

constructor()
No arguments accepted.
var TextActionContext = require('text_action_context').TextActionContext;
var textContext = new TextActionContext();
setSelections(ranges)
Void; accepts an array of ranges or range-like objects and uses them to set the selections in the active text window
setSelection(range)
Void; shortcut method to set a single selection and accepts a single range-like object as its parameter
getSelections()
Returns array of range-like objects that represent the current selected text in the active text window
getFirstSelection()
Returns a Range object; represents the first selection in the active text window
expandSelection(expandTo)
Void; shortcut to expand the current selection to the next expandTo item
// calls expandSelectionToItem()
textContext.expandSelection('Item');
expandSelectionToItem()
Void; expands the current selections in the window to the next greatest itemizer item
lineNumber(atIndex)
Returns int; the line number of the current line (if nothing is passed) or the line number for the given index
rangeForLine(lineNumber)
Returns a Range object; the range representing the current line in the active text context (if no lineNumber is passed in) or the line represented by lineNumber
getItemByRange(range)
Returns CEItem object; the smallest (deepest) item that fully encloses the given range. May be null if nothing is found.
getItemParentByRange(range)
Returns CEItem object; attempts to return the parent itemizer item (one step up from the deepest item)
itemFromRange(range, getParentIfMatch)
Returns CEItem object; shortcut to getItemByRange() if you pass false for getParentIfMatch, or if you pass true attempts to find the parent using getItemParentByRange()
lineEndingString()
Returns the line ending set as the default in Espresso’s preferences.
indentationString()
Returns the indentation string set as default in Espresso’s preferences (for example, a tab or four spaces)
xHTMLCloseString()
Returns the string used to close self-closing elements in XHTML (defined within TEA for Espresso’s preferences)

textContext (TextActionContext object)

For ease of use (and since you should never need more than one TextActionContext object), this module exports an initialized TextActionContext object called textContext.

var textContext = require('text_action_context').textContext;
Clicky Web Analytics