Ellié Computing Home Page
My Shopping Cart

Your shopping cart is empty

Display Cart

Call us at +1 586 62 ELLIE / +1 586 62 35543 Office Closed
sales@elliecomputing.com - Contact us


TextDocument.Content object

 

 

Prototype for TextDocument.Content objects

Syntax

You cannot create these objects, you can only get access to them inside an TextDocument.

var doc = current_frame.coordinator.document; // with an activate text view
var left_content = doc.content.left;

Parameters

 none.

Property Of

none.

Implemented In

ECMerge 2.1

Description

 TextDocument.Content let you access the content of a particular pane. When viewed, it allows also to modify that content.

Properties

Property Description
length Integer. length in bytes of the text in this content (characters are encoded in UTF8)

 

Methods

get_text
line_from_position
position_from_line
set_text

Examples

Example 1.

Obtaining the length of a content.

var doc = current_frame.coordinator.document; // with an active text frame
var left_content = doc.content.left;
var sel = new TextDocument.Selection (left_content);
alert ("There are "+ sel.end + " characters in the left content and "+left_content.line_from_position(sel.end)+" lines");

See Also 

  TextDocument object.

Method set_text

Syntax

function set_text (selection, text)
returns the position after the last inserted character

Parameters

selection. TextDocument.Selection object. Selection to be replaced, maybe empty, in this case, the selection.range.start is used as the insertion position.
text. String. Replacement text

Method Of

TextDocument.Content object.

Implemented In

ECMerge 2.1

Description

Replaces the selection with given text.
Currently, this function can be used only on the "result" side content for merges, and "left" for a text editor. As well, it can be used only when the document is viewed.

Examples

see TextDocument.transaction examples.

See Also 

TextDocument.Content object

Method get_text

Syntax

function get_text (selection)
returns a String.

Parameters

selection. TextDocument.Selection object. Selection from which the text is requested

Method Of

TextDocument.Content object.

Implemented In

ECMerge 2.1

Description

Returns the text covered by the selection.

Examples

Example 1.

Retrieves the 100 th first characters of the right side and logs them:

var doc = current_frame.coordinator.document; // with an active text frame
log (doc.content.left.get_text (LinearRange (0, 100));

See Also 

  TextDocument.Content object, TextDocument.Selection object

Method line_from_position

Syntax

function line_from_position (position)
returns an Integer

Parameters

position. Integer. Position (in bytes) in the text document. Text document are represented as UTF8 characters.

Method Of

TextDocument.Content object.

Implemented In

ECMerge 2.1

Description

Returns the line containing the given position. Positions as well as lines are zero-based.

Examples

Example 1.

Displays a message box with the line of the current position.

var doc = current_frame.coordinator.document;
var current_view = current_frame.coordinator.current_view;

alert (doc.content[current_view.role].line_from_position(current_view.clone_selection().range.start));

See Also 

  TextDocument.Content object, TextDocument.Content.position_from_line method

 

Method position_from_line

Syntax

function position_from_line (line)
returns an Integer

Parameters

line. Integer. Line number from which the position is requested

Method Of

TextDocument.Content object.

Implemented In

ECMerge 2.1

Description

Returns position of the first character of the specified line. Positions as well as lines are zero-based.

Examples

Example 1.

Displays a message box with the position of the current line.

var current_view = current_frame.coordinator.current_view;
var doc_content = current_frame.coordinator.document.content[current_view.role];

alert (doc_content.position_from_line(doc_content.line_from_position(current_view.clone_selection().range.start)));

See Also 

  TextDocument.Content object, TextDocument.Content.line_from_position method