interface IDocument {
// Properties
readonly ${name}: string;
${size}: number;
readonly ${views}: ${IDocumentView}[];
// Methods
${saveAsync}(forceBackup = false): Promise<void>;
${saveAsAsync}(path: string, format?: string): Promise<void>;
${undo}(steps = 1): void;
${redo}(steps = 1): void;
${cancel}(): void;
${close}(closeMode = ${CloseMode}.Prompt): boolean;
// Low-Level Data Access
${read}(offset: number, size: number): Uint8Array;
${write}(data: ${IPattern}, offset: number, fillSize?: number): void;
${insert}(data: ${IPattern}, offset: number, insertSize?: number): void;
${delete}(offset: number, size?: number): void;
${deleteAsync}(selection: ${ISelection}): Promise<void>;
}
// This interface is not available in managed environment
// This interface is not available in native environment
readonly name: string;
// This property is not available in managed environment
// This property is not available in native environment
Returns current document's name. Maybe empty if the document was created using newDocument method. The following information is returned, depending on document's type:
| Type | Name |
|---|---|
| File, encoded file | Full path to the file. |
| Volume, physical disk | Either the full path to device, or device's friendly name. |
size: number;
// This property is not available in managed environment
// This property is not available in native environment
This property returns the current document size. You can assign a new value to this property to change the size of the document. This operation creates a record in document operation history.
var document = newDocument();
document.size = 100;
readonly views: ${IDocumentView}[];
// This property is not available in managed environment
// This property is not available in native environment
This property holds an array of all document views.
var document = newDocument();
activate(document.views[0]);
saveAsync(forceBackup = false): Promise<void>;
// This method is not available in managed environment
// This method is not available in native environment
forceBackuptrue to force creation of a backup.A promise object that gets completed when save operation finishes. If save operation fails, promise is completed with an exception.
Saves the changes made to the document. If the document does not have a name yet, a user is prompted to select the target.
saveAsAsync(path: string, format?: string): Promise<void>;
// This method is not available in managed environment
// This method is not available in native environment
pathformatA promise object that gets completed when save operation finishes. If save operation fails, promise is completed with an exception.
Saves a copy of the document to the specified file. Optional format parameter may override the original document format:
| Format | Description |
|---|---|
"binary" | Save as a normal file. |
"intel-hex" | Save as Intel Hex encoded file. |
"motorola-hex" | Save as Motorola S-Records encoded file. |
undo(steps = 1): void;
// This method is not available in managed environment
// This method is not available in native environment
stepsUndoes the given number of steps in the document's operation history.
redo(steps = 1): void;
// This method is not available in managed environment
// This method is not available in native environment
stepsRedoes (repeats) the given number of steps in the document's operation history.
cancel(): void;
// This method is not available in managed environment
// This method is not available in native environment
Cancel an ongoing asynchronous operation. If an asynchronous operation is actually running, it is completed with an exception.
close(closeMode = ${CloseMode}.Prompt): boolean;
// This method is not available in managed environment
// This method is not available in native environment
closeModetrue if the document has been closed successfully, false otherwise.
Closes the document and all its document views. Optional closeMode parameter is used if the document has unsaved changes:
| Value | Description |
|---|---|
Prompt | Ask the user to save changes. The user can choose “yes”, “no” or “cancel”. In the latter case, close returns false. |
Save | Save unsaved changes. |
Discard | Discard unsaved changes. |
read(offset: number, size: number): Uint8Array;
// This method is not available in managed environment
// This method is not available in native environment
offsetsizeReads document data into Uint8Array object.
write(data: ${IPattern}, offset: number, fillSize?: number): void;
// This method is not available in managed environment
// This method is not available in native environment
dataoffsetfillSizeWrite (or fill) a given pattern to the specific location in a document.
insert(data: ${IPattern}, offset: number, insertSize?: number): void;
// This method is not available in managed environment
// This method is not available in native environment
dataoffsetinsertSizeInsert a given pattern to the specific location in a document, shifting the remaining data to the right.
delete(offset: number, size?: number): void;
// This method is not available in managed environment
// This method is not available in native environment
offsetsizeDelete a given range from the document, shifting the remaining data to the left.
deleteAsync(selection: ${ISelection}): Promise<void>;
// This method is not available in managed environment
// This method is not available in native environment
selectionDelete given ranges from the document, shifting the remaining data to the left.