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 object

 

 

Prototype for TextDocument objects

Syntax

To create a TextDocument do this:

var parameters = new Document.Parameters ( );
parameters.document_type = "texts";

var doc = new Document (parameters, "view");

Parameters

 none. Use Document constructor.

Property Of

none.

Implemented In

ECMerge 2.1

Description

TextDocument objects are the documents which do text comparisons and edition. They provide ways to modify text and give information about loaded comparisons and files.
When the graphical user interface is present, they allow you to alter current state of editable views and resolve conflicts. When no view is opened on a text document, only read-only operations are available, these operations let you study the files, their comparison and produce an output by yourself.

Properties

Property Description
conflicts Array of TextDocument.Conflict. Collection of the conflicts.
content Array of TextDocument.Content. Read-Only. Collection of the contents loaded from the data sources
information See description in Document object.

Properties of information[side]

Property Description
syntax_colouring_language String. Read-only. Indicates which language is actually used to colour the current text. Use the option " typed.texts.display.language" in the OptionsSet to force a particular language.


 

 

Methods

transaction
differences

Examples

Example 1.

Check that a document is a text document, and displays the number of conflicts

if (doc instanceof TextDocument)
    alert ("document contains "+ doc.conflicts.length + "conflict(s)");

See Also 

  TextDocument.Content object, TextDocument.Conflict object

Method transaction

Syntax

function transaction ( f )

Parameters

f. Function. f is executed within an edition transaction.

Method Of

TextDocument object.

Implemented In

ECMerge 2.1

Description

 This function is used when you want to call many times "set_text" on a TextDocument.Content or solve many conflicts (through resolution macros) and have all the commands undone at once.

Examples

Example 1.

Appends many times a text to the current view:

function append_text (content, text)
{
    content.set_text (
        new TextDocument.Selection(content,
            LinearRange(content.length, 0) ),
        text);
}

var doc = current_frame.coordinator.document;
var updated_side = doc.parameters.gui_type.substring(0,5) == 'merge' ? 'result' : 'left';
var content = doc.content[updated_side];
var view = current_frame.coordinator.current_view;

doc.transaction (function() {
    for (var i=0; i<1000; ++i)
        append_text (content, "hello world for "+ i +"th time!\n");
    } );

See Also 

TextDocument object, TextDocument.Content.set_text method.

Method differences

Syntax

function differences ( couple )
returns an Array of TextDocument.Difference object.

Parameters

couple. Side Couple string. Couple for which the differences are requested. In 2-way, only "left-right" is legal.

Method Of

TextDocument object.

Implemented In

ECMerge 2.1

Description

Returns a Array of differences describing the left side in the given couple was modified with respect to the other side of the couple.

Examples

Example 1.

Displays a message box telling whether the two sides are identical or not:

var doc = current_frame.coordinator.document;
alert ( "Left and right sides are "+ (doc.differences ("left-right").length == 0 ? "identical" : "different") );

See Also 

TextDocument object,  TextDocument.Difference object