xmlterm changes only (not part of the default build).
Improved full screen implementation; added bold and underline styles. Centralized UI event handling. Added checks to limit number of output lines displayed. Added capability to interrupt hung output data streams. Nearing full backwards compatibility with xterm. git-svn-id: svn://10.0.0.236/trunk@62265 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -9,9 +9,11 @@ of invoking XMLterm.
|
||||
XMLterm control-flow/layering hierarchy
|
||||
=======================================
|
||||
|
||||
mozilla-executable xmlterm-executable
|
||||
mozilla-executable geckoterm-executable
|
||||
| |
|
||||
../ui/content/xmlterm.html |
|
||||
../ui/content/xmlterm.xul |
|
||||
| |
|
||||
../ui/content/xmlterm.html ../ui/content/xmlterm.html
|
||||
| |
|
||||
mozXMLTermShell ../geckoterm/mozGeckoTerm
|
||||
| | |
|
||||
@@ -24,11 +26,11 @@ of invoking XMLterm.
|
||||
mozXMLTermSession mozLineTermAux mozXMLTermListeners
|
||||
| | |
|
||||
| | |
|
||||
mozXMLTermStream... (LineTerm) (user input)
|
||||
(rendering ...) (pseudo-TTY/shell)
|
||||
(rendering...) (LineTerm) (user input)
|
||||
(pseudo-TTY/shell)
|
||||
|
||||
|
||||
2 Dec 1999
|
||||
1 Mar 2000
|
||||
===========================================================================
|
||||
FILES:
|
||||
|
||||
|
||||
@@ -273,10 +273,11 @@ int lterm_metacomplete(int lterm, const UNICHAR *buf, int count);
|
||||
* OPCODES contains a bit mask describing the type of output (see below).
|
||||
* Using Extended Backus-Naur Form notation:
|
||||
*
|
||||
* OPCODES ::= STREAMDATA NEWLINE?
|
||||
* OPCODES ::= STREAMDATA NEWLINE? ERROR?
|
||||
* COOKIESTR? DOCSTREAM? XMLSTREAM? JSSTREAM? WINSTREAM?
|
||||
* if StreamMode data is being returned.
|
||||
* (NEWLINE, if set, denotes that the stream has terminated)
|
||||
* (NEWLINE, if set, denotes that the stream has terminated;
|
||||
* if ERROR is also set, it means that the stream has terminated abnormally.)
|
||||
*
|
||||
* OPCODES ::= SCREENDATA BELL? ( OUTPUT | CLEAR | INSERT | DELETE | SCROLL )?
|
||||
* if ScreenMode data is being returned.
|
||||
@@ -337,12 +338,13 @@ int lterm_read(int lterm, int timeout, UNICHAR *buf, int count,
|
||||
#define LTERM_COMPLETION_CODE 0x1000U /* Completion requested */
|
||||
#define LTERM_NEWLINE_CODE 0x2000U /* Complete (new) line */
|
||||
#define LTERM_HIDE_CODE 0x4000U /* Hide output */
|
||||
#define LTERM_ERROR_CODE 0x8000U /* Error in output */
|
||||
|
||||
#define LTERM_COOKIESTR_CODE 0x8000U /* Stream prefixed with cookie */
|
||||
#define LTERM_DOCSTREAM_CODE 0x10000U /* Stream contains complete document */
|
||||
#define LTERM_XMLSTREAM_CODE 0x20000U /* Stream contains XML, not HTML */
|
||||
#define LTERM_JSSTREAM_CODE 0x40000U /* Stream contains Javascript */
|
||||
#define LTERM_WINSTREAM_CODE 0x80000U /* Display stream in entire window */
|
||||
#define LTERM_COOKIESTR_CODE 0x10000U /* Stream prefixed with cookie */
|
||||
#define LTERM_DOCSTREAM_CODE 0x20000U /* Stream contains complete document */
|
||||
#define LTERM_XMLSTREAM_CODE 0x40000U /* Stream contains XML, not HTML */
|
||||
#define LTERM_JSSTREAM_CODE 0x80000U /* Stream contains Javascript */
|
||||
#define LTERM_WINSTREAM_CODE 0x100000U /* Display stream in entire window */
|
||||
|
||||
|
||||
/* LTERM/XTERM 16-bit style mask:
|
||||
|
||||
@@ -741,6 +741,11 @@ static int ltermProcessCSISequence(struct lterms *lts, const UNICHAR *buf,
|
||||
* Ps = 37 / 47 fg/bg White
|
||||
* Ps = 39 / 49 fg/bg Default
|
||||
*/
|
||||
|
||||
/* Enforce default value for parameter (hack!) */
|
||||
if (paramCount == 0)
|
||||
param1 = 0;
|
||||
|
||||
LTERM_LOG(ltermProcessCSISequence,52,("Character Attr %d\n", param1));
|
||||
switch (param1) {
|
||||
case 0:
|
||||
@@ -868,6 +873,7 @@ static int ltermProcessDECPrivateMode(struct lterms *lts,
|
||||
const int *paramValues, int paramCount, UNICHAR uch, int *opcodes)
|
||||
{
|
||||
struct LtermOutput *lto = &(lts->ltermOutput);
|
||||
int param1, param2;
|
||||
|
||||
LTERM_LOG(ltermProcessDECPrivateMode,50,("ch='%c', cursorChar=%d, Chars=%d\n",
|
||||
(char) uch, lto->outputCursorChar, lto->outputChars));
|
||||
@@ -875,13 +881,31 @@ static int ltermProcessDECPrivateMode(struct lterms *lts,
|
||||
/* Set returned opcodes to zero */
|
||||
*opcodes = 0;
|
||||
|
||||
/* Default parameter values: 1, 1 */
|
||||
param1 = (paramCount > 0) ? paramValues[0] : 1;
|
||||
param2 = (paramCount > 1) ? paramValues[1] : 1;
|
||||
|
||||
switch (uch) {
|
||||
case U_h_CHAR: /* DEC Private Mode Set (DECSET) */
|
||||
LTERM_LOG(ltermProcessDECPrivateMode,2,("Unimplemented %c\n", (char) uch));
|
||||
if ((param1 % 100) == 47) {
|
||||
/* Switch to screen mode */
|
||||
if (lto->outputMode == LTERM2_LINE_MODE) {
|
||||
ltermSwitchToScreenMode(lts);
|
||||
*opcodes = LTERM_SCREENDATA_CODE | LTERM_CLEAR_CODE;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
case U_l_CHAR: /* DEC Private Mode Reset (DECRST) */
|
||||
LTERM_LOG(ltermProcessDECPrivateMode,2,("Unimplemented %c\n", (char) uch));
|
||||
if ((param1 % 100) == 47) {
|
||||
/* Switch to line mode */
|
||||
if (lto->outputMode == LTERM1_SCREEN_MODE) {
|
||||
ltermSwitchToLineMode(lts);
|
||||
*opcodes = LTERM_LINEDATA_CODE;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
case U_r_CHAR: /* Restore previously saved DEC Private Mode Values */
|
||||
|
||||
@@ -438,7 +438,8 @@ int ltermWrite(struct lterms *lts, int *opcodes)
|
||||
/** Reads a (possibly incomplete) line from LTERM.
|
||||
* The LtermRead structure *LTR contains both input and output parameters,
|
||||
* returning opcodes values of
|
||||
* OPCODES ::= STREAMDATA NEWLINE? COOKIESTR? DOCSTREAM? XMLSTREAM? WINSTREAM?
|
||||
* OPCODES ::= STREAMDATA NEWLINE? ERROR?
|
||||
* COOKIESTR? DOCSTREAM? XMLSTREAM? WINSTREAM?
|
||||
* if StreamMode data is being returned.
|
||||
*
|
||||
* OPCODES ::= SCREENDATA BELL? ( OUTPUT | CLEAR | INSERT | DELETE | SCROLL )?
|
||||
@@ -790,10 +791,27 @@ int ltermRead(struct lterms *lts, struct LtermRead *ltr, int timeout)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Interrupts output operations in response to an input TTY interrupt signal
|
||||
* @return 0 if successful,
|
||||
* -1 if an error occurred
|
||||
*/
|
||||
int ltermInterruptOutput(struct lterms *lts)
|
||||
{
|
||||
struct LtermOutput *lto = &(lts->ltermOutput);
|
||||
|
||||
if (lto->outputMode == LTERM0_STREAM_MODE) {
|
||||
/* Abnormally terminate output stream */
|
||||
lto->streamOpcodes |= LTERM_ERROR_CODE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/** Returns stream data from STDOUT
|
||||
* (Auxiliary procedure for ltermRead.)
|
||||
* OPCODES ::= STREAMDATA NEWLINE? COOKIESTR? DOCSTREAM? XMLSTREAM? WINSTREAM?
|
||||
* OPCODES ::= STREAMDATA NEWLINE? ERROR?
|
||||
* COOKIESTR? DOCSTREAM? XMLSTREAM? WINSTREAM?
|
||||
* The LtermRead structure *LTR contains both input and output parameters.
|
||||
* @return 0 if successful,
|
||||
* -1 if an error occurred while reading,
|
||||
@@ -806,9 +824,28 @@ static int ltermReturnStreamData(struct lterms *lts, struct LtermRead *ltr)
|
||||
|
||||
LTERM_LOG(ltermReturnStreamData,30,("start\n"));
|
||||
|
||||
if (lto->decodedChars == 0)
|
||||
if (lto->streamOpcodes & LTERM_ERROR_CODE) {
|
||||
/* Error in stream output; terminate stream abnormally */
|
||||
LTERM_LOG(ltermReturnStreamData,32,("Error termination of STREAM mode\n"));
|
||||
|
||||
if (lto->savedOutputMode == LTERM1_SCREEN_MODE) {
|
||||
if (ltermSwitchToScreenMode(lts) != 0)
|
||||
return -1;
|
||||
} else {
|
||||
if (ltermSwitchToLineMode(lts) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
ltr->opcodes = lto->streamOpcodes | LTERM_STREAMDATA_CODE
|
||||
| LTERM_NEWLINE_CODE;
|
||||
ltr->read_count = 0;
|
||||
return 0;
|
||||
|
||||
} else if (lto->decodedChars == 0) {
|
||||
/* No output data available; return null opcode */
|
||||
return 0;
|
||||
}
|
||||
|
||||
ltr->opcodes = LTERM_STREAMDATA_CODE | lto->streamOpcodes;
|
||||
|
||||
if (ucslen(lto->streamTerminator) == 0) {
|
||||
@@ -866,7 +903,7 @@ static int ltermReturnStreamData(struct lterms *lts, struct LtermRead *ltr)
|
||||
if (ltermSwitchToLineMode(lts) != 0)
|
||||
return -1;
|
||||
}
|
||||
LTERM_LOG(ltermReturnStreamData,22,("terminating STREAM mode\n"));
|
||||
LTERM_LOG(ltermReturnStreamData,32,("terminating STREAM mode\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -460,6 +460,12 @@ static int ltermLineInput(struct lterms *lts,
|
||||
uch = U_LINEFEED; /* essentially newline behaviour otherwise */
|
||||
}
|
||||
|
||||
if (uch == lts->control[TTYINTERRUPT]) {
|
||||
/* Interrupt output operations, if necessary */
|
||||
if (ltermInterruptOutput(lts) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (metaInput) {
|
||||
/* meta input; do not send line */
|
||||
*opcodes |= LTERM_META_CODE;
|
||||
@@ -536,6 +542,15 @@ static int ltermLineInput(struct lterms *lts,
|
||||
case U_CTL_Y: /* yank */
|
||||
case U_TAB: /* command completion */
|
||||
|
||||
if ( (lti->inputChars == 0) && (uch == U_CTL_D) &&
|
||||
!((lts->processType == LTERM_TCSH_PROCESS) &&
|
||||
(lti->inputMode >= LTERM3_COMPLETION_MODE)) ) {
|
||||
/* If lone ^D and not TCSH completion, simply transmit it */
|
||||
if (ltermSendData(lts, &uch, 1) != 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Assert that completion character occurs at end of buffer;
|
||||
* enforced by lterm_write.
|
||||
*/
|
||||
@@ -633,14 +648,6 @@ static int ltermRequestCompletion(struct lterms *lts, UNICHAR uch)
|
||||
LTERM_LOG(ltermRequestCompletion,40,
|
||||
("++++++++++++ COMPLETION REQUEST uch=0x%X\n\n", uch));
|
||||
|
||||
if ((uch == U_CTL_D) &&
|
||||
!(lts->processType == LTERM_TCSH_PROCESS)){
|
||||
/* If ^D and not TCSH, simply transmit character */
|
||||
if (ltermSendData(lts, &uch, 1) != 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (uch) {
|
||||
case U_TAB:
|
||||
/* Send line and copy to echo buffer */
|
||||
|
||||
@@ -535,6 +535,7 @@ extern LtermGlobal ltermGlobal;
|
||||
/* Visible prototypes */
|
||||
|
||||
/* ltermIO.c */
|
||||
int ltermInterruptOutput(struct lterms *lts);
|
||||
int ltermSendLine(struct lterms *lts, UNICHAR uch,
|
||||
int echoControl, int completionCode);
|
||||
int ltermRead(struct lterms *lts, struct LtermRead *ltr, int timeout);
|
||||
|
||||
@@ -330,6 +330,12 @@ mozXMLTermKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||
case nsIDOMKeyEvent::DOM_VK_PAGE_DOWN:
|
||||
JSCommand = "ScrollPageDown";
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_F1:
|
||||
JSCommand = "HideAll";
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_F2:
|
||||
JSCommand = "ShowAll";
|
||||
break;
|
||||
default: // ignore event without consuming
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -118,10 +118,12 @@ protected:
|
||||
STDIN_ELEMENT,
|
||||
STDOUT_ELEMENT,
|
||||
STDERR_ELEMENT,
|
||||
MIXED_ELEMENT,
|
||||
WARNING_ELEMENT,
|
||||
SESSION_ELEMENT_TYPES
|
||||
};
|
||||
|
||||
/** user-generated input event type */
|
||||
/** allowed user-generated input event type */
|
||||
enum SessionEventType {
|
||||
CLICK_EVENT = 0,
|
||||
DBLCLICK_EVENT,
|
||||
@@ -141,9 +143,9 @@ protected:
|
||||
NO_NODE = 0,
|
||||
PRE_STDOUT_NODE,
|
||||
PRE_STDERR_NODE,
|
||||
SPAN_STDOUT_NODE,
|
||||
SPAN_STDERR_NODE,
|
||||
SPAN_MIXED_NODE,
|
||||
PRE_STDIN_NODE,
|
||||
DIV_MIXED_NODE,
|
||||
SPAN_DUMMY_NODE,
|
||||
OUTPUT_DISPLAY_TYPES
|
||||
};
|
||||
|
||||
@@ -155,6 +157,9 @@ protected:
|
||||
HTML_FRAGMENT,
|
||||
HTML_DOCUMENT,
|
||||
XML_DOCUMENT,
|
||||
INSECURE_FRAGMENT,
|
||||
OVERFLOW_FRAGMENT,
|
||||
INCOMPLETE_FRAGMENT,
|
||||
OUTPUT_MARKUP_TYPES
|
||||
};
|
||||
|
||||
@@ -237,7 +242,7 @@ protected:
|
||||
PRBool streamIsSecure);
|
||||
|
||||
/** Breaks output display by flushing and deleting incomplete lines */
|
||||
NS_IMETHOD BreakOutput(void);
|
||||
NS_IMETHOD BreakOutput(PRBool positionCursorBelow);
|
||||
|
||||
/** Processes output string with specified style
|
||||
* @param aString string to be processed
|
||||
@@ -251,6 +256,13 @@ protected:
|
||||
PRBool newline,
|
||||
PRBool streamOutput);
|
||||
|
||||
/** Ensures the total number of output lines stays within a limit
|
||||
* by deleting the oldest output line.
|
||||
* @param deleteAllOld if true, delete all previous display nodes
|
||||
* (excluding the current one)
|
||||
*/
|
||||
NS_IMETHOD LimitOutputLines(PRBool deleteAllOld);
|
||||
|
||||
/** Appends text string to output buffer
|
||||
* (appended text may need to be flushed for it to be actually displayed)
|
||||
* @param aString string to be processed
|
||||
@@ -289,15 +301,45 @@ protected:
|
||||
nsIDOMNode* beforeNode = nsnull,
|
||||
PRBool replace = false);
|
||||
|
||||
/** Deep refresh of selected attributes for DOM elements
|
||||
/** Substitute all occurrences of the '#' character in aString with
|
||||
* aNumber, if aNumber >= 0;
|
||||
* @ param aString string to be modified
|
||||
* @ param aNumber number to substituted
|
||||
*/
|
||||
void SubstituteCommandNumber(nsString& aString,
|
||||
PRInt32 aNumber);
|
||||
|
||||
/** Sanitize event handler attribute values by imposing syntax checks.
|
||||
* @param aAttrValue attribute value to be sanitized
|
||||
* @param aEventName name of event being handled ("Click", "DblClick", ...)
|
||||
*/
|
||||
void SanitizeAttribute(nsString& aAttrValue,
|
||||
const char* aEventName);
|
||||
|
||||
/** Deep sanitizing of event handler attributes ("on*") prior to insertion
|
||||
* of HTML fragments, to enfore consistent UI behaviour in XMLTerm and
|
||||
* for security. The following actions are carried out:
|
||||
* 1. Any SCRIPT tags in the fragment are simply deleted
|
||||
* 2. All event handler attributes, except a few selected ones, are deleted.
|
||||
* 3. The retained event handler attribute values are subject to strict
|
||||
* checks.
|
||||
* 4. If entryNumber >= 0, all '#' characters in the ID attribute and
|
||||
* retained event handler attributes are substituted with entryNumber.
|
||||
*
|
||||
* @param domNode DOM node for HTML fragment to be sanitized
|
||||
* @param parentNode parent DOM node (needed to delete SCRIPT elements;
|
||||
* set to null if root element)
|
||||
* @param entryNumber entry number (default value = -1)
|
||||
*/
|
||||
NS_IMETHOD DeepSanitizeFragment(nsCOMPtr<nsIDOMNode>& domNode,
|
||||
nsIDOMNode* parentNode,
|
||||
PRInt32 entryNumber);
|
||||
|
||||
/** Deep refresh of selected event handler attributes for DOM elements
|
||||
* (WORKAROUND for inserting HTML fragments properly)
|
||||
* @param domNode DOM node of branch to be refreshed
|
||||
* @param entryNumber entry number (default value = -1)
|
||||
* (if entryNumber >= 0, all '#' characters in event
|
||||
* handler scripts are substituted by entryNumber)
|
||||
*/
|
||||
NS_IMETHOD DeepRefreshAttributes(nsCOMPtr<nsIDOMNode>& domNode,
|
||||
PRInt32 entryNumber = -1);
|
||||
NS_IMETHOD DeepRefreshEventHandlers(nsCOMPtr<nsIDOMNode>& domNode);
|
||||
|
||||
/** Forces display of data in output buffer
|
||||
* @param flushAction type of flush action: display, split-off, clear, or
|
||||
@@ -305,6 +347,9 @@ protected:
|
||||
*/
|
||||
NS_IMETHOD FlushOutput(FlushActionType flushAction);
|
||||
|
||||
/** Positions cursor below the last output element */
|
||||
void PositionOutputCursor(mozILineTermAux* lineTermAux);
|
||||
|
||||
/** Scrolls document to align bottom and left margin with screen */
|
||||
NS_IMETHOD ScrollToBottomLeft(void);
|
||||
|
||||
@@ -336,18 +381,17 @@ protected:
|
||||
*/
|
||||
NS_IMETHOD GetRow(PRInt32 aRow, nsIDOMNode** aRowNode);
|
||||
|
||||
/** Returns DOM text node and offset corresponding to screen row/col position
|
||||
/** Positions cursor to specified screen row/col position
|
||||
*/
|
||||
NS_IMETHOD GetScreenText(PRInt32 aRow, PRInt32 aCol,
|
||||
nsIDOMNode** aTextNode,
|
||||
PRInt32 *aOffset);
|
||||
NS_IMETHOD PositionScreenCursor(PRInt32 aRow, PRInt32 aCol);
|
||||
|
||||
/** 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);
|
||||
NS_IMETHOD NewRow(nsIDOMNode* beforeRowNode,
|
||||
nsIDOMNode** resultNode);
|
||||
|
||||
/** Displays screen output string with specified style
|
||||
* @param aString string to be processed
|
||||
@@ -375,12 +419,16 @@ protected:
|
||||
* @param parentNode parent node for element
|
||||
* @param blockNode (output) block-level DOM node for created element
|
||||
* @param textNode (output) child text DOM node of element
|
||||
* @param beforeNode child node before which to insert new node
|
||||
* if null, insert after last child node
|
||||
* (default value is null)
|
||||
*/
|
||||
NS_IMETHOD NewElementWithText(const nsString& tagName,
|
||||
const nsString& name, PRInt32 number,
|
||||
nsIDOMNode* parentNode,
|
||||
nsCOMPtr<nsIDOMNode>& blockNode,
|
||||
nsCOMPtr<nsIDOMNode>& textNode);
|
||||
nsCOMPtr<nsIDOMNode>& textNode,
|
||||
nsIDOMNode* beforeNode = nsnull);
|
||||
|
||||
/** Creates an empty anchor (A) element with tag name tagName with attributes
|
||||
* CLASS="classAttribute", and ID="classAttribute#", and appends it as a
|
||||
@@ -407,11 +455,15 @@ protected:
|
||||
* (If < 0, no ID attribute is defined)
|
||||
* @param parentNode parent node for element
|
||||
* @param blockNode (output) block-level DOM node for created element
|
||||
* @param beforeNode child node before which to insert new node
|
||||
* if null, insert after last child node
|
||||
* (default value is null)
|
||||
*/
|
||||
NS_IMETHOD NewElement(const nsString& tagName,
|
||||
const nsString& name, PRInt32 number,
|
||||
nsIDOMNode* parentNode,
|
||||
nsCOMPtr<nsIDOMNode>& blockNode);
|
||||
nsCOMPtr<nsIDOMNode>& blockNode,
|
||||
nsIDOMNode* beforeNode = nsnull);
|
||||
|
||||
/** Creates a new DOM text node, and appends it as a child of the
|
||||
* specified parent.
|
||||
@@ -571,6 +623,9 @@ protected:
|
||||
/** current text node for command output */
|
||||
nsCOMPtr<nsIDOMNode> mOutputTextNode;
|
||||
|
||||
/** line offset of current text node for command output */
|
||||
PRInt32 mOutputTextOffset;
|
||||
|
||||
/** current XMLTerm stream interface for stream display */
|
||||
nsCOMPtr<mozIXMLTermStream> mXMLTermStream;
|
||||
|
||||
@@ -592,13 +647,16 @@ protected:
|
||||
AutoDetectOption mAutoDetect;
|
||||
|
||||
|
||||
/** flag indicating whether a line break needs to be output */
|
||||
PRBool mLineBreakNeeded;
|
||||
|
||||
/** flag marking the first line of output */
|
||||
PRBool mFirstOutputLine;
|
||||
|
||||
|
||||
/** total count of PRE/mixed text lines displayed for this entry */
|
||||
PRInt32 mEntryOutputLines;
|
||||
|
||||
/** count of PRE complete text lines in buffer */
|
||||
PRInt32 mPreTextBufferLines;
|
||||
|
||||
/** buffer for incomplete line of PRE text */
|
||||
nsString mPreTextIncomplete;
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMWindowCollection.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
#include "mozXMLT.h"
|
||||
@@ -275,6 +276,32 @@ mozXMLTermUtils::ExecuteScript(nsIDOMDocument* aDOMDocument,
|
||||
}
|
||||
|
||||
|
||||
/** Returns the specified attribute value associated with a DOM node,
|
||||
* or a null string if the attribute is not defined, or if the DOM node
|
||||
* is not an element.
|
||||
* @param aDOMNode node whose attribute is to be determined
|
||||
* @param aAttName attribute to be determined
|
||||
* @param aAttValue output attribute value
|
||||
* @return NS_OK if no errors occurred
|
||||
*/
|
||||
NS_EXPORT nsresult
|
||||
mozXMLTermUtils::GetNodeAttribute(nsIDOMNode* aDOMNode,
|
||||
const char* aAttName,
|
||||
nsString& aAttValue)
|
||||
{
|
||||
XMLT_LOG(mozXMLTermUtils::GetNodeAttribute,20,("aAttName=%s\n", aAttName));
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(aDOMNode);
|
||||
if (!domElement) {
|
||||
aAttValue = "";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString attName = aAttName;
|
||||
return domElement->GetAttribute(attName, aAttValue);
|
||||
}
|
||||
|
||||
|
||||
/** Returns a timestamp string containing the local time, if at least
|
||||
* deltaSec seconds have elapsed since the last timestamp. Otherwise,
|
||||
* a null string is returned.
|
||||
|
||||
@@ -103,6 +103,19 @@ class mozXMLTermUtils
|
||||
const nsString& aScript,
|
||||
nsString& aOutput);
|
||||
|
||||
/** Returns the specified attribute value associated with a DOM node,
|
||||
* or a null string if the attribute is not defined, or if the DOM node
|
||||
* is not an element.
|
||||
* @param aDOMNode node whose attribute is to be determined
|
||||
* @param aAttName attribute to be determined
|
||||
* @param aAttValue output attribute value
|
||||
* @return NS_OK if no errors occurred
|
||||
*/
|
||||
static NS_EXPORT nsresult
|
||||
GetNodeAttribute(nsIDOMNode* aDOMNode,
|
||||
const char* aAttName,
|
||||
nsString& aAttValue);
|
||||
|
||||
/** Returns a timestamp string containing the local time, if at least
|
||||
* deltaSec seconds have elapsed since the last timestamp. Otherwise,
|
||||
* a null string is returned.
|
||||
|
||||
@@ -23,13 +23,14 @@ my $dir = cwd();
|
||||
foreach my $url (@ARGV) { # for each argument
|
||||
my ($protocol, $slashpair, $username, $host, $port, $pathname);
|
||||
|
||||
# Check if argument is a valid URL
|
||||
if ( $url =~ m%\b # initiator
|
||||
([a-zA-Z]\w*)?: # protocol
|
||||
(//)? # slashpair
|
||||
(?:([\w.]+)@)? # username
|
||||
([\w\-]+(?:\.[\w\-]+)*)? # host
|
||||
(?::(\d+))? # port
|
||||
(/\S*?)? # pathname
|
||||
(/\S*?) # pathname
|
||||
(?=>|\"|\'|\s|[.,!](?:\s|\Z)|\Z) # terminator (look ahead)
|
||||
%x ) {
|
||||
|
||||
@@ -45,6 +46,7 @@ foreach my $url (@ARGV) { # for each argument
|
||||
|
||||
## print STDERR "Not an URL; assume local file $url\n";
|
||||
|
||||
# Create a file URL
|
||||
($protocol, $slashpair, $username, $host, $port, $pathname) =
|
||||
("file", "//", "", "", "", $url);
|
||||
|
||||
@@ -105,7 +107,7 @@ foreach my $url (@ARGV) { # for each argument
|
||||
(?:([\w.]+)@)? # username
|
||||
([\w\-]+(?:\.[\w\-]+)*)? # host
|
||||
(?::(\d+))? # port
|
||||
(/\S*?)? # pathname
|
||||
(/\S*?) # pathname
|
||||
(?=>|\"|\'|\s|[.,!](?:\s|\Z)|\Z) # terminator (look ahead)
|
||||
%x ) {
|
||||
$urlvals[$nurl] = $&;
|
||||
@@ -120,7 +122,7 @@ foreach my $url (@ARGV) { # for each argument
|
||||
$urldesc = $urlstr if !$urldesc;
|
||||
|
||||
my $clickcmd =
|
||||
qq%onclick="return clickXMLTerm('textlink',-#,'$urlstr')"%;
|
||||
qq%onClick="return HandleEvent(event,'click','textlink',-\#,'$urlstr')"%;
|
||||
|
||||
print "\e{S$cookie\a"; # HTML stream escape sequence
|
||||
if ($nurl >= 2) {
|
||||
@@ -138,25 +140,28 @@ foreach my $url (@ARGV) { # for each argument
|
||||
print "<pre>";
|
||||
|
||||
while (<INFILE>) {
|
||||
s/&/&/g;
|
||||
s/</</g;
|
||||
s/>/">"/g;
|
||||
s%\b # initiator
|
||||
([a-zA-Z]\w*)?: # protocol
|
||||
(//)? # slashpair
|
||||
(?:([\w.]+)@)? # username
|
||||
([\w\-]+(?:\.[\w\-]+)*)? # host
|
||||
(?::(\d+))? # port
|
||||
(/\S*?)? # pathname
|
||||
(?=>|\"|\'|\s|[.,!](?:\s|\Z)|\Z) # terminator (look ahead)
|
||||
%<span class="textlink" onClick="return clickXMLTerm('textlink',-1,'$&')">$&</span>%xg;
|
||||
s/">"/>/g;
|
||||
s/&/&/g; # Replace & with &
|
||||
s/</</g; # Replace < with <
|
||||
s/>/">"/g; # Temporarily replace > with ">"
|
||||
# to allow termination of <http://xyz.com> etc.
|
||||
|
||||
s%\b # URL word boundary
|
||||
([a-zA-Z]\w*)?: # protocol
|
||||
(//)? # slashpair
|
||||
(?:([\w.]+)@)? # username
|
||||
([\w\-]+(?:\.[\w\-]+)*)? # host
|
||||
(?::(\d+))? # port
|
||||
(/\S*?) # pathname
|
||||
(?=>|\"|\'|\s|[.,!](?:\s|\Z)|\Z) # URL terminator (look ahead)
|
||||
%<span class="textlink" onClick="return HandleEvent(event,'click','textlink',-\#,'$&')">$&</span>%xg;
|
||||
|
||||
s/">"/>/g; # Replace ">" with > in the end
|
||||
|
||||
print $_;
|
||||
}
|
||||
|
||||
print "</pre>";
|
||||
print "\000"; # Terminate HTML stream
|
||||
print "\000"; # Terminate HTML stream
|
||||
close INFILE;
|
||||
|
||||
} else { # unknown file type
|
||||
|
||||
@@ -46,7 +46,7 @@ foreach $file (glob("*")) { # for each file in current directory
|
||||
if ($opt_window) {
|
||||
$sendcmd = "createln";
|
||||
} else {
|
||||
$sendcmd = "sendln";
|
||||
$sendcmd = "exec";
|
||||
}
|
||||
|
||||
my ($filetype, $fileimg, $sendtxt1, $sendtxt2);
|
||||
@@ -74,22 +74,23 @@ foreach $file (glob("*")) { # for each file in current directory
|
||||
$_ = <INFILE>;
|
||||
close INFILE;
|
||||
|
||||
# Extract content URL and the icon URL (if any)
|
||||
my @urlvals;
|
||||
my $nurl = 0;
|
||||
while ( m%\b # initiator
|
||||
(http|file|mailto): # scheme
|
||||
while ( m%\b # URL word boundary
|
||||
(http|file|mailto): # protocol
|
||||
(//)? # slashpair
|
||||
(?:([\w.]+)@)? # username
|
||||
([\w\-]+(?:\.[\w\-]+)*)? # host
|
||||
(?::(\d+))? # port
|
||||
(/\S*?)? # pathname
|
||||
(?=>|\"|\'|\s|[.,!](?:\s|\Z)|\Z) # terminator (look ahead)
|
||||
(/\S*?) # pathname
|
||||
(?=>|\"|\'|\s|[.,!](?:\s|\Z)|\Z) # URL terminator (look ahead)
|
||||
%x ) {
|
||||
$urlvals[$nurl] = $&;
|
||||
s%$&%%;
|
||||
$nurl++;
|
||||
}
|
||||
s%\A\s*(\S.*?)?\s*\Z%$1%;
|
||||
s%\A\s*(\S.*?)?\s*\Z%$1%; # trim leading/trailing space
|
||||
|
||||
if ($nurl >= 1) {
|
||||
my $urldesc = $_;
|
||||
@@ -100,9 +101,9 @@ foreach $file (glob("*")) { # for each file in current directory
|
||||
|
||||
$filetype = "urlfile";
|
||||
if ($nurl >= 2) {
|
||||
$fileimg = "$urlvals[1]";
|
||||
$fileimg = "$urlvals[1]"; # use icon URL
|
||||
} else {
|
||||
$fileimg = "$imgdir/$img{$filetype}";
|
||||
$fileimg = "$imgdir/$img{$filetype}"; #default URL icon
|
||||
}
|
||||
$sendtxt1 = "$urlstr";
|
||||
$sendtxt2 = "$urlstr";
|
||||
@@ -124,7 +125,7 @@ foreach $file (glob("*")) { # for each file in current directory
|
||||
my $tail = $comps[$#comps]; # file name
|
||||
|
||||
my $clickcmd =
|
||||
qq%onclick="return clickXMLTerm('$sendcmd',-\#,'$sendtxt1','$sendtxt2')"%;
|
||||
qq%onClick="return HandleEvent(event,'click','$sendcmd',-\#,'$sendtxt1','$sendtxt2')"%;
|
||||
|
||||
$rowimg .= "<TD><IMG HEIGHT=48 WIDTH=48 SRC='$fileimg' $clickcmd>";
|
||||
$rowtxt .= "<TD><SPAN CLASS='$filetype' $clickcmd>";
|
||||
|
||||
@@ -55,7 +55,7 @@ foreach file ($files)
|
||||
else
|
||||
set cmd="sendln"
|
||||
endif
|
||||
set clickcmd="onclick="'"'"return clickXMLTerm('$cmd',-1,'$sendtxt')"'"'
|
||||
set clickcmd="onClick="'"'"return ClickXMLTerm('$cmd',-1,'$sendtxt')"'"'
|
||||
|
||||
set rowimg="${rowimg}<TD><IMG SRC='$sendimg' $clickcmd>"
|
||||
set rowtxt="${rowtxt}<TD><SPAN CLASS='$filetype' $clickcmd>"
|
||||
|
||||
@@ -20,11 +20,11 @@ int main(void)
|
||||
<IMG align=center src='chrome://navigator/skin/animthrob_single.gif'> \
|
||||
<B>Please click a button</B> <BR> \
|
||||
<INPUT ID='button-b#' TYPE=button VALUE='Bold' \
|
||||
onClick=\"return clickXMLTerm('sendln','#','b')\"> \
|
||||
onClick=\"return HandleEvent(event, 'click', 'sendln','#','b')\"> \
|
||||
<INPUT ID='button-e#' TYPE=button VALUE='Emphasis' \
|
||||
onClick=\"return clickXMLTerm('sendln','#','e')\"> \
|
||||
onClick=\"return HandleEvent(event, 'click', 'sendln','#','e')\"> \
|
||||
<INPUT ID='button-q#' TYPE=button VALUE='Quit' \
|
||||
onClick=\"return clickXMLTerm('sendln','#','q')\"> \
|
||||
onClick=\"return HandleEvent(event, 'click', 'sendln','#','q')\"> \
|
||||
<BR></FORM> \
|
||||
</BODY></HTML>");
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ int main(void)
|
||||
<IMG align=center src='chrome://navigator/skin/animthrob_single.gif'> \
|
||||
<B>Please click a button</B> <BR> \
|
||||
<INPUT ID='button-b#' TYPE=button VALUE='Bold' \
|
||||
onClick=\"return clickXMLTerm('sendln','#','b')\"> \
|
||||
onClick=\"return HandleEvent(event, 'click', 'sendln','#','b')\"> \
|
||||
<INPUT ID='button-e#' TYPE=button VALUE='Emphasis' \
|
||||
onClick=\"return clickXMLTerm('sendln','#','e')\"> \
|
||||
onClick=\"return HandleEvent(event, 'click', 'sendln','#','e')\"> \
|
||||
<INPUT ID='button-q#' TYPE=button VALUE='Quit' \
|
||||
onClick=\"return clickXMLTerm('sendln','#','q')\"> \
|
||||
onClick=\"return HandleEvent(event, 'click', 'sendln','#','q')\"> \
|
||||
<BR></FORM>");
|
||||
|
||||
printf("%c", '\0'); /* Escape sequence signalling end of HTML */
|
||||
|
||||
@@ -4,10 +4,10 @@ function StartupXMLTerm() {
|
||||
dump("StartupXMLTerm:"+window.frames[0].name+"\n");
|
||||
|
||||
if (window.frames.length == 2) {
|
||||
window.frames[1].xmltbrowser = window.frames[0];
|
||||
xmltwin = frames[1];
|
||||
xmltwin = window.frames[1];
|
||||
xmltwin.xmltbrowser = window.frames[0];
|
||||
} else {
|
||||
xmltwin = frames[0];
|
||||
xmltwin = window.frames[0];
|
||||
}
|
||||
|
||||
dump("StartupXMLterm: WINDOW.ARGUMENTS="+window.arguments+"\n");
|
||||
@@ -27,11 +27,10 @@ function StartupXMLTerm() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the XMLTerm shell in the window
|
||||
// Store the XMLTerm shell in current window and in the XMLTerm frame
|
||||
window.xmlterm = xmltshell;
|
||||
xmltwin.xmlterm = xmltshell;
|
||||
|
||||
// Initialize XMLTerm shell in content window with argvals
|
||||
window.xmlterm.Init(xmltwin, "",
|
||||
window.arguments);
|
||||
window.xmlterm.Init(xmltwin, "", window.arguments);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
|
||||
<SCRIPT language="JavaScript">
|
||||
|
||||
// CONVENTION: All pre-defined XMLTerm Javascript functions
|
||||
// begin with an upper letter. This allows
|
||||
// an easy distinction with user defined functions,
|
||||
// which should begin with a lower case letter.
|
||||
|
||||
// Show all output
|
||||
function ShowAll() {
|
||||
return DisplayAllOutput(true);
|
||||
@@ -146,73 +151,103 @@
|
||||
return (false);
|
||||
}
|
||||
|
||||
// Click handler
|
||||
function clickXMLTerm(name, number, arg1, arg2) {
|
||||
dump("clickXMLTerm("+name+","+number+","+arg1+","+arg2+")\n");
|
||||
// Centralized event handler
|
||||
// eventType values:
|
||||
// click
|
||||
//
|
||||
// targetType:
|
||||
// textlink - hyperlink
|
||||
// prompt - command prompt
|
||||
// command - command line
|
||||
// exec - execute command with sendln/createln
|
||||
// (depending upon window.commandMode)
|
||||
// send - transmit arg to LineTerm
|
||||
// sendln - transmit arg+newline to LineTerm
|
||||
// createln - transmit arg+newline as first command to new XMLTerm
|
||||
//
|
||||
// entryNumber: >=0 means process only if current entry
|
||||
// <0 means process anytime
|
||||
//
|
||||
// arg1: command/pathname string (without newline)
|
||||
// arg2: alternate command line (for use in current entry only;
|
||||
// uses relative pathnames assuming current working directory)
|
||||
//
|
||||
function HandleEvent(eventObj, eventType, targetType, entryNumber,
|
||||
arg1, arg2) {
|
||||
dump("HandleEvent("+eventObj+","+eventType+","+targetType+","+
|
||||
entryNumber+","+arg1+","+arg2+")\n");
|
||||
|
||||
if (name === "prompt") {
|
||||
var outputElement = document.getElementById("output"+number);
|
||||
var promptElement = document.getElementById("prompt"+number);
|
||||
//dump(promptElement.style.getPropertyValue("text-decoration"));
|
||||
|
||||
if (outputElement.style.display == "none") {
|
||||
outputElement.style.display = "block";
|
||||
promptElement.style.setProperty("text-decoration","none","");
|
||||
} else {
|
||||
outputElement.style.display = "none";
|
||||
promptElement.style.setProperty("text-decoration","underline","");
|
||||
}
|
||||
|
||||
} else if (name === "command") {
|
||||
var commandElement = document.getElementById(name+number);
|
||||
var command = commandElement.firstChild.data;
|
||||
dump("command = "+command+"\n\n");
|
||||
window.xmlterm.SendText("\025"+command+"\n", document.cookie);
|
||||
|
||||
} else {
|
||||
|
||||
if ((number >= 0) &&
|
||||
(window.xmlterm.currentEntryNumber != number)) {
|
||||
dump("NOT CURRENT COMMAND\n");
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (name == "send") {
|
||||
dump("send = "+arg1+"\n");
|
||||
window.xmlterm.SendText(arg1, document.cookie);
|
||||
// Entry independent targets
|
||||
if (action === "textlink") {
|
||||
dump("textlink = "+arg1+"\n");
|
||||
Load(arg1);
|
||||
|
||||
} else if (name == "textlink") {
|
||||
dump("textlink = "+arg1+"\n");
|
||||
Load(arg1);
|
||||
|
||||
} else if (name == "sendln") {
|
||||
} else if (eventType === "click") {
|
||||
if (targetType === "prompt") {
|
||||
var outputElement = document.getElementById("output"+entryNumber);
|
||||
var promptElement = document.getElementById("prompt"+entryNumber);
|
||||
//dump(promptElement.style.getPropertyValue("text-decoration"));
|
||||
|
||||
if ((Math.abs(number)+1 == window.xmlterm.currentEntryNumber) &&
|
||||
if (outputElement.style.display == "none") {
|
||||
outputElement.style.display = "block";
|
||||
promptElement.style.setProperty("text-decoration","none","");
|
||||
} else {
|
||||
outputElement.style.display = "none";
|
||||
promptElement.style.setProperty("text-decoration","underline","");
|
||||
}
|
||||
|
||||
} else if (targetType === "command") {
|
||||
var commandElement = document.getElementById(targetType+entryNumber);
|
||||
var command = commandElement.firstChild.data;
|
||||
dump("command = "+command+"\n\n");
|
||||
window.xmlterm.SendText("\025"+command+"\n", document.cookie);
|
||||
|
||||
} else {
|
||||
// Targets which may be qualified only for current entry
|
||||
|
||||
if ((entryNumber >= 0) &&
|
||||
(window.xmlterm.currentEntryNumber != entryNumber)) {
|
||||
dump("NOT CURRENT COMMAND\n");
|
||||
return (false);
|
||||
}
|
||||
|
||||
var action = targetType;
|
||||
|
||||
if (action === "exec") {
|
||||
if (window.commandMode === "window") {
|
||||
action = "createln";
|
||||
} else {
|
||||
action = "sendln";
|
||||
}
|
||||
}
|
||||
|
||||
if (action === "send") {
|
||||
dump("send = "+arg1+"\n");
|
||||
window.xmlterm.SendText(arg1, document.cookie);
|
||||
|
||||
} else if (action === "sendln") {
|
||||
|
||||
if ((Math.abs(entryNumber)+1 == window.xmlterm.currentEntryNumber) &&
|
||||
(arg2 != null)) {
|
||||
// Current command
|
||||
dump("sendln = "+arg2+"\n\n");
|
||||
window.xmlterm.SendText("\025"+arg2+"\n", document.cookie);
|
||||
} else {
|
||||
// Not current command
|
||||
dump("sendln = "+arg1+"\n\n");
|
||||
window.xmlterm.SendText("\025"+arg1+"\n", document.cookie);
|
||||
}
|
||||
// Current command
|
||||
dump("sendln = "+arg2+"\n\n");
|
||||
window.xmlterm.SendText("\025"+arg2+"\n", document.cookie);
|
||||
} else {
|
||||
// Not current command
|
||||
dump("sendln = "+arg1+"\n\n");
|
||||
window.xmlterm.SendText("\025"+arg1+"\n", document.cookie);
|
||||
}
|
||||
|
||||
} else if (name == "createln") {
|
||||
dump("createln = "+arg1+"\n\n");
|
||||
newwin = NewXMLTerm(arg1+"\n");
|
||||
} else if (action === "createln") {
|
||||
dump("createln = "+arg1+"\n\n");
|
||||
newwin = NewXMLTerm(arg1+"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
// Double Click handler
|
||||
function dblclickXMLTerm(name, number, arg1) {
|
||||
dump("dblclickXMLTerm("+name+","+number+","+arg1+")\n");
|
||||
return (false);
|
||||
}
|
||||
|
||||
// Set history buffer count using form entry
|
||||
function SetHistoryValue() {
|
||||
var field = document.getElementById('InputValue');
|
||||
@@ -225,6 +260,35 @@
|
||||
return SetPrompt(field.value);
|
||||
}
|
||||
|
||||
// Usage tips
|
||||
var tips = new Array();
|
||||
tips[0] = 'Click the SetPrompt button to use a cool Mozilla prompt from dmoz.org!';
|
||||
tips[1] = '"js:SetPrompt(HTMLstring);" sets prompt to HTML string.';
|
||||
tips[2] = 'Type "js:func(arg);" to execute inline Javascript function func.';
|
||||
tips[3] = 'Inline Javascript ("js:...") can be used to produce HTML output.';
|
||||
tips[4] = 'XMLterm supports full screen commands like "vi", "emacs -nw", and "less".';
|
||||
tips[5] = 'Use "xls -i" for iconic display of directory contents.';
|
||||
tips[6] = 'Use "xcat file" to display file.';
|
||||
|
||||
// Display random usage tip
|
||||
// (should cease to operate after a few cycles;
|
||||
// need to use Prefs to keep track of that)
|
||||
function UsageTip() {
|
||||
var tipCount = tips.length;
|
||||
var ranval = Math.random();
|
||||
var tipIndex = Math.floor(ranval * tipCount);
|
||||
if (tipIndex >= tipCount) tipIndex = 0;
|
||||
|
||||
dump("xmlterm: UsageTip "+tipIndex+","+ranval+"\n");
|
||||
|
||||
var tiphead = document.getElementById('tiphead');
|
||||
var tipdata = document.getElementById('tipdata');
|
||||
tiphead.firstChild.data = "Tip:";
|
||||
tipdata.firstChild.data = tips[tipIndex];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Display more tips
|
||||
function MoreTips() {
|
||||
dump("xmlterm: MoreTips\n");
|
||||
@@ -258,6 +322,8 @@
|
||||
function LoadHandler() {
|
||||
dump("xmlterm: LoadHandler ... "+window.xmlterm+"\n");
|
||||
|
||||
UsageTip();
|
||||
|
||||
if (window.xmlterm) {
|
||||
// XMLTerm already initialized
|
||||
return (false);
|
||||
@@ -358,13 +424,14 @@
|
||||
<TBODY>
|
||||
<TR><TD ALIGN=center>
|
||||
<FORM NAME="XMLTERM form">
|
||||
<INPUT TYPE="button" VALUE="Show all output"
|
||||
onClick="return ShowAll();">
|
||||
<INPUT TYPE="button" VALUE="Hide all output"
|
||||
onClick="return HideAll();">
|
||||
<INPUT TYPE="button" VALUE="Show all output"
|
||||
onClick="return ShowAll();">
|
||||
<INPUT TYPE="button" VALUE="SetHistory"
|
||||
onClick="return SetHistoryValue();">
|
||||
<INPUT TYPE="button" VALUE="SetPrompt" onClick="return SetPromptValue();">
|
||||
<INPUT TYPE="button" VALUE="NewXMLTerm" onClick="return NewXMLTerm('');">
|
||||
<BR>
|
||||
Input Value:
|
||||
<INPUT SIZE=50 TYPE="text" ID="InputValue"
|
||||
@@ -373,9 +440,9 @@
|
||||
</FORM>
|
||||
</TABLE>
|
||||
|
||||
<SPAN CLASS="tips" ID="tips">
|
||||
<B>Tip:</B> Click the SetPrompt button to use a cool Mozilla prompt from dmoz.org!
|
||||
</SPAN>
|
||||
<SPAN CLASS="tiphead" ID="tiphead" STYLE="font-weight:bold"> </SPAN>
|
||||
<SPAN CLASS="tipdata" ID="tipdata"> </SPAN>
|
||||
|
||||
<SPAN CLASS="moretips" ID="moretips" onClick="return MoreTips();">
|
||||
More tips/news
|
||||
</SPAN>
|
||||
|
||||
@@ -1,21 +1,435 @@
|
||||
<TITLE> XMLterm Init Frame </TITLE>
|
||||
<!-- xmlterm.html: XMLterm page -->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>XMLterm Page</TITLE>
|
||||
|
||||
<FRAMESET ROWS="*,*">
|
||||
<LINK TITLE="DefaultStyle" REL="stylesheet" TYPE="text/css"
|
||||
HREF="chrome://xmlterm/skin/xmltpage.css">
|
||||
|
||||
<FRAME NAME="xmltbrowser" SRC="about:blank">
|
||||
<SCRIPT language="JavaScript">
|
||||
|
||||
<FRAME SRC="chrome://xmlterm/content/xmlterm.html">
|
||||
// CONVENTION: All pre-defined XMLTerm Javascript functions
|
||||
// begin with an upper letter. This allows
|
||||
// an easy distinction with user defined functions,
|
||||
// which should begin with a lower case letter.
|
||||
|
||||
<NOFRAMES>
|
||||
// Show all output
|
||||
function ShowAll() {
|
||||
return DisplayAllOutput(true);
|
||||
}
|
||||
|
||||
<BODY>
|
||||
// Hide all output
|
||||
function HideAll() {
|
||||
return DisplayAllOutput(false);
|
||||
}
|
||||
|
||||
XMLterm No Frames Page
|
||||
<BR>
|
||||
See <A HREF="http://xmlterm.org">xmlterm.org</A> for more information.
|
||||
// Set history buffer size
|
||||
function SetHistory(value) {
|
||||
dump("SetHistory("+value+")\n");
|
||||
window.xmlterm.SetHistory(value, document.cookie);
|
||||
return (false);
|
||||
}
|
||||
|
||||
</BODY>
|
||||
// Set prompt
|
||||
function SetPrompt(value) {
|
||||
dump("SetPrompt("+value+")\n");
|
||||
window.xmlterm.SetPrompt(value, document.cookie);
|
||||
return (false);
|
||||
}
|
||||
|
||||
</NOFRAMES>
|
||||
// Create new XMLTerm window
|
||||
function NewXMLTerm(firstcommand) {
|
||||
newwin = window.openDialog( "chrome://xmlterm/content/xmlterm.xul",
|
||||
"xmlterm", "chrome,dialog=no,resizable",
|
||||
firstcommand);
|
||||
//newwin = window.xmlterm.NewXMLTermWindow(firstcommand);
|
||||
dump("NewXMLTerm: "+newwin+"\n")
|
||||
return (false);
|
||||
}
|
||||
|
||||
</FRAMESET>
|
||||
// Handle resize events
|
||||
function Resize(event) {
|
||||
dump("Resize()\n");
|
||||
window.xmlterm.Resize();
|
||||
return (false);
|
||||
}
|
||||
|
||||
// Scroll Home
|
||||
function ScrollHome(isShift, isControl) {
|
||||
dump("ScrollHome("+isShift+","+isControl+")\n");
|
||||
if (isShift && window.xmltbrowser) {
|
||||
window.xmltbrowser.scroll(0,0);
|
||||
} else {
|
||||
window.scroll(0,0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Scroll End
|
||||
function ScrollEnd(isShift, isControl) {
|
||||
dump("ScrollEnd("+isShift+","+isControl+")\n");
|
||||
if (isShift && window.xmltbrowser) {
|
||||
window.xmltbrowser.scroll(0,9999);
|
||||
} else {
|
||||
window.scroll(0,9999);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Scroll PageUp
|
||||
function ScrollPageUp(isShift, isControl) {
|
||||
dump("ScrollPageUp("+isShift+","+isControl+")\n");
|
||||
|
||||
if (isShift && window.xmltbrowser) {
|
||||
window.xmltbrowser.scrollBy(0,-300);
|
||||
} else {
|
||||
window.scrollBy(0,-300);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Scroll PageDown
|
||||
function ScrollPageDown(isShift, isControl) {
|
||||
dump("ScrollPageDown("+isShift+","+isControl+")\n");
|
||||
if (isShift && window.xmltbrowser) {
|
||||
window.xmltbrowser.scrollBy(0,300);
|
||||
} else {
|
||||
window.scrollBy(0,300);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Form Focus (workaround for form input being transmitted to xmlterm)
|
||||
function FormFocus() {
|
||||
dump("FormFocus()\n");
|
||||
window.xmlterm.IgnoreKeyPress(true, document.cookie);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Form Blur (workaround for form input being transmitted to xmlterm)
|
||||
function FormBlur() {
|
||||
dump("FormBlur()\n");
|
||||
window.xmlterm.IgnoreKeyPress(false, document.cookie);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Handle default meta command
|
||||
function MetaDefault(arg1) {
|
||||
return Load("http://"+arg1);
|
||||
}
|
||||
|
||||
// Load URL in XMLTermBrowser window
|
||||
function Load(url) {
|
||||
var succeeded = false;
|
||||
if (window.xmltbrowser) {
|
||||
dump("Load:xmltbrowser.location.href="+window.xmltbrowser.location.href+"\n");
|
||||
if (window.xmltbrowser.location.href.length) {
|
||||
window.xmltbrowser.location = url;
|
||||
succeeded = true;
|
||||
}
|
||||
}
|
||||
if (!succeeded) {
|
||||
window.xmltbrowser = window.open(url, "xmltbrowser");
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
// Control display of all output elements
|
||||
function DisplayAllOutput(flag) {
|
||||
var outputElements = document.getElementsByName("output");
|
||||
for (i=0; i<outputElements.length; i++) {
|
||||
var outputElement = outputElements[i];
|
||||
outputElement.style.display = (flag) ? "block" : "none";
|
||||
}
|
||||
|
||||
var promptElements = document.getElementsByName("prompt");
|
||||
for (i=0; i<promptElements.length; i++) {
|
||||
promptElement = promptElements[i];
|
||||
promptElement.style.setProperty("text-decoration",
|
||||
(flag) ? "none" : "underline", "")
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
// Centralized event handler
|
||||
// eventType values:
|
||||
// click
|
||||
//
|
||||
// targetType:
|
||||
// textlink - hyperlink
|
||||
// prompt - command prompt
|
||||
// command - command line
|
||||
// exec - execute command with sendln/createln
|
||||
// (depending upon window.commandMode)
|
||||
// send - transmit arg to LineTerm
|
||||
// sendln - transmit arg+newline to LineTerm
|
||||
// createln - transmit arg+newline as first command to new XMLTerm
|
||||
//
|
||||
// entryNumber: >=0 means process only if current entry
|
||||
// <0 means process anytime
|
||||
//
|
||||
// arg1: command/pathname string (without newline)
|
||||
// arg2: alternate command line (for use in current entry only;
|
||||
// uses relative pathnames assuming current working directory)
|
||||
//
|
||||
function HandleEvent(eventObj, eventType, targetType, entryNumber,
|
||||
arg1, arg2) {
|
||||
dump("HandleEvent("+eventObj+","+eventType+","+targetType+","+
|
||||
entryNumber+","+arg1+","+arg2+")\n");
|
||||
|
||||
// Entry independent targets
|
||||
if (action === "textlink") {
|
||||
dump("textlink = "+arg1+"\n");
|
||||
Load(arg1);
|
||||
|
||||
} else if (eventType === "click") {
|
||||
if (targetType === "prompt") {
|
||||
var outputElement = document.getElementById("output"+entryNumber);
|
||||
var promptElement = document.getElementById("prompt"+entryNumber);
|
||||
//dump(promptElement.style.getPropertyValue("text-decoration"));
|
||||
|
||||
if (outputElement.style.display == "none") {
|
||||
outputElement.style.display = "block";
|
||||
promptElement.style.setProperty("text-decoration","none","");
|
||||
} else {
|
||||
outputElement.style.display = "none";
|
||||
promptElement.style.setProperty("text-decoration","underline","");
|
||||
}
|
||||
|
||||
} else if (targetType === "command") {
|
||||
var commandElement = document.getElementById(targetType+entryNumber);
|
||||
var command = commandElement.firstChild.data;
|
||||
dump("command = "+command+"\n\n");
|
||||
window.xmlterm.SendText("\025"+command+"\n", document.cookie);
|
||||
|
||||
} else {
|
||||
// Targets which may be qualified only for current entry
|
||||
|
||||
if ((entryNumber >= 0) &&
|
||||
(window.xmlterm.currentEntryNumber != entryNumber)) {
|
||||
dump("NOT CURRENT COMMAND\n");
|
||||
return (false);
|
||||
}
|
||||
|
||||
var action = targetType;
|
||||
|
||||
if (action === "exec") {
|
||||
if (window.commandMode === "window") {
|
||||
action = "createln";
|
||||
} else {
|
||||
action = "sendln";
|
||||
}
|
||||
}
|
||||
|
||||
if (action === "send") {
|
||||
dump("send = "+arg1+"\n");
|
||||
window.xmlterm.SendText(arg1, document.cookie);
|
||||
|
||||
} else if (action === "sendln") {
|
||||
|
||||
if ((Math.abs(entryNumber)+1 == window.xmlterm.currentEntryNumber) &&
|
||||
(arg2 != null)) {
|
||||
// Current command
|
||||
dump("sendln = "+arg2+"\n\n");
|
||||
window.xmlterm.SendText("\025"+arg2+"\n", document.cookie);
|
||||
} else {
|
||||
// Not current command
|
||||
dump("sendln = "+arg1+"\n\n");
|
||||
window.xmlterm.SendText("\025"+arg1+"\n", document.cookie);
|
||||
}
|
||||
|
||||
} else if (action === "createln") {
|
||||
dump("createln = "+arg1+"\n\n");
|
||||
newwin = NewXMLTerm(arg1+"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
// Set history buffer count using form entry
|
||||
function SetHistoryValue() {
|
||||
var field = document.getElementById('InputValue');
|
||||
return SetHistory(field.value);
|
||||
}
|
||||
|
||||
// Set prompt using form entry
|
||||
function SetPromptValue() {
|
||||
var field = document.getElementById('InputValue');
|
||||
return SetPrompt(field.value);
|
||||
}
|
||||
|
||||
// Usage tips
|
||||
var tips = new Array();
|
||||
tips[0] = 'Click the SetPrompt button to use a cool Mozilla prompt from dmoz.org!';
|
||||
tips[1] = '"js:SetPrompt(HTMLstring);" sets prompt to HTML string.';
|
||||
tips[2] = 'Type "js:func(arg);" to execute inline Javascript function func.';
|
||||
tips[3] = 'Inline Javascript ("js:...") can be used to produce HTML output.';
|
||||
tips[4] = 'XMLterm supports full screen commands like "vi", "emacs -nw", and "less".';
|
||||
tips[5] = 'Use "xls -i" for iconic display of directory contents.';
|
||||
tips[6] = 'Use "xcat file" to display file.';
|
||||
|
||||
// Display random usage tip
|
||||
// (should cease to operate after a few cycles;
|
||||
// need to use Prefs to keep track of that)
|
||||
function UsageTip() {
|
||||
var tipCount = tips.length;
|
||||
var ranval = Math.random();
|
||||
var tipIndex = Math.floor(ranval * tipCount);
|
||||
if (tipIndex >= tipCount) tipIndex = 0;
|
||||
|
||||
dump("xmlterm: UsageTip "+tipIndex+","+ranval+"\n");
|
||||
|
||||
var tiphead = document.getElementById('tiphead');
|
||||
var tipdata = document.getElementById('tipdata');
|
||||
tiphead.firstChild.data = "Tip:";
|
||||
tipdata.firstChild.data = tips[tipIndex];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Display more tips
|
||||
function MoreTips() {
|
||||
dump("xmlterm: MoreTips\n");
|
||||
|
||||
var moreTipsElement = document.getElementById('moretips');
|
||||
var moreTipsFrame = document.getElementById('moretipsframe');
|
||||
|
||||
if (moreTipsFrame) {
|
||||
// Remove more tips iframe
|
||||
document.body.removeChild(moreTipsFrame);
|
||||
moreTipsElement.firstChild.data = "More tips/news";
|
||||
} else {
|
||||
// Create more tips iframe
|
||||
moreTipsFrame = document.createElement("iframe");
|
||||
moreTipsFrame.setAttribute('ID', 'moretipsframe');
|
||||
moreTipsFrame.setAttribute('CLASS', 'moretipsframe');
|
||||
moreTipsFrame.setAttribute('WIDTH', '100%');
|
||||
moreTipsFrame.setAttribute('SRC', 'http://xmlterm.org/newstips.html');
|
||||
|
||||
dump(moreTipsFrame);
|
||||
|
||||
// Insert more tips iframe in body
|
||||
var sessionElement = document.getElementById('session');
|
||||
document.body.insertBefore(moreTipsFrame, sessionElement);
|
||||
moreTipsElement.firstChild.data = "Hide tips/news";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// onLoad event handler
|
||||
function LoadHandler() {
|
||||
dump("xmlterm: LoadHandler ... "+window.xmlterm+"\n");
|
||||
|
||||
//UsageTip();
|
||||
|
||||
if (window.xmlterm) {
|
||||
// XMLTerm already initialized
|
||||
return (false);
|
||||
}
|
||||
|
||||
dump("LoadHandler: WINDOW.ARGUMENTS="+window.arguments+"\n");
|
||||
|
||||
dump("Trying to make an XMLTerm Shell through the component manager...\n");
|
||||
|
||||
var xmltshell = Components.classes["component://mozilla/xmlterm/xmltermshell"].createInstance();
|
||||
|
||||
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;
|
||||
|
||||
// Content window same as current window
|
||||
var contentWindow = window;
|
||||
|
||||
// Initialize XMLTerm shell in content window with argvals
|
||||
window.xmlterm.Init(contentWindow, "", "");
|
||||
|
||||
//dump("LoadHandler:"+document.cookie+"\n");
|
||||
|
||||
dump("contentWindow="+contentWindow+"\n");
|
||||
dump("document="+document+"\n");
|
||||
dump("documentElement="+document.documentElement+"\n");
|
||||
|
||||
// Handle resize events
|
||||
//contentWindow.addEventListener("onresize", Resize);
|
||||
contentWindow.onresize = Resize;
|
||||
|
||||
// Set focus to appropriate frame
|
||||
contentWindow.focus();
|
||||
|
||||
//contentWindow.xmlterm = xmlterm;
|
||||
|
||||
//dump(contentWindow.xmlterm);
|
||||
|
||||
// The following code is for testing IFRAMEs only
|
||||
dump("[Main] "+window+"\n");
|
||||
dump(window.screenX+", "+window.screenY+"\n");
|
||||
dump(window.scrollX+", "+window.scrollY+"\n");
|
||||
dump(window.pageXOffset+", "+window.pageYOffset+"\n");
|
||||
|
||||
dump("IFRAME checks\n");
|
||||
var iframe = document.getElementById('iframe1');
|
||||
|
||||
dump("iframe="+iframe+"\n");
|
||||
|
||||
frames=document.frames;
|
||||
dump("frames="+frames+"\n");
|
||||
dump("frames.length="+frames.length+"\n");
|
||||
|
||||
framewin = frames[0];
|
||||
|
||||
dump("framewin="+framewin+"\n");
|
||||
dump("framewin.document="+framewin.document+"\n");
|
||||
|
||||
dump(framewin.screenX+", "+framewin.screenY+"\n");
|
||||
dump(framewin.scrollX+", "+framewin.scrollY+"\n");
|
||||
dump(framewin.pageXOffset+", "+framewin.pageYOffset+"\n");
|
||||
|
||||
var body = framewin.document.getElementsByTagName("BODY")[0];
|
||||
dump("body="+body+"\n");
|
||||
|
||||
var height= body.scrollHeight;
|
||||
dump("height="+height+"\n");
|
||||
|
||||
// iframe.height = 800;
|
||||
// iframe.width = 700;
|
||||
|
||||
// framewin.sizeToContent();
|
||||
|
||||
framewin.xmltshell = xmltshell;
|
||||
dump(framewin.xmltshell+"\n");
|
||||
|
||||
dump("xmlterm: LoadHandler completed\n");
|
||||
return (false);
|
||||
}
|
||||
|
||||
</SCRIPT>
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY onLoad="return LoadHandler();">
|
||||
|
||||
<HR>
|
||||
<P>
|
||||
<!--
|
||||
<IFRAME NAME="iframet" SRC="chrome://xmlterm/content/xmltblank.html"
|
||||
FRAMEBORDER=0>
|
||||
</IFRAME>
|
||||
-->
|
||||
|
||||
<DIV CLASS="session" ID="session">
|
||||
</DIV>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
@@ -36,6 +36,6 @@
|
||||
html:src="about:blank" flex="100%"/>
|
||||
|
||||
<html:iframe id="content-frame" type="content" html:name="content"
|
||||
html:src="chrome://xmlterm/content/xmlterm.html" flex="100%"/>
|
||||
html:src="chrome://xmlterm/content/xmlterm2.html" flex="100%"/>
|
||||
|
||||
</window>
|
||||
|
||||
@@ -14,11 +14,16 @@ 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 }
|
||||
PRE.row { margin: 0; padding-top: 0; padding-bottom: 0 }
|
||||
SPAN.row { margin: 0; padding-top: 0; padding-bottom: 0 }
|
||||
SPAN.boldstyle { font-weight: bold; margin: 0; padding-top: 0; padding-bottom: 0 }
|
||||
SPAN.underlinestyle { text-decoration: underline; margin: 0; padding-top: 0; padding-bottom: 0 }
|
||||
SPAN.blinkstyle { font-weight: bold; margin: 0; padding-top: 0; padding-bottom: 0 }
|
||||
SPAN.inversestyle { font-weight: bold; margin: 0; padding-top: 0; padding-bottom: 0 }
|
||||
|
||||
/* Tips */
|
||||
SPAN.tips { font-family: sans-serif }
|
||||
SPAN.tiphead { font-family: sans-serif; font-weight: bold }
|
||||
SPAN.tipdata { font-family: sans-serif }
|
||||
SPAN.moretips { font-family: sans-serif; color: blue; cursor: hand;
|
||||
font-weight: bold; text-decoration: underline };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user