diff --git a/mozilla/extensions/xmlterm/INSTALL b/mozilla/extensions/xmlterm/INSTALL index 666ec7b5eb6..33868b73902 100644 --- a/mozilla/extensions/xmlterm/INSTALL +++ b/mozilla/extensions/xmlterm/INSTALL @@ -5,7 +5,7 @@ INSTALL: Installation instructions for XMLterm source code *NOTE* Check the XMLterm web site 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 diff --git a/mozilla/extensions/xmlterm/Makefile.in b/mozilla/extensions/xmlterm/Makefile.in index 93b7eb5e169..0d000e1dd23 100644 --- a/mozilla/extensions/xmlterm/Makefile.in +++ b/mozilla/extensions/xmlterm/Makefile.in @@ -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 = diff --git a/mozilla/extensions/xmlterm/README b/mozilla/extensions/xmlterm/README index 6118604cdae..e69e12624ad 100644 --- a/mozilla/extensions/xmlterm/README +++ b/mozilla/extensions/xmlterm/README @@ -18,19 +18,20 @@ XMLterm is an open source project in its early stages. Comments and contributions are welcome! R. Saravanan -26 Dec 1999 +26 Feb 2000 =========== 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 -- diff --git a/mozilla/extensions/xmlterm/UUID.txt b/mozilla/extensions/xmlterm/UUID.txt index 507bdcfb205..670338d4b74 100644 --- a/mozilla/extensions/xmlterm/UUID.txt +++ b/mozilla/extensions/xmlterm/UUID.txt @@ -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" diff --git a/mozilla/extensions/xmlterm/base/lineterm.h b/mozilla/extensions/xmlterm/base/lineterm.h index 0b67b28f9b4..a65c22e084b 100644 --- a/mozilla/extensions/xmlterm/base/lineterm.h +++ b/mozilla/extensions/xmlterm/base/lineterm.h @@ -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. diff --git a/mozilla/extensions/xmlterm/base/ltermManager.c b/mozilla/extensions/xmlterm/base/ltermManager.c index 6175bbb62a4..87a9c13915f 100644 --- a/mozilla/extensions/xmlterm/base/ltermManager.c +++ b/mozilla/extensions/xmlterm/base/ltermManager.c @@ -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 diff --git a/mozilla/extensions/xmlterm/base/ltermOutput.c b/mozilla/extensions/xmlterm/base/ltermOutput.c index dd61c5142ba..09eada91b40 100644 --- a/mozilla/extensions/xmlterm/base/ltermOutput.c +++ b/mozilla/extensions/xmlterm/base/ltermOutput.c @@ -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; diff --git a/mozilla/extensions/xmlterm/base/ltermPrivate.h b/mozilla/extensions/xmlterm/base/ltermPrivate.h index 98d2f03ac87..0847b13d916 100644 --- a/mozilla/extensions/xmlterm/base/ltermPrivate.h +++ b/mozilla/extensions/xmlterm/base/ltermPrivate.h @@ -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 */ diff --git a/mozilla/extensions/xmlterm/base/mozILineTerm.idl b/mozilla/extensions/xmlterm/base/mozILineTerm.idl index 8def00d3d93..edd18056f9f 100644 --- a/mozilla/extensions/xmlterm/base/mozILineTerm.idl +++ b/mozilla/extensions/xmlterm/base/mozILineTerm.idl @@ -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); diff --git a/mozilla/extensions/xmlterm/base/mozILineTermAux.h b/mozilla/extensions/xmlterm/base/mozILineTermAux.h index 3374a05134b..186ba2b5e1a 100644 --- a/mozilla/extensions/xmlterm/base/mozILineTermAux.h +++ b/mozilla/extensions/xmlterm/base/mozILineTermAux.h @@ -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, diff --git a/mozilla/extensions/xmlterm/base/mozIXMLTermShell.idl b/mozilla/extensions/xmlterm/base/mozIXMLTermShell.idl index 795845d6e55..b79f6499da9 100644 --- a/mozilla/extensions/xmlterm/base/mozIXMLTermShell.idl +++ b/mozilla/extensions/xmlterm/base/mozIXMLTermShell.idl @@ -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) */ diff --git a/mozilla/extensions/xmlterm/base/mozIXMLTermSuspend.h b/mozilla/extensions/xmlterm/base/mozIXMLTermSuspend.h new file mode 100644 index 00000000000..1ccc9ffc5cb --- /dev/null +++ b/mozilla/extensions/xmlterm/base/mozIXMLTermSuspend.h @@ -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 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___ */ diff --git a/mozilla/extensions/xmlterm/base/mozIXMLTerminal.h b/mozilla/extensions/xmlterm/base/mozIXMLTerminal.h index a1a759eb326..57111ad8a44 100644 --- a/mozilla/extensions/xmlterm/base/mozIXMLTerminal.h +++ b/mozilla/extensions/xmlterm/base/mozIXMLTerminal.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 */ diff --git a/mozilla/extensions/xmlterm/base/mozLineTerm.cpp b/mozilla/extensions/xmlterm/base/mozLineTerm.cpp index 0ca0e2b87d5..979f90230b4 100644 --- a/mozilla/extensions/xmlterm/base/mozLineTerm.cpp +++ b/mozilla/extensions/xmlterm/base/mozLineTerm.cpp @@ -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); diff --git a/mozilla/extensions/xmlterm/base/mozLineTerm.h b/mozilla/extensions/xmlterm/base/mozLineTerm.h index 2afe6ad6adf..f217e941272 100644 --- a/mozilla/extensions/xmlterm/base/mozLineTerm.h +++ b/mozilla/extensions/xmlterm/base/mozLineTerm.h @@ -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, diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp index 70645bd804e..c5926341bf1 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp @@ -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 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 keyEvent; keyEvent = do_QueryInterface(aKeyEvent); @@ -253,63 +237,135 @@ mozXMLTermKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) return NS_OK; } +#if 0 // Debugging + nsCOMPtr presShell; + result = mXMLTerminal->GetPresShell(getter_AddRefs(presShell)); + if (NS_SUCCEEDED(result) && presShell) { + nsCOMPtr selection; + result = presShell->GetSelection(SELECTION_NORMAL, + getter_AddRefs(selection)); + if (NS_SUCCEEDED(result) && selection) { + nsCOMPtr 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 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); } } diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermListeners.h b/mozilla/extensions/xmlterm/base/mozXMLTermListeners.h index 4a39707d22b..32a42862312 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermListeners.h +++ b/mozilla/extensions/xmlterm/base/mozXMLTermListeners.h @@ -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; }; diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp index ceaae365c14..70b085e2b70 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp @@ -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 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; diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermSession.h b/mozilla/extensions/xmlterm/base/mozXMLTermSession.h index 760ed964d92..27f3515399a 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermSession.h +++ b/mozilla/extensions/xmlterm/base/mozXMLTermSession.h @@ -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 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; diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp index 34c8ba7d84f..705753f3f27 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp @@ -25,10 +25,25 @@ #include +#undef RAW_GTK_WINDOW + #include "nscore.h" #include "nsCOMPtr.h" #include "nsString.h" +#ifdef RAW_GTK_WINDOW +#include +#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 contentAreaWebShell( do_QueryInterface(mContentAreaDocShell) ); + + XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check0, contWebShell=0x%x\n", + (int) contentAreaWebShell.get())); + + nsCOMPtr topContainer = nsnull; + result = contentAreaWebShell->GetTopLevelWindow(getter_AddRefs(topContainer)); + XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check0, topContainer=0x%x\n", + (int) topContainer.get())); + + nsCOMPtr topWin( do_QueryInterface(topContainer) ); + XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check0, topWin=0x%x\n", + (int) topWin.get())); + + // Determine preferences + nsCOMPtr 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 gSimpleContainer = nsnull; + result = NS_NewSimpleContainer(getter_AddRefs(gSimpleContainer)); + + if (NS_FAILED(result) || !gSimpleContainer) { + return result; // Exit main program + } + + // Determine window dimensions + GtkAllocation *alloc = >K_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 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 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 webShellWin; + nsCOMPtr 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; +} diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermShell.h b/mozilla/extensions/xmlterm/base/mozXMLTermShell.h index 910e93fdd5f..371b202757f 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermShell.h +++ b/mozilla/extensions/xmlterm/base/mozXMLTermShell.h @@ -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 */ diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp index 43c7c3b53b7..fe269aeaa7b 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp @@ -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 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 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; diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.h b/mozilla/extensions/xmlterm/base/mozXMLTerminal.h index a735e814446..b4bd28e646b 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.h +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.h @@ -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; diff --git a/mozilla/extensions/xmlterm/doc/BUGS b/mozilla/extensions/xmlterm/doc/BUGS index 4285b3f6dc4..6b774755353 100644 --- a/mozilla/extensions/xmlterm/doc/BUGS +++ b/mozilla/extensions/xmlterm/doc/BUGS @@ -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) diff --git a/mozilla/extensions/xmlterm/doc/INSTALL.xmlterm b/mozilla/extensions/xmlterm/doc/INSTALL.xmlterm index 62f32014be5..54c608e6844 100644 --- a/mozilla/extensions/xmlterm/doc/INSTALL.xmlterm +++ b/mozilla/extensions/xmlterm/doc/INSTALL.xmlterm @@ -3,21 +3,22 @@ XMLterm installation instructions for Linux binaries *NOTE* This work in progress. User beware! -*NOTE* Check the XMLterm web site for updates. +*NOTE* This plain text INSTALL file may be out date. Please check + 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. -- diff --git a/mozilla/extensions/xmlterm/geckoterm/Makefile.in b/mozilla/extensions/xmlterm/geckoterm/Makefile.in index 64cacd24c69..45c2286121d 100644 --- a/mozilla/extensions/xmlterm/geckoterm/Makefile.in +++ b/mozilla/extensions/xmlterm/geckoterm/Makefile.in @@ -50,7 +50,7 @@ endif DEBUG = 1 # Program -PROGRAM = xmlterm +PROGRAM = geckoterm # Exported header files EXPORTS = mozISimpleContainer.h diff --git a/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp b/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp index 57cc46e2707..4107aade398 100644 --- a/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp +++ b/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp @@ -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(); diff --git a/mozilla/extensions/xmlterm/linetest/lterm.c b/mozilla/extensions/xmlterm/linetest/lterm.c index 4e1bc36dcf4..fa0df115ed5 100644 --- a/mozilla/extensions/xmlterm/linetest/lterm.c +++ b/mozilla/extensions/xmlterm/linetest/lterm.c @@ -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); diff --git a/mozilla/extensions/xmlterm/ui/Makefile.in b/mozilla/extensions/xmlterm/ui/Makefile.in index 5b1fb7cd585..c39083d1c20 100644 --- a/mozilla/extensions/xmlterm/ui/Makefile.in +++ b/mozilla/extensions/xmlterm/ui/Makefile.in @@ -34,8 +34,8 @@ # makefile for xmlterm/ui directory ifdef STAND_ALONE -DEPTH = . -topsrcdir = . +DEPTH = .. +topsrcdir = .. VPATH = . srcdir = . include $(topsrcdir)/config/autoconf.mk diff --git a/mozilla/extensions/xmlterm/ui/content/Makefile.in b/mozilla/extensions/xmlterm/ui/content/Makefile.in index b1aec051fc7..5dcad8d39ef 100644 --- a/mozilla/extensions/xmlterm/ui/content/Makefile.in +++ b/mozilla/extensions/xmlterm/ui/content/Makefile.in @@ -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) diff --git a/mozilla/extensions/xmlterm/ui/content/README b/mozilla/extensions/xmlterm/ui/content/README index 92d35581409..4ffc83ec39b 100644 --- a/mozilla/extensions/xmlterm/ui/content/README +++ b/mozilla/extensions/xmlterm/ui/content/README @@ -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 diff --git a/mozilla/extensions/xmlterm/ui/content/XMLTermCommands.js b/mozilla/extensions/xmlterm/ui/content/XMLTermCommands.js new file mode 100644 index 00000000000..da763cda2ae --- /dev/null +++ b/mozilla/extensions/xmlterm/ui/content/XMLTermCommands.js @@ -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); +} diff --git a/mozilla/extensions/xmlterm/ui/content/xmlterm.html b/mozilla/extensions/xmlterm/ui/content/xmlterm.html index aa80613381e..058c3cc4bb4 100644 --- a/mozilla/extensions/xmlterm/ui/content/xmlterm.html +++ b/mozilla/extensions/xmlterm/ui/content/xmlterm.html @@ -1,13 +1,133 @@ - + - XMLterm Test Page + XMLterm Page + HREF="chrome://xmlterm/skin/xmltpage.css">