Help Topics

Plugin API

The functions available in the plugin api are exported by the EditPlug program and imported by your plugin DLL.

If you are using C/C++, make a EditPlugAPI.h header file with the functions you need to import (we will offer one for download a some point) or just declare the functions as extern "C" in your C files and use them. If you are using Delphi, use the EditPlugAPI.pas file which contains the functions available in the API.

API Functions


procedure epSetActiveEdSelText(p: pchar); cdecl;
Sets the active editor's selection text to parameter p.

Above is a delphi example. What do you place in header file, or your program if using C++?
extern "C" VOID __cdecl epSetActiveEdSelText(char* p);
In plain C you would not need extern "C", just use extern.

function epGetActiveEdSelLen: longint; cdecl;
Returns the length of the active editor's selected text. Returns -1 if no active editor exists.

function epGetActiveEdTextLen: longint; cdecl;
Returns the length of the active editor's text. Returns -1 if no active editor exists.

function epGetActiveEdSelText(buf: pchar; len: longint): longint; cdecl;
Fills buf with the active editor's selection text and returns number of characters copied. Make sure to allocate enough space for buf. len is the length of the string buffer allocated by caller (include null char in length as +1). Use the related epGetActiveEdSelLen function to obtain the space to allocate in your buffer.

function epGetActiveEdText(buf: pchar; len: longint): longint; cdecl;
Fills buf with the active editor's text and returns number of characters copied. Make sure to allocate enough space for buf. len is the length of the string buffer allocated by caller (include null char in length as +1). Use the related epGetActiveEdTextLen function to obtain the space to allocate in your buffer.

function epSetActiveEdSelStart(pos: longint): longbool; cdecl;
Sets the active editor selstart position, returns true if successful.

function epSetActiveEdSelEnd(pos: longint): longbool; cdecl;
Sets the active editor selend position, returns true if successful.

function epGetActiveEdSelStart: longint; cdecl;
Returns the active editor selstart position. Returns -1 if no active editor exists.

function epGetActiveEdSelEnd: longint; cdecl;
Returns the active editor selend position. Returns -1 if no active editor exists.

function epGetEdCount: longint; cdecl;
Returns the number of editors (tabs) open.

function epGetEdIndex: longint; cdecl;
Returns the current editor tab index.

function epSetActiveEd(idx: longint): longbool; cdecl;
Sets the active editor to the specified tab index. Returns true if successful.

function epSetEdSelText(idx: longint; txt: pchar): longbool; cdecl;
Sets the selection text to the editor specified by its tab index. Returns true if successful.

function epSetEdText(idx: longint; txt: pchar): longbool; cdecl;
Sets the entire text to the editor specified by its tab index. Returns true if successful.

procedure epNewEd; cdecl;
Opens a new editor.

function epGetEdFileName(idx: longint; buf: pchar; len: longint): longint; cdecl;
Fills buf with the editor's file name and returns number of characters copied. Make sure to allocate enough space for buf. Idx is the tabindex of the editor. len is the length of the string buffer allocated by caller (include null char in length as +1). Use the related epGetEdFileNameLen function to obtain the space to allocate in your buffer.

function epGetEdFileNameLen(idx: longint): longint; cdecl;
Returns the length of the filename if the editor specified by its tab index. Returns -1 if the specified index was invalid.

procedure epActiveEdRemoveSel; cdecl;
Removes any selection in the active editor.

procedure epSetParentToMainWin(child: HWND); cdecl;
Sets the parent of child to the main EditPlug window.

function epGetActiveEdFileNameLen: longint; cdecl;
Returns the active editor file name length. Returns -1 if no active editor exists.

function epGetActiveEdFileName(buf: pchar; len: longint): longint; cdecl;
Fills buf with the active editor's file name and returns number of characters copied. Make sure to allocate enough space for buf. len is the length of the string buffer allocated by caller (include null char in length as +1). Use the related epGetActiveEdTextLen function to obtain the space to allocate in your buffer.

procedure epAddSearchResult(fname: pchar; s: pchar; coord: TBufCoord; len: longint); cdecl;
Adds a line to the search results pane. Coord is the char and line number (x, y). len is the length of the line being added.

procedure epClearSearchResults; cdecl;
Clears any results in the search result pane.

procedure epClearOutputConsole(freeobjects: longbool); cdecl;
Clears any lines in the output console pane.

procedure epAddOutputConsoleMsg(s: pchar; IgnoreForParsing: longbool); cdecl;
Adds a line to the output console pane. If ignore for parsing is true, then the line will not be parsed for char/line number.

procedure epGetMainWinPos(out rslt: TWinPos); cdecl;
Fills rslt with the window position of the main EditPlug window.

function epGetMainWinHandle: HWND; cdecl;
Returns the main EditPlug window handle.

function epFilesModified: longbool; cdecl;
Returns true if any open files are modified.

function epFileModified(idx: longint): longbool; cdecl;
Returns true if the file is modified in the editor specified by the tab index.

procedure epSearchResultsBeginUpdate; cdecl;
Begin updating the search results. For optimizing GUI calls to the search results listbox.

procedure epSearchResultsEndUpdate; cdecl;
End updating the search results.

procedure epAppProcessMessages; cdecl;
Process application messages so the program does not hang. Use with caution (similar to multi threading).

function epRemovePluginTab(plugid: HINST): longbool; cdecl;
Removes a plugin tab if a plugin has previously created a tab. Returns true if successful. Returns true if the tab was removed, false if couldn't find tab or plugid.

function epCreatePluginTabEx(plugid: HINST; winhandle: HWND; adjustheight: longint): longbool; cdecl;
Creates a plugin but with custom height adjustment used to fine tune the appearance of the window in the tab. Use this function to create a tab if not all the window is showing in the tab. Returns true if tab was created and plugid was valid, returns false if tab is already created or plugid invalid.

function epCreatePluginTab(plugid: HINST; winhandle: HWND): longbool; cdecl;
Creates a plugin tab in the Plug Panel. plugid is the unique plugin id. winhandle is the handle of the window being placed in the tab. Return value is the same as epCreatePluginTabEx.

procedure epSaveActiveEdFile; cdecl;
Saves the active editor file.

procedure epSaveAllFiles; cdecl;
Saves all the files in the editor.

function epGetActiveEdTmpHtmFileLen: longint; cdecl;
Returns the active editor temporary html file length if the editor has one. Returns -1 if no active editor exists.

function epGetActiveEdTmpHtmFile(buf: pchar; len: longint): longint; cdecl;
Fills buf with the active editor's temporary html file name and returns number of characters copied. Make sure to allocate enough space for buf. len is the length of the string buffer allocated by caller (include null char in length as +1). Use the related epGetActiveEdTmpHtmFileLen function to obtain the space to allocate in your buffer.

procedure epMakeActiveEdTmpHtmFile; cdecl;
Makes a temporary html file for an editor with no current file name (unnamed).

function epActiveEdUnnamed: longbool; cdecl;
Returns whether the active editor is unnamed (no current file name)

function epOpenFile(fname: pchar): longbool; cdecl;
Opens a file in the editor. Returns true if successful.

function epGetEdSelStart(idx: longint): longint; cdecl;
Returns the selstart position of the editor specified by its tab index. Returns -1 if specified index was invalid.

function epGetEdSelLen(idx: longint): longint; cdecl;
Returns the length of the selection of the editor specified by its tab index. Returns -1 if specified index was invalid.

function epGetEdSelEnd(idx: longint): longint; cdecl;
Returns the selend position of the editor specified by its tab index. Returns -1 if specified index was invalid.

function epGetEdTextLen(idx: longint): longint; cdecl;
Returns the length of the text of the editor specified by its tab index. Returns -1 if specified index was invalid.

function epGetEdText(buf: pchar; len: longint; idx: longint): longint; cdecl;
Fills buf with the editor's text and returns number of characters copied. Make sure to allocate enough space for buf. len is the length of the string buffer allocated by caller (include null char in length as +1). Use the related epGetEdTextLen function to obtain the space to allocate in your buffer.

function epSetEdSelStart(idx: longint; pos: longint): longbool; cdecl;
Sets the selstart position of the editor specified by its tab index. Returns true if successful.

function epSetEdSelEnd(idx: longint; pos: longint): longbool; cdecl;
Sets the selend position of the editor specified by its tab index. Returns true if successful.

procedure epEdRemoveSel(idx: longint); cdecl;
Removes any selection in the editor specified by its tab index.

function epLoadPlugin(name: pchar): longbool; cdecl;
Loads a plugin by its folder name. Returns true if successful.

procedure epSetActiveEdFocus; cdecl;
Sets the active editor to focus.

procedure epSetMainWinFocus; cdecl;
Sets the main EditPlug window to focus.

function epGetAppExePathLen: longint; cdecl;
Returns the length of the exe file name path.

function epGetAppExePath(buf: pchar; len: longint): longint; cdecl;
Fills buf with the exe file name path and returns number of characters copied. Make sure to allocate enough space for buf. len is the length of the string buffer allocated by caller (include null char in length as +1). Use the related epGetAppExePathLen function to obtain the space to allocate in your buffer.

function epGetActiveEdLine: longint; cdecl;
Returns the current line number of the cursor in the active editor. Returns -1 if no active editor exists.

function epGetActiveEdColumn: longint; cdecl;
Returns the current column number of the cursor in the active editor. Returns -1 if no active editor exists.

function epGetActiveEdWordLen: longint; cdecl;
Returns the length of the word under the cursor of the active editor. Returns -1 if no active editor exists.

function epGetActiveEdWord(buf: pchar; len: longint): longint; cdecl;
Fills buf with the word under the cursor of the active editor and returns number of characters copied. Make sure to allocate enough space for buf. len is the length of the string buffer allocated by caller (include null char in length as +1). Use the related epGetActiveEdWordLen function to obtain the space to allocate in your buffer.

procedure epConsoleExecCmd(CmdLine: pchar; StartInDir: pchar; ParseRule: pchar; ScrollToLastLine: longbool); cdecl;
Executes a program and places the output in the console output pane. StartInDir should not be left blank. ParseRule contains the rule for parsing the output. If ScrollToLastLine is true then at the end of the output the console output pane is scrolled to the last line.

procedure epConsoleJumpToLastLine; cdecl;
Scrolls the console output pane to the last line.

function epGetFilePanDirLen: longint; cdecl;
Returns the length of the file panel current directory path. Returns -1 if no file panel has been created.

function epGetFilePanDir(buf: pchar; len: longint): longint; cdecl;
Fills buf with the file panel current directory path and returns number of characters copied. Make sure to allocate enough space for buf. len is the length of the string buffer allocated by caller (include null char in length as +1). Use the related epGetFilePanDirLen function to obtain the space to allocate in your buffer.

function epGetFilePanSelFilesLen: longint; cdecl;
Returns the length of the selected files in the file panel. Returns -1 if no file panel has been created.

function epGetFilePanSelFiles(buf: pchar; len: longint): longint; cdecl;
Fills buf with the file panel selected files separated by carriage return, and returns number of characters copied. Make sure to allocate enough space for buf. len is the length of the string buffer allocated by caller (include null char in length as +1). Use the related epGetFilePanDirLen function to obtain the space to allocate in your buffer.

procedure epGetActiveEdBlockBegin(var coord: TBufCoord); cdecl;
Fills coord with the active editor block begin coordinates (char and line or x and y). Returns -1 in coord values if no active editor exists.

procedure epGetActiveEdBlockEnd(var coord: TBufCoord); cdecl;
Fills coord with the active editor block end coordinates (char and line or x and y). Returns -1 in coord values if no active editor exists.

procedure epSaveActiveEdTmpHtmFile;
Saves the temporary html file if the editor filename is unnamed and a TmpHtmFile has been made previously

Delphi Wrappers

function epGetActiveEdTextAsString: string;
Same as epGetActiveEdText but returns a delphi ansistring.

function epGetActiveEdSelTextAsString: string;
Same as epGetActiveEdSelText but returns a delphi ansistring.

function epGetActiveEdFilenameAsString: string;
Same as epGetActiveEdFilename but returns a delphi ansistring.

procedure epMoveWinToTopRight(form: TForm);
Moves a child form to the top right of the EditPlug main window.

function epGetEdFileNameAsString(idx: integer): string;
Same as epGetEdFileName but returns a delphi ansistring.

function epGetActiveEdTmpHtmFileAsString: string;
Same as epGetActiveEdTmpHtmFile but returns a delphi ansistring.

function epGetEdTextAsString(idx: integer): string;
Same as epGetEdText but returns a delphi ansistring.

function epGetAppExePathAsString: string;
Same as epGetAppExePath but returns a delphi ansistring.

function epGetActiveEdWordAsString: string;
Same as epGetActiveEdWord but returns a delphi ansistring.

function epGetFilePanSelFilesAsString: string;
Same as epGetFilePanSelFiles but returns a delphi ansistring.

function epGetFilePanDirAsString: string;
Same as epGetFilePanDir but returns a delphi ansistring.