Class LpexCommand

java.lang.Object
   |
   +----LpexCommand

public class LpexCommand
extends Object
The LpexCommand class provides access to the LPEX JPI (the LPEX editor Java Programming Interface). It is the base class for lpexlets - LPEX external commands written in Java. It consists of entry points for LPEX to call the lpexlet, which the lpexlet will override as necessary, but never itself call:
   lpexEntry(),
   lpexNotify(),
   lpexDocExit(),
   lpexExit(),
 
and of methods to access the LPEX editor, such as:
   lpexCall(),
   lpexGetParm(),
   lpexGetText().
 
The lpexlet class will subclass LpexCommand, and provide any overriding methods for the LPEX calls into the lpexlet.

This is a preliminary, "as is" release, subject to change.


Variable Index

 o LPEX_ELE_PROTECTED
lpexGetElementState() - the element is protected.
 o LPEX_ELE_SHOW
lpexGetElementState() - the element is a SHOW element.
 o LPEX_ELE_VISIBLE
lpexGetElementState() - the element is visible.
 o LPEX_NOTIFY_DOCEXIT
lpexNotify() - ask for document-exit notifications.
 o LPEX_NOTIFY_EXIT
lpexNotify() - ask for LPEX-exit notification.
 o LPEX_NOTIFY_NONE
lpexNotify() - ask LPEX to send no notifications.

Constructor Index

 o LpexCommand()

Method Index

 o lpexCall(String, String)
Call an LPEX function - run a command with a separate arguments string.
 o lpexCommand(String)
Run an LPEX command.
 o lpexDialogUp(boolean)
This should be called before and after a modal dialog or message box is presented to the user.
 o lpexDocExit(int)
Called by LPEX to inform this lpexlet that an LPEX document is being exited.
 o lpexEntry(String)
Called by LPEX - the main entry point into the lpexlet.
 o lpexExit(String)
Called by LPEX to inform this lpexlet that it is being unloaded, and that it should destroy any resources that it has allocated.
 o lpexGetClass()
Fastpath to the common LPEX command QUERY CLASS.
 o lpexGetElementState()
Get the state of an element.
 o lpexGetFonts()
Fastpath to the common LPEX command QUERY FONTS.
 o lpexGetIntParm(String)
Fastpath to get an LPEX integer parameter (setting).
 o lpexGetModes()
Fastpath to the common LPEX command QUERY MODES.
 o lpexGetParm(String)
Get an LPEX parameter (setting).
 o lpexGetText()
Fastpath to the common LPEX command QUERY CONTENT.
 o lpexNext()
Fastpath to the common LPEX command NEXT.
 o lpexNotify()
Called by LPEX to register the notifications this lpexlet is interested in.
 o lpexPrev()
Fastpath to the common LPEX command PREV.
 o lpexProfile()
Get information on the LPEX profile.
 o lpexSetClass(int)
Fastpath to the common LPEX command SET CLASS.
 o lpexSetFonts(String)
Fastpath to the common LPEX command SET FONTS.
 o lpexSetIntParm(String, int)
Fastpath to set an LPEX integer parameter (setting).
 o lpexSetText(String)
Fastpath to the common LPEX command SET CONTENT.

Variables

 o LPEX_NOTIFY_NONE
 public static final int LPEX_NOTIFY_NONE
lpexNotify() - ask LPEX to send no notifications.

See Also:
lpexNotify
 o LPEX_NOTIFY_DOCEXIT
 public static final int LPEX_NOTIFY_DOCEXIT
lpexNotify() - ask for document-exit notifications.

See Also:
lpexNotify
 o LPEX_NOTIFY_EXIT
 public static final int LPEX_NOTIFY_EXIT
lpexNotify() - ask for LPEX-exit notification.

See Also:
lpexNotify
 o LPEX_ELE_VISIBLE
 public static final int LPEX_ELE_VISIBLE
lpexGetElementState() - the element is visible. This flag indicates that the current element will show in the current edit view when given a chance (e.g., scrolled to).

See Also:
lpexGetElementState
 o LPEX_ELE_SHOW
 public static final int LPEX_ELE_SHOW
lpexGetElementState() - the element is a SHOW element. SHOW elements are not part of the document, and will not normally be saved in the document file. For example, error messages from a compilation will usually be imbedded in the edit view as SHOW elements.

See Also:
lpexGetElementState
 o LPEX_ELE_PROTECTED
 public static final int LPEX_ELE_PROTECTED
lpexGetElementState() - the element is protected. This flag indicates the current element is protected from overtype changes.

See Also:
lpexGetElementState

Constructors

 o LpexCommand
 public LpexCommand()

Methods

 o lpexEntry
 public static int lpexEntry(String arg)
Called by LPEX - the main entry point into the lpexlet. The lpexlet (the Java class that implements the LPEX external command) should override this method to do the real work.

The implementation of this method provided by the LpexCommand class does nothing, except return 0.

Example: If the user enters this on the LPEX command line:

   java Test info
 
lpexEntry() in Test.class will be called, with arg set to "info".

Parameters:
arg - any argument(s) sent to the lpexlet
Returns:
0 - success; >0 - warning; <0 - error. Certain error codes between -30 and -1 will be returned to the caller by LPEX's lpexlet-handling code. Therefore, lpexlet error return codes should be chosen outside this range. An error return code will prevent lpexNotify() from being called.
See Also:
lpexNotify
 o lpexNotify
 public static int lpexNotify()
Called by LPEX to register the notifications this lpexlet is interested in. There are two events the lpexlet may be notified of: an LPEX document is being exited (LPEX_NOTIFY_DOCEXIT), and the lpexlet is being unloaded and the Java Virtual Machine (JVM) destroyed (LPEX_NOTIFY_EXIT). The JVM will be terminated when the editor is exited, or when the user runs the command UNLINK JAVA. LPEX_NOTIFY_NONE may be sent to register no notifications. LPEX calls this method once, after the first call to lpexEntry() which doesn't return a negative result.

LPEX notifies the lpexlet of the registered events through lpexDocExit() and lpexExit().

The implementation of this method provided by the LpexCommand class returns LPEX_NOTIFY_NONE.

C/C++ API: LpexDocExit() / lxdocexit(), and LpexExit() / lxexit(); either is called for any external command DLL that EXPORTs these entry points.

Returns:
LPEX_NOTIFY_NONE (default), or any combination of LPEX_NOTIFY_DOCEXIT and LPEX_NOTIFY_EXIT.
See Also:
lpexEntry, lpexDocExit, lpexExit
 o lpexDocExit
 public static int lpexDocExit(int docnum)
Called by LPEX to inform this lpexlet that an LPEX document is being exited. A subclass of LpexCommand should override this method if it has any operation that it wants to perform when a (particular) LPEX document is exited.

The implementation of this method provided by the LpexCommand class does nothing, except return 0.

Parameters:
docnum - the document being exited in the editor
See Also:
lpexNotify, lpexEntry
 o lpexExit
 public static int lpexExit(String arg)
Called by LPEX to inform this lpexlet that it is being unloaded, and that it should destroy any resources that it has allocated. A subclass of LpexCommand should override this method if it has any operation that it wants to perform before it is destroyed.

The implementation of this method provided by the LpexCommand class does nothing, except return 0.

See Also:
lpexNotify, lpexEntry
 o lpexCommand
 public static native int lpexCommand(String cmdargs)
Run an LPEX command. This gives the lpexlet access to the entire LPEX repertoire of commands. See the Editor reference.

C/C++ API: LpexCommand("cmdargs") / lxcmd("cmdargs").

Examples:

   lpexCommand("NEXT");
   lpexCommand("MSG Hello, world!");
   lpexCommand("SET DISPWIDTH 90");
 

Parameters:
cmdargs - the LPEX command and its arguments
 o lpexCall
 public static native int lpexCall(String cmd,
                                   String args)
Call an LPEX function - run a command with a separate arguments string. This gives the lpexlet access to the entire LPEX repertoire of commands. See the Editor reference.

C/C++ API: LpexCall("cmd","args") / lxcall("cmd","args").

Examples:

    lpexCall("NEXT", "");
    lpexCall("MSG", "Hello, world!");
 

Parameters:
cmd - the LPEX command
args - arguments for the LPEX command
 o lpexGetParm
 public static native String lpexGetParm(String parm)
Get an LPEX parameter (setting). Equivalent editor command: QUERY parm. This lets the lpexlet query any of the LPEX parameters. See the Editor reference.

C/C++ API: LpexQuery("parm") / lxquery("parm"). A major difference is that lpexGetParm() only returns the value of the queried parameter.

Example:

    String q = lpexGetParm("ELEMENTS");
 
will return "25" in q for a current document that has 25 elements.

Parameters:
parm - name of the LPEX parameter to get
See Also:
lpexGetIntParm
 o lpexGetElementState
 public static native int lpexGetElementState()
Get the state of an element. Returns a combination of flags describing the current element (LPEX_ELE_VISIBLE, LPEX_ELE_SHOW, LPEX_ELE_PROTECTED).

C/C++ API: LpexQueryElementState() / lxqelestate(). Similar editor commands: QUERY SHOW, QUERY PROTECT + QUERY CLASS.

See Also:
LPEX_ELE_PROTECTED, LPEX_ELE_SHOW, LPEX_ELE_VISIBLE
 o lpexDialogUp
 public static native void lpexDialogUp(boolean up)
This should be called before and after a modal dialog or message box is presented to the user. Pass in true before the dialog is brought up, and false after the dialog was dismissed. This will ensure LPEX is not exited while the dialog is up.

C/C++ API: LpexDialogUp(up).

Parameters:
up - true: a modal dialog is brought up; false: the modal dialog is dismissed
 o lpexProfile
 public static native String lpexProfile()
Get information on the LPEX profile. On Windows, this is the registry key for storing LPEX settings.

C/C++ API: LpexProfile().

 o lpexNext
 public static native int lpexNext()
Fastpath to the common LPEX command NEXT. Move the current position to the next element.

C/C++ API: LpexNext("") / lxnext(). Equivalent editor command: NEXT ELEMENT.

 o lpexPrev
 public static native int lpexPrev()
Fastpath to the common LPEX command PREV. Move the current position to the previous element.

C/C++ API: LpexPrev("") / lxprev(). Equivalent editor command: PREV ELEMENT.

 o lpexGetIntParm
 public static native int lpexGetIntParm(String parm)
Fastpath to get an LPEX integer parameter (setting).

C/C++ API: LpexQuery("parm") / lxquery("parm"), followed by atoi() on the parameter value returned. Similar editor command: QUERY parm.

Example:

    int e = lpexGetIntParm("ELEMENTS");
 
will return 25 in e for a current document that consists of 25 elements.

Parameters:
parm - the LPEX parameter to query. It should be an integer parameter.
See Also:
lpexGetParm
 o lpexSetIntParm
 public static native int lpexSetIntParm(String parm,
                                         int value)
Fastpath to set an LPEX integer parameter (setting).

C/C++ API: LpexCall("SET parm value") / lxcall("SET parm value"), after conversion of the parameter value to a string. Similar editor command: SET parm value.

Example:

    int rc = lpexSetIntParm("DISPDEPTH", 25);
 

Parameters:
parm - the LPEX parameter to set
value - the new value for the parameter
 o lpexGetText
 public static native String lpexGetText()
Fastpath to the common LPEX command QUERY CONTENT.

C/C++ API: LpexQueryText() / lxqtext(). Equivalent editor command: QUERY CONTENT.

 o lpexSetText
 public static native int lpexSetText(String text)
Fastpath to the common LPEX command SET CONTENT.

C/C++ API: LpexSetText("text") / lxstext("text"). Equivalent editor command: SET CONTENT text.

Parameters:
text - the new text contents of the element
 o lpexGetFonts
 public static native String lpexGetFonts()
Fastpath to the common LPEX command QUERY FONTS.

C/C++ API: LpexQueryFonts() / lxqfont(). Equivalent editor command: QUERY FONTS.

 o lpexSetFonts
 public static native int lpexSetFonts(String fonts)
Fastpath to the common LPEX command SET FONTS.

C/C++ API: LpexSetFonts("fonts") / lxsfont("fonts"). Equivalent editor command: SET FONTS fonts.

Parameters:
fonts - the string of font characters to set for the element
 o lpexGetModes
 public static native String lpexGetModes()
Fastpath to the common LPEX command QUERY MODES.

C/C++ API: LpexQueryCharModes() / lxqmode(). Equivalent editor command: QUERY MODES.

 o lpexGetClass
 public static native int lpexGetClass()
Fastpath to the common LPEX command QUERY CLASS.

C/C++ API: LpexQueryClass() / lxqclass(). Similar editor command: QUERY CLASS, but lpexGetClass() returns the class bits set for the element, rather than the class names.

 o lpexSetClass
 public static native int lpexSetClass(int lpexclass)
Fastpath to the common LPEX command SET CLASS.

C/C++ API: LpexSetClass(lpexclass) / lxsclass(lpexclass). Similar editor command: SET CLASS lpexclass, but lpexSetClass() passes in the class-bits aggregate to be set for the element, rather than the class names.

Parameters:
lpexclass - the 32-bit aggregate for the classes to set for the element