HTML Kit site requirements.

HTML editor / Support Document
HomeHTML-Kit downloadsAdd-ins that update and extend HTML-Kit's capabilitiesSoftware and authoring support channelsRegister -- download add-ons and support HTML-KitOnline tools for HTML-Kit users
 

Support Document

 Home > Support > Support Documents > Plugins > How to: Add new commands...
 
 
How to: Add new commands to the Command Prompt
The information in this document applies to:
 Summary

This document describes how to write plugins that can handle commands issued using the Command Prompt.
 
 Details

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 ---
 
 
 
Document ID: H000141
Reviewed On: 02-Mar-2002
THE INFORMATION IN THIS DOCUMENT IS PROVIDED ON AN AS-IS BASIS WITHOUT WARRANTY OF ANY KIND. PROVIDER SPECIFICALLY DISCLAIMS ANY OTHER WARRANTY, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL PROVIDER BE LIABLE FOR ANY CONSEQUENTIAL, INDIRECT, SPECIAL OR INCIDENTAL DAMAGES, EVEN IF PROVIDER HAS BEEN ADVISED BY "USER" OF THE POSSIBILITY OF SUCH POTENTIAL LOSS OR DAMAGE. "USER" AGREES TO HOLD PROVIDER HARMLESS FROM AND AGAINST ANY AND ALL CLAIMS, LOSSES, LIABILITIES AND EXPENSES.