Hex Editor - Binary File Editing Software for Windows
Download Hex Editor Neo Hide this button

IDocument Interface

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;
}
// This interface is not available in managed environment
// This interface is not available in native environment

IDocument Properties

name

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:

TypeName
File, encoded fileFull path to the file.
Volume, physical diskEither the full path to device, or device's friendly name.

size

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;

views

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]);

IDocument Methods

saveAsync

saveAsync(forceBackup = false): Promise<void>;
// This method is not available in managed environment
// This method is not available in native environment
forceBackup
Set to true 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

saveAsAsync(path: string, format?: string): Promise<void>;
// This method is not available in managed environment
// This method is not available in native environment
path
A full path to the file where to save a document.
format
An optional format in which to save a file. If omitted, uses the original document format.

A 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:

FormatDescription
"binary"Save as a normal file.
"intel-hex"Save as Intel Hex encoded file.
"motorola-hex"Save as Motorola S-Records encoded file.

undo

undo(steps = 1): void;
// This method is not available in managed environment
// This method is not available in native environment
steps
The number of steps to undo.

Undoes the given number of steps in the document's operation history.

redo

redo(steps = 1): void;
// This method is not available in managed environment
// This method is not available in native environment
steps
The number of steps to redo.

Redoes (repeats) the given number of steps in the document's operation history.

cancel

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

close(closeMode = ${CloseMode}.Prompt): boolean;
// This method is not available in managed environment
// This method is not available in native environment
closeMode
An optional closing mode.

true 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:

ValueDescription
PromptAsk the user to save changes. The user can choose “yes”, “no” or “cancel”. In the latter case, close returns false.
SaveSave unsaved changes.
DiscardDiscard unsaved changes.