xmlterm changes only (not part of the default build).

Created some plain vanilla chrome files to invoke XMLterm through mozilla.
Compiles with Feb25 tree.
This commit is contained in:
svn%xmlterm.org 2000-02-29 15:55:36 +00:00
Родитель 0fe1244474
Коммит 2c9a11bf31
41 изменённых файлов: 1186 добавлений и 376 удалений

Просмотреть файл

@ -5,7 +5,7 @@ INSTALL: Installation instructions for XMLterm source code
*NOTE* Check the XMLterm web site <http://xmlterm.org> for updates.
26 Dec 1999
28 Feb 2000
QUICK INSTALLATION INSTRUCTIONS (Linux/Solaris)
-----------------------------------------------
@ -15,8 +15,9 @@ b) cd mozilla/extensions/xmlterm
c) ./makemake -r
d) make all
e) cd ../../dist/bin
f) ./mozilla chrome://xmlterm/content/xmlterm.html
g) ./run-mozilla.sh xmlterm
f) ./xmlterm
OR
./mozilla -chrome chrome://xmlterm/content/xmlterm.xul
DETAILED INSTALLATION INSTRUCTIONS
@ -88,22 +89,26 @@ To clean up completely, type
make clean
4. Using XMLterm within the browser
-----------------------------------
4. Running XMLterm using mozilla
--------------------------------
At this time, XMLterm cannot be accessed through the menu bar. After Step 3,
execute the following command in the "mozilla/dist/bin" directory:
./mozilla chrome://xmlterm/content/xmlterm.html
./xmlterm
This should create an XMLterm in the browser window. Then click on that window
with the mouse to shift focus and start typing UNIX commands.
(You may also type this URL into the browser's URL box.)
"xmlterm" is shorthand for the following command, which you may also execute
directly
./mozilla -chrome chrome://xmlterm/content/xmlterm.xul
The above command(s) should create an XMLterm window. Click on that window
with the mouse to give it focus and start typing UNIX commands.
**NOTE**
The command prompt is assumed to be terminated by one of the characters
"#$%>?", followed by a space. If this is not the case, many features will not
work. This restriction will be relaxed in the future.
"#$%>?", followed by a space. If this is not the case, many features will
not work. This restriction will be relaxed in the future.
The command line can be edited using EMACS-style key bindings.
Command completion should also work with TCSH and BASH, as should history
@ -112,7 +117,7 @@ recall.
By default, blue coloring is used to indicate clickable display elements.
Note that the prompt and the input command line are clickable.
(Of course, the appearance of XMLterm is completely configurable
using the CSS stylesheet chrome://xmlterm/skin/default/xmlterm.css)
using the CSS stylesheet chrome://xmlterm/skin/default/xmltpage.css)
After typing one or two commands, click on the prompt string of any previous
command to see what happens! Then click again on the same prompt string.
@ -122,27 +127,42 @@ Clicking on a previous command line (to the right of the prompt) re-executes
the command.
The sample Perl script "xls", the iconic/hypertext version of the Unix "ls"
command, is in the "tests" directory. Copy it to a directory in your
executable path to use it.
command, is in the "scripts" directory. Also in the "scripts" directory
is "xcat", an XMLterm-aware version of the "cat" command.
5. Using the lightweight "xmlterm" stand-alone program
------------------------------------------------------
5. Setting the path
-------------------
Step 3 also creates an executable called "xmlterm" in the "mozilla/dist/bin"
To use XMLterm most efficiently, add the mozilla binary directory
(mozilla/dist/bin) to your execution PATH variable by modifying
your shell initialization file (.profile/.cshrc). This will enable you to use
commands such as "xmlterm", "xls", and "xcat" easily.
6. Using the lightweight "geckoterm" stand-alone program
--------------------------------------------------------
Step 3 also creates an executable called "geckoterm" in the "mozilla/dist/bin"
directory. This is a lightweight program implementing XMLterm using the Gecko
layout engine only, without the added baggage of the full browser. To use it,
type the following command in the "mozilla/dist/bin" directory:
./run-mozilla.sh xmlterm
./run-mozilla.sh geckoterm
This will create an XMLterm window. Click on this window to give it focus
before typing Unix commands.
Note: At present, the "xmlterm" executable works only with the GTK front end.
Notes:
a) The Mozilla component registry may need to be updated by running
xmlterm using mozilla at least once (as in step 4) before trying to
run "geckoterm".
b) At present, the "geckoterm" executable works only with the GTK front
end.
6. Stand-alone mode (optional)
7. Stand-alone mode (optional)
------------------------------
Although XMLterm resides in the Mozilla source tree, portions of it are

Просмотреть файл

@ -56,7 +56,7 @@ DIRS = base tests linetest
else # not STAND_ALONE
DIRS = base ui geckoterm tests
DIRS = base ui scripts tests geckoterm
LIBRARY_NAME =

Просмотреть файл

@ -18,19 +18,20 @@ XMLterm is an open source project in its early stages. Comments and
contributions are welcome!
R. Saravanan <svn@xmlterm.org>
26 Dec 1999 <http://xmlterm.org>
26 Feb 2000 <http://xmlterm.org>
===========
QUICK SET-UP INSTRUCTIONS (Linux/Solaris)
-----------------------------------------
a) (Build Mozilla from the source tarball)
a) (Build mozilla from the source tarball)
b) cd mozilla/extensions/xmlterm
c) ./makemake -r
d) make all
e) cd ../../dist/bin
f) ./mozilla chrome://xmlterm/content/xmlterm.html
g) ./run-mozilla.sh xmlterm
f) ./xmlterm
OR
./mozilla -chrome chrome://xmlterm/content/xmlterm.xul
NOTES:
@ -68,7 +69,8 @@ The main subdirectories of the "xmlterm" directory are:
doc/ some documentation
geckoterm/ lightweight XMLterm executable
linetest/ stand-alone line terminal testing executables
tests/ XMLterm test programs and scripts, including "pagelets"
scripts/ XMLterm scripts (xls, xcat, ...)
tests/ XMLterm test programs (HelloWorld pagelet, ...)
ui/* user interface/chrome files
--

Просмотреть файл

@ -1,7 +1,7 @@
UUID.txt: UUIDs used by XMLTerm
-------------------------------
2 Dec 1999
28 Feb 2000
A block of 256 UUIDs was generated by running uuidgen,
ranging from
@ -21,6 +21,7 @@ mozIXMLTermShell IID "0eb82b30-43a2-11d3-8e76-006008948af5"
mozXMLTermShell CID "0eb82b31-43a2-11d3-8e76-006008948af5"
mozIXMLTermStream IID "0eb82b40-43a2-11d3-8e76-006008948af5"
mozXMLTermStream CID "0eb82b41-43a2-11d3-8e76-006008948af5"
mozIXMLTermSuspend IID "0eb82b50-43a2-11d3-8e76-006008948af5"
mozISimpleContainer IID "0eb82bF0-43a2-11d3-8e76-006008948af5"
mozSimpleContainer CID "0eb82bF1-43a2-11d3-8e76-006008948af5"

Просмотреть файл

@ -100,6 +100,8 @@ int lterm_new();
* or a null string, all streams are considered insecure.
* (only MAXCOOKIESTR-1 characters of the cookie string are used for checking)
*
* INIT_COMMAND contains an initialization command string, if any (not echoed)
*
* PROMPT_REGEXP contains a REGEXP string describing the command prompt.
* (**NOTE** For the moment, only a list of prompt delimiters is accepted;
* a typical list of prompt delimiters would be "#$%>?")
@ -157,7 +159,8 @@ int lterm_new();
* user had entered it.
*/
int lterm_open(int lterm, char *const argv[], const char* cookie,
int lterm_open(int lterm, char *const argv[],
const char* cookie, const char* init_command,
const UNICHAR* prompt_regexp, int options, int process_type,
lterm_callback_func_t callback_func, void *callback_data);
@ -273,6 +276,7 @@ int lterm_metacomplete(int lterm, const UNICHAR *buf, int count);
* OPCODES ::= STREAMDATA NEWLINE?
* COOKIESTR? DOCSTREAM? XMLSTREAM? JSSTREAM? WINSTREAM?
* if StreamMode data is being returned.
* (NEWLINE, if set, denotes that the stream has terminated)
*
* OPCODES ::= SCREENDATA BELL? ( OUTPUT | CLEAR | INSERT | DELETE | SCROLL )?
* if ScreenMode data is being returned.

Просмотреть файл

@ -225,7 +225,8 @@ int lterm_new()
* (documented in the LTERM interface)
* @return 0 on success, or -1 on error
*/
int lterm_open(int lterm, char *const argv[], const char* cookie,
int lterm_open(int lterm, char *const argv[],
const char* cookie, const char* init_command,
const UNICHAR* prompt_regexp, int options, int process_type,
lterm_callback_func_t callback_func, void *callback_data)
{
@ -536,19 +537,26 @@ int lterm_open(int lterm, char *const argv[], const char* cookie,
} else {
int result;
char* shellInitFormat;
char* initStr = "";
if (init_command != NULL)
initStr = (char *) init_command;
if ((lts->processType == LTERM_CSH_PROCESS) ||
(lts->processType == LTERM_TCSH_PROCESS)) {
/* C-shell family */
shellInitFormat = "setenv LTERM_COOKIE '%s'\n";
shellInitFormat = "setenv LTERM_COOKIE '%s'; if (-f $HOME/.xmltermrc) source $HOME/.xmltermrc\n%s";
} else {
/* Bourne-shell family */
shellInitFormat = "LTERM_COOKIE='%s'; export LTERM_COOKIE\n";
shellInitFormat = "LTERM_COOKIE='%s'; export LTERM_COOKIE; if [ -f $HOME/.xmltermrc ]; then source $HOME/.xmltermrc; fi\n%s";
}
if (strlen(shellInitFormat)+strlen(lts->cookie) <= MAXSHELLINITSTR+1) {
sprintf(lts->shellInitStr, shellInitFormat, lts->cookie);
/* **** WATCH OUT FOR BUFFER OVERFLOW!!! *** */
if (strlen(shellInitFormat)-4+strlen(lts->cookie)+strlen(initStr) <=
MAXSHELLINITSTR-1) {
sprintf(lts->shellInitStr, shellInitFormat, lts->cookie, initStr);
} else {
LTERM_WARNING("lterm_open: Warning - shell initialization string too long\n");
lts->shellInitStr[0] = '\0';
@ -905,6 +913,9 @@ int lterm_resize(int lterm, int rows, int cols)
lto = &(lts->ltermOutput);
LTERM_LOG(lterm_resize,0,("lto->outputMode=%d\n",
lto->outputMode));
/* Free full screen buffers */
if (lto->screenChar != NULL)
FREE(lto->screenChar);
@ -912,7 +923,6 @@ int lterm_resize(int lterm, int rows, int cols)
if (lto->screenStyle != NULL)
FREE(lto->screenStyle);
/* Clear screen buffer */
lto->screenChar = NULL;
lto->screenStyle = NULL;
@ -920,6 +930,12 @@ int lterm_resize(int lterm, int rows, int cols)
lts->nRows = rows;
lts->nCols = cols;
if (lto->outputMode == LTERM1_SCREEN_MODE) {
/* Clear screen */
if (ltermClearOutputScreen(lts) != 0)
return -1;
}
if (lts->ptyMode) {
/* Resize PTY */
#ifndef NO_PTY

Просмотреть файл

@ -161,6 +161,13 @@ int ltermProcessOutput(struct lterms *lts, int *opcodes, int *opvals,
lto->cursorCol--;
break;
case U_TAB: /* Tab */
LTERM_LOG(ltermProcessOutput,32,("Screen mode, TAB\n"));
lto->cursorCol = ((lto->cursorCol/8)+1)*8;
if (lto->cursorCol > lts->nCols-1)
lto->cursorCol = lts->nCols-1;
break;
case U_BEL: /* Bell */
LTERM_LOG(ltermProcessOutput,32,("************ Screen mode, BELL\n"));
bellFlag = 1;

Просмотреть файл

@ -235,7 +235,7 @@ typedef FILE FILESTREAM;
#define MAXPROMPT 256 /* Maximum length of prompt regexp+1 */
#define MAXRAWINCOMPLETE 5 /* Maximum incomplete raw buffer size */
#define MAXSTREAMTERM 11 /* Maximum stream terminator buffer size */
#define MAXSHELLINITSTR 128 /* Maximum length of shell init string+1 */
#define MAXSHELLINITSTR 256 /* Maximum length of shell init string+1 */
#define MAXCOOKIESTR 64 /* Maximum length of cookie string+1 */
#define MAXESCAPEPARAMS 16 /* Maximum no. of numeric ESCAPE parameters */
#define MAXSTRINGPARAM 512 /* Maximum length of string ESCAPE parameters */

Просмотреть файл

@ -35,7 +35,9 @@ 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
* 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
@ -45,7 +47,7 @@ interface mozILineTerm : nsISupports
* @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 promptRegexp,
void Open(in wstring command, in wstring initInput, in wstring promptRegexp,
in PRInt32 options, in PRInt32 processType,
in nsIDOMDocument domDoc);

Просмотреть файл

@ -44,6 +44,7 @@ class mozILineTermAux : public mozILineTerm {
// mozILineTerm interface
NS_IMETHOD Open(const PRUnichar *command,
const PRUnichar *initInput,
const PRUnichar *promptRegexp,
PRInt32 options, PRInt32 processType,
nsIDOMDocument *domDoc) = 0;
@ -75,6 +76,7 @@ class mozILineTermAux : public mozILineTerm {
* @param aCookie (output) cookie associated with LineTerm
*/
NS_IMETHOD OpenAux(const PRUnichar *command,
const PRUnichar *initInput,
const PRUnichar *promptRegexp,
PRInt32 options, PRInt32 processType,
nsIDOMDocument *domDoc,

Просмотреть файл

@ -76,11 +76,18 @@ interface mozIXMLTermShell : nsISupports
*/
void SetPrompt(in wstring aPrompt, in wstring aCookie);
/** Ignore key press events
* (workaround for form input being transmitted to xmlterm)
* @param aIgnore ignore flag (true/false)
* @param aCookie document.cookie string for authentication
*/
void IgnoreKeyPress(in boolean aIgnore, in wstring aCookie);
/** Opens new XMLterm window with specified args (not yet implemented)
* @param args argument string to be passed to XMLterm
* (at the moment this just contains any initial input data)
*/
void NewXMLTermWindow(in wstring args);
nsIDOMWindow NewXMLTermWindow(in wstring args);
/** Exit browser, closing all windows (not yet implemented)
*/

Просмотреть файл

@ -0,0 +1,48 @@
/*
* 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):
*/
// mozIXMLTermSuspend.h: interface to suspend/resume select XMLterm operations
//
#ifndef mozIXMLTermSuspend_h___
#define mozIXMLTermSuspend_h___
#include "nscore.h"
#include "nsISupports.h"
/* {0eb82b50-43a2-11d3-8e76-006008948af5} */
#define MOZIXMLTERMSUSPEND_IID_STR "0eb82b50-43a2-11d3-8e76-006008948af5"
#define MOZIXMLTERMSUSPEND_IID \
{0x0eb82b50, 0x43a2, 0x11d3, \
{ 0x8e, 0x76, 0x00, 0x60, 0x08, 0x94, 0x8a, 0xf5 }}
class mozIXMLTermSuspend : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(MOZIXMLTERMSUSPEND_IID);
// mozIXMLTermSuspend interface
NS_IMETHOD GetSuspend(PRBool* aSuspend) = 0;
NS_IMETHOD SetSuspend(const PRBool aSuspend) = 0;
};
#endif /* mozIXMLTermSuspend_h___ */

Просмотреть файл

@ -91,6 +91,16 @@ public:
*/
NS_IMETHOD SetPrompt(const PRUnichar* aPrompt) = 0;
/** Gets ignore key press flag
* @param aIgnore ignore key press flag
*/
NS_IMETHOD GetKeyIgnore(PRBool* aIgnore) = 0;
/** Sets ignore key press flag
* @param aIgnore ignore key press flag
*/
NS_IMETHOD SetKeyIgnore(const PRBool aIgnore) = 0;
/** Writes string to terminal as if the user had typed it (without authenitcation)
* @param aString string to be transmitted to terminal
*/

Просмотреть файл

@ -284,6 +284,7 @@ NS_IMETHODIMP mozLineTerm::GetSecurePrincipal(nsIDOMDocument *domDoc,
/** Open LineTerm without callback
*/
NS_IMETHODIMP mozLineTerm::Open(const PRUnichar *command,
const PRUnichar *initInput,
const PRUnichar *promptRegexp,
PRInt32 options, PRInt32 processType,
nsIDOMDocument *domDoc)
@ -295,7 +296,8 @@ NS_IMETHODIMP mozLineTerm::Open(const PRUnichar *command,
}
nsAutoString aCookie;
return OpenAux(command, promptRegexp, options, processType, domDoc,
return OpenAux(command, initInput, promptRegexp,
options, processType, domDoc,
nsnull, aCookie);
}
@ -303,6 +305,7 @@ NS_IMETHODIMP mozLineTerm::Open(const PRUnichar *command,
/** Open LineTerm, with an Observer for callback to process new input/output
*/
NS_IMETHODIMP mozLineTerm::OpenAux(const PRUnichar *command,
const PRUnichar *initInput,
const PRUnichar *promptRegexp,
PRInt32 options, PRInt32 processType,
nsIDOMDocument *domDoc,
@ -374,11 +377,17 @@ NS_IMETHODIMP mozLineTerm::OpenAux(const PRUnichar *command,
char* cookieCStr = mCookie.ToNewCString();
XMLT_LOG(mozLineTerm::Open,22, ("mCookie=%s\n", cookieCStr));
// Convert initInput to CString
nsCAutoString initCStr (initInput);
XMLT_LOG(mozLineTerm::Open,22, ("initInput=%s\n", initCStr.GetBuffer()));
if (anObserver != nsnull) {
result = lterm_open(mLTerm, NULL, cookieCStr, L"#$%>?", options,
result = lterm_open(mLTerm, NULL, cookieCStr, initCStr.GetBuffer(),
L"#$%>?", options,
processType, mozLineTerm::Callback, (void *) this);
} else {
result = lterm_open(mLTerm, NULL, cookieCStr, L"#$%>?", options,
result = lterm_open(mLTerm, NULL, cookieCStr, initCStr.GetBuffer(),
L"#$%>?", options,
processType, NULL, NULL);
}
@ -592,6 +601,9 @@ NS_IMETHODIMP mozLineTerm::ReadAux(PRInt32 *opcodes, PRInt32 *opvals,
XMLT_LOG(mozLineTerm::ReadAux,30,("\n"));
if (!_retval)
return NS_ERROR_NULL_POINTER;
retCode = lterm_read(mLTerm, 0, ubuf, MAXCOL-1,
ustyle, opcodes, opvals,
buf_row, buf_col, &cursor_row, &cursor_col);
@ -602,7 +614,7 @@ NS_IMETHODIMP mozLineTerm::ReadAux(PRInt32 *opcodes, PRInt32 *opvals,
// Return null pointer(s)
*_retval = nsnull;
if (retstyle != nsnull)
if (retstyle)
*retstyle = nsnull;
} else {
@ -610,7 +622,7 @@ NS_IMETHODIMP mozLineTerm::ReadAux(PRInt32 *opcodes, PRInt32 *opvals,
mCursorRow = cursor_row;
mCursorColumn = cursor_col;
XMLT_LOG(mozLineTerm::Read,72,("cursor_col=%d\n", cursor_col));
XMLT_LOG(mozLineTerm::ReadAux,72,("cursor_col=%d\n", cursor_col));
int allocBytes = sizeof(PRUnichar)*(retCode + 1);
*_retval = (PRUnichar*) nsAllocator::Alloc(allocBytes);

Просмотреть файл

@ -46,6 +46,7 @@ public:
// mozILineTerm interface
NS_IMETHOD Open(const PRUnichar *command,
const PRUnichar *initInput,
const PRUnichar *promptRegexp,
PRInt32 options, PRInt32 processType,
nsIDOMDocument *domDoc);
@ -63,6 +64,7 @@ public:
// (not scriptable, no authentication cookie required)
NS_IMETHOD OpenAux(const PRUnichar *command,
const PRUnichar *initInput,
const PRUnichar *promptRegexp,
PRInt32 options, PRInt32 processType,
nsIDOMDocument *domDoc,

Просмотреть файл

@ -24,6 +24,7 @@
#include "nsIServiceManager.h"
#include "mozXMLT.h"
#include "mozXMLTermUtils.h"
#include "mozXMLTermListeners.h"
#include "nsIDOMKeyEvent.h"
@ -103,7 +104,9 @@ NS_NewXMLTermDragListener(nsIDOMEventListener ** aInstancePtrResult,
// mozXMLTermKeyListener implementation
/////////////////////////////////////////////////////////////////////////
mozXMLTermKeyListener::mozXMLTermKeyListener()
mozXMLTermKeyListener::mozXMLTermKeyListener() :
mXMLTerminal(nsnull),
mSuspend(false)
{
NS_INIT_REFCNT();
}
@ -139,6 +142,9 @@ mozXMLTermKeyListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
} else if (aIID.Equals(NS_GET_IID(nsIDOMKeyListener))) {
*aInstancePtr = NS_STATIC_CAST(nsIDOMKeyListener*,this);
} else if (aIID.Equals(NS_GET_IID(mozIXMLTermSuspend))) {
*aInstancePtr = NS_STATIC_CAST(mozIXMLTermSuspend*,this);
} else {
return NS_ERROR_NO_INTERFACE;
}
@ -149,6 +155,23 @@ mozXMLTermKeyListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
}
NS_IMETHODIMP mozXMLTermKeyListener::GetSuspend(PRBool* aSuspend)
{
if (!*aSuspend)
return NS_ERROR_NULL_POINTER;
*aSuspend = mSuspend;
return NS_OK;
}
NS_IMETHODIMP mozXMLTermKeyListener::SetSuspend(const PRBool aSuspend)
{
XMLT_LOG(mozXMLTermKeyListener::SetSuspend,50,("aSuspend=0x%x\n",
aSuspend));
mSuspend = aSuspend;
return NS_OK;
}
// Individual key handlers return NS_OK to indicate NOT consumed
// by default, an error is returned indicating event is consumed
@ -163,8 +186,6 @@ mozXMLTermKeyListener::HandleEvent(nsIDOMEvent* aEvent)
NS_IMETHODIMP
mozXMLTermKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
{
nsresult result;
nsCOMPtr<nsIDOMKeyEvent> keyEvent;
keyEvent = do_QueryInterface(aKeyEvent);
if (!keyEvent) {
@ -172,58 +193,20 @@ mozXMLTermKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
return NS_OK;
}
PRBool isShift, ctrlKey, altKey;
PRBool shiftKey, ctrlKey, altKey;
PRUint32 keyCode;
XMLT_LOG(mozXMLTermKeyListener::KeyDown,50,("\n"));
XMLT_LOG(mozXMLTermKeyListener::KeyDown,50,("mSuspend=0x%x\n",
mSuspend));
if (NS_SUCCEEDED(keyEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(keyEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(keyEvent->GetShiftKey(&shiftKey)) &&
NS_SUCCEEDED(keyEvent->GetCtrlKey(&ctrlKey)) &&
NS_SUCCEEDED(keyEvent->GetAltKey(&altKey)) ) {
XMLT_LOG(mozXMLTermKeyListener::KeyDown,52,
("keyCode=0x%x, ctrlKey=%d, altKey=%d\n", keyCode, ctrlKey, altKey));
PRUint32 keyChar = 0;
if (!ctrlKey && !altKey) {
// Not control/alt key event
switch (keyCode) {
case nsIDOMKeyEvent::DOM_VK_LEFT:
keyChar = U_CTL_B;
break;
case nsIDOMKeyEvent::DOM_VK_RIGHT:
keyChar = U_CTL_F;
break;
case nsIDOMKeyEvent::DOM_VK_UP:
keyChar = U_CTL_P;
break;
case nsIDOMKeyEvent::DOM_VK_DOWN:
keyChar = U_CTL_N;
break;
case nsIDOMKeyEvent::DOM_VK_ESCAPE:
keyChar = U_ESCAPE;
break;
case nsIDOMKeyEvent::DOM_VK_TAB: // Consume TAB to avoid scroll problems
keyChar = 0;
break;
default: // ignore event without consuming
return NS_OK;
}
} else if (ctrlKey == PR_TRUE) {
keyChar = keyCode - 0x40U; // Is this portable?
}
XMLT_LOG(mozXMLTermKeyListener::KeyDown,52,("keyChar=0x%x\n", keyChar));
if ((keyChar > 0) && (keyChar < U_SPACE)) {
// Transmit valid non-null control character
const PRUnichar temUString[] = {keyChar,0};
nsAutoString keyString(temUString);
result = mXMLTerminal->SendTextAux(keyString);
}
("code=0x%x, shift=%d, ctrl=%d, alt=%d\n",
keyCode, shiftKey, ctrlKey, altKey));
}
// Consume key down event
@ -244,7 +227,8 @@ mozXMLTermKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
{
nsresult result;
XMLT_LOG(mozXMLTermKeyListener::KeyPress,50,("\n"));
XMLT_LOG(mozXMLTermKeyListener::KeyPress,50,("mSuspend=0x%x\n",
mSuspend));
nsCOMPtr<nsIDOMKeyEvent> keyEvent;
keyEvent = do_QueryInterface(aKeyEvent);
@ -253,63 +237,135 @@ mozXMLTermKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
return NS_OK;
}
#if 0 // Debugging
nsCOMPtr<nsIPresShell> presShell;
result = mXMLTerminal->GetPresShell(getter_AddRefs(presShell));
if (NS_SUCCEEDED(result) && presShell) {
nsCOMPtr<nsIDOMSelection> selection;
result = presShell->GetSelection(SELECTION_NORMAL,
getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection) {
nsCOMPtr<nsIDOMNode> childNode, parentNode;
result = selection->GetFocusNode(getter_AddRefs(childNode));
if (NS_SUCCEEDED(result) && childNode) {
PRInt32 j;
nsAutoString nodeName;
for (j=0; (j<6) && childNode; j++) {
result = childNode->GetParentNode(getter_AddRefs(parentNode));
if (NS_SUCCEEDED(result) && parentNode) {
result = parentNode->GetNodeName(nodeName);
if (NS_SUCCEEDED(result)) {
nsCAutoString CNodeName = nodeName;
XMLT_LOG(mozXMLTermKeyListener::KeyPress,58,("nodeName=%s\n",
CNodeName.GetBuffer()));
}
childNode = parentNode;
} else {
childNode = nsnull;
}
}
}
}
}
#endif
PRUint32 keyCode;
PRBool isShift, ctrlKey, altKey;
PRBool shiftKey, ctrlKey, altKey;
if (NS_SUCCEEDED(keyEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(keyEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(keyEvent->GetShiftKey(&shiftKey)) &&
NS_SUCCEEDED(keyEvent->GetCtrlKey(&ctrlKey)) &&
NS_SUCCEEDED(keyEvent->GetAltKey(&altKey)) ) {
PRUint32 keyChar = 0;
nsAutoString JSCommand = "";
result = keyEvent->GetCharCode(&keyChar);
XMLT_LOG(mozXMLTermKeyListener::KeyPress,52,
("keyChar=0x%x, ctrlKey=%d, altKey=%d\n", keyChar, ctrlKey, altKey));
("code=0x%x, char=0x%x, shift=%d, ctrl=%d, alt=%d\n",
keyCode, keyChar, shiftKey, ctrlKey, altKey));
if (ctrlKey == PR_TRUE) {
// Do nothing for Ctrl-Alt key events; just consume then
if (keyChar == 0) {
// Key that hasn't been mapped to a character code
if (altKey == PR_FALSE) {
// Control character, without Alt
if ((keyChar > 0) && (keyChar < U_SPACE)) {
// Transmit valid non-null control character
const PRUnichar temUString[] = {keyChar,0};
nsAutoString keyString(temUString);
result = mXMLTerminal->SendTextAux(keyString);
}
switch (keyCode) {
case nsIDOMKeyEvent::DOM_VK_SHIFT:
case nsIDOMKeyEvent::DOM_VK_CONTROL:
case nsIDOMKeyEvent::DOM_VK_ALT:
break; // ignore modifier key event
case nsIDOMKeyEvent::DOM_VK_BACK_SPACE:
case nsIDOMKeyEvent::DOM_VK_DELETE:
keyChar = U_BACKSPACE;
break;
case nsIDOMKeyEvent::DOM_VK_TAB:
keyChar = U_TAB;
break;
case nsIDOMKeyEvent::DOM_VK_RETURN:
keyChar = U_LINEFEED;
break;
case nsIDOMKeyEvent::DOM_VK_LEFT:
keyChar = U_CTL_B;
break;
case nsIDOMKeyEvent::DOM_VK_RIGHT:
keyChar = U_CTL_F;
break;
case nsIDOMKeyEvent::DOM_VK_UP:
keyChar = U_CTL_P;
break;
case nsIDOMKeyEvent::DOM_VK_DOWN:
keyChar = U_CTL_N;
break;
case nsIDOMKeyEvent::DOM_VK_ESCAPE:
keyChar = U_ESCAPE;
break;
case nsIDOMKeyEvent::DOM_VK_HOME:
JSCommand = "ScrollHome";
break;
case nsIDOMKeyEvent::DOM_VK_END:
JSCommand = "ScrollEnd";
break;
case nsIDOMKeyEvent::DOM_VK_PAGE_UP:
JSCommand = "ScrollPageUp";
break;
case nsIDOMKeyEvent::DOM_VK_PAGE_DOWN:
JSCommand = "ScrollPageDown";
break;
default: // ignore event without consuming
return NS_OK;
}
} else {
// Unmodified key event (including TAB/BACKSPACE/RETURN/LINEFEED)
} else if ((ctrlKey == PR_TRUE) && (altKey == PR_FALSE) &&
(keyChar > 0x60U) && (keyChar < 0xA0U)) {
// Control character, without Alt; adjust character code
keyChar = keyChar - 0x60U; // Is this portable?
}
if (keyChar == 0) {
// Key that hasn't been mapped to a character code
switch (keyCode) {
case nsIDOMKeyEvent::DOM_VK_BACK_SPACE:
case nsIDOMKeyEvent::DOM_VK_DELETE:
keyChar = U_BACKSPACE;
break;
case nsIDOMKeyEvent::DOM_VK_TAB:
keyChar = U_TAB;
break;
case nsIDOMKeyEvent::DOM_VK_RETURN:
keyChar = U_LINEFEED;
break;
default: // ignore event without consuming
return NS_OK;
}
if (JSCommand.Length() > 0) {
// Execute JS command
nsCOMPtr<nsIDOMDocument> domDocument;
result = mXMLTerminal->GetDocument(getter_AddRefs(domDocument));
if (NS_SUCCEEDED(result) && domDocument) {
nsAutoString JSInput = JSCommand;
nsAutoString JSOutput = "";
JSInput.Append("(");
JSInput.Append(shiftKey,10);
JSInput.Append(",");
JSInput.Append(ctrlKey,10);
JSInput.Append(");");
result = mozXMLTermUtils::ExecuteScript(domDocument,
JSInput,
JSOutput);
}
}
// Translate Carriage Return to LineFeed (may not be portable??)
if (keyChar == U_CRETURN) keyChar = U_LINEFEED;
// Translate Carriage Return to LineFeed (may not be portable??)
if (keyChar == U_CRETURN) keyChar = U_LINEFEED;
if ((keyChar > 0) && (keyChar <= 0xFFFDU)) {
// Transmit valid non-null Unicode character
const PRUnichar temUString[] = {keyChar,0};
nsAutoString keyString(temUString);
result = mXMLTerminal->SendTextAux(keyString);
}
if (!mSuspend && (keyChar > 0) && (keyChar <= 0xFFFDU)) {
// Transmit valid non-null Unicode character
const PRUnichar temUString[] = {keyChar,0};
nsAutoString keyString(temUString);
result = mXMLTerminal->SendTextAux(keyString);
}
}

Просмотреть файл

@ -37,9 +37,12 @@
#include "nsCOMPtr.h"
#include "mozIXMLTerminal.h"
#include "mozIXMLTermSuspend.h"
/* XMLTerm Key Listener */
class mozXMLTermKeyListener : public nsIDOMKeyListener {
class mozXMLTermKeyListener : public nsIDOMKeyListener,
public mozIXMLTermSuspend
{
public:
mozXMLTermKeyListener();
virtual ~mozXMLTermKeyListener();
@ -61,9 +64,16 @@ public:
virtual nsresult KeyUp(nsIDOMEvent* aKeyEvent);
virtual nsresult KeyPress(nsIDOMEvent* aKeyEvent);
// mozIXMLTermSuspend interface
NS_IMETHOD GetSuspend(PRBool* aSuspend);
NS_IMETHOD SetSuspend(const PRBool aSuspend);
protected:
/** non-owning reference to containing XMLTerminal object (for callback) */
mozIXMLTerminal* mXMLTerminal;
/** suspend flag */
PRBool mSuspend;
};

Просмотреть файл

@ -84,7 +84,7 @@ const char* const mozXMLTermSession::sessionEventNames[] = {
const char* const mozXMLTermSession::metaCommandNames[] = {
"",
"",
"default",
"http",
"js",
"tree",
@ -135,11 +135,11 @@ mozXMLTermSession::mozXMLTermSession() :
mXMLTermStream(nsnull),
mMetaCommandType(NO_META_COMMAND),
mOutputType(LINE_OUTPUT),
mOutputDisplayType(NO_NODE),
mOutputMarkupType(PLAIN_TEXT),
mMetaCommandType(NO_META_COMMAND),
mAutoDetect(FIRST_LINE),
mLineBreakNeeded(false),
@ -156,6 +156,7 @@ mozXMLTermSession::mozXMLTermSession() :
mBotScrollRow(0),
mRestoreInputEcho(false),
mNeedsResizing(false),
mShellPrompt(""),
mPromptHTML(""),
@ -288,6 +289,17 @@ NS_IMETHODIMP mozXMLTermSession::Finalize(void)
}
/** Sets XMLTerm flag to indicate XMLTerm needs to be resized
*/
NS_IMETHODIMP mozXMLTermSession::NeedsResizing(void)
{
XMLT_LOG(mozXMLTermSession::NeedsResizing,0,("\n"));
mNeedsResizing = true;
return NS_OK;
}
/** Resizes XMLterm to match a resized window.
* @param lineTermAux LineTermAux object to be resized (may be null)
*/
@ -342,7 +354,7 @@ NS_IMETHODIMP mozXMLTermSession::Resize(mozILineTermAux* lineTermAux)
// Determine number of rows/columns
mScreenRows = (int) ((frameHeight-44) / ydel);
mScreenCols = (int) (frameWidth / xdel);
mScreenCols = (int) ((frameWidth-20) / xdel);
if (mScreenRows < 1) mScreenRows = 1;
if (mScreenCols < 1) mScreenCols = 1;
@ -354,7 +366,7 @@ NS_IMETHODIMP mozXMLTermSession::Resize(mozILineTermAux* lineTermAux)
("Resizing XMLterm, xdel=%e, ydel=%e, rows=%d, cols=%d\n",
xdel, ydel, mScreenRows, mScreenCols));
if (!lineTermAux) {
if (lineTermAux) {
// Resize associated LineTerm
result = lineTermAux->ResizeAux(mScreenRows, mScreenCols);
if (NS_FAILED(result))
@ -468,8 +480,8 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
break;
XMLT_LOG(mozXMLTermSession::ReadAll,62,
("opcodes=0x%x,mMetaCommandType=%d,mEntryHasOutput=%d\n",
opcodes, mMetaCommandType, mEntryHasOutput));
("opcodes=0x%x,mOutputType=%d,mEntryHasOutput=%d\n",
opcodes, mOutputType, mEntryHasOutput));
if (opcodes == 0) break;
@ -491,29 +503,30 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
XMLT_LOG(mozXMLTermSession::ReadAll,68,("bufString=%s\n", temCString));
nsCRT::free(temCString);
if (screenData && (mMetaCommandType != SCREEN_META_COMMAND)) {
if (screenData && (mOutputType != SCREEN_OUTPUT)) {
// Initiate screen mode
XMLT_LOG(mozXMLTermSession::ReadAll,62,("Initiate SCREEN mode\n"));
// Break stream output display
result = BreakOutput();
if (NS_FAILED(result))
return result;
break;
// Create screen element (resize)
result = NewScreen(true);
// Create screen element
result = NewScreen();
if (NS_FAILED(result))
return result;
break;
mMetaCommandType = SCREEN_META_COMMAND;
mOutputType = SCREEN_OUTPUT;
// Disable input echo
lineTermAux->SetEchoFlag(false);
mRestoreInputEcho = true;
}
if (!screenData && (mMetaCommandType == SCREEN_META_COMMAND)) {
if (!screenData && (mOutputType == SCREEN_OUTPUT)) {
// Terminate screen mode
mMetaCommandType = NO_META_COMMAND;
mOutputType = LINE_OUTPUT;
XMLT_LOG(mozXMLTermSession::ReadAll,0,
("Terminating screen mode\n"));
@ -531,8 +544,8 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
if (streamData) {
// Process stream data
if (mMetaCommandType == NO_META_COMMAND) {
mMetaCommandType = STREAM_META_COMMAND;
if (mOutputType != STREAM_OUTPUT) {
mOutputType = STREAM_OUTPUT;
// Disable input echo
lineTermAux->SetEchoFlag(false);
@ -576,14 +589,14 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
// Initialize stream output
result = InitStream(streamURL, streamMarkupType, streamIsSecure);
if (NS_FAILED(result))
return result;
break;
}
// Process stream output
bufStyle = "";
result = ProcessOutput(bufString, bufStyle, false, true);
if (NS_FAILED(result))
return result;
break;
if (newline) {
if (!mEntryHasOutput) {
@ -594,9 +607,9 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
// Break stream output display
result = BreakOutput();
if (NS_FAILED(result))
return result;
break;
mMetaCommandType = NO_META_COMMAND;
mOutputType = LINE_OUTPUT;
flushOutput = true;
}
@ -613,14 +626,14 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
result = mSessionNode->RemoveChild(mScreenNode,
getter_AddRefs(resultNode));
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
break;
mScreenNode = nsnull;
// Create new screen element (no resize)
result = NewScreen(false);
// Create new screen element
result = NewScreen();
if (NS_FAILED(result))
return result;
break;
} else if (opcodes & LTERM_INSERT_CODE) {
// Insert rows
@ -636,13 +649,15 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
for (row=0; row < opvals; row++) {
result = GetRow(mBotScrollRow+opvals-1, getter_AddRefs(rowNode));
if (NS_FAILED(result) || !rowNode)
return NS_ERROR_FAILURE;
break;
result = mScreenNode->RemoveChild(rowNode,
getter_AddRefs(resultNode));
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
break;
}
if (NS_FAILED(result))
break;
// Insert individual row elements above
if (buf_row < opvals) {
@ -650,7 +665,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
} else {
result = GetRow(buf_row, getter_AddRefs(rowNode));
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
break;
}
for (row=0; row < opvals; row++)
@ -671,13 +686,15 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
for (row=0; row < opvals; row++) {
result = GetRow(buf_row, getter_AddRefs(rowNode));
if (NS_FAILED(result) || !rowNode)
return NS_ERROR_FAILURE;
break;
result = mScreenNode->RemoveChild(rowNode,
getter_AddRefs(resultNode));
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
break;
}
if (NS_FAILED(result))
break;
// Insert individual row elements above
if (mBotScrollRow == 0) {
@ -685,7 +702,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
} else {
result = GetRow(mBotScrollRow+opvals-1, getter_AddRefs(rowNode));
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
break;
}
for (row=0; row < opvals; row++)
@ -709,7 +726,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
result = DisplayRow(bufString, bufStyle, buf_row);
if (NS_FAILED(result))
return result;
break;
}
// Determine cursor position
@ -718,6 +735,9 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
result = lineTermAux->GetCursorRow(&cursorRow);
result = lineTermAux->GetCursorColumn(&cursorCol);
XMLT_LOG(mozXMLTermSession::ReadAll,62, ("cursorRow=%d, cursorCol=%d\n",
cursorRow, cursorCol));
// Get selection
nsCOMPtr<nsIDOMSelection> selection;
@ -732,16 +752,13 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
getter_AddRefs(cursTextNode), &offset);
if (NS_FAILED(result) || !cursTextNode)
return result;
break;
result = selection->Collapse(cursTextNode, offset);
if (NS_FAILED(result))
return result;
break;
}
// Scroll to end of page
ScrollToBottomLeft();
} else {
// Process line data
PRBool promptLine, inputLine, metaCommand, completionRequested;
@ -825,8 +842,8 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
("delimOffset=%d\n", delimOffset));
if (delimOffset == 0) {
// Default to HTTP protocol
mMetaCommandType = HTTP_META_COMMAND;
// Default protocol
mMetaCommandType = DEFAULT_META_COMMAND;
} else {
// Identify meta command type
@ -863,7 +880,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
// Create new entry block
result = NewEntry(promptStr);
if (NS_FAILED(result))
return result;
break;
}
// Display input and position cursor
@ -878,7 +895,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
result = DisplayInput(bufString, bufStyle, cursorCol);
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
break;
if (newline && mXMLTerminal) {
// Complete meta command; XMLterm instantiated
@ -886,6 +903,27 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
switch (mMetaCommandType) {
case DEFAULT_META_COMMAND:
{
// Construct Javascript command to handle default meta comand
nsAutoString JSCommand = "MetaDefault(\"";
JSCommand.Append(commandArgs);
JSCommand.Append("\");");
// Execute JavaScript command
result = mozXMLTermUtils::ExecuteScript(mDOMDocument,
JSCommand,
metaCommandOutput);
if (NS_FAILED(result))
metaCommandOutput = "Error in displaying URL\n";
nsCAutoString cstrout = metaCommandOutput;
printf("mozXMLTermSession::ReadAll, DEFAULT_META output=%s\n",
cstrout.GetBuffer());
}
break;
case HTTP_META_COMMAND:
{
// Display URL using IFRAME
@ -896,7 +934,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
result = NewIFrame(mOutputBlockNode, mCurrentEntryNumber,
2, url, width, height);
if (NS_FAILED(result))
return result;
metaCommandOutput = "Error in displaying URL\n";
}
break;
@ -947,21 +985,27 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
break;
}
if (mMetaCommandType == JS_META_COMMAND) {
if ((mMetaCommandType == DEFAULT_META_COMMAND) ||
(mMetaCommandType == JS_META_COMMAND)) {
// Display metacommand output
mEntryHasOutput = true;
XMLT_LOG(mozXMLTermSession::ReadAll,62,("metaCommandOutput\n"));
// Ignore the string "false", if that's the only output
if (metaCommandOutput.Equals("false"))
metaCommandOutput = "";
// Check metacommand output for markup (secure)
result = AutoDetectMarkup(metaCommandOutput, true, true);
if (NS_FAILED(result))
return result;
break;
nsAutoString nullStyle ("");
result = ProcessOutput(metaCommandOutput, nullStyle, true,
mOutputMarkupType != PLAIN_TEXT);
if (NS_FAILED(result))
return result;
break;
// Break metacommand output display
result = BreakOutput();
@ -985,7 +1029,15 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
// Create new entry block
result = NewEntry(promptStr);
if (NS_FAILED(result))
return result;
break;
}
// Resize XMLTerm before command output, if request has been made
if (mNeedsResizing) {
mNeedsResizing = false;
result = Resize(lineTermAux);
if (NS_FAILED(result))
break;
}
// Display input and position cursor
@ -1000,7 +1052,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
result = DisplayInput(bufString, bufStyle, cursorCol);
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
break;
if (newline) {
// Start of command output
@ -1022,7 +1074,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
// Complete line; check for markup (insecure)
result = AutoDetectMarkup(bufString, mFirstOutputLine, false);
if (NS_FAILED(result))
return result;
break;
// Not first output line anymore
mFirstOutputLine = false;
@ -1032,14 +1084,14 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
// Display plain text output
result = ProcessOutput(bufString, bufStyle, newline, false);
if (NS_FAILED(result))
return result;
break;
} else if (newline) {
// Process autodetected stream output (complete lines only)
bufStyle = "";
result = ProcessOutput(bufString, bufStyle, true, true);
if (NS_FAILED(result))
return result;
break;
}
}
}
@ -1051,7 +1103,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
("Closing LineTerm, result=%d\n", result));
lineTermAux->CloseAux();
return NS_ERROR_FAILURE;
return result;
}
if (flushOutput) {
@ -1062,10 +1114,11 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
result = mPresShell->ScrollSelectionIntoView(SELECTION_NORMAL,
SELECTION_FOCUS_REGION);
// Scroll frame (ignore result)
// ScrollToBottomLeft();
}
// Scroll frame (ignore result)
ScrollToBottomLeft();
return NS_OK;
}
@ -1447,7 +1500,7 @@ NS_IMETHODIMP mozXMLTermSession::ProcessOutput(const nsString& aString,
return NS_OK;
} else {
// Not meta command
// Not LS meta command
switch (mOutputMarkupType) {
@ -2543,7 +2596,7 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt)
* containing an empty text node, and append it as a
* child of the main BODY element. Also make it the current display element.
*/
NS_IMETHODIMP mozXMLTermSession::NewScreen(PRBool resize)
NS_IMETHODIMP mozXMLTermSession::NewScreen(void)
{
nsresult result;
@ -2561,11 +2614,6 @@ NS_IMETHODIMP mozXMLTermSession::NewScreen(PRBool resize)
mScreenNode = divNode;
if (resize) {
// Resize XMLTerm
mXMLTerminal->Resize();
}
// Create individual row elements
PRInt32 row;
for (row=0; row < mScreenRows; row++) {
@ -2582,7 +2630,7 @@ NS_IMETHODIMP mozXMLTermSession::GetRow(PRInt32 aRow, nsIDOMNode** aRowNode)
{
nsresult result;
XMLT_LOG(mozXMLTermSession::GetRow,60,("row=%d\n", aRow));
XMLT_LOG(mozXMLTermSession::GetRow,60,("aRow=%d\n", aRow));
if (!aRowNode)
return NS_ERROR_NULL_POINTER;
@ -2595,6 +2643,9 @@ NS_IMETHODIMP mozXMLTermSession::GetRow(PRInt32 aRow, nsIDOMNode** aRowNode)
PRUint32 nChildren = 0;
childNodes->GetLength(&nChildren);
XMLT_LOG(mozXMLTermSession::GetRow,62,("nChildren=%d, mScreenRows=%d\n",
nChildren, mScreenRows));
PRInt32 rowIndex = mScreenRows - aRow - 1;
if ((rowIndex < 0) || (rowIndex >= (PRInt32)nChildren))
return NS_ERROR_FAILURE;

Просмотреть файл

@ -61,10 +61,9 @@ class mozXMLTermSession
*/
NS_IMETHOD Finalize(void);
/** Resizes XMLterm to match a resized window.
* @param lineTermAux LineTermAux object to be resized (may be null)
/** Sets XMLTerm flag to indicate XMLTerm needs to be resized
*/
NS_IMETHOD Resize(mozILineTermAux* lineTermAux);
NS_IMETHOD NeedsResizing(void);
/** Preprocesses user input before it is transmitted to LineTerm
* @param aString (inout) input data to be preprocessed
@ -129,6 +128,14 @@ protected:
SESSION_EVENT_TYPES
};
/** output type */
enum OutputType {
LINE_OUTPUT = 0,
SCREEN_OUTPUT,
STREAM_OUTPUT,
OUTPUT_TYPES
};
/** display style of output */
enum OutputDisplayType {
NO_NODE = 0,
@ -147,7 +154,8 @@ protected:
JS_FRAGMENT,
HTML_FRAGMENT,
HTML_DOCUMENT,
XML_DOCUMENT
XML_DOCUMENT,
OUTPUT_MARKUP_TYPES
};
/** settings for automatic markup detection */
@ -168,8 +176,7 @@ protected:
/** type of currently active meta command */
enum MetaCommandType {
NO_META_COMMAND = 0,
SCREEN_META_COMMAND,
STREAM_META_COMMAND,
DEFAULT_META_COMMAND,
HTTP_META_COMMAND,
JS_META_COMMAND,
TREE_META_COMMAND,
@ -196,6 +203,11 @@ protected:
TREE_ACTION_CODES = 7
};
/** Resizes XMLterm to match a resized window.
* @param lineTermAux LineTermAux object to be resized (may be null)
*/
NS_IMETHOD Resize(mozILineTermAux* lineTermAux);
/** Displays ("echoes") input text string with style and positions cursor
* @param aString string to be displayed
* @param aStyle style values for string (see lineterm.h)
@ -318,7 +330,7 @@ protected:
* containing an empty text node, and append it as a
* child of the main BODY element. Also make it the current display element.
*/
NS_IMETHOD NewScreen(PRBool resize);
NS_IMETHOD NewScreen(void);
/** Returns DOM PRE node corresponding to specified screen row
*/
@ -563,17 +575,19 @@ protected:
nsCOMPtr<mozIXMLTermStream> mXMLTermStream;
/** currently active meta command (if any) */
MetaCommandType mMetaCommandType;
/** currently active output type */
OutputType mOutputType;
/** currently active display style of output */
OutputDisplayType mOutputDisplayType;
/** currently active markup style of output */
OutputMarkupType mOutputMarkupType;
/** currently active meta command (if any) */
MetaCommandType mMetaCommandType;
/** currently active setting for automatic markup detection */
AutoDetectOption mAutoDetect;
@ -614,6 +628,9 @@ protected:
/** restore input echo flag */
PRBool mRestoreInputEcho;
/** needs resizing flag */
PRBool mNeedsResizing;
/** shell prompt string */
nsString mShellPrompt;

Просмотреть файл

@ -25,10 +25,25 @@
#include <stdio.h>
#undef RAW_GTK_WINDOW
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#ifdef RAW_GTK_WINDOW
#include <gtk/gtk.h>
#include "gtkmozarea.h"
#include "gdksuperwin.h"
#include "mozISimpleContainer.h"
#else
#include "nsIWidget.h"
#include "nsWidgetsCID.h"
#include "nsIWebShell.h"
#include "nsIWebShellWindow.h"
#include "nsIBaseWindow.h"
#endif
#include "nsIDocumentViewer.h"
#include "nsIDocument.h"
@ -47,13 +62,20 @@
#include "nsIDOMWindow.h"
#include "mozXMLT.h"
#include "mozXMLTermUtils.h"
#include "mozXMLTermShell.h"
// Define Interface IDs
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
// Define Class IDs
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
// Define Interface IDs
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
#ifdef RAW_GTK_WINDOW
#else
static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID);
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
#endif
/////////////////////////////////////////////////////////////////////////
@ -118,6 +140,9 @@ mozXMLTermShell::QueryInterface(REFNSIID aIID,void** aInstancePtr)
} else if ( aIID.Equals(NS_GET_IID(mozIXMLTermShell)) ) {
*aInstancePtr = NS_STATIC_CAST(mozIXMLTermShell*,this);
} else if ( aIID.Equals(NS_GET_IID(nsIWebShellContainer)) ) {
*aInstancePtr = NS_STATIC_CAST(nsIWebShellContainer*,this);
} else {
return NS_ERROR_NO_INTERFACE;
}
@ -182,6 +207,29 @@ NS_IMETHODIMP mozXMLTermShell::SetPrompt(const PRUnichar* aPrompt,
}
/** Ignore key press events
* (workaround for form input being transmitted to xmlterm)
* @param aIgnore ignore flag (true/false)
* @param aCookie document.cookie string for authentication
*/
NS_IMETHODIMP mozXMLTermShell::IgnoreKeyPress(const PRBool aIgnore,
const PRUnichar* aCookie)
{
if (mXMLTerminal) {
nsresult result;
PRBool matchesCookie;
result = mXMLTerminal->MatchesCookie(aCookie, &matchesCookie);
if (NS_FAILED(result) || !matchesCookie)
return NS_ERROR_FAILURE;
return mXMLTerminal->SetKeyIgnore(aIgnore);
} else {
return NS_ERROR_NOT_INITIALIZED;
}
}
// Initialize XMLTermShell
NS_IMETHODIMP
mozXMLTermShell::Init(nsIDOMWindow* aContentWin,
@ -313,13 +361,156 @@ NS_IMETHODIMP mozXMLTermShell::SendText(const PRUnichar* aString,
// Create new XMLTerm window with specified argument string
NS_IMETHODIMP
mozXMLTermShell::NewXMLTermWindow(const PRUnichar* args)
mozXMLTermShell::NewXMLTermWindow(const PRUnichar* args,
nsIDOMWindow **_retval)
{
nsresult result = NS_OK;
nsresult result;
PRInt32 width = 760;
PRInt32 height = 400;
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,10,("\n"));
return result;
if (!_retval)
return NS_ERROR_NULL_POINTER;
*_retval = nsnull;
if (!mContentAreaDocShell)
return NS_ERROR_FAILURE;
// Get top window
nsCOMPtr<nsIWebShell> contentAreaWebShell( do_QueryInterface(mContentAreaDocShell) );
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check0, contWebShell=0x%x\n",
(int) contentAreaWebShell.get()));
nsCOMPtr<nsIWebShellContainer> topContainer = nsnull;
result = contentAreaWebShell->GetTopLevelWindow(getter_AddRefs(topContainer));
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check0, topContainer=0x%x\n",
(int) topContainer.get()));
nsCOMPtr<nsIWebShellWindow> topWin( do_QueryInterface(topContainer) );
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check0, topWin=0x%x\n",
(int) topWin.get()));
// Determine preferences
nsCOMPtr<nsIPref> prefs = nsnull;
result = mContentAreaDocShell->GetPrefs(getter_AddRefs(prefs));
#ifdef RAW_GTK_WINDOW // Create window using raw GTK calls
GtkWidget *mainWin = NULL;
GtkWidget *mozArea = NULL;
GdkSuperWin *superWin = NULL;
mainWin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size( GTK_WINDOW(mainWin), width, height);
gtk_window_set_title(GTK_WINDOW(mainWin), "XMLterm2");
mozArea = gtk_mozarea_new();
gtk_container_add(GTK_CONTAINER(mainWin), mozArea);
gtk_widget_realize(mozArea);
gtk_widget_show(mozArea);
superWin = GTK_MOZAREA(mozArea)->superwin;
gdk_window_show(superWin->bin_window);
gdk_window_show(superWin->shell_window);
gtk_widget_show(mainWin);
// Create simple container
nsCOMPtr<mozISimpleContainer> gSimpleContainer = nsnull;
result = NS_NewSimpleContainer(getter_AddRefs(gSimpleContainer));
if (NS_FAILED(result) || !gSimpleContainer) {
return result; // Exit main program
}
// Determine window dimensions
GtkAllocation *alloc = &GTK_WIDGET(mainWin)->allocation;
// Initialize container it to hold a doc shell
result = gSimpleContainer->Init((nsNativeWidget *) superWin,
alloc->width, alloc->height, prefs);
if (NS_FAILED(result)) {
return result; // Exit main program
}
// Get reference to doc shell embedded in a simple container
nsCOMPtr<nsIDocShell> docShell;
result = gSimpleContainer->GetDocShell(*getter_AddRefs(docShell));
if (NS_FAILED(result) || !docShell) {
return result; // Exit main program
}
// Load initial XMLterm document
result = gSimpleContainer->LoadURL(
"file:///home/svn/mysrc/web/home/links.html");
if (NS_FAILED(result))
return result;
///nsCOMPtr<nsIWebShell> webShell( do_QueryInterface(docShell) );
///nsString aStr("file:///home/svn/mysrc/web/home/links.html");
///result = webShell->LoadURL(aStr.GetUnicode());
///if (NS_FAILED(result))
/// return result;
// Return new DOM window
result = mozXMLTermUtils::ConvertDocShellToDOMWindow(docShell, _retval);
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check8, *_retval=0x%x\n",
*_retval));
if (NS_FAILED(result) || !*_retval)
return NS_ERROR_FAILURE;
#else // Use nsIAppShellService
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check4\n"));
// Create the Application Shell instance...
nsIAppShellService* appShellSvc = nsnull;
result = nsServiceManager::GetService(kAppShellServiceCID,
NS_GET_IID(nsIAppShellService),
(nsISupports**)&appShellSvc);
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check5\n"));
if (NS_FAILED(result) || !appShellSvc)
return NS_ERROR_FAILURE;
// Create top level window
nsCOMPtr<nsIWebShellWindow> webShellWin;
nsCOMPtr<nsIURI> uri = nsnull;
//nsCAutoString urlCString("chrome://xmlterm/content/xmlterm.html");
//result = uri->SetSpec(urlCString.GetBuffer());
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check6\n"));
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
appShellSvc->CreateTopLevelWindow((nsIWebShellWindow*) nsnull,
uri,
PR_TRUE,
PR_FALSE,
(PRUint32) 0,
(nsIXULWindowCallbacks*)nsnull,
width, height,
getter_AddRefs(webShellWin));
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check7, webShellWin=0x%x\n",
webShellWin.get()));
if (NS_FAILED(result))
return result;
// Return new DOM window
result = webShellWin->GetDOMWindow(_retval);
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check8, *_retval=0x%x\n",
*_retval));
if (NS_FAILED(result) || !*_retval)
return NS_ERROR_FAILURE;
#endif
return NS_OK;
}
@ -341,3 +532,34 @@ mozXMLTermShell::Exit()
}
return NS_OK;
}
NS_IMETHODIMP mozXMLTermShell::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason)
{
XMLT_LOG(mozXMLTermShell::WillLoadURL,0,("\n"));
return NS_OK;
}
NS_IMETHODIMP mozXMLTermShell::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
{
XMLT_LOG(mozXMLTermShell::BeginLoadURL,0,("\n"));
return NS_OK;
}
NS_IMETHODIMP mozXMLTermShell::ProgressLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax)
{
XMLT_LOG(mozXMLTermShell::ProgressLoadURL,0,("\n"));
return NS_OK;
}
NS_IMETHODIMP mozXMLTermShell::EndLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL,
nsresult aStatus)
{
XMLT_LOG(mozXMLTermShell::EndLoadURL,0,("\n"));
return NS_OK;
}

Просмотреть файл

@ -35,7 +35,9 @@
#include "mozIXMLTermShell.h"
class mozXMLTermShell : public mozIXMLTermShell {
class mozXMLTermShell : public mozIXMLTermShell,
public nsIWebShellContainer
{
public:
mozXMLTermShell();
@ -51,6 +53,9 @@ class mozXMLTermShell : public mozIXMLTermShell {
NS_IMETHOD SetPrompt(const PRUnichar* aPrompt, const PRUnichar* aCookie);
NS_IMETHOD IgnoreKeyPress(const PRBool aIgnore,
const PRUnichar* aCookie);
NS_IMETHOD Init(nsIDOMWindow* aContentWin,
const PRUnichar* URL,
const PRUnichar* args);
@ -63,11 +68,30 @@ class mozXMLTermShell : public mozIXMLTermShell {
NS_IMETHOD SendText(const PRUnichar* aString, const PRUnichar* aCookie);
NS_IMETHOD NewXMLTermWindow(const PRUnichar* args);
NS_IMETHOD NewXMLTermWindow(const PRUnichar* args,
nsIDOMWindow **_retval);
NS_IMETHOD Exit(void);
NS_IMETHOD Finalize(void);
// nsIWebShellContainer interface
NS_IMETHOD WillLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL,
nsLoadType aReason);
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL);
NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL,
PRInt32 aProgress,
PRInt32 aProgressMax);
NS_IMETHOD EndLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL,
nsresult aStatus);
protected:
/** object initialization flag */

Просмотреть файл

@ -52,6 +52,7 @@
#include "mozXMLT.h"
#include "mozXMLTermUtils.h"
#include "mozXMLTerminal.h"
#include "mozIXMLTermSuspend.h"
////////////////////////////////////////////////////////////////////////
@ -94,7 +95,7 @@ mozXMLTerminal::mozXMLTerminal() :
mCommand(""),
mPromptExpr(""),
mFirstInput(""),
mInitInput(""),
mXMLTermShell(nsnull),
mDocShell(nsnull),
@ -111,7 +112,6 @@ mozXMLTerminal::mozXMLTerminal() :
mDragListener(nsnull)
{
NS_INIT_REFCNT();
mFirstInputLock = PR_NewLock();
}
@ -120,8 +120,6 @@ mozXMLTerminal::~mozXMLTerminal()
if (mInitialized) {
Finalize();
}
PR_DestroyLock(mFirstInputLock);
}
@ -146,50 +144,71 @@ NS_INTERFACE_MAP_END
NS_IMETHODIMP mozXMLTerminal::GetCurrentEntryNumber(PRInt32 *aNumber)
{
if (mXMLTermSession) {
return mXMLTermSession->GetCurrentEntryNumber(aNumber);
} else {
if (!mXMLTermSession)
return NS_ERROR_FAILURE;
}
return mXMLTermSession->GetCurrentEntryNumber(aNumber);
}
NS_IMETHODIMP mozXMLTerminal::GetHistory(PRInt32 *aHistory)
{
if (mXMLTermSession) {
return mXMLTermSession->GetHistory(aHistory);
} else {
if (!mXMLTermSession)
return NS_ERROR_FAILURE;
}
return mXMLTermSession->GetHistory(aHistory);
}
NS_IMETHODIMP mozXMLTerminal::SetHistory(PRInt32 aHistory)
{
if (mXMLTermSession) {
return mXMLTermSession->SetHistory(aHistory);
} else {
if (!mXMLTermSession)
return NS_ERROR_FAILURE;
}
return mXMLTermSession->SetHistory(aHistory);
}
NS_IMETHODIMP mozXMLTerminal::GetPrompt(PRUnichar **aPrompt)
{
if (mXMLTermSession) {
return mXMLTermSession->GetPrompt(aPrompt);
} else {
if (!mXMLTermSession)
return NS_ERROR_FAILURE;
}
return mXMLTermSession->GetPrompt(aPrompt);
}
NS_IMETHODIMP mozXMLTerminal::SetPrompt(const PRUnichar* aPrompt)
{
if (mXMLTermSession) {
return mXMLTermSession->SetPrompt(aPrompt);
} else {
if (!mXMLTermSession)
return NS_ERROR_FAILURE;
}
return mXMLTermSession->SetPrompt(aPrompt);
}
NS_IMETHODIMP mozXMLTerminal::GetKeyIgnore(PRBool* aIgnore)
{
if (!mKeyListener)
return NS_ERROR_FAILURE;
nsCOMPtr<mozIXMLTermSuspend> suspend= do_QueryInterface(mKeyListener);
if (!suspend)
return NS_ERROR_FAILURE;
return suspend->GetSuspend(aIgnore);
}
NS_IMETHODIMP mozXMLTerminal::SetKeyIgnore(const PRBool aIgnore)
{
if (!mKeyListener)
return NS_ERROR_FAILURE;
nsCOMPtr<mozIXMLTermSuspend> suspend= do_QueryInterface(mKeyListener);
if (!suspend)
return NS_ERROR_FAILURE;
return suspend->SetSuspend(aIgnore);
}
@ -222,7 +241,7 @@ NS_IMETHODIMP mozXMLTerminal::Init(nsIDocShell* aDocShell,
// NOTE: Need to parse args string!!!
mCommand = "";
mPromptExpr = "";
mFirstInput = args;
mInitInput = args;
// Initialization completed
mInitialized = PR_TRUE;
@ -457,6 +476,7 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
#endif
nsAutoString cookie;
result = mLineTermAux->OpenAux(mCommand.GetUnicode(),
mInitInput.GetUnicode(),
mPromptExpr.GetUnicode(),
options, LTERM_DETERMINE_PROCESS,
mDOMDocument, anObserver, cookie);
@ -572,18 +592,6 @@ NS_IMETHODIMP mozXMLTerminal::SendText(const nsString& aString,
result = mXMLTermSession->Preprocess(sendStr, consumed);
if (!consumed) {
PR_Lock(mFirstInputLock);
if (mFirstInput.Length() > 0) {
result = mLineTermAux->Write(mFirstInput.GetUnicode(), aCookie);
if (NS_FAILED(result))
return result;
mFirstInput = "";
}
PR_Unlock(mFirstInputLock);
result = mLineTermAux->Write(sendStr.GetUnicode(), aCookie);
if (NS_FAILED(result)) {
// Close LineTerm
@ -673,21 +681,6 @@ NS_IMETHODIMP mozXMLTerminal::Poll(void)
return result;
}
if (processedData && (mFirstInput.Length() > 0)) {
// Send first input command line(s)
PR_Lock(mFirstInputLock);
result = mLineTermAux->Write(mFirstInput.GetUnicode(),
mCookie.GetUnicode());
mFirstInput = "";
PR_Unlock(mFirstInputLock);
if (NS_FAILED(result))
return result;
}
return NS_OK;
}
@ -789,7 +782,7 @@ NS_IMETHODIMP mozXMLTerminal::Resize(void)
if (!mXMLTermSession)
return NS_ERROR_FAILURE;
result = mXMLTermSession->Resize(mLineTermAux);
result = mXMLTermSession->NeedsResizing();
if (NS_FAILED(result))
return result;

Просмотреть файл

@ -65,6 +65,8 @@ class mozXMLTerminal : public mozIXMLTerminal,
NS_IMETHOD SetHistory(PRInt32 aHistory);
NS_IMETHOD GetPrompt(PRUnichar **aPrompt);
NS_IMETHOD SetPrompt(const PRUnichar* aPrompt);
NS_IMETHOD GetKeyIgnore(PRBool* aIgnore);
NS_IMETHOD SetKeyIgnore(const PRBool aIgnore);
NS_IMETHOD SendTextAux(const nsString& aString);
NS_IMETHOD SendText(const nsString& aString, const PRUnichar* aCookie);
@ -127,10 +129,7 @@ class mozXMLTerminal : public mozIXMLTerminal,
nsString mPromptExpr;
/** initial input string to be sent to LineTerm */
nsString mFirstInput;
/** first input lock */
PRLock* mFirstInputLock;
nsString mInitInput;
/** non-owning reference to containing XMLTermShell object */
mozIXMLTermShell* mXMLTermShell;

Просмотреть файл

@ -1,7 +1,7 @@
Known bugs
----------
21 Feb 2000
29 Feb 2000
1. XMLterm bug: Early use of "xls -i" does not scroll properly
@ -16,5 +16,7 @@ Known bugs
results in LTERM exiting abnormally when user exits emacs. An interrupt
error seems to occur while polling for output in ltermRead.
5. Full screen XMLTerm operation: forward cursor positioning (^F) behaves
erratically
5. When cursor is at leftmost position on the line, clickin on the window
moves it up (very annoying)
6. vi command does not scroll properly prior to first input (somewhat annoying)

Просмотреть файл

@ -3,21 +3,22 @@ XMLterm installation instructions for Linux binaries
*NOTE* This work in progress. User beware!
*NOTE* Check the XMLterm web site <http://xmlterm.org> for updates.
*NOTE* This plain text INSTALL file may be out date. Please check
<http://xmlterm.org/install.html> for the most recent information.
26 Dec 1999
28 Feb 2000
1. First obtain the Mozilla Linux binary tar file
ftp://ftp.mozilla.org/pub/mozilla/releases/m11/mozilla-i686-pc-linux-gnu-M11.tar.gz"
ftp://ftp.mozilla.org/pub/mozilla/releases/m14/mozilla-i686-pc-linux-gnu-M14.tar.gz"
and untar it in any convenient location. This will create a
directory named "package" containing the binaries.
2. Untar the XMLterm binary tar file "xmlterm-i686-pc-linux-gnu-M11.tar.gz"
2. Untar the XMLterm binary tar file "xmlterm-i686-pc-linux-gnu-M14.tar.gz"
in the "package" directory created above.
3. Type the following command in the "package" directory:
./mozilla chrome://xmlterm/content/xmlterm.html
./mozilla -chrome chrome://xmlterm/content/xmlterm.xul
This should create an XMLTerm in the browser window. Then click on
that window with the mouse to shift focus and start typing UNIX
@ -31,10 +32,20 @@ XMLterm installation instructions for Linux binaries
4. To use the stand-alone XMLterm executable called "xmlterm",
type the following command in the "package" directory:
./run-mozilla.sh xmlterm
./xmlterm
(The Mozilla component registry may need to be updated by running the
full browser using step 3 at least once before running "xmlterm".)
"xmlterm" is shorthand for the following command, which you may also execute
directly
./mozilla -chrome chrome://xmlterm/content/xmlterm.xul
The above command(s) should create an XMLterm window. Click on that window
with the mouse to give it focus and start typing UNIX commands.
**NOTE**
The command prompt is assumed to be terminated by one of the characters
"#$%>?", followed by a space. If this is not the case, many features will
not work. This restriction will be relaxed in the future.
5. The command line can be edited using EMACS-style key bindings.
Command completion should also work with TCSH and BASH, as should history
@ -52,9 +63,12 @@ XMLterm installation instructions for Linux binaries
Clicking on a previous command line (to the right of the prompt) re-executes
the command.
7. The sample Perl script "xls", the iconic/hypertext version of the Unix
"ls" command, is also installed in the "package" directory. Adding
the "package" directory to your path should enable you to use the "xls"
command.
7. The sample Perl script "xls", the iconic/hypertext version of the Unix "ls"
command, is in the "package" directory. Also in the "package" directory
is "xcat", an XMLterm-aware version of the "cat" command.
8. To use XMLterm most efficiently, add the mozilla "package" directory
to your execution PATH variable by modifying your shell initialization file
(.profile/.cshrc). This will enable you to use commands such as
"xmlterm", "xls", and "xcat" easily.
--

Просмотреть файл

@ -50,7 +50,7 @@ endif
DEBUG = 1
# Program
PROGRAM = xmlterm
PROGRAM = geckoterm
# Exported header files
EXPORTS = mozISimpleContainer.h

Просмотреть файл

@ -179,7 +179,7 @@ int main( int argc, char *argv[] )
gdk_rgb_init();
mainWin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size( GTK_WINDOW(mainWin), 720, 484);
gtk_window_set_default_size( GTK_WINDOW(mainWin), 740, 484);
gtk_window_set_title(GTK_WINDOW(mainWin), "XMLterm");
mozArea = gtk_mozarea_new();

Просмотреть файл

@ -289,7 +289,7 @@ int main(int argc, char *argv[]) {
if (!ptyFlag) options |= LTERM_NOPTY_FLAG;
ltermNumber = lterm_new();
retValue = lterm_open(ltermNumber, commandArgs, NULL, uregexp,
retValue = lterm_open(ltermNumber, commandArgs, NULL, NULL, uregexp,
options, processType, NULL, NULL);
if (retValue < 0) {
fprintf(stderr, "lterm: Error %d in opening LTERM\n", retValue);

Просмотреть файл

@ -0,0 +1 @@
Makefile

Просмотреть файл

@ -34,8 +34,8 @@
# makefile for xmlterm/ui directory
ifdef STAND_ALONE
DEPTH = .
topsrcdir = .
DEPTH = ..
topsrcdir = ..
VPATH = .
srcdir = .
include $(topsrcdir)/config/autoconf.mk

Просмотреть файл

@ -34,8 +34,8 @@
# makefile for xmlterm/ui/content directory
ifdef STAND_ALONE
DEPTH = .
topsrcdir = .
DEPTH = ../..
topsrcdir = ../..
VPATH = .
srcdir = .
include $(topsrcdir)/config/autoconf.mk
@ -55,6 +55,9 @@ include $(topsrcdir)/config/rules.mk
EXPORT_RESOURCE_CONTENT = \
$(srcdir)/xmlterm.html \
$(srcdir)/xmlterm.xul \
$(srcdir)/xmlterm2.xul \
$(srcdir)/XMLTermCommands.js \
$(srcdir)/xmltblank.html \
$(NULL)

Просмотреть файл

@ -1,5 +1,11 @@
content --- XUL, Javascript, and HTML for user interface
xmlterm.html XMLterm startup file containing HTML and Javascript
Uses mozIXMLTermShell to create XMLterm
Uses ../skin/xmlterm.css for stylesheets
xmlterm.html XMLterm startup file containing HTML and Javascript
Uses mozIXMLTermShell to create XMLterm
Uses ../skin/xmltpage.css for stylesheets
xmlterm.xul XUL wrapper for xmlterm.html
xmlterm2.xul XUL wrapper for xmlterm.html, with additional browser frame
XMLTermCommands.js Javascript commands used by XUL wrappers

Просмотреть файл

@ -0,0 +1,37 @@
function StartupXMLTerm() {
dump("StartupXMLTerm:\n");
dump("StartupXMLTerm:"+window.frames.length+"\n");
dump("StartupXMLTerm:"+window.frames[0].name+"\n");
if (window.frames.length == 2) {
window.frames[1].xmltbrowser = window.frames[0];
xmltwin = frames[1];
} else {
xmltwin = frames[0];
}
dump("StartupXMLterm: WINDOW.ARGUMENTS="+window.arguments+"\n");
dump("Trying to make an XMLTerm Shell through the component manager...\n");
var xmltshell = Components.classes["component://mozilla/xmlterm/xmltermshell"].createInstance();
dump("Interface xmltshell1 = " + xmltshell + "\n");
xmltshell = xmltshell.QueryInterface(Components.interfaces.mozIXMLTermShell);
dump("Interface xmltshell2 = " + xmltshell + "\n");
if (!xmltshell) {
dump("Failed to create XMLTerm shell\n");
window.close();
return;
}
// Store the XMLTerm shell in the window
window.xmlterm = xmltshell;
xmltwin.xmlterm = xmltshell;
// Initialize XMLTerm shell in content window with argvals
window.xmlterm.Init(xmltwin, "",
window.arguments);
}

Просмотреть файл

@ -1,13 +1,133 @@
<!-- xmlterm.html: XMLterm startup page -->
<!-- xmlterm.html: XMLterm page -->
<HTML>
<HEAD>
<TITLE>XMLterm Test Page</TITLE>
<TITLE>XMLterm Page</TITLE>
<LINK TITLE="DefaultStyle" REL="stylesheet" TYPE="text/css"
HREF="chrome://xmlterm/skin/xmlterm.css">
HREF="chrome://xmlterm/skin/xmltpage.css">
<SCRIPT language="JavaScript">
// Show all output
function ShowAll() {
return DisplayAllOutput(true);
}
// Hide all output
function HideAll() {
return DisplayAllOutput(false);
}
// Set history buffer size
function SetHistory(value) {
dump("SetHistory("+value+")\n");
window.xmlterm.SetHistory(value, document.cookie);
return (false);
}
// Set prompt
function SetPrompt(value) {
dump("SetPrompt("+value+")\n");
window.xmlterm.SetPrompt(value, document.cookie);
return (false);
}
// Create new XMLTerm window
function NewXMLTerm(firstcommand) {
newwin = window.openDialog( "chrome://xmlterm/content/xmlterm.xul",
"", "", firstcommand);
//newwin = window.xmlterm.NewXMLTermWindow(firstcommand);
dump("NewXMLTerm: "+newwin+"\n")
return (false);
}
// Handle resize events
function Resize(event) {
dump("Resize()\n");
window.xmlterm.Resize();
return (false);
}
// Scroll Home
function ScrollHome(isShift, isControl) {
dump("ScrollHome("+isShift+","+isControl+")\n");
if (isShift && window.xmltbrowser) {
window.xmltbrowser.scroll(0,0);
} else {
window.scroll(0,0);
}
return false;
}
// Scroll End
function ScrollEnd(isShift, isControl) {
dump("ScrollEnd("+isShift+","+isControl+")\n");
if (isShift && window.xmltbrowser) {
window.xmltbrowser.scroll(0,9999);
} else {
window.scroll(0,9999);
}
return false;
}
// Scroll PageUp
function ScrollPageUp(isShift, isControl) {
dump("ScrollPageUp("+isShift+","+isControl+")\n");
if (isShift && window.xmltbrowser) {
window.xmltbrowser.scrollBy(0,-300);
} else {
window.scrollBy(0,-300);
}
return false;
}
// Scroll PageDown
function ScrollPageDown(isShift, isControl) {
dump("ScrollPageDown("+isShift+","+isControl+")\n");
if (isShift && window.xmltbrowser) {
window.xmltbrowser.scrollBy(0,300);
} else {
window.scrollBy(0,300);
}
return false;
}
// Form Focus (workaround for form input being transmitted to xmlterm)
function FormFocus() {
dump("FormFocus()\n");
window.xmlterm.IgnoreKeyPress(true, document.cookie);
return false;
}
// Form Blur (workaround for form input being transmitted to xmlterm)
function FormBlur() {
dump("FormBlur()\n");
window.xmlterm.IgnoreKeyPress(false, document.cookie);
return false;
}
// Handle default meta command
function MetaDefault(arg1) {
return Load("http://"+arg1);
}
// Load URL in XMLTermBrowser window
function Load(url) {
var succeeded = false;
if (window.xmltbrowser) {
dump("Load:xmltbrowser.location.href="+window.xmltbrowser.location.href+"\n");
if (window.xmltbrowser.location.href.length) {
window.xmltbrowser.location = url;
succeeded = true;
}
}
if (!succeeded) {
window.xmltbrowser = window.open(url, "xmltbrowser");
}
return (false);
}
// Control display of all output elements
function DisplayAllOutput(flag) {
var outputElements = document.getElementsByName("output");
@ -26,9 +146,8 @@
}
// Click handler
function clickXMLTerm(name, number, arg) {
dump("clickXMLTerm("+name+","+number+","+arg+")\n");
//dump("clickXMLTerm:document.cookie="+document.cookie+"\n");
function clickXMLTerm(name, number, arg1, arg2) {
dump("clickXMLTerm("+name+","+number+","+arg1+","+arg2+")\n");
if (name === "prompt") {
var outputElement = document.getElementById("output"+number);
@ -47,38 +166,40 @@
var commandElement = document.getElementById(name+number);
var command = commandElement.firstChild.data;
dump("command = "+command+"\n\n");
window.xmltermshell.SendText("\025"+command+"\n", document.cookie);
window.xmlterm.SendText("\025"+command+"\n", document.cookie);
} else {
if ((number >= 0) &&
(window.xmltermshell.currentEntryNumber != number)) {
(window.xmlterm.currentEntryNumber != number)) {
dump("NOT CURRENT COMMAND\n");
return (false);
}
if (name == "directory") {
var command = "ls: "+arg;
dump("command = "+command+"\n\n");
window.xmltermshell.SendText("\025"+command+"\n", document.cookie);
if (name == "send") {
dump("send = "+arg1+"\n");
window.xmlterm.SendText(arg1, document.cookie);
} else if (name == "executable") {
var command = arg;
dump("command = "+command+"\n\n");
window.xmltermshell.SendText("\025"+command+"\n", document.cookie);
} else if (name == "send") {
dump("send = "+arg+"\n");
window.xmltermshell.SendText(arg, document.cookie);
} else if (name == "textlink") {
dump("textlink = "+arg1+"\n");
Load(arg1);
} else if (name == "sendln") {
dump("sendln = "+arg+"\n\n");
window.xmltermshell.SendText("\025"+arg+"\n", document.cookie);
if ((Math.abs(number)+1 == window.xmlterm.currentEntryNumber) &&
(arg2 != null)) {
// Current command
dump("sendln = "+arg2+"\n\n");
window.xmlterm.SendText("\025"+arg2+"\n", document.cookie);
} else {
// Not current command
dump("sendln = "+arg1+"\n\n");
window.xmlterm.SendText("\025"+arg1+"\n", document.cookie);
}
} else if (name == "createln") {
dump("createln = "+arg+"\n\n");
xmltermshell.NewXMLTermWindow(arg+"\n");
dump("createln = "+arg1+"\n\n");
newwin = NewXMLTerm(arg1+"\n");
}
}
@ -86,42 +207,34 @@
}
// Double Click handler
function dblclickXMLTerm(name, number, arg) {
dump("dblclickXMLTerm("+name+","+number+","+arg+")\n");
function dblclickXMLTerm(name, number, arg1) {
dump("dblclickXMLTerm("+name+","+number+","+arg1+")\n");
return (false);
}
// Set history buffer size
function SetHistory() {
var field = document.getElementById('HistoryValue');
dump("SetHistory "+field.value+"\n");
xmltermshell.SetHistory(field.value, document.cookie);
return (false);
// Set history buffer count using form entry
function SetHistoryValue() {
var field = document.getElementById('InputValue');
return SetHistory(field.value);
}
// Set prompt
function SetPrompt() {
var field = document.getElementById('PromptValue');
dump("SetPrompt "+field.value+"\n");
xmltermshell.prompt = field.value;
return (false);
}
// Create new XMLTerm window
function CreateXMLTermWindow(firstcommand) {
xmltermshell.NewXMLTermWindow(firstcommand);
return (false);
// Set prompt using form entry
function SetPromptValue() {
var field = document.getElementById('InputValue');
return SetPrompt(field.value);
}
// onLoad event handler
function LoadHandler() {
dump("xmlterm: LoadHandler ... "+window.xmltermshell+"\n");
dump("xmlterm: LoadHandler ... "+window.xmlterm+"\n");
if (window.xmltermshell) {
if (window.xmlterm) {
// XMLTerm already initialized
return (false);
}
dump("LoadHandler: WINDOW.ARGUMENTS="+window.arguments+"\n");
dump("Trying to make an XMLTerm Shell through the component manager...\n");
var xmltshell = Components.classes["component://mozilla/xmlterm/xmltermshell"].createInstance();
@ -138,13 +251,13 @@
}
// Store the XMLTerm shell in the window
window.xmltermshell = xmltshell;
window.xmlterm = xmltshell;
// Content window same as current window
var contentWindow = window;
// Initialize XMLTerm shell in content window with argvals
window.xmltermshell.Init(contentWindow, "", "");
window.xmlterm.Init(contentWindow, "", "");
//dump("LoadHandler:"+document.cookie+"\n");
@ -152,15 +265,20 @@
dump("document="+document+"\n");
dump("documentElement="+document.documentElement+"\n");
// Handle resize events
//contentWindow.addEventListener("onresize", Resize);
contentWindow.onresize = Resize;
// Set focus to appropriate frame
contentWindow.focus();
//contentWindow.xmltermshell = xmltermshell;
//contentWindow.xmlterm = xmlterm;
//dump(contentWindow.xmltermshell);
//dump(contentWindow.xmlterm);
return (false);
// The following code is for testing IFRAMEs only
dump("[Main] "+window+"\n");
dump(window.screenX+", "+window.screenY+"\n");
dump(window.scrollX+", "+window.scrollY+"\n");
@ -213,15 +331,16 @@
<TR><TD ALIGN=center>
<FORM NAME="XMLTERM form">
<INPUT TYPE="button" VALUE="Show all output"
onClick="return DisplayAllOutput(true);">
onClick="return ShowAll();">
<INPUT TYPE="button" VALUE="Hide all output"
onClick="return DisplayAllOutput(false);">
<INPUT TYPE="button" VALUE="New XMLterm"
onClick="return CreateXMLTermWindow('');">
onClick="return HideAll();">
<INPUT TYPE="button" VALUE="SetHistory"
onClick="return SetHistoryValue();">
<INPUT TYPE="button" VALUE="SetPrompt" onClick="return SetPromptValue();">
<BR>
History Buffer Size:
<INPUT TYPE="text" ID="HistoryValue" VALUE="">
<INPUT TYPE="button" VALUE="Set" onClick="return SetHistory();">
Input Value:
<INPUT SIZE=50 TYPE="text" ID="InputValue" VALUE=""
onFocus="return FormFocus();" onBlur="return FormBlur();">
</FORM>
</TABLE>

Просмотреть файл

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<!--
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 lineterm.
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):
-->
<?xml-stylesheet href="chrome://xmlterm/skin/xmlterm.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
<!DOCTYPE window>
<window id="xmlterm-window" xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="StartupXMLTerm();"
title="xmlterm" align="vertical" width="740" height="484">
<html:script src="chrome://xmlterm/content/XMLTermCommands.js"></html:script>
<html:iframe id="content-frame" type="content" html:name="content"
html:src="chrome://xmlterm/content/xmlterm.html" flex="100%"/>
</window>

Просмотреть файл

@ -0,0 +1,21 @@
<TITLE> XMLterm Init Frame </TITLE>
<FRAMESET ROWS="*,*">
<FRAME NAME="xmltbrowser" SRC="about:blank">
<FRAME SRC="chrome://xmlterm/content/xmlterm.html">
<NOFRAMES>
<BODY>
XMLterm No Frames Page
<BR>
See <A HREF="http://xmlterm.org">xmlterm.org</A> for more information.
</BODY>
</NOFRAMES>
</FRAMESET>

Просмотреть файл

@ -0,0 +1,41 @@
<?xml version="1.0"?>
<!--
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 lineterm.
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):
-->
<?xml-stylesheet href="chrome://xmlterm/skin/xmlterm.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
<!DOCTYPE window>
<window id="xmlterm-window" xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="StartupXMLTerm();"
title="xmlterm2" align="vertical" width="740" height="484">
<html:script src="chrome://xmlterm/content/XMLTermCommands.js"></html:script>
<html:iframe id="content-frame2" type="content" html:name="content2"
html:src="about:blank" flex="100%"/>
<html:iframe id="content-frame" type="content" html:name="content"
html:src="chrome://xmlterm/content/xmlterm.html" flex="100%"/>
</window>

Просмотреть файл

@ -34,8 +34,8 @@
# makefile for xmlterm/ui/skin directory
ifdef STAND_ALONE
DEPTH = .
topsrcdir = .
DEPTH = ../..
topsrcdir = ../..
VPATH = .
srcdir = .
include $(topsrcdir)/config/autoconf.mk
@ -55,6 +55,7 @@ include $(topsrcdir)/config/rules.mk
EXPORT_RESOURCE_SKIN = \
$(srcdir)/xmlterm.css \
$(srcdir)/xmltpage.css \
$(NULL)
EXPORT_RESOURCE_TOOLBAR = \

Просмотреть файл

@ -1,5 +1,8 @@
skin --- CSS stylesheets and images for user interface
xmlterm.css Stylesheet for XMLterm startup file ../content/xmlterm.html
xmlterm.css Stylesheet for XUL wrapper ../content/xmlterm.xul
xmltpage.css Stylesheet for XMLterm startup file ../content/xmlterm.html

Просмотреть файл

@ -1,23 +1,14 @@
/* xmlterm.css: XMLterm default style sheet */
/* xmlterm.css: Stylesheet for XUL wrapper ../content/xmlterm.xul */
BODY { font-family: monaco, courier, elite, monospace;
background-color: #FFFFFF;
}
@import url(chrome://global/skin/);
DIV, PRE, SPAN { margin: 0; padding-top: 0; padding-bottom: 0 }
PRE { font-family: monaco;
line-height: 120% }
/* Input components */
SPAN.prompt { color: blue }
SPAN.command { color: blue }
/* Screen display */
PRE.row { margin: 0; padding-top: 0; padding-bottom: 0 }
SPAN.row { margin: 0; padding-top: 0; padding-bottom: 0 }
/* Directory display */
SPAN.plainfile { font-family: monaco}
SPAN.directory { font-family: monaco; color: blue; cursor: hand }
SPAN.executable { font-family: monaco; color: blue; cursor: hand }
/**
* remove black border from iframe
*/
html|iframe {
min-width: 10px;
min-height: 10px;
width: 100px;
height: 100px;
border: none;
}

Просмотреть файл

@ -0,0 +1,28 @@
/* xmltpage.css: default style sheet for xmlterm.html */
BODY { font-family: monaco, courier, elite, monospace;
background-color: #FFFFFF;
}
DIV, PRE, SPAN { margin: 0; padding-top: 0; padding-bottom: 0 }
PRE { font-family: monaco;
line-height: 120% }
/* Input components */
SPAN.prompt { color: blue }
SPAN.command { color: blue }
/* Screen display */
PRE.row { margin: 0; padding-top: 0; padding-bottom: 0 }
SPAN.row { margin: 0; padding-top: 0; padding-bottom: 0 }
/* Highlighting */
DIV.textlink { font-family: monaco; color: blue; cursor: hand }
SPAN.textlink { font-family: monaco; color: blue; cursor: hand }
SPAN.directory { font-family: monaco; color: blue; cursor: hand }
SPAN.executable { font-family: monaco; color: blue; cursor: hand }
SPAN.plainfile { font-family: monaco; color: blue; cursor: hand}
SPAN.imagefile { font-family: monaco; color: blue; cursor: hand}
SPAN.urlfile { font-family: monaco; color: blue; cursor: hand}