Prototype for TextDocument.Content objects
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;
none.
none.
ECMerge 2.1
TextDocument.Content let you access the content of a particular pane. When viewed, it allows also to modify that content.
Property | Description |
length | Integer. length in bytes of the text in this content (characters are encoded in UTF8) |
get_text
line_from_position
position_from_line
set_text
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");
function set_text (selection, text)
returns the position after the last inserted
character
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
TextDocument.Content object.
ECMerge 2.1
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.
see TextDocument.transaction examples.
TextDocument.Content object
function get_text (selection)
returns a String.
selection. TextDocument.Selection object. Selection from which the text is requested
TextDocument.Content object.
ECMerge 2.1
Returns the text covered by the selection.
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));
TextDocument.Content object, TextDocument.Selection object
function line_from_position (position)
returns an Integer
position. Integer. Position (in bytes) in the text document. Text document are represented as UTF8 characters.
TextDocument.Content object.
ECMerge 2.1
Returns the line containing the given position. Positions as well as lines are zero-based.
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));
TextDocument.Content object, TextDocument.Content.position_from_line method
function position_from_line (line)
returns an Integer
line. Integer. Line number from which the position is requested
TextDocument.Content object.
ECMerge 2.1
Returns position of the first character of the specified line. Positions as well as lines are zero-based.
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)));
TextDocument.Content object, TextDocument.Content.line_from_position method