Starting with HTML-Kit Build 292, plugins can handle commands and phrases issued through the Command Prompt tab in HTML-Kit's Messages Window. This feature can be used to add modular and customizable "intelligence" to the application. For example, a calculator plugin could add a "calc" command that can be used to perform calculations, and a color picker plugin could add commands to convert hex color codes to color names.
The following sample plugin adds two new commands to the Command Prompt. Save the following code to a file named demoCommandPromptHandler.hks and install it using the "Tools | Install | Plugin" main menu option. To test the plugin, type HI or DEMOCMD in the Command Prompt input box and press Enter.
--- cut here --- function hkp_Register(pDataIn, pDataOut) { hkp_DataSetGlobalSuffix("_1"); // name of the plugin (must be unique) hkp_DataAdd(pDataOut, "NAME", "demoCommandPromptHandler"); // no need to show a button on the ActionsBar hkp_DataAddInt(pDataOut, "BUTTON_VISIBLE", 0); // editor not required hkp_DataAddInt(pDataOut, "MODE_EDITOR_REQUIRED", 0); // respond to commands "democmd" and "hi" hkp_DataAdd(pDataOut, "COMMANDPROMPT_COMMANDS", "democmd,hi"); // some help text hkp_DataAdd(pDataOut, "COMMANDPROMPT_HELP", "Simple echo plugin."); // request command prompt events hkp_DataAddInt(pDataOut, "COMMANDPROMPT_EVENT_ONINVOKE", 1); hkp_DataSetGlobalSuffix(""); } function hkp_Main(pDataIn, pDataOut) { // is this a command prompt event? if( 1400 == hkp_DataGetInt(pDataIn, "EVENT", 0) ) { var sOut = "", sText = ""; if( hkp_DataGet(pDataIn, "COMMANDPROMPT_IN_CMDLINE_COMMAND", &sText) ) { sOut += "You typed '" + sText + "'"; } if( hkp_DataGet(pDataIn, "COMMANDPROMPT_IN_CMDLINE_PARAMS", &sText) && length(sText) ) { sOut += " followed by '" + sText + "'."; } hkp_DataAdd(pDataOut, "COMMANDPROMPT_OUTPUT", sOut); } // no other output either way hkp_DataAddInt(pDataOut, "MODE_OUTPUT", 1); } --- cut here ---