/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is XMLterm.
 *
 * The Initial Developer of the Original Code is
 * Ramalingam Saravanan.
 * Portions created by the Initial Developer are Copyright (C) 1999
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

/* 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;
};

