/*
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (the "MPL"); you may not use this file
 * except in compliance with the MPL. You may obtain a copy of
 * the MPL at http://www.mozilla.org/MPL/
 * 
 * Software distributed under the MPL is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the MPL for the specific language governing
 * rights and limitations under the MPL.
 * 
 * The Original Code is XMLterm.
 * 
 * The Initial Developer of the Original Code is Ramalingam Saravanan.
 * Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
 * Copyright (C) 1999 Ramalingam Saravanan. All Rights Reserved.
 * 
 * Contributor(s):
 */

/* mozILineTerm.idl: Javascript-accessible interface to LineTerm
 */

#include "nsISupports.idl"
#include "nsIObserver.idl"
#include "domstubs.idl"

%{C++
#include "nsString.h"
class nsIDOMDocument;

#define MOZLINETERM_CLASSNAME  "LineTerm Component"
#define MOZLINETERM_CONTRACTID "@mozilla.org/xmlterm/lineterm;1"

#define MOZLINETERM_CID                      \
{ /* 0eb82b01-43a2-11d3-8e76-006008948af5 */ \
   0x0eb82b01, 0x43a2, 0x11d3,               \
{0x8e, 0x76, 0x00, 0x60, 0x08, 0x94, 0x8a, 0xf5} }
%}

[scriptable, uuid(0eb82b00-43a2-11d3-8e76-006008948af5)]

interface mozILineTerm : nsISupports
{
  /** Opens LineTerm, a line-oriented terminal interface (without graphics)
   * @param command name of command to be executed; usually a shell,
   *        e.g., "/bin/sh"; if set to null string, the command name is
   *        determined from the environment variable SHELL (ASCII only)
   * @param initInput initial input string to be transmitted to terminal;
   *        set to null string, if none. (ASCII only)
   * @param promptRegexp command prompt regular expression (for future use);
   *        at the moment, any string terminated by one of the characters
   *        "#$%>?", followed by a space, is assumed to be a prompt
   * @param options LineTerm option bits (usually 0; see lineterm.h)
   * @param processType command shell type; if set to -1, type is determined
   *        from the command name
   * @param domDoc DOM document object associated with the LineTerm
   *        (document.cookie will be defined for this document on return)
   */
  void Open(in wstring command, in wstring initInput, in wstring promptRegexp,
            in PRInt32 options, in PRInt32 processType,
            in nsIDOMDocument domDoc);

  /** Closes LineTerm
   * @param aCookie document.cookie string for authentication
   */
  void Close(in wstring aCookie);

  /** Writes string to LineTerm as if the user had typed it (command input)
   * @param buf string to be transmitted to LineTerm
   * @param aCookie document.cookie string for authentication
   */
  void Write(in wstring buf, in wstring aCookie);

  /** Read output data string and parameters from LineTerm (command output)
   * @param opcodes (output) output data descriptor bits (see lineterm.h)
   * @param opvals (output) output data value(s)
   * @param buf_row (output) row number (>=-1)
   *               (-1 denotes line mode and 0 represents bottom row)
   * @param buf_col (output) column number (>=0)
   * @param aCookie document.cookie string for authentication
   * @return output data string from LineTerm
   */
  wstring Read(out PRInt32 opcodes, out PRInt32 opvals,
               out PRInt32 buf_row, out PRInt32 buf_col, in wstring aCookie);
};

[ref] native nsNativeStringRef(nsString);

/* NOT SCRIPTABLE */
[uuid(0eb82b10-43a2-11d3-8e76-006008948af5)]

interface mozILineTermAux : mozILineTerm
{

  /** Opens LineTerm, a line-oriented terminal interface (without graphics)
   * @param command name of command to be executed; usually a shell,
   *        e.g., "/bin/sh"; if set to null string, the command name is
   *        determined from the environment variable SHELL
   * @param promptRegexp command prompt regular expression (for future use);
   *        at the moment, any string terminated by one of the characters
   *        "#$%>?", followed by a space, is assumed to be a prompt
   * @param options LineTerm option bits (usually 0; see lineterm.h)
   * @param processType command shell type; if set to -1, type is determined
   *        from the command name
   * @param nRows no. of screen rows
   * @param nCols no. of screen columns
   * @param xPixels screen width in pixels (or 0 if unknown)
   * @param yPixels screen height in pixels (or 0 if unknown)
   * @param domDoc DOM document object associated with the LineTerm
   *        (document.cookie will be defined for this document on return)
   * @param aCookie (output) cookie associated with LineTerm
   */

  void openAux(in wstring command,
               in wstring initInput,
               in wstring promptRegexp,
               in PRInt32 options, in PRInt32 processType,
               in PRInt32 nRows, in PRInt32 nCols,
               in PRInt32 xPixels, in PRInt32 yPixels,
               in nsIDOMDocument domDoc,
               in nsIObserver anObserver,
               in nsNativeStringRef aCookie);

  /** Suspend/restores LineTerm operation
   * @param aSuspend suspension state flag
   */
  void suspendAux(in boolean suspend);

  /** Closes LineTerm
   */
  void closeAux();

  /** Close all LineTerms, not just this one
   */
  void closeAllAux();

  /** Resizes XMLterm to match a resized window.
   * @param nRows number of rows
   * @param nCols number of columns
   */
  void resizeAux(in long nRows, in long nCols);

  /** Read output data and style strings and parameters from LineTerm
   * @param opcodes (output) output data descriptor bits (see lineterm.h)
   * @param opvals (output) output data value(s)
   * @param buf_row (output) row number (>=-1)
   *                (-1 denotes line mode and 0 represents bottom row)
   * @param buf_col (output) column number (>=0)
   * @param _retval (output) success code
   * @param retstyle (output) output style string
   * @return output data string from LineTerm
   */
  void readAux(out long opcodes, out long opvals,
               out long buf_row, out long buf_col,
               out wstring retval, out wstring retstyle);

  void getCookie(in nsNativeStringRef aCookie);

  attribute long cursorRow;
  attribute long cursorColumn;
  attribute boolean echoFlag;
};

