From abcb23fef96a7117bc0f6931e5e4506bc1b9331c Mon Sep 17 00:00:00 2001 From: "svn%xmlterm.org" Date: Tue, 22 Feb 2000 20:18:19 +0000 Subject: [PATCH] xmlterm changes only, a=leaf (not part of the default build). Implemented full screen operations in XMLTerm, although still buggy. Commands like 'less', 'vi', and 'emacs -nw' now work in stand-alone xmlterm, although scrolling is still messed up. Compiles with Feb21 tree. git-svn-id: svn://10.0.0.236/trunk@61437 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/xmlterm/INSTALL | 26 +- mozilla/extensions/xmlterm/README | 17 +- mozilla/extensions/xmlterm/base/lineterm.h | 31 +- mozilla/extensions/xmlterm/base/ltermIO.c | 17 +- .../extensions/xmlterm/base/ltermManager.c | 112 +++- mozilla/extensions/xmlterm/base/ltermOutput.c | 23 +- .../extensions/xmlterm/base/ltermPrivate.h | 6 +- .../extensions/xmlterm/base/mozILineTerm.idl | 4 - .../extensions/xmlterm/base/mozILineTermAux.h | 23 +- .../xmlterm/base/mozIXMLTermShell.idl | 27 +- .../extensions/xmlterm/base/mozIXMLTerminal.h | 10 + .../extensions/xmlterm/base/mozLineTerm.cpp | 42 +- mozilla/extensions/xmlterm/base/mozLineTerm.h | 24 +- .../xmlterm/base/mozXMLTermListeners.cpp | 3 + .../xmlterm/base/mozXMLTermSession.cpp | 532 +++++++++++++++++- .../xmlterm/base/mozXMLTermSession.h | 56 +- .../xmlterm/base/mozXMLTermShell.cpp | 85 ++- .../extensions/xmlterm/base/mozXMLTermShell.h | 15 +- .../xmlterm/base/mozXMLTerminal.cpp | 72 ++- .../extensions/xmlterm/base/mozXMLTerminal.h | 9 +- mozilla/extensions/xmlterm/config/rules.mk | 3 + mozilla/extensions/xmlterm/doc/BUGS | 7 +- .../xmlterm/geckoterm/mozGeckoTerm.cpp | 7 +- .../xmlterm/geckoterm/mozSimpleContainer.cpp | 16 - mozilla/extensions/xmlterm/linetest/lterm.c | 34 +- .../xmlterm/ui/content/xmlterm.html | 3 +- .../extensions/xmlterm/ui/skin/xmlterm.css | 4 + 27 files changed, 1045 insertions(+), 163 deletions(-) diff --git a/mozilla/extensions/xmlterm/INSTALL b/mozilla/extensions/xmlterm/INSTALL index 1639277cc11..666ec7b5eb6 100644 --- a/mozilla/extensions/xmlterm/INSTALL +++ b/mozilla/extensions/xmlterm/INSTALL @@ -5,13 +5,27 @@ INSTALL: Installation instructions for XMLterm source code *NOTE* Check the XMLterm web site for updates. -7 Dec 1999 +26 Dec 1999 + +QUICK INSTALLATION INSTRUCTIONS (Linux/Solaris) +----------------------------------------------- + +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 + + +DETAILED INSTALLATION INSTRUCTIONS +---------------------------------- In the following discussion, file and directory names are relative to the main ("mozilla/extensions/xmlterm") directory. See the end of the README file for a brief description of the subdirectories. - 1. Source tree (skip this step if XMLterm is already in the source tree) ------------------------------------------------------------------------ @@ -117,8 +131,12 @@ executable path to use it. Step 3 also creates an executable called "xmlterm" 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. Executing -"xmlterm" will create an XMLterm window. Click on this window to give it focus +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 + +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. diff --git a/mozilla/extensions/xmlterm/README b/mozilla/extensions/xmlterm/README index fd502eecadc..6118604cdae 100644 --- a/mozilla/extensions/xmlterm/README +++ b/mozilla/extensions/xmlterm/README @@ -17,13 +17,24 @@ document. XMLterm is an open source project in its early stages. Comments and contributions are welcome! -R. Saravanan -28 Nov 1999 +R. Saravanan +26 Dec 1999 =========== +QUICK SET-UP INSTRUCTIONS (Linux/Solaris) +----------------------------------------- + +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 + NOTES: - 1. See the INSTALL file for configuration/installation instructions. + 1. See the INSTALL file for detailed configuration/installation instructions. 2. See the file doc/INSTALL.xmlterm for binary installation instructions. diff --git a/mozilla/extensions/xmlterm/base/lineterm.h b/mozilla/extensions/xmlterm/base/lineterm.h index dd9c36beb48..0b67b28f9b4 100644 --- a/mozilla/extensions/xmlterm/base/lineterm.h +++ b/mozilla/extensions/xmlterm/base/lineterm.h @@ -63,7 +63,7 @@ extern "C" { /* LTERM module number (used for trace/log operations) */ #define LTERM_TLOG_MODULE 1 -/* Initializes all LTERM operations; +/** Initializes all LTERM operations; * needs to be called before any calls to lterm_new. * @return 0 on success, or -1 on error. * @@ -90,7 +90,7 @@ int lterm_init(int messageLevel); int lterm_new(); -/* Opens line terminal indexed by LTERM for input/output and creates +/** Opens line terminal indexed by LTERM for input/output and creates * a process attached to it to execute the command line contained in string * array ARGV. * Called from the adminstrative/output thread of LTERM. @@ -162,7 +162,7 @@ int lterm_open(int lterm, char *const argv[], const char* cookie, lterm_callback_func_t callback_func, void *callback_data); -/* Closes line terminal indexed by LTERM. +/** Closes line terminal indexed by LTERM. * The default action is to block until active calls to lterm_write * and lterm_read to complete. * Called from the administrative/output thread of LTERM. @@ -178,14 +178,14 @@ int lterm_close(int lterm); int lterm_delete(int lterm); -/* Closes all LTERMs, but does not delete them. +/** Closes all LTERMs, but does not delete them. * This may be used to free any resources associated with LTERMs for clean up. * The closed LTERMs should still be deleted, if possible. */ void lterm_close_all(void); -/* Set input echo flag for line terminal indexed by LTERM. +/** Set input echo flag for line terminal indexed by LTERM. * Called from the output thread of LTERM. * @return 0 on success, or -1 on error. */ @@ -193,16 +193,18 @@ void lterm_close_all(void); int lterm_setecho(int lterm, int echo_flag); -/* Resizes the line terminal indexed by LTERM. +/** Resizes the line terminal indexed by LTERM to new row/column count. * Called from the output thread of LTERM. * @return 0 on success, or -1 on error. */ -int lterm_resize(int lterm, int rows, int cols, - int xpix, int ypix); +int lterm_resize(int lterm, int rows, int cols); -/* Sets cursor position in line terminal indexed by LTERM. +/** Sets cursor position in line terminal indexed by LTERM. + * NOT YET IMPLEMENTED + * Row numbers increase upward, starting from 0. + * Column numbers increase rightward, starting from 0. * Called from the output thread of LTERM. * @return 0 on success, or -1 on error. */ @@ -210,7 +212,7 @@ int lterm_resize(int lterm, int rows, int cols, int lterm_setcursor(int lterm, int row, int col); -/* Writes supplied to Unicode string in BUF of length COUNT to +/** Writes supplied to Unicode string in BUF of length COUNT to * line terminal indexed by LTERM. * (May be called from any thread, since it uses a pipe to communicate * with the output thread.) @@ -231,7 +233,7 @@ int lterm_setcursor(int lterm, int row, int col); int lterm_write(int lterm, const UNICHAR *buf, int count, int dataType); -/* Completes meta input in line terminal indexed by LTERM with the +/** Completes meta input in line terminal indexed by LTERM with the * supplied to Unicode string in BUF of length COUNT. * Called from the output thread of the LTERM. * @return 0 on success, or -1 on error. @@ -240,7 +242,7 @@ int lterm_write(int lterm, const UNICHAR *buf, int count, int dataType); int lterm_metacomplete(int lterm, const UNICHAR *buf, int count); -/* reads upto COUNT Unicode characters from a single line of output +/** reads upto COUNT Unicode characters from a single line of output * from line terminal indexed by LTERM into BUF. * Called from the output thread of the LTERM. * Returns the number of characters read (>=0) on a successful read. @@ -274,6 +276,8 @@ int lterm_metacomplete(int lterm, const UNICHAR *buf, int count); * * OPCODES ::= SCREENDATA BELL? ( OUTPUT | CLEAR | INSERT | DELETE | SCROLL )? * if ScreenMode data is being returned. + * If none of the flags OUTPUT ... SCROLL are set in screen mode, + * do nothing but position the cursor (and ring the bell, if need be). * * OPCODES ::= LINEDATA BELL? ( CLEAR * | ( PROMPT | OUTPUT)? INPUT ( NEWLINE HIDE? )? @@ -289,8 +293,7 @@ int lterm_metacomplete(int lterm, const UNICHAR *buf, int count); * * BUF_ROW and BUF_COL denote the row and starting column at which to * display the data in BUF. - * (If character count returned by lterm_read is zero, implying there is no - * data in BUF, then values of BUF_ROW and BUF_COL should be ignored.) + * (BUF_ROW and BUF_COL are not used for CLEAR option in screen/line mode) * In ScreenMode or LineMode, CURSOR_ROW and CURSOR_COL denote the final * cursor position after any data in BUF is displayed. * diff --git a/mozilla/extensions/xmlterm/base/ltermIO.c b/mozilla/extensions/xmlterm/base/ltermIO.c index 2b4b436ce3e..3666f2cd96b 100644 --- a/mozilla/extensions/xmlterm/base/ltermIO.c +++ b/mozilla/extensions/xmlterm/base/ltermIO.c @@ -467,6 +467,19 @@ int ltermRead(struct lterms *lts, struct LtermRead *ltr, int timeout) LTERM_LOG(ltermRead,20,("start outputMode=%d\n", lto->outputMode)); + if (lto->outputMode == LTERM1_SCREEN_MODE) { + char modifiedRows[81]; + int showRows = (lts->nRows < 80) ? lts->nRows : 80; + for (j=0; jmodifiedCol[j] > -1) + modifiedRows[j] = 'M'; + else + modifiedRows[j] = '.'; + } + modifiedRows[showRows] = '\0'; + LTERM_LOG(ltermRead,28,("modifiedRows=%s\n", modifiedRows)); + } + waitTime = timeout; if (lts->inputBufRecord) { @@ -492,7 +505,7 @@ int ltermRead(struct lterms *lts, struct LtermRead *ltr, int timeout) break; } - if (waitTime == 0) { + if (jnRows) { LTERM_LOG(ltermRead,21,("j=%d, modifiedCol[j] = %d\n", j, lto->modifiedCol[j])); } @@ -816,7 +829,7 @@ static int ltermReturnStreamData(struct lterms *lts, struct LtermRead *ltr) lto->decodedOutput[lto->decodedChars] = U_NUL; /* There should be no NULs in decoded output */ - assert(ucslen(lto->decodedOutput) == lto->decodedChars); + assert((int)ucslen(lto->decodedOutput) == lto->decodedChars); /* Search for stream terminator string in decoded output */ locTerminator = ucsucs(lto->decodedOutput, lto->streamTerminator); diff --git a/mozilla/extensions/xmlterm/base/ltermManager.c b/mozilla/extensions/xmlterm/base/ltermManager.c index 59b5ddc1ac5..6175bbb62a4 100644 --- a/mozilla/extensions/xmlterm/base/ltermManager.c +++ b/mozilla/extensions/xmlterm/base/ltermManager.c @@ -308,10 +308,9 @@ int lterm_open(int lterm, char *const argv[], const char* cookie, lto->decodedChars = 0; lto->incompleteEscapeSequence = 0; - /* Set screen parameters (VT100) */ + /* Set default screen size (VT100) */ lts->nRows = 24; lts->nCols = 80; - lts->screenSize = lts->nRows * lts->nCols; /* Clear screen buffer */ lto->screenChar = NULL; @@ -437,7 +436,7 @@ int lterm_open(int lterm, char *const argv[], const char* cookie, LTERM_OPEN_ERROR_RETURN(lterm,lts, "lterm_open: Error - PTY resizing failed\n") } -#endif /* NO_PTY */ +#endif /* !NO_PTY */ /* Copy PTY structure */ lts->pty = ptyStruc; @@ -689,7 +688,7 @@ int ltermClose(struct lterms *lts) /* Close PTY */ #ifndef NO_PTY pty_close(&(lts->pty)); -#endif +#endif /* !NO_PTY */ } else { /* Destroy process */ @@ -868,6 +867,111 @@ int lterm_setecho(int lterm, int echo_flag) } +/** Resizes the line terminal indexed by LTERM to new row/column count. + * Called from the output thread of LTERM. + * @return 0 on success, or -1 on error. + */ + +int lterm_resize(int lterm, int rows, int cols) +{ + struct lterms *lts; + struct LtermOutput *lto; + + CHECK_IF_VALID_LTERM_NUMBER(lterm_resize,lterm) + + LTERM_LOG(lterm_resize,10,("Resizing LTERM=%d, rows=%d, cols=%d\n", + lterm, rows, cols)); + + if ((rows <= 0) || (cols <= 0)) + return -1; + + GLOBAL_LOCK; + + lts = ltermGlobal.termList[lterm]; + + if (lts == NULL || !lts->opened || lts->suspended) { + /* LTERM is deleted/closed/suspended */ + if (lts == NULL) + LTERM_WARNING("lterm_resize: Warning - LTERM %d not active\n", lterm); + GLOBAL_UNLOCK; + return -2; + } + + if ((rows == lts->nRows) && (cols == lts->nCols)) { + /* Nothing to do */ + GLOBAL_UNLOCK; + return 0; + } + + lto = &(lts->ltermOutput); + + /* Free full screen buffers */ + if (lto->screenChar != NULL) + FREE(lto->screenChar); + + if (lto->screenStyle != NULL) + FREE(lto->screenStyle); + + /* Clear screen buffer */ + lto->screenChar = NULL; + lto->screenStyle = NULL; + + /* Resize screen */ + lts->nRows = rows; + lts->nCols = cols; + + if (lts->ptyMode) { + /* Resize PTY */ +#ifndef NO_PTY + if (pty_resize(&(lts->pty), lts->nRows, lts->nCols, 0, 0) != 0) { + GLOBAL_UNLOCK; + return -1; + } +#endif /* !NO_PTY */ + } + + GLOBAL_UNLOCK; + + return 0; +} + + +/** Sets cursor position in line terminal indexed by LTERM. + * NOT YET IMPLEMENTED + * Row numbers increase upward, starting from 0. + * Column numbers increase rightward, starting from 0. + * Called from the output thread of LTERM. + * @return 0 on success, or -1 on error. + */ + +int lterm_setcursor(int lterm, int row, int col) +{ + struct lterms *lts; + + CHECK_IF_VALID_LTERM_NUMBER(lterm_setcursor,lterm) + + LTERM_LOG(lterm_setcursor,10, + ("Setting cursor, LTERM=%d row=%d, col=%d (NOT YET IMPLEMENTED)\n", + lterm, row, col)); + + GLOBAL_LOCK; + + lts = ltermGlobal.termList[lterm]; + + if (lts == NULL || !lts->opened || lts->suspended) { + /* LTERM is deleted/closed/suspended */ + if (lts == NULL) + LTERM_WARNING("lterm_setcursor: Warning - LTERM %d not active\n", lterm); + GLOBAL_UNLOCK; + return -2; + } + + GLOBAL_UNLOCK; + + return 0; +} + + /** Writes a string to LTERM (documented in the LTERM interface) */ int lterm_write(int lterm, const UNICHAR *buf, int count, int dataType) { diff --git a/mozilla/extensions/xmlterm/base/ltermOutput.c b/mozilla/extensions/xmlterm/base/ltermOutput.c index 7defc29408a..dd61c5142ba 100644 --- a/mozilla/extensions/xmlterm/base/ltermOutput.c +++ b/mozilla/extensions/xmlterm/base/ltermOutput.c @@ -141,7 +141,7 @@ int ltermProcessOutput(struct lterms *lts, int *opcodes, int *opvals, /* Replace character and style info at current cursor location */ j = lto->cursorRow*lts->nCols + lto->cursorCol; - assert(j < lts->screenSize); + assert(j < (lts->nRows * lts->nCols)); lto->screenChar[j] = uch; lto->screenStyle[j] = ustyle; @@ -375,6 +375,19 @@ int ltermProcessOutput(struct lterms *lts, int *opcodes, int *opvals, } } + if (lto->outputMode == LTERM1_SCREEN_MODE) { + char modifiedRows[81]; + int showRows = (lts->nRows < 80) ? lts->nRows : 80; + for (j=0; jmodifiedCol[j] > -1) + modifiedRows[j] = 'M'; + else + modifiedRows[j] = '.'; + } + modifiedRows[showRows] = '\0'; + LTERM_LOG(ltermProcessOutput,38,("modifiedRows=%s\n", modifiedRows)); + } + LTERM_LOG(ltermProcessOutput,31,("returned opcodes=0x%X\n", *opcodes)); return 0; @@ -397,7 +410,7 @@ void ltermClearOutputLine(struct lterms *lts) } -/** Clears output screen buffer (allocating memory, if first time) */ +/** Clears output screen buffer (allocating memory, if first time/resized) */ int ltermClearOutputScreen(struct lterms *lts) { struct LtermOutput *lto = &(lts->ltermOutput); @@ -407,7 +420,9 @@ int ltermClearOutputScreen(struct lterms *lts) if (lto->screenChar == NULL) { /* Allocate memory for full screen */ - lto->screenChar = (UNICHAR *) MALLOC(lts->screenSize * sizeof(UNICHAR)); + int screenSize = lts->nRows * lts->nCols; + + lto->screenChar = (UNICHAR *) MALLOC(screenSize * sizeof(UNICHAR)); if (lto->screenChar == NULL) { LTERM_ERROR("ltermClearOutputScreen: Error - failed to allocate memory for chars\n"); @@ -415,7 +430,7 @@ int ltermClearOutputScreen(struct lterms *lts) } assert(lto->screenStyle == NULL); - lto->screenStyle = (UNISTYLE *) MALLOC(lts->screenSize * sizeof(UNISTYLE)); + lto->screenStyle = (UNISTYLE *) MALLOC(screenSize * sizeof(UNISTYLE)); if (lto->screenStyle == NULL) { LTERM_ERROR("ltermClearOutputScreen: Error - failed to allocate memory for style\n"); diff --git a/mozilla/extensions/xmlterm/base/ltermPrivate.h b/mozilla/extensions/xmlterm/base/ltermPrivate.h index c1298f27b5c..98d2f03ac87 100644 --- a/mozilla/extensions/xmlterm/base/ltermPrivate.h +++ b/mozilla/extensions/xmlterm/base/ltermPrivate.h @@ -437,8 +437,8 @@ struct LtermOutput { int modifiedCol[MAXROW]; /* first modified column in each row; -1 if no column has been modified */ - UNICHAR *screenChar; /* Screen character array (screenSize long) */ - UNISTYLE *screenStyle; /* Screen style array (screenSize long) */ + UNICHAR *screenChar; /* Screen character array (nRows*nCols long) */ + UNISTYLE *screenStyle; /* Screen style array (nRows*nCols long) */ }; /* LTERM process structure: managed by lterm_create, lterm_close */ @@ -503,8 +503,6 @@ struct lterms { int nRows; /* Number of rows */ int nCols; /* Number of columns */ - long screenSize; /* Screen size, in characters - = nRows*nCols */ UNICHAR promptRegexp[MAXPROMPT]; /* prompt regular expression JUST A LIST OF DELIMITERS AT PRESENT */ diff --git a/mozilla/extensions/xmlterm/base/mozILineTerm.idl b/mozilla/extensions/xmlterm/base/mozILineTerm.idl index 8f5e2307891..8def00d3d93 100644 --- a/mozilla/extensions/xmlterm/base/mozILineTerm.idl +++ b/mozilla/extensions/xmlterm/base/mozILineTerm.idl @@ -32,10 +32,6 @@ class nsIDOMDocument; interface mozILineTerm : nsISupports { - attribute long cursorRow; - attribute long cursorColumn; - attribute boolean echoFlag; - /** 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 diff --git a/mozilla/extensions/xmlterm/base/mozILineTermAux.h b/mozilla/extensions/xmlterm/base/mozILineTermAux.h index 06a3c1e386e..3374a05134b 100644 --- a/mozilla/extensions/xmlterm/base/mozILineTermAux.h +++ b/mozilla/extensions/xmlterm/base/mozILineTermAux.h @@ -43,12 +43,6 @@ class mozILineTermAux : public mozILineTerm { NS_DEFINE_STATIC_IID_ACCESSOR(MOZILINETERMAUX_IID) // mozILineTerm interface - NS_IMETHOD GetCursorRow(PRInt32 *aCursorRow) = 0; - NS_IMETHOD SetCursorRow(PRInt32 aCursorRow) = 0; - - NS_IMETHOD GetCursorColumn(PRInt32 *aCursorColumn) = 0; - NS_IMETHOD SetCursorColumn(PRInt32 aCursorColumn) = 0; - NS_IMETHOD Open(const PRUnichar *command, const PRUnichar *promptRegexp, PRInt32 options, PRInt32 processType, @@ -100,6 +94,12 @@ class mozILineTermAux : public mozILineTerm { */ NS_IMETHOD CloseAllAux(void) = 0; + /** Resizes XMLterm to match a resized window. + * @param nRows number of rows + * @param nCols number of columns + */ + NS_IMETHOD ResizeAux(PRInt32 nRows, PRInt32 nCols) = 0; + /** Read output data and style strings and parameters from LineTerm * @param opcodes (output) output data descriptor bits (see lineterm.h) * @param opvals (output) output data value(s) @@ -113,6 +113,17 @@ class mozILineTermAux : public mozILineTerm { NS_IMETHOD ReadAux(PRInt32 *opcodes, PRInt32 *opvals, PRInt32 *buf_row, PRInt32 *buf_col, PRUnichar **_retval, PRUnichar **retstyle) = 0; + + NS_IMETHOD GetCookie(nsString& aCookie) = 0; + + NS_IMETHOD GetCursorRow(PRInt32 *aCursorRow) = 0; + NS_IMETHOD SetCursorRow(PRInt32 aCursorRow) = 0; + + NS_IMETHOD GetCursorColumn(PRInt32 *aCursorColumn) = 0; + NS_IMETHOD SetCursorColumn(PRInt32 aCursorColumn) = 0; + + NS_IMETHOD GetEchoFlag(PRBool *aEchoFlag) = 0; + NS_IMETHOD SetEchoFlag(PRBool aEchoFlag) = 0; }; // Factory for mozILineTermAux diff --git a/mozilla/extensions/xmlterm/base/mozIXMLTermShell.idl b/mozilla/extensions/xmlterm/base/mozIXMLTermShell.idl index 2ae58044ca2..795845d6e55 100644 --- a/mozilla/extensions/xmlterm/base/mozIXMLTermShell.idl +++ b/mozilla/extensions/xmlterm/base/mozIXMLTermShell.idl @@ -35,8 +35,6 @@ class nsIDOMWindow; interface mozIXMLTermShell : nsISupports { readonly attribute long currentEntryNumber; /* current entry (command) no. */ - attribute long history; /* command history buffer count */ - attribute wstring prompt; /* HTML prompt string */ /** Initializes XMLterm in specified window * @param contentWin content window object @@ -45,21 +43,38 @@ interface mozIXMLTermShell : nsISupports * @param args argument string to be passed to XMLterm * (at the moment this just contains any initial input data) */ - void Init(in nsIDOMWindow contentWin, in wstring URL, in wstring args); + void Init(in nsIDOMWindow aContentWin, in wstring URL, in wstring args); - /** Finalizes (closes) XMLterm + /** Closes XMLterm, freeing resources + * @param aCookie document.cookie string for authentication */ - void Finalize(); + void Close(in wstring aCookie); /** Polls for readable data from XMLterm */ void Poll(); + /** Resizes XMLterm to match a resized window. + */ + void Resize(); + /** Writes string to terminal as if the user had typed it (command input) * @param buf string to be transmitted to terminal * @param aCookie document.cookie string for authentication */ - void SendText(in wstring buf, in wstring cookie); + void SendText(in wstring aString, in wstring aCookie); + + /** Sets command history buffer count + * @param aHistory history buffer count + * @param aCookie document.cookie string for authentication + */ + void SetHistory(in long aHistory, in wstring aCookie); + + /** Sets command prompt + * @param aPrompt command prompt string (HTML) + * @param aCookie document.cookie string for authentication + */ + void SetPrompt(in wstring aPrompt, in wstring aCookie); /** Opens new XMLterm window with specified args (not yet implemented) * @param args argument string to be passed to XMLterm diff --git a/mozilla/extensions/xmlterm/base/mozIXMLTerminal.h b/mozilla/extensions/xmlterm/base/mozIXMLTerminal.h index f85249d9bd1..a1a759eb326 100644 --- a/mozilla/extensions/xmlterm/base/mozIXMLTerminal.h +++ b/mozilla/extensions/xmlterm/base/mozIXMLTerminal.h @@ -120,6 +120,16 @@ public: * @param aPresShell (output) presentation shell */ NS_IMETHOD GetPresShell(nsIPresShell** aPresShell) = 0; + + /** Checks if supplied cookie is valid for XMLTerm + * @param aCookie supplied cookie string + * @param _retval true if supplied cookie matches XMLTerm cookie + */ + NS_IMETHOD MatchesCookie(const PRUnichar* aCookie, PRBool *_retval) = 0; + + /** Resizes XMLterm to match a resized window. + */ + NS_IMETHOD Resize(void) = 0; }; #define MOZXMLTERMINAL_CID \ diff --git a/mozilla/extensions/xmlterm/base/mozLineTerm.cpp b/mozilla/extensions/xmlterm/base/mozLineTerm.cpp index dce65757f96..0ca0e2b87d5 100644 --- a/mozilla/extensions/xmlterm/base/mozLineTerm.cpp +++ b/mozilla/extensions/xmlterm/base/mozLineTerm.cpp @@ -479,6 +479,25 @@ NS_IMETHODIMP mozLineTerm::CloseAllAux(void) } +/** Resizes XMLterm to match a resized window. + * @param nRows number of rows + * @param nCols number of columns + */ +NS_IMETHODIMP mozLineTerm::ResizeAux(PRInt32 nRows, PRInt32 nCols) +{ + int retCode; + + XMLT_LOG(mozLineTerm::ResizeAux,30,("nRows=%d, nCols=%d\n", nRows, nCols)); + + // Resize LTERM + retCode = lterm_resize(mLTerm, (int) nRows, (int) nCols); + if (retCode < 0) + return NS_ERROR_FAILURE; + + return NS_OK; +} + + /** Writes a string to LTERM */ NS_IMETHODIMP mozLineTerm::Write(const PRUnichar *buf, @@ -618,6 +637,13 @@ NS_IMETHODIMP mozLineTerm::ReadAux(PRInt32 *opcodes, PRInt32 *opvals, } +NS_IMETHODIMP mozLineTerm::GetCookie(nsString& aCookie) +{ + aCookie = mCookie; + return NS_OK; +} + + NS_IMETHODIMP mozLineTerm::GetCursorRow(PRInt32 *aCursorRow) { *aCursorRow = mCursorRow; @@ -627,13 +653,19 @@ NS_IMETHODIMP mozLineTerm::GetCursorRow(PRInt32 *aCursorRow) NS_IMETHODIMP mozLineTerm::SetCursorRow(PRInt32 aCursorRow) { + int retCode; + if (mSuspended) { XMLT_ERROR("mozLineTerm::SetCursorRow: Error - LineTerm %d is suspended\n", mLTerm); return NS_ERROR_FAILURE; } - return NS_OK; // Do nothing for the moment + retCode = lterm_setcursor(mLTerm, aCursorRow, mCursorColumn); + if (retCode < 0) + return NS_ERROR_FAILURE; + + return NS_OK; } @@ -646,13 +678,19 @@ NS_IMETHODIMP mozLineTerm::GetCursorColumn(PRInt32 *aCursorColumn) NS_IMETHODIMP mozLineTerm::SetCursorColumn(PRInt32 aCursorColumn) { + int retCode; + if (mSuspended) { XMLT_ERROR("mozLineTerm::SetCursorColumn: Error - LineTerm %d is suspended\n", mLTerm); return NS_ERROR_FAILURE; } - return NS_OK; // Do nothing for the moment + retCode = lterm_setcursor(mLTerm, mCursorRow, aCursorColumn); + if (retCode < 0) + return NS_ERROR_FAILURE; + + return NS_OK; } diff --git a/mozilla/extensions/xmlterm/base/mozLineTerm.h b/mozilla/extensions/xmlterm/base/mozLineTerm.h index 8cb69ce9968..2afe6ad6adf 100644 --- a/mozilla/extensions/xmlterm/base/mozLineTerm.h +++ b/mozilla/extensions/xmlterm/base/mozLineTerm.h @@ -45,15 +45,6 @@ public: NS_DECL_ISUPPORTS // mozILineTerm interface - NS_IMETHOD GetCursorRow(PRInt32 *aCursorRow); - NS_IMETHOD SetCursorRow(PRInt32 aCursorRow); - - NS_IMETHOD GetCursorColumn(PRInt32 *aCursorColumn); - NS_IMETHOD SetCursorColumn(PRInt32 aCursorColumn); - - NS_IMETHOD GetEchoFlag(PRBool *aEchoFlag); - NS_IMETHOD SetEchoFlag(PRBool aEchoFlag); - NS_IMETHOD Open(const PRUnichar *command, const PRUnichar *promptRegexp, PRInt32 options, PRInt32 processType, @@ -70,6 +61,7 @@ public: // mozILineTermAux interface add ons // (not scriptable, no authentication cookie required) + NS_IMETHOD OpenAux(const PRUnichar *command, const PRUnichar *promptRegexp, PRInt32 options, PRInt32 processType, @@ -83,9 +75,23 @@ public: NS_IMETHOD CloseAllAux(void); + NS_IMETHOD ResizeAux(PRInt32 nRows, PRInt32 nCols); + NS_IMETHOD ReadAux(PRInt32 *opcodes, PRInt32 *opvals, PRInt32 *buf_row, PRInt32 *buf_col, PRUnichar **_retval, PRUnichar **retstyle); + + NS_IMETHOD GetCookie(nsString& aCookie); + + NS_IMETHOD GetCursorRow(PRInt32 *aCursorRow); + NS_IMETHOD SetCursorRow(PRInt32 aCursorRow); + + NS_IMETHOD GetCursorColumn(PRInt32 *aCursorColumn); + NS_IMETHOD SetCursorColumn(PRInt32 aCursorColumn); + + NS_IMETHOD GetEchoFlag(PRBool *aEchoFlag); + NS_IMETHOD SetEchoFlag(PRBool aEchoFlag); + // others /** GTK event callback function diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp index f09c794d3c9..70645bd804e 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp @@ -202,6 +202,9 @@ mozXMLTermKeyListener::KeyDown(nsIDOMEvent* aKeyEvent) 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; diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp index d79280dacd9..ceaae365c14 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp @@ -46,8 +46,14 @@ #include "nsIDOMDocumentFragment.h" #include "nsIDOMNSRange.h" +#include "nsIViewManager.h" +#include "nsIScrollableView.h" + #include "nsIHTMLContent.h" +#include "nsFont.h" +#include "nsIFontMetrics.h" + #include "mozXMLT.h" #include "mozILineTermAux.h" #include "mozIXMLTerminal.h" @@ -143,6 +149,12 @@ mozXMLTermSession::mozXMLTermSession() : mPreTextBuffered(""), mPreTextDisplayed(""), + mScreenNode(nsnull), + mScreenRows(24), + mScreenCols(80), + mTopScrollRow(23), + mBotScrollRow(0), + mRestoreInputEcho(false), mShellPrompt(""), @@ -247,6 +259,8 @@ NS_IMETHODIMP mozXMLTermSession::Init(mozIXMLTerminal* aXMLTerminal, NS_IMETHODIMP mozXMLTermSession::Finalize(void) { + mScreenNode = nsnull; + mOutputBlockNode = nsnull; mOutputDisplayNode = nsnull; mOutputTextNode = nsnull; @@ -274,6 +288,83 @@ NS_IMETHODIMP mozXMLTermSession::Finalize(void) } +/** Resizes XMLterm to match a resized window. + * @param lineTermAux LineTermAux object to be resized (may be null) + */ +NS_IMETHODIMP mozXMLTermSession::Resize(mozILineTermAux* lineTermAux) +{ + nsresult result; + + // Get presentation context + nsCOMPtr presContext; + result = mPresShell->GetPresContext( getter_AddRefs(presContext) ); + if (NS_FAILED(result)) + return result; + + // Get the default fixed pitch font + nsFont defaultFixedFont("dummyfont", NS_FONT_STYLE_NORMAL, + NS_FONT_VARIANT_NORMAL, + NS_FONT_WEIGHT_NORMAL, + NS_FONT_DECORATION_NONE, 16); + + result = presContext->GetDefaultFixedFont(defaultFixedFont); + if (NS_FAILED(result)) + return result; + + // Get metrics for fixed font + nsCOMPtr fontMetrics; + result = presContext->GetMetricsFor(defaultFixedFont, + getter_AddRefs(fontMetrics)); + if (NS_FAILED(result) || !fontMetrics) + return result; + + // Get font height (includes leading?) + nscoord fontHeight, fontWidth; + result = fontMetrics->GetHeight(fontHeight); + result = fontMetrics->GetMaxAdvance(fontWidth); + + // Determine docshell size in twips + nsRect shellArea; + result = presContext->GetVisibleArea(shellArea); + if (NS_FAILED(result)) + return result; + + // Determine twips to pixels conversion factor + float pixelScale, frameHeight, frameWidth, xdel, ydel; + presContext->GetTwipsToPixels(&pixelScale); + + // Convert dimensions to pixels + frameHeight = pixelScale * shellArea.height; + frameWidth = pixelScale * shellArea.width; + + xdel = pixelScale * fontWidth; + ydel = pixelScale * fontHeight + 2; + + // Determine number of rows/columns + mScreenRows = (int) ((frameHeight-44) / ydel); + mScreenCols = (int) (frameWidth / xdel); + + if (mScreenRows < 1) mScreenRows = 1; + if (mScreenCols < 1) mScreenCols = 1; + + mTopScrollRow = mScreenRows - 1; + mBotScrollRow = 0; + + XMLT_LOG(mozXMLTermSession::Resize,0, + ("Resizing XMLterm, xdel=%e, ydel=%e, rows=%d, cols=%d\n", + xdel, ydel, mScreenRows, mScreenCols)); + + if (!lineTermAux) { + // Resize associated LineTerm + result = lineTermAux->ResizeAux(mScreenRows, mScreenCols); + if (NS_FAILED(result)) + return result; + } + + return NS_OK; +} + + /** Preprocesses user input before it is transmitted to LineTerm * @param aString (inout) input data to be preprocessed * @param consumed (output) true if input data has been consumed @@ -353,7 +444,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, { PRInt32 opcodes, opvals, buf_row, buf_col; PRUnichar *buf_str, *buf_style; - PRBool newline, streamData; + PRBool newline, streamData, screenData; nsAutoString bufString, bufStyle; XMLT_LOG(mozXMLTermSession::ReadAll,60,("\n")); @@ -377,15 +468,16 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, break; XMLT_LOG(mozXMLTermSession::ReadAll,62, - ("opcodes=0x%x, mMetaCommandType=%d, mEntryHasOutput=%d\n", + ("opcodes=0x%x,mMetaCommandType=%d,mEntryHasOutput=%d\n", opcodes, mMetaCommandType, mEntryHasOutput)); if (opcodes == 0) break; processedData = true; + screenData = (opcodes & LTERM_SCREENDATA_CODE); streamData = (opcodes & LTERM_STREAMDATA_CODE); - newline = (opcodes & LTERM_NEWLINE_CODE); + newline = (opcodes & LTERM_NEWLINE_CODE); // Copy character/style strings bufString = buf_str; @@ -395,6 +487,48 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, nsAllocator::Free(buf_str); nsAllocator::Free(buf_style); + char* temCString = bufString.ToNewCString(); + XMLT_LOG(mozXMLTermSession::ReadAll,68,("bufString=%s\n", temCString)); + nsCRT::free(temCString); + + if (screenData && (mMetaCommandType != SCREEN_META_COMMAND)) { + // Initiate screen mode + + // Break stream output display + result = BreakOutput(); + if (NS_FAILED(result)) + return result; + + // Create screen element (resize) + result = NewScreen(true); + if (NS_FAILED(result)) + return result; + + mMetaCommandType = SCREEN_META_COMMAND; + + // Disable input echo + lineTermAux->SetEchoFlag(false); + mRestoreInputEcho = true; + } + + if (!screenData && (mMetaCommandType == SCREEN_META_COMMAND)) { + // Terminate screen mode + mMetaCommandType = NO_META_COMMAND; + + XMLT_LOG(mozXMLTermSession::ReadAll,0, + ("Terminating screen mode\n")); + + // Delete screen element + nsCOMPtr resultNode; + mSessionNode->RemoveChild(mScreenNode, getter_AddRefs(resultNode)); + mScreenNode = nsnull; + + if (mRestoreInputEcho) { + lineTermAux->SetEchoFlag(true); + mRestoreInputEcho = false; + } + } + if (streamData) { // Process stream data if (mMetaCommandType == NO_META_COMMAND) { @@ -466,14 +600,156 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, flushOutput = true; } + } else if (screenData) { + // Process screen data + + if (opcodes & LTERM_CLEAR_CODE) { + // Clear screen + XMLT_LOG(mozXMLTermSession::ReadAll,62, + ("Clear screen, opvals=%d, buf_row=%d\n", + opvals, buf_row)); + + nsCOMPtr resultNode; + result = mSessionNode->RemoveChild(mScreenNode, + getter_AddRefs(resultNode)); + if (NS_FAILED(result)) + return NS_ERROR_FAILURE; + + mScreenNode = nsnull; + + // Create new screen element (no resize) + result = NewScreen(false); + if (NS_FAILED(result)) + return result; + + } else if (opcodes & LTERM_INSERT_CODE) { + // Insert rows + PRInt32 row; + nsCOMPtr rowNode, resultNode; + + XMLT_LOG(mozXMLTermSession::ReadAll,62, + ("Insert rows, opvals=%d, buf_row=%d\n", + opvals, buf_row)); + + if (opvals > 0) { + // Delete row elements below + for (row=0; row < opvals; row++) { + result = GetRow(mBotScrollRow+opvals-1, getter_AddRefs(rowNode)); + if (NS_FAILED(result) || !rowNode) + return NS_ERROR_FAILURE; + + result = mScreenNode->RemoveChild(rowNode, + getter_AddRefs(resultNode)); + if (NS_FAILED(result)) + return NS_ERROR_FAILURE; + } + + // Insert individual row elements above + if (buf_row < opvals) { + rowNode = nsnull; + } else { + result = GetRow(buf_row, getter_AddRefs(rowNode)); + if (NS_FAILED(result)) + return NS_ERROR_FAILURE; + } + + for (row=0; row < opvals; row++) + NewRow(rowNode); + } + + } else if (opcodes & LTERM_DELETE_CODE) { + // Delete rows + PRInt32 row; + nsCOMPtr rowNode, resultNode; + + XMLT_LOG(mozXMLTermSession::ReadAll,62, + ("Delete rows, opvals=%d, buf_row=%d\n", + opvals, buf_row)); + + if (opvals > 0) { + // Delete row elements below + for (row=0; row < opvals; row++) { + result = GetRow(buf_row, getter_AddRefs(rowNode)); + if (NS_FAILED(result) || !rowNode) + return NS_ERROR_FAILURE; + + result = mScreenNode->RemoveChild(rowNode, + getter_AddRefs(resultNode)); + if (NS_FAILED(result)) + return NS_ERROR_FAILURE; + } + + // Insert individual row elements above + if (mBotScrollRow == 0) { + rowNode = nsnull; + } else { + result = GetRow(mBotScrollRow+opvals-1, getter_AddRefs(rowNode)); + if (NS_FAILED(result)) + return NS_ERROR_FAILURE; + } + + for (row=0; row < opvals; row++) + NewRow(rowNode); + } + + } else if (opcodes & LTERM_SCROLL_CODE) { + // Set scrolling region + XMLT_LOG(mozXMLTermSession::ReadAll,62, + ("Set scrolling region, opvals=%d, buf_row=%d\n", + opvals, buf_row)); + + mTopScrollRow = opvals; + mBotScrollRow = buf_row; + + } else if (opcodes & LTERM_OUTPUT_CODE) { + // Display row + XMLT_LOG(mozXMLTermSession::ReadAll,62, + ("Display buf_row=%d\n", + buf_row)); + + result = DisplayRow(bufString, bufStyle, buf_row); + if (NS_FAILED(result)) + return result; + } + + // Determine cursor position + PRInt32 cursorRow = 0; + PRInt32 cursorCol = 0; + result = lineTermAux->GetCursorRow(&cursorRow); + result = lineTermAux->GetCursorColumn(&cursorCol); + + // Get selection + nsCOMPtr selection; + + result = mPresShell->GetSelection(SELECTION_NORMAL, + getter_AddRefs(selection)); + if (NS_SUCCEEDED(result) && selection) { + // Collapse selection to cursor position + nsCOMPtr cursTextNode; + PRInt32 offset; + + result = GetScreenText(cursorRow, cursorCol, + getter_AddRefs(cursTextNode), &offset); + + if (NS_FAILED(result) || !cursTextNode) + return result; + + result = selection->Collapse(cursTextNode, offset); + if (NS_FAILED(result)) + return result; + } + + // Scroll to end of page + ScrollToBottomLeft(); + } else { - // Process non-stream data + // Process line data PRBool promptLine, inputLine, metaCommand, completionRequested; flushOutput = true; - inputLine = (opcodes & LTERM_INPUT_CODE); - promptLine = (opcodes & LTERM_PROMPT_CODE); + inputLine = (opcodes & LTERM_INPUT_CODE); + promptLine = (opcodes & LTERM_PROMPT_CODE); metaCommand = (opcodes & LTERM_META_CODE); completionRequested = (opcodes & LTERM_COMPLETION_CODE); @@ -545,7 +821,8 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, int delimOffset = metaLine.FindChar((PRUnichar) ':'); PR_ASSERT(delimOffset >= 0); - XMLT_LOG(mozXMLTermSession::ReadAll,62, ("delimOffset=%d\n", delimOffset)); + XMLT_LOG(mozXMLTermSession::ReadAll,62, + ("delimOffset=%d\n", delimOffset)); if (delimOffset == 0) { // Default to HTTP protocol @@ -768,10 +1045,11 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, } } - XMLT_LOG(mozXMLTermSession::ReadAll,62,(" result=%d\n", result)); - if (NS_FAILED(result)) { // Close LineTerm + XMLT_LOG(mozXMLTermSession::ReadAll,62, + ("Closing LineTerm, result=%d\n", result)); + lineTermAux->CloseAux(); return NS_ERROR_FAILURE; } @@ -785,7 +1063,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, SELECTION_FOCUS_REGION); // Scroll frame (ignore result) - // result = ScrollBottomLeft(); + // ScrollToBottomLeft(); } return NS_OK; @@ -1026,7 +1304,8 @@ NS_IMETHODIMP mozXMLTermSession::InitStream(const nsString& streamURL, url.GetBuffer(), contentType.GetBuffer(), 800); if (NS_FAILED(result)) { - fprintf(stderr, "mozXMLTerminal::Activate: Failed to open stream\n"); + fprintf(stderr, + "mozXMLTermSession::InitStream: Failed to open stream\n"); return result; } @@ -1939,33 +2218,45 @@ NS_IMETHODIMP mozXMLTermSession::FlushOutput(FlushActionType flushAction) /** Scrolls document to align bottom and left margin with screen */ -NS_IMETHODIMP mozXMLTermSession::ScrollBottomLeft(void) +NS_IMETHODIMP mozXMLTermSession::ScrollToBottomLeft(void) { nsresult result; - XMLT_LOG(mozXMLTermSession::ScrollBottomLeft,70,("\n")); - - if (!mCurrentEntryNode) - return NS_ERROR_FAILURE; + XMLT_LOG(mozXMLTermSession::ScrollToBottomLeft,70,("\n")); +#if 0 // Scroll primary frame to bottom of view - nsCOMPtr blockContent (do_QueryInterface(mCurrentEntryNode)); + nsCOMPtr blockContent (do_QueryInterface(mSessionNode)); if (!blockContent) return NS_ERROR_FAILURE; nsIFrame* primaryFrame; result = mPresShell->GetPrimaryFrameFor(blockContent, &primaryFrame); - if (NS_FAILED(result)) { - return NS_ERROR_FAILURE; - } + if (NS_FAILED(result)) + return result; result = mPresShell->ScrollFrameIntoView(primaryFrame, NS_PRESSHELL_SCROLL_BOTTOM, NS_PRESSHELL_SCROLL_LEFT); - if (NS_FAILED(result)) { + if (NS_FAILED(result)) + return result; + +#else + // Root scrollable view for presShell. + nsCOMPtr viewManager; + result = mPresShell->GetViewManager(getter_AddRefs(viewManager)); + if (NS_FAILED(result) || !viewManager) return NS_ERROR_FAILURE; - } + + nsCOMPtr scrollableView; + result = viewManager->GetRootScrollableView(getter_AddRefs(scrollableView)); + if (NS_FAILED(result) || !scrollableView) + return NS_ERROR_FAILURE; + + // Scroll to bottom of view + scrollableView->ScrollByWhole(false); +#endif return NS_OK; } @@ -2248,6 +2539,203 @@ NS_IMETHODIMP mozXMLTermSession::NewEntry(const nsString& aPrompt) } +/** Create a DIV element with attributes NAME="screen" and CLASS="screen", + * 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) +{ + nsresult result; + + XMLT_LOG(mozXMLTermSession::NewScreen,0,("\n")); + + // Create screen element and append as child of session element + nsCOMPtr divNode; + nsAutoString tagName = "div"; + nsAutoString name = "screen"; + result = NewElement(tagName, name, 0, + mSessionNode, divNode); + + if (NS_FAILED(result) || !divNode) + return NS_ERROR_FAILURE; + + mScreenNode = divNode; + + if (resize) { + // Resize XMLTerm + mXMLTerminal->Resize(); + } + + // Create individual row elements + PRInt32 row; + for (row=0; row < mScreenRows; row++) { + NewRow(nsnull); + } + + return NS_OK; +} + + +/** Returns DOM PRE node corresponding to specified screen row + */ +NS_IMETHODIMP mozXMLTermSession::GetRow(PRInt32 aRow, nsIDOMNode** aRowNode) +{ + nsresult result; + + XMLT_LOG(mozXMLTermSession::GetRow,60,("row=%d\n", aRow)); + + if (!aRowNode) + return NS_ERROR_NULL_POINTER; + + nsCOMPtr childNodes; + result = mScreenNode->GetChildNodes(getter_AddRefs(childNodes)); + if (NS_FAILED(result) || !childNodes) + return NS_ERROR_FAILURE; + + PRUint32 nChildren = 0; + childNodes->GetLength(&nChildren); + + PRInt32 rowIndex = mScreenRows - aRow - 1; + if ((rowIndex < 0) || (rowIndex >= (PRInt32)nChildren)) + return NS_ERROR_FAILURE; + + nsCOMPtr childNode; + result = childNodes->Item(rowIndex, getter_AddRefs(childNode)); + + if (NS_FAILED(result) || !childNode) + return NS_ERROR_FAILURE; + + *aRowNode = childNode.get(); + NS_ADDREF(*aRowNode); + + XMLT_LOG(mozXMLTermSession::GetRow,61,("returning\n")); + + return NS_OK; +} + + +/** Returns DOM text node and offset corresponding to screen row/col position + */ +NS_IMETHODIMP mozXMLTermSession::GetScreenText(PRInt32 aRow, PRInt32 aCol, + nsIDOMNode** aTextNode, + PRInt32 *aOffset) +{ + nsresult result; + + XMLT_LOG(mozXMLTermSession::GetScreenText,60,("row=%d, col=%d\n",aRow,aCol)); + + if (!aTextNode || !aOffset) + return NS_ERROR_NULL_POINTER; + + // Get row node + nsCOMPtr rowNode; + result = GetRow(aRow, getter_AddRefs(rowNode)); + if (NS_FAILED(result) || !rowNode) + return NS_ERROR_FAILURE; + + // Get text node + nsCOMPtr textNode; + result = rowNode->GetFirstChild(getter_AddRefs(textNode)); + if (NS_FAILED(result) || !textNode) + return result; + + PRUint16 nodeType; + result = textNode->GetNodeType(&nodeType); + if (NS_FAILED(result)) + return result; + + if (nodeType == nsIDOMNode::TEXT_NODE) { + /* Text node */ + *aTextNode = textNode.get(); + NS_ADDREF(*aTextNode); + *aOffset = aCol; + + } else { + /* Not a text node */ + *aTextNode = nsnull; + *aOffset = 0; + } + + return NS_OK; +} + + +/** Create a PRE element with attributes NAME="row", CLASS="row", + * containing an empty text node, and insert it as a + * child of the SCREEN element before beforeRowNode, or at the + * end if beforeRowNode is null. + */ +NS_IMETHODIMP mozXMLTermSession::NewRow(nsIDOMNode* beforeRowNode) +{ + nsresult result; + + XMLT_LOG(mozXMLTermSession::NewRow,60,("\n")); + + // Create PRE display node + nsCOMPtr preNode, textNode; + nsAutoString tagName = "pre"; + nsAutoString elementName = "row"; + + result = NewElementWithText(tagName, elementName, -1, + mScreenNode, preNode, textNode); + + if (NS_FAILED(result) || !preNode || !textNode) + return NS_ERROR_FAILURE; + + // Set PRE element attributes + nsCOMPtr preElement = do_QueryInterface(preNode); + nsAutoString att("cols"); + nsAutoString val(""); + val.Append(mScreenCols,10); + preElement->SetAttribute(att, val); + + att = "rows"; + val = "1"; + preElement->SetAttribute(att, val); + + nsCOMPtr resultNode; + + if (beforeRowNode) { + // Insert row node + result = mScreenNode->InsertBefore(preNode, beforeRowNode, + getter_AddRefs(resultNode)); + } else { + // Append row node + result = mScreenNode->AppendChild(preNode, + getter_AddRefs(resultNode)); + } + + return NS_OK; +} + + +/** Displays screen output string with specified style + * @param aString string to be processed + * @param aStyle style values for string (see lineterm.h) + * (if it is a null string, STDOUT style is assumed) + * @param aRow row in which to insert string + */ +NS_IMETHODIMP mozXMLTermSession::DisplayRow(const nsString& aString, + const nsString& aStyle, + PRInt32 aRow) +{ + nsresult result; + PRInt32 offset; + + XMLT_LOG(mozXMLTermSession::DisplayRow,70,("aRow=%d\n", aRow)); + + nsCOMPtr rowTextNode; + result = GetScreenText(aRow, 0, getter_AddRefs(rowTextNode), &offset); + if (NS_FAILED(result) || !rowTextNode) + return result; + + result = SetDOMText(rowTextNode, aString); + if (NS_FAILED(result)) + return result; + return NS_OK; +} + + /** Append a BR element as the next child of specified parent. * @param parentNode parent node for BR element */ diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermSession.h b/mozilla/extensions/xmlterm/base/mozXMLTermSession.h index 760ab834d43..760ed964d92 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermSession.h +++ b/mozilla/extensions/xmlterm/base/mozXMLTermSession.h @@ -61,6 +61,11 @@ class mozXMLTermSession */ NS_IMETHOD Finalize(void); + /** Resizes XMLterm to match a resized window. + * @param lineTermAux LineTermAux object to be resized (may be null) + */ + NS_IMETHOD Resize(mozILineTermAux* lineTermAux); + /** Preprocesses user input before it is transmitted to LineTerm * @param aString (inout) input data to be preprocessed * @param consumed (output) true if input data has been consumed @@ -163,6 +168,7 @@ protected: /** type of currently active meta command */ enum MetaCommandType { NO_META_COMMAND = 0, + SCREEN_META_COMMAND, STREAM_META_COMMAND, HTTP_META_COMMAND, JS_META_COMMAND, @@ -288,7 +294,7 @@ protected: NS_IMETHOD FlushOutput(FlushActionType flushAction); /** Scrolls document to align bottom and left margin with screen */ - NS_IMETHOD ScrollBottomLeft(void); + NS_IMETHOD ScrollToBottomLeft(void); /** Create a DIV element with attributes NAME="preface", CLASS="preface", * and ID="preface0", containing an empty text node, and append it as a @@ -308,6 +314,38 @@ protected: */ NS_IMETHOD NewEntry(const nsString& aPrompt); + /** Create a DIV element with attributes NAME="screen" and CLASS="screen", + * 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); + + /** Returns DOM PRE node corresponding to specified screen row + */ + NS_IMETHOD GetRow(PRInt32 aRow, nsIDOMNode** aRowNode); + + /** Returns DOM text node and offset corresponding to screen row/col position + */ + NS_IMETHOD GetScreenText(PRInt32 aRow, PRInt32 aCol, + nsIDOMNode** aTextNode, + PRInt32 *aOffset); + + /** Create a PRE element with attributes NAME="row", CLASS="row", + * containing an empty text node, and insert it as a + * child of the SCREEN element before beforeRowNode, or at the + * end if beforeRowNode is null. + */ + NS_IMETHOD NewRow(nsIDOMNode* beforeRowNode); + + /** Displays screen output string with specified style + * @param aString string to be processed + * @param aStyle style values for string (see lineterm.h) + * (if it is a null string, STDOUT style is assumed) + * @param aRow row in which to insert string + */ + NS_IMETHOD DisplayRow(const nsString& aString, const nsString& aStyle, + PRInt32 aRow); + /** Append a BR element as the next child of specified parent. * @param parentNode parent node for BR element */ @@ -557,6 +595,22 @@ protected: nsString mPreTextDisplayed; + /** Screen element */ + nsCOMPtr mScreenNode; + + /** Number of rows in screen */ + PRInt32 mScreenRows; + + /** Number of columns in screen */ + PRInt32 mScreenCols; + + /** Top scrolling row */ + PRInt32 mTopScrollRow; + + /** Bottom scrolling row */ + PRInt32 mBotScrollRow; + + /** restore input echo flag */ PRBool mRestoreInputEcho; diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp index 94773f16bd6..34c8ba7d84f 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp @@ -138,40 +138,44 @@ NS_IMETHODIMP mozXMLTermShell::GetCurrentEntryNumber(PRInt32 *aNumber) } -NS_IMETHODIMP mozXMLTermShell::GetHistory(PRInt32 *aHistory) +/** Sets command history buffer count + * @param aHistory history buffer count + * @param aCookie document.cookie string for authentication + */ +NS_IMETHODIMP mozXMLTermShell::SetHistory(PRInt32 aHistory, + const PRUnichar* aCookie) { if (mXMLTerminal) { - return mXMLTerminal->GetHistory(aHistory); - } else { - return NS_ERROR_NOT_INITIALIZED; - } -} + nsresult result; + PRBool matchesCookie; + result = mXMLTerminal->MatchesCookie(aCookie, &matchesCookie); + if (NS_FAILED(result) || !matchesCookie) + return NS_ERROR_FAILURE; - -NS_IMETHODIMP mozXMLTermShell::SetHistory(PRInt32 aHistory) -{ - if (mXMLTerminal) { return mXMLTerminal->SetHistory(aHistory); + } else { return NS_ERROR_NOT_INITIALIZED; } } -NS_IMETHODIMP mozXMLTermShell::GetPrompt(PRUnichar **aPrompt) +/** Sets command prompt + * @param aPrompt command prompt string (HTML) + * @param aCookie document.cookie string for authentication + */ +NS_IMETHODIMP mozXMLTermShell::SetPrompt(const PRUnichar* aPrompt, + const PRUnichar* aCookie) { if (mXMLTerminal) { - return mXMLTerminal->GetPrompt(aPrompt); - } else { - return NS_ERROR_NOT_INITIALIZED; - } -} + nsresult result; + PRBool matchesCookie; + result = mXMLTerminal->MatchesCookie(aCookie, &matchesCookie); + if (NS_FAILED(result) || !matchesCookie) + return NS_ERROR_FAILURE; - -NS_IMETHODIMP mozXMLTermShell::SetPrompt(const PRUnichar* aPrompt) -{ - if (mXMLTerminal) { return mXMLTerminal->SetPrompt(aPrompt); + } else { return NS_ERROR_NOT_INITIALIZED; } @@ -228,6 +232,28 @@ mozXMLTermShell::Init(nsIDOMWindow* aContentWin, } +/** Closes XMLterm, freeing resources + * @param aCookie document.cookie string for authentication + */ +NS_IMETHODIMP +mozXMLTermShell::Close(const PRUnichar* aCookie) +{ + XMLT_LOG(mozXMLTermShell::Close,10,("\n")); + + if (mInitialized && mXMLTerminal) { + nsresult result; + PRBool matchesCookie; + result = mXMLTerminal->MatchesCookie(aCookie, &matchesCookie); + if (NS_FAILED(result) || !matchesCookie) + return NS_ERROR_FAILURE; + + Finalize(); + } + + return NS_OK; +} + + // De-initialize XMLTermShell and free resources NS_IMETHODIMP mozXMLTermShell::Finalize(void) @@ -259,18 +285,29 @@ NS_IMETHODIMP mozXMLTermShell::Poll(void) } +/** Resizes XMLterm to match a resized window. + */ +NS_IMETHODIMP mozXMLTermShell::Resize(void) +{ + if (!mXMLTerminal) + return NS_ERROR_NOT_INITIALIZED; + + return mXMLTerminal->Resize(); +} + + // Send string to LineTerm as if the user had typed it -NS_IMETHODIMP mozXMLTermShell::SendText(const PRUnichar* buf, - const PRUnichar* cookie) +NS_IMETHODIMP mozXMLTermShell::SendText(const PRUnichar* aString, + const PRUnichar* aCookie) { if (!mXMLTerminal) return NS_ERROR_FAILURE; - nsAutoString sendStr (buf); + nsAutoString sendStr (aString); XMLT_LOG(mozXMLTermShell::SendText,10,("length=%d\n", sendStr.Length())); - return mXMLTerminal->SendText(sendStr, cookie); + return mXMLTerminal->SendText(sendStr, aCookie); } diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermShell.h b/mozilla/extensions/xmlterm/base/mozXMLTermShell.h index abd588f5553..910e93fdd5f 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermShell.h +++ b/mozilla/extensions/xmlterm/base/mozXMLTermShell.h @@ -47,24 +47,27 @@ class mozXMLTermShell : public mozIXMLTermShell { NS_IMETHOD GetCurrentEntryNumber(PRInt32 *aNumber); - NS_IMETHOD GetHistory(PRInt32 *aHistory); - NS_IMETHOD SetHistory(PRInt32 aHistory); - NS_IMETHOD GetPrompt(PRUnichar **aPrompt); - NS_IMETHOD SetPrompt(const PRUnichar* aPrompt); + NS_IMETHOD SetHistory(PRInt32 aHistory, const PRUnichar* aCookie); + + NS_IMETHOD SetPrompt(const PRUnichar* aPrompt, const PRUnichar* aCookie); NS_IMETHOD Init(nsIDOMWindow* aContentWin, const PRUnichar* URL, const PRUnichar* args); - NS_IMETHOD Finalize(void); + NS_IMETHOD Close(const PRUnichar* aCookie); + NS_IMETHOD Poll(void); - NS_IMETHOD SendText(const PRUnichar* buf, const PRUnichar* cookie); + NS_IMETHOD Resize(void); + + NS_IMETHOD SendText(const PRUnichar* aString, const PRUnichar* aCookie); NS_IMETHOD NewXMLTermWindow(const PRUnichar* args); NS_IMETHOD Exit(void); + NS_IMETHOD Finalize(void); protected: /** object initialization flag */ diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp index 557303d7953..43c7c3b53b7 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp @@ -173,7 +173,6 @@ NS_IMETHODIMP mozXMLTerminal::SetHistory(PRInt32 aHistory) } } - NS_IMETHODIMP mozXMLTerminal::GetPrompt(PRUnichar **aPrompt) { if (mXMLTermSession) { @@ -399,9 +398,6 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void) return NS_ERROR_FAILURE; // Get reference to presentation shell - if (mPresShell != nsnull) - return NS_ERROR_FAILURE; - nsCOMPtr presContext; result = mDocShell->GetPresContext(getter_AddRefs(presContext)); if (NS_FAILED(result) || !presContext) @@ -414,16 +410,19 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void) // Get reference to DOMDocument nsCOMPtr document; - result = mPresShell->GetDocument(getter_AddRefs(document)); + result = presShell->GetDocument(getter_AddRefs(document)); - nsCOMPtr domDocument = do_QueryInterface(document); - if (NS_FAILED(result) || !domDocument) + if (NS_FAILED(result) || !document) return NS_ERROR_FAILURE; - // Save references to DOMDocument and presentation shell + nsCOMPtr domDocument = do_QueryInterface(document); + if (!domDocument) + return NS_ERROR_FAILURE; + + // Save references to presentation shell and DOMDocument // (SVN: Should these be addref'ed and released in the destructor?) - mDOMDocument = domDocument; // no addref mPresShell = presShell; // no addref + mDOMDocument = domDocument; // no addref // Instantiate and initialize XMLTermSession object mXMLTermSession = new mozXMLTermSession(); @@ -471,6 +470,11 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void) // Save cookie mCookie = cookie; + // Resize XMLterm + result = Resize(); + if (NS_FAILED(result)) + return result; + // Get the DOM event receiver for document nsCOMPtr eventReceiver; result = mDOMDocument->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), @@ -664,8 +668,10 @@ NS_IMETHODIMP mozXMLTerminal::Poll(void) PRBool processedData; result = mXMLTermSession->ReadAll(mLineTermAux, processedData); - if (NS_FAILED(result)) + if (NS_FAILED(result)) { + XMLT_WARNING("mozXMLTerminal::Poll: Warning - Error return 0x%x from ReadAll\n", result); return result; + } if (processedData && (mFirstInput.Length() > 0)) { // Send first input command line(s) @@ -705,6 +711,7 @@ NS_IMETHODIMP mozXMLTerminal::GetDocument(nsIDOMDocument** aDoc) { if (!aDoc) return NS_ERROR_NULL_POINTER; + *aDoc = nsnull; NS_PRECONDITION(mDOMDocument, "bad state, null mDOMDocument"); @@ -720,6 +727,7 @@ NS_IMETHODIMP mozXMLTerminal::GetDocShell(nsIDocShell** aDocShell) { if (!aDocShell) return NS_ERROR_NULL_POINTER; + *aDocShell = nsnull; NS_PRECONDITION(mDocShell, "bad state, null mDocShell"); @@ -735,6 +743,7 @@ NS_IMETHODIMP mozXMLTerminal::GetPresShell(nsIPresShell** aPresShell) { if (!aPresShell) return NS_ERROR_NULL_POINTER; + *aPresShell = nsnull; NS_PRECONDITION(mPresShell, "bad state, null mPresShell"); @@ -745,6 +754,49 @@ NS_IMETHODIMP mozXMLTerminal::GetPresShell(nsIPresShell** aPresShell) } +/** Checks if supplied cookie is valid for XMLTerm + * @param aCookie supplied cookie string + * @param _retval true if supplied cookie matches XMLTerm cookie + */ +NS_IMETHODIMP mozXMLTerminal::MatchesCookie(const PRUnichar* aCookie, + PRBool *_retval) +{ + XMLT_LOG(mozXMLTerminal::MatchesCookie,20,("\n")); + + if (!_retval) + return NS_ERROR_NULL_POINTER; + + // Check if supplied cookie matches XMLTerm cookie + *_retval = mCookie.Equals(aCookie); + + if (!(*_retval)) { + XMLT_ERROR("mozXMLTerminal::MatchesCookie: Error - Cookie mismatch\n"); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} + + +/** Resizes XMLterm to match a resized window. + */ +NS_IMETHODIMP mozXMLTerminal::Resize(void) +{ + nsresult result; + + XMLT_LOG(mozXMLTerminal::Resize,20,("\n")); + + if (!mXMLTermSession) + return NS_ERROR_FAILURE; + + result = mXMLTermSession->Resize(mLineTermAux); + if (NS_FAILED(result)) + return result; + + return NS_OK; +} + + // nsIDocumentLoaderObserver methods NS_IMETHODIMP mozXMLTerminal::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.h b/mozilla/extensions/xmlterm/base/mozXMLTerminal.h index ce5fd2922bc..a735e814446 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.h +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.h @@ -61,7 +61,6 @@ class mozXMLTerminal : public mozIXMLTerminal, NS_IMETHOD Poll(void); NS_IMETHOD GetCurrentEntryNumber(PRInt32 *aNumber); - NS_IMETHOD GetHistory(PRInt32 *aHistory); NS_IMETHOD SetHistory(PRInt32 aHistory); NS_IMETHOD GetPrompt(PRUnichar **aPrompt); @@ -78,6 +77,10 @@ class mozXMLTerminal : public mozIXMLTerminal, NS_IMETHOD GetPresShell(nsIPresShell** aPresShell); + NS_IMETHOD MatchesCookie(const PRUnichar* aCookie, PRBool *_retval); + + NS_IMETHOD Resize(void); + // nsIDocumentLoaderObserver interface NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand); @@ -106,6 +109,10 @@ class mozXMLTerminal : public mozIXMLTerminal, const PRUnichar *someData); // Others + + /** Activates XMLterm and instantiates LineTerm; + * called at the the end of Init page loading. + */ NS_IMETHOD Activate(void); protected: diff --git a/mozilla/extensions/xmlterm/config/rules.mk b/mozilla/extensions/xmlterm/config/rules.mk index f6f2c831bfb..7163cdeb0d0 100644 --- a/mozilla/extensions/xmlterm/config/rules.mk +++ b/mozilla/extensions/xmlterm/config/rules.mk @@ -86,6 +86,7 @@ all: export libs progs export: $(EXPORTS) ifneq (,$(EXPORTS)) + mkdir -p $(topsrcdir)/dist/include +for x in $^; do \ rm $(topsrcdir)/dist/include/$$x; \ echo ln -s `pwd`/$$x $(topsrcdir)/dist/include/$$x; \ @@ -95,9 +96,11 @@ endif +$(LOOP_OVER_DIRS) libs: $(LIBRARY) + mkdir -p $(topsrcdir)/dist/lib $(topsrcdir)/base/lib +$(LOOP_OVER_DIRS) progs: $(SIMPLE_PROGRAMS) + mkdir -p $(topsrcdir)/tests/lib $(topsrcdir)/linetest/lib +$(LOOP_OVER_DIRS) clean: diff --git a/mozilla/extensions/xmlterm/doc/BUGS b/mozilla/extensions/xmlterm/doc/BUGS index 5225af93126..4285b3f6dc4 100644 --- a/mozilla/extensions/xmlterm/doc/BUGS +++ b/mozilla/extensions/xmlterm/doc/BUGS @@ -1,7 +1,7 @@ Known bugs ---------- -13 Feb 2000 +21 Feb 2000 1. XMLterm bug: Early use of "xls -i" does not scroll properly @@ -16,6 +16,5 @@ Known bugs results in LTERM exiting abnormally when user exits emacs. An interrupt error seems to occur while polling for output in ltermRead. -5. Mozilla bug?: Typing backspace/delete at end of input line aborts XMLterm - Bug in collapsing selection to cursor location? - (nsDOMSelection::Collapse called from mozXMLtermSession::DisplayInput) +5. Full screen XMLTerm operation: forward cursor positioning (^F) behaves + erratically diff --git a/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp b/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp index 19f5f5c346e..57cc46e2707 100644 --- a/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp +++ b/mozilla/extensions/xmlterm/geckoterm/mozGeckoTerm.cpp @@ -80,6 +80,11 @@ static void event_processor_configure(GtkWidget *window, // Resize doc shell window gSimpleContainer->Resize(alloc->width, alloc->height); + if (gXMLTerminal) { + // Resize XMLTerm + gXMLTerminal->Resize(); + } + return; } @@ -174,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), 600, 400); + gtk_window_set_default_size( GTK_WINDOW(mainWin), 720, 484); gtk_window_set_title(GTK_WINDOW(mainWin), "XMLterm"); mozArea = gtk_mozarea_new(); diff --git a/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.cpp b/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.cpp index 50034886735..341819d6418 100644 --- a/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.cpp +++ b/mozilla/extensions/xmlterm/geckoterm/mozSimpleContainer.cpp @@ -198,24 +198,8 @@ NS_IMETHODIMP mozSimpleContainer::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIChannel *aChannel, PRUint32 aStatus) { - nsresult result; - fprintf(stderr, "mozSimpleContainer::OnEndDocumentLoad\n"); - nsCOMPtr presShell; - result = mDocShell->GetPresShell(getter_AddRefs(presShell)); - if (NS_FAILED(result) || !presShell) - return result; - - nsCOMPtr document; - result = presShell->GetDocument(getter_AddRefs(document)); - if (NS_FAILED(result) || !document) - return result; - - nsCOMPtr domDoc = do_QueryInterface(document, &result); - if (NS_FAILED(result) || !domDoc) - return result; - return NS_OK; } diff --git a/mozilla/extensions/xmlterm/linetest/lterm.c b/mozilla/extensions/xmlterm/linetest/lterm.c index 2b166c2ba79..4e1bc36dcf4 100644 --- a/mozilla/extensions/xmlterm/linetest/lterm.c +++ b/mozilla/extensions/xmlterm/linetest/lterm.c @@ -572,18 +572,20 @@ void *output_handler(void *arg) topScrollRow = opvals; botScrollRow = buf_row; - } else if (n_read > 0) { + } else if (opcodes & LTERM_OUTPUT_CODE) { /* Data available for display */ move(ymax-1-buf_row, buf_col); clrtoeol(); - if (style[0] != LTERM_STDOUT_STYLE) - attr_on(A_REVERSE, NULL); + if (n_read > 0) { + if (style[0] != LTERM_STDOUT_STYLE) + attr_on(A_REVERSE, NULL); - writeUnicode(-1, buf, n_read); + writeUnicode(-1, buf, n_read); - if (style[0] != LTERM_STDOUT_STYLE) - attr_off(A_REVERSE, NULL); + if (style[0] != LTERM_STDOUT_STYLE) + attr_off(A_REVERSE, NULL); + } } /* Position cursor */ @@ -620,18 +622,20 @@ void *output_handler(void *arg) sprintf(esc_seq, "\033[%d;%dr", ymax-opvals, ymax-buf_row); write(1, esc_seq, strlen(esc_seq)); - } else if (n_read > 0) { + } else if (opcodes & LTERM_OUTPUT_CODE) { /* Data available for display */ sprintf(esc_seq, "\033[%d;%dH", ymax-buf_row, buf_col+1); write(1, esc_seq, strlen(esc_seq)); - if (style[0] != LTERM_STDOUT_STYLE) - write(1, "\033[7m", 4); + if (n_read > 0) { + if (style[0] != LTERM_STDOUT_STYLE) + write(1, "\033[7m", 4); - writeUnicode(1, buf, n_read); + writeUnicode(1, buf, n_read); - if (style[0] != LTERM_STDOUT_STYLE) - write(1, "\033[27m", 5); + if (style[0] != LTERM_STDOUT_STYLE) + write(1, "\033[27m", 5); + } } sprintf(esc_seq, "\033[%d;%dH", ymax-cursor_row, cursor_col+1); @@ -652,7 +656,8 @@ void *output_handler(void *arg) /* Move cursor to bottom of screen, clear line and display line */ move(ymax-1,0); clrtoeol(); - writeUnicode(-1, buf, n_read); + if (n_read > 0) + writeUnicode(-1, buf, n_read); move(ymax-1,cursor_col); if (opcodes & LTERM_NEWLINE_CODE) { @@ -674,7 +679,8 @@ void *output_handler(void *arg) if (opcodes & LTERM_META_CODE) write(1, "META", 4); - writeUnicode(1, buf, n_read); + if (n_read > 0) + writeUnicode(1, buf, n_read); for (j=0; j< (n_read-cursor_col); j++) write(1, "\033[D", 3); diff --git a/mozilla/extensions/xmlterm/ui/content/xmlterm.html b/mozilla/extensions/xmlterm/ui/content/xmlterm.html index f8ff1eca909..aa80613381e 100644 --- a/mozilla/extensions/xmlterm/ui/content/xmlterm.html +++ b/mozilla/extensions/xmlterm/ui/content/xmlterm.html @@ -95,8 +95,7 @@ function SetHistory() { var field = document.getElementById('HistoryValue'); dump("SetHistory "+field.value+"\n"); - xmltermshell.history = field.value; - field.value = xmltermshell.history; + xmltermshell.SetHistory(field.value, document.cookie); return (false); } diff --git a/mozilla/extensions/xmlterm/ui/skin/xmlterm.css b/mozilla/extensions/xmlterm/ui/skin/xmlterm.css index bc645b041ab..e8c4e968922 100644 --- a/mozilla/extensions/xmlterm/ui/skin/xmlterm.css +++ b/mozilla/extensions/xmlterm/ui/skin/xmlterm.css @@ -13,6 +13,10 @@ PRE { font-family: monaco; 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 }