fjsc: line endings.

windows-high-dpi
Doug Coleman 2018-03-13 14:50:23 -05:00
parent 4785479ea0
commit 81ff054785
4 changed files with 1040 additions and 1040 deletions

View File

@ -1,356 +1,356 @@
<HTML>
<HEAD>
<TITLE>mass:werk termlib faq</TITLE>
<STYLE TYPE="text/css">
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #cccccc;
}
.lh13 {
line-height: 13px;
}
.lh15 {
line-height: 15px;
}
pre {
font-family: courier,fixed,swiss,sans-serif;
color: #ccffaa;
font-size: 12px;
line-height: 15px;
}
.prop {
font-family: courier,fixed,swiss,sans-serif;
color: #bbee99;
font-size: 12px;
line-height: 15px;
}
h1 {
font-family: courier,fixed,swiss,sans-serif;
font-size: 16px;
color: #cccccc;
}
b.quest {
font-family: courier,fixed,swiss,sans-serif;
font-size: 14px;
font-weight: bold;
color: #bbee99;
}
a,a:link,a:visited {
text-decoration: none;
color: #77dd11;
}
a:hover {
text-decoration: underline;
color: #77dd11;
}
a:active {
text-decoration: underline;
color: #dddddd;
}
@media print {
body { background-color: #ffffff; }
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #000000;
}
.lh13 {
line-height: 13px;
}
.lh15 {
line-height: 15px;
}
pre,.prop {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #000000;
line-height: 15px;
}
h1 {
font-family: courier,fixed,swiss,sans-serif;
font-size: 16px;
color: #000000;
}
b.quest {
font-family: courier,fixed,swiss,sans-serif;
font-size: 14px;
font-weight: bold;
color: #000000;
}
a,a:link,a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: underline;
color: #000000;
}
a:active {
text-decoration: underline;
color: #000000;
}
}
</STYLE>
</HEAD>
<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"
TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"><A NAME="top"></A>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">
<TR>
<TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>
<TD>|</TD>
<TD NOWRAP>faq</TD>
<TD>|</TD>
<TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" WIDTH="700" ALIGN="center">
<TR><TD>
<H1>frequently asked questions</H1>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
<UL>
<LI CLASS="lh15"><A HREF="#chrome">Can I add chrome to the terminal? (e.g. a window header, a close box)</A></LI>
<LI CLASS="lh15"><A HREF="#embed">How can I embed a terminal relative to my HTML layout?</A></LI>
<LI CLASS="lh15"><A HREF="#syntax">I pasted your sample code and just got an error. - ???</A></LI>
<LI CLASS="lh15"><A HREF="#keyboard">I can't get any input, but I don't get any erros too.</A></LI>
<LI CLASS="lh15"><A HREF="#keylock">How can I temporary disable the keyboard handlers?</A></LI>
<LI CLASS="lh15"><A HREF="#linesranges">How can I set the cusor to the start / the end of the command line?</A></LI>
<LI CLASS="lh15"><A HREF="#historyunique">How can I limit the command history to unique entries only?</A></LI>
<LI CLASS="lh15"><A HREF="#rebuild">How can I change my color theme on the fly?</A></LI>
<LI CLASS="lh15"><A HREF="#connect">How can I connect to a server?</A></LI>
</UL>
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="chrome"></A>
&nbsp;<BR>
<B CLASS="quest">Can I add chrome to the terminal? (e.g. a window header, a close box)</B><BR><BR>
Not by the means of the Terminal object's interface (since there are way too many things that you may possibly want to add).<BR>
The Terminal object allows you to specify the background color, the frame color, the frame's width and the font class used. If you want to add more chrome, you must align this in a separate division element.<BR><BR>
To calculate the dimensions of the terminal use this formula:<BR><BR>
width:&nbsp; 2 * frameWidth + conf.cols * &lt;width of &nbsp;&gt; + 2 * 2px padding (left and right)<BR>
height: 2 * frameWidth + conf.rows * conf.rowHeight + 2 * 2px padding (top and bottom).<BR><BR>
Or you could get the empirical values for width and height by calling a terminal's `<SPAN CLASS="prop">getDimensions()</SPAN>' method, once the terminal is open. (see documentation in &quot;readme.txt&quot;).<BR><BR>
Finnally, you could obviously embed the terminal's division element in your custom chrome layout (see below). [This will not be compatible to Netscape 4.]<BR><BR>
p.e.:<PRE>
&lt;div id=&quot;myTerminal1&quot; style=&quot;position:absolute; top:100px; left:100px;&quot;&gt;
&lt;table class=&quot;termChrome&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&quot;termTitle&quot;&gt;terminal 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;termBody&quot;&gt;&lt;div id=&quot;termDiv1&quot; style=&quot;position:relative&quot;&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
// get a terminal for this
var term1 = new Terminal(
{
x: 0,
y: 0,
id: 1,
termDiv: &quot;termDiv1&quot;,
handler: myTermHandler
}
);
term1.open();
// and this is how to move the chrome and the embedded terminal
TermGlobals.setElementXY( &quot;myTerminal1&quot;, 200, 80 );
</PRE>
To keep track of the instance for any widgets use the terminal's `id' property. (You must set this in the configuration object to a unique value for this purpose.)<BR><BR>
For a demonstration see the <A HREF="chrome_sample.html">Chrome Sample Page</A>.
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="embed"></A>
&nbsp;<BR>
<B CLASS="quest">How can I embed a terminal relative to my HTML layout?</B><BR><BR>
Define your devision element with attribute &quot;position&quot; set to &quot;relative&quot; and place this inside your layout. Call &quot;new Terminal()&quot; with config-values { x: 0, y: 0 } to leave it at its relative origin.
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="syntax"></A>
&nbsp;<BR>
<B CLASS="quest">I pasted your sample code and just got an error. - ???</B><BR><BR>
The short examples are kept arbitrarily simple to show the syntax.<BR>
Make sure that your divison element(s) is/are rendered by the browser before `Terminal.open()' is called.<BR><BR>
Does not work:
<PRE> &lt;head&gt;
&lt;script&gt;
var term = new Terminal();
term.open();
&lt;/script&gt;
&lt;/head&gt;
</PRE>
Does work:
<PRE> &lt;head&gt;
&lt;script&gt;
var term;
function termOpen() {
// to be called from outside after compile time
term = new Terminal();
term.open();
}
&lt;/script&gt;
&lt;/head&gt;
</PRE>
c.f. &quot;readme.txt&quot;<BR>
(Opening a terminal by clicking a link implies also that the page has currently focus.)<BR><BR>
With v.1.01 and higher this doesn't cause an error any more.<BR>`Terminal.prototype.open()' now returns a value for success.
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="keyboard"></A>
&nbsp;<BR>
<B CLASS="quest">I can't get any input, but I don't get any erros too.</B><BR><BR>
The Terminal object's functionality relies on the browsers ability to generate and handle keyboard events.<BR>
Sadly some browsers lack a full implementation of the event model. (e.g. Konquerer [khtml] and early versions of Apple Safari, which is a descendant of khtml.)
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="keylock"></A>
&nbsp;<BR>
<B CLASS="quest">How can I temporary disable the keyboard handlers?</B><BR>
<SPAN CLASS="prop">(The terminal is blocking my HTML form fields, etc.)</SPAN><BR><BR>
With version 1.03 there's a global property `<SPAN CLASS="prop">TermGlobals.keylock</SPAN>'. Set this to `true' to disable the keyboard handlers without altering any other state. Reset it to `false' to continue with your terminal session(s).
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="linesranges"></A>
&nbsp;<BR>
<B CLASS="quest">How can I set the cusor to the start / the end of the command line?</B><BR><BR>
In case you need to implement a shortcut (like ^A of some UN*X-shells) to jump to the beginning or the end of the current input line, there are two private instance methods you could utilize:<BR><BR>
`<SPAN CLASS="prop">_getLineEnd(&lt;row&gt;, &lt;col&gt;)</SPAN>' returns an array [&lt;row&gt;, &lt;col&gt;] with the position of the last character in the logical input line with ASCII value &gt;= 32 (0x20).<BR><BR>
`<SPAN CLASS="prop">_getLineStart(&lt;row&gt;, &lt;col&gt;)</SPAN>' returns an array [&lt;row&gt;, &lt;col&gt;] with the position of the first character in the logical input line with ASCII value &gt;= 32 (0x20).<BR><BR>
Both take a row and a column of a cursor position as arguments.<BR><BR>
p.e.:
<PRE>
// jump to the start of the input line
myCtrlHandler() {
// catch ^A and jump to start of the line
if (this.inputChar == 1) {
var firstChar = this._getLineStart(this.r, this.c);
this.cursorSet(firstChar[0], firstChar[1]);
}
}</PRE>
(Keep in mind that this is not exactly a good example, since some browser actually don't issue a keyboard event for
&quot;^A&quot;. And other browsers, which do catch such codes, are not very reliable in that.)
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="historyunique"></A>
&nbsp;<BR>
<B CLASS="quest">How can I limit the command history to unique entries only?</B><BR>
<SPAN CLASS="prop">(My application effords commands to be commonly repeated.)</SPAN><BR><BR>
With version 1.05 there is a new configuration and control flag `<SPAN CLASS="prop">historyUnique</SPAN>'. All you need is setting this to `true' in your terminal's configuration object.
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="rebuild"></A>
&nbsp;<BR>
<B CLASS="quest">How can I change my color theme on the fly?</B><BR><BR>
With version 1.07 there is a new method `<SPAN CLASS="prop">Terminal.rebuild()</SPAN>'.<BR>
This method updates the GUI to current config settings while preserving all other state.<BR><BR>
p.e.:
<PRE>
// change color settings on the fly
// here: set bgColor to white and font style to class &quot;termWhite&quot;
// method rebuild() updates the GUI without side effects
// assume var term holds a referene to a Terminal object already active
term.conf.bgColor = '#ffffff';
term.conf.fontClass = 'termWhite';
term.rebuild();</PRE>
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="connect"></A>
&nbsp;<BR>
<B CLASS="quest">How can I connect to a server?</B><BR><BR>
The Terminal object only provides an interface to handle console input and output.<BR>
External connections have to be handled outside the Terminal object. You could use the XMLHttpRequest-Object (and use a communication model like AJAX or JSON) or connect via a frame or iframe element to a foreign host.<BR><BR>
Handling connections is considered to be out of the realm of the &quot;termlib.js&quot; library.<BR>
The code you need is in fact quite simple:
<PRE>
function connectToHost(url) {
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
request = new ActiveXObject('Microsoft.XMLHTTP');
}
if (request) {
request.onreadystatechange = requestChangeHandler;
request.open('GET', url);
request.send('');
}
else {
// XMLHttpRequest not implemented
}
}
function requestChangeHandler() {
if (request.readyState == 4) {
// readyState 4: complete; now test for server's response status
if (request.status == 200) {
// response in request.responseText or request.responseXML if XML-code
// if it's JS-code we could get this by eval(request.responseText)
// by this we could import whole functions to be used via the terminal
}
else {
// connection error
// status code and message in request.status and request.statusText
}
}
}
</PRE>
You should use this only together with a timer (window.setTimeout()) to handle connection timeouts.<BR>
Additionally you would need some syntax to authenticate and tell the server what you want.<BR>
For this purpose you could use the following methods of the XMLHttpRequest object:<BR><BR>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="3">
<TR VALIGN="top"><TD NOWRAP CLASS="prop">setRequestHeader(&quot;<I>headerLabel</I>&quot;, &quot;<I>value</I>&quot;)</TD><TD>set a HTTP header to be sent to the server</TD></TR>
<TR VALIGN="top"><TD NOWRAP CLASS="prop">getResponseHeader(&quot;<I>headerLabel</I>&quot;)</TD><TD>get a HTTP header sent from the server</TD></TR>
<TR VALIGN="top"><TD NOWRAP CLASS="prop">open(<I>method</I>, &quot;<I>url</I>&quot; [, <I>asyncFlag</I> [,<BR>&nbsp; &quot;<I>userid</I>&quot; [, &quot;<I>password</I>&quot;]]])</TD><TD>assign the destination properties to the request.<BR>be aware that userid and password are not encrypted!</TD></TR>
<TR VALIGN="top"><TD NOWRAP CLASS="prop">send(<I>content</I>)</TD><TD>transmit a message body (post-string or DOM object)</TD></TR>
<TR VALIGN="top"><TD NOWRAP CLASS="prop">abort()</TD><TD>use this to stop a pending connection</TD></TR>
</TABLE>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
Norbert Landsteiner - August 2005<BR>
<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
<A HREF="#top">&gt; top of page</A>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;
</TD></TR>
</TABLE>
<DIV ID="termDiv" STYLE="position:absolute; top:20px; left:100px;"></DIV>
</BODY>
<HTML>
<HEAD>
<TITLE>mass:werk termlib faq</TITLE>
<STYLE TYPE="text/css">
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #cccccc;
}
.lh13 {
line-height: 13px;
}
.lh15 {
line-height: 15px;
}
pre {
font-family: courier,fixed,swiss,sans-serif;
color: #ccffaa;
font-size: 12px;
line-height: 15px;
}
.prop {
font-family: courier,fixed,swiss,sans-serif;
color: #bbee99;
font-size: 12px;
line-height: 15px;
}
h1 {
font-family: courier,fixed,swiss,sans-serif;
font-size: 16px;
color: #cccccc;
}
b.quest {
font-family: courier,fixed,swiss,sans-serif;
font-size: 14px;
font-weight: bold;
color: #bbee99;
}
a,a:link,a:visited {
text-decoration: none;
color: #77dd11;
}
a:hover {
text-decoration: underline;
color: #77dd11;
}
a:active {
text-decoration: underline;
color: #dddddd;
}
@media print {
body { background-color: #ffffff; }
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #000000;
}
.lh13 {
line-height: 13px;
}
.lh15 {
line-height: 15px;
}
pre,.prop {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #000000;
line-height: 15px;
}
h1 {
font-family: courier,fixed,swiss,sans-serif;
font-size: 16px;
color: #000000;
}
b.quest {
font-family: courier,fixed,swiss,sans-serif;
font-size: 14px;
font-weight: bold;
color: #000000;
}
a,a:link,a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: underline;
color: #000000;
}
a:active {
text-decoration: underline;
color: #000000;
}
}
</STYLE>
</HEAD>
<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"
TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"><A NAME="top"></A>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">
<TR>
<TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>
<TD>|</TD>
<TD NOWRAP>faq</TD>
<TD>|</TD>
<TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" WIDTH="700" ALIGN="center">
<TR><TD>
<H1>frequently asked questions</H1>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
<UL>
<LI CLASS="lh15"><A HREF="#chrome">Can I add chrome to the terminal? (e.g. a window header, a close box)</A></LI>
<LI CLASS="lh15"><A HREF="#embed">How can I embed a terminal relative to my HTML layout?</A></LI>
<LI CLASS="lh15"><A HREF="#syntax">I pasted your sample code and just got an error. - ???</A></LI>
<LI CLASS="lh15"><A HREF="#keyboard">I can't get any input, but I don't get any erros too.</A></LI>
<LI CLASS="lh15"><A HREF="#keylock">How can I temporary disable the keyboard handlers?</A></LI>
<LI CLASS="lh15"><A HREF="#linesranges">How can I set the cusor to the start / the end of the command line?</A></LI>
<LI CLASS="lh15"><A HREF="#historyunique">How can I limit the command history to unique entries only?</A></LI>
<LI CLASS="lh15"><A HREF="#rebuild">How can I change my color theme on the fly?</A></LI>
<LI CLASS="lh15"><A HREF="#connect">How can I connect to a server?</A></LI>
</UL>
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="chrome"></A>
&nbsp;<BR>
<B CLASS="quest">Can I add chrome to the terminal? (e.g. a window header, a close box)</B><BR><BR>
Not by the means of the Terminal object's interface (since there are way too many things that you may possibly want to add).<BR>
The Terminal object allows you to specify the background color, the frame color, the frame's width and the font class used. If you want to add more chrome, you must align this in a separate division element.<BR><BR>
To calculate the dimensions of the terminal use this formula:<BR><BR>
width:&nbsp; 2 * frameWidth + conf.cols * &lt;width of &nbsp;&gt; + 2 * 2px padding (left and right)<BR>
height: 2 * frameWidth + conf.rows * conf.rowHeight + 2 * 2px padding (top and bottom).<BR><BR>
Or you could get the empirical values for width and height by calling a terminal's `<SPAN CLASS="prop">getDimensions()</SPAN>' method, once the terminal is open. (see documentation in &quot;readme.txt&quot;).<BR><BR>
Finnally, you could obviously embed the terminal's division element in your custom chrome layout (see below). [This will not be compatible to Netscape 4.]<BR><BR>
p.e.:<PRE>
&lt;div id=&quot;myTerminal1&quot; style=&quot;position:absolute; top:100px; left:100px;&quot;&gt;
&lt;table class=&quot;termChrome&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&quot;termTitle&quot;&gt;terminal 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;termBody&quot;&gt;&lt;div id=&quot;termDiv1&quot; style=&quot;position:relative&quot;&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
// get a terminal for this
var term1 = new Terminal(
{
x: 0,
y: 0,
id: 1,
termDiv: &quot;termDiv1&quot;,
handler: myTermHandler
}
);
term1.open();
// and this is how to move the chrome and the embedded terminal
TermGlobals.setElementXY( &quot;myTerminal1&quot;, 200, 80 );
</PRE>
To keep track of the instance for any widgets use the terminal's `id' property. (You must set this in the configuration object to a unique value for this purpose.)<BR><BR>
For a demonstration see the <A HREF="chrome_sample.html">Chrome Sample Page</A>.
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="embed"></A>
&nbsp;<BR>
<B CLASS="quest">How can I embed a terminal relative to my HTML layout?</B><BR><BR>
Define your devision element with attribute &quot;position&quot; set to &quot;relative&quot; and place this inside your layout. Call &quot;new Terminal()&quot; with config-values { x: 0, y: 0 } to leave it at its relative origin.
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="syntax"></A>
&nbsp;<BR>
<B CLASS="quest">I pasted your sample code and just got an error. - ???</B><BR><BR>
The short examples are kept arbitrarily simple to show the syntax.<BR>
Make sure that your divison element(s) is/are rendered by the browser before `Terminal.open()' is called.<BR><BR>
Does not work:
<PRE> &lt;head&gt;
&lt;script&gt;
var term = new Terminal();
term.open();
&lt;/script&gt;
&lt;/head&gt;
</PRE>
Does work:
<PRE> &lt;head&gt;
&lt;script&gt;
var term;
function termOpen() {
// to be called from outside after compile time
term = new Terminal();
term.open();
}
&lt;/script&gt;
&lt;/head&gt;
</PRE>
c.f. &quot;readme.txt&quot;<BR>
(Opening a terminal by clicking a link implies also that the page has currently focus.)<BR><BR>
With v.1.01 and higher this doesn't cause an error any more.<BR>`Terminal.prototype.open()' now returns a value for success.
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="keyboard"></A>
&nbsp;<BR>
<B CLASS="quest">I can't get any input, but I don't get any erros too.</B><BR><BR>
The Terminal object's functionality relies on the browsers ability to generate and handle keyboard events.<BR>
Sadly some browsers lack a full implementation of the event model. (e.g. Konquerer [khtml] and early versions of Apple Safari, which is a descendant of khtml.)
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="keylock"></A>
&nbsp;<BR>
<B CLASS="quest">How can I temporary disable the keyboard handlers?</B><BR>
<SPAN CLASS="prop">(The terminal is blocking my HTML form fields, etc.)</SPAN><BR><BR>
With version 1.03 there's a global property `<SPAN CLASS="prop">TermGlobals.keylock</SPAN>'. Set this to `true' to disable the keyboard handlers without altering any other state. Reset it to `false' to continue with your terminal session(s).
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="linesranges"></A>
&nbsp;<BR>
<B CLASS="quest">How can I set the cusor to the start / the end of the command line?</B><BR><BR>
In case you need to implement a shortcut (like ^A of some UN*X-shells) to jump to the beginning or the end of the current input line, there are two private instance methods you could utilize:<BR><BR>
`<SPAN CLASS="prop">_getLineEnd(&lt;row&gt;, &lt;col&gt;)</SPAN>' returns an array [&lt;row&gt;, &lt;col&gt;] with the position of the last character in the logical input line with ASCII value &gt;= 32 (0x20).<BR><BR>
`<SPAN CLASS="prop">_getLineStart(&lt;row&gt;, &lt;col&gt;)</SPAN>' returns an array [&lt;row&gt;, &lt;col&gt;] with the position of the first character in the logical input line with ASCII value &gt;= 32 (0x20).<BR><BR>
Both take a row and a column of a cursor position as arguments.<BR><BR>
p.e.:
<PRE>
// jump to the start of the input line
myCtrlHandler() {
// catch ^A and jump to start of the line
if (this.inputChar == 1) {
var firstChar = this._getLineStart(this.r, this.c);
this.cursorSet(firstChar[0], firstChar[1]);
}
}</PRE>
(Keep in mind that this is not exactly a good example, since some browser actually don't issue a keyboard event for
&quot;^A&quot;. And other browsers, which do catch such codes, are not very reliable in that.)
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="historyunique"></A>
&nbsp;<BR>
<B CLASS="quest">How can I limit the command history to unique entries only?</B><BR>
<SPAN CLASS="prop">(My application effords commands to be commonly repeated.)</SPAN><BR><BR>
With version 1.05 there is a new configuration and control flag `<SPAN CLASS="prop">historyUnique</SPAN>'. All you need is setting this to `true' in your terminal's configuration object.
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="rebuild"></A>
&nbsp;<BR>
<B CLASS="quest">How can I change my color theme on the fly?</B><BR><BR>
With version 1.07 there is a new method `<SPAN CLASS="prop">Terminal.rebuild()</SPAN>'.<BR>
This method updates the GUI to current config settings while preserving all other state.<BR><BR>
p.e.:
<PRE>
// change color settings on the fly
// here: set bgColor to white and font style to class &quot;termWhite&quot;
// method rebuild() updates the GUI without side effects
// assume var term holds a referene to a Terminal object already active
term.conf.bgColor = '#ffffff';
term.conf.fontClass = 'termWhite';
term.rebuild();</PRE>
</TD></TR>
<TR><TD CLASS="lh13"><A NAME="connect"></A>
&nbsp;<BR>
<B CLASS="quest">How can I connect to a server?</B><BR><BR>
The Terminal object only provides an interface to handle console input and output.<BR>
External connections have to be handled outside the Terminal object. You could use the XMLHttpRequest-Object (and use a communication model like AJAX or JSON) or connect via a frame or iframe element to a foreign host.<BR><BR>
Handling connections is considered to be out of the realm of the &quot;termlib.js&quot; library.<BR>
The code you need is in fact quite simple:
<PRE>
function connectToHost(url) {
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
request = new ActiveXObject('Microsoft.XMLHTTP');
}
if (request) {
request.onreadystatechange = requestChangeHandler;
request.open('GET', url);
request.send('');
}
else {
// XMLHttpRequest not implemented
}
}
function requestChangeHandler() {
if (request.readyState == 4) {
// readyState 4: complete; now test for server's response status
if (request.status == 200) {
// response in request.responseText or request.responseXML if XML-code
// if it's JS-code we could get this by eval(request.responseText)
// by this we could import whole functions to be used via the terminal
}
else {
// connection error
// status code and message in request.status and request.statusText
}
}
}
</PRE>
You should use this only together with a timer (window.setTimeout()) to handle connection timeouts.<BR>
Additionally you would need some syntax to authenticate and tell the server what you want.<BR>
For this purpose you could use the following methods of the XMLHttpRequest object:<BR><BR>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="3">
<TR VALIGN="top"><TD NOWRAP CLASS="prop">setRequestHeader(&quot;<I>headerLabel</I>&quot;, &quot;<I>value</I>&quot;)</TD><TD>set a HTTP header to be sent to the server</TD></TR>
<TR VALIGN="top"><TD NOWRAP CLASS="prop">getResponseHeader(&quot;<I>headerLabel</I>&quot;)</TD><TD>get a HTTP header sent from the server</TD></TR>
<TR VALIGN="top"><TD NOWRAP CLASS="prop">open(<I>method</I>, &quot;<I>url</I>&quot; [, <I>asyncFlag</I> [,<BR>&nbsp; &quot;<I>userid</I>&quot; [, &quot;<I>password</I>&quot;]]])</TD><TD>assign the destination properties to the request.<BR>be aware that userid and password are not encrypted!</TD></TR>
<TR VALIGN="top"><TD NOWRAP CLASS="prop">send(<I>content</I>)</TD><TD>transmit a message body (post-string or DOM object)</TD></TR>
<TR VALIGN="top"><TD NOWRAP CLASS="prop">abort()</TD><TD>use this to stop a pending connection</TD></TR>
</TABLE>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
Norbert Landsteiner - August 2005<BR>
<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
<A HREF="#top">&gt; top of page</A>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;
</TD></TR>
</TABLE>
<DIV ID="termDiv" STYLE="position:absolute; top:20px; left:100px;"></DIV>
</BODY>
</HTML>

View File

@ -1,207 +1,207 @@
<HTML>
<HEAD>
<TITLE>mass:werk termlib</TITLE>
<STYLE TYPE="text/css">
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #cccccc;
}
.lh13 {
line-height: 13px;
}
.lh15 {
line-height: 15px;
}
pre {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #ccffaa;
line-height: 15px;
}
.prop {
font-family: courier,fixed,swiss,sans-serif;
color: #bbee99;
font-size: 12px;
line-height: 15px;
}
h1 {
font-family: courier,fixed,swiss,sans-serif;
font-size: 16px;
color: #cccccc;
}
a,a:link,a:visited {
text-decoration: none;
color: #77dd11;
}
a:hover {
text-decoration: underline;
color: #77dd11;
}
a:active {
text-decoration: underline;
color: #dddddd;
}
@media print {
body { background-color: #ffffff; }
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #000000;
}
.lh13 {
line-height: 13px;
}
.lh15 {
line-height: 15px;
}
pre,.prop {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #000000;
line-height: 15px;
}
h1 {
font-family: courier,fixed,swiss,sans-serif;
font-size: 16px;
color: #000000;
}
a,a:link,a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: underline;
color: #000000;
}
a:active {
text-decoration: underline;
color: #000000;
}
}
</STYLE>
</HEAD>
<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"
TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"><A NAME="top"></A>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">
<TR>
<TD NOWRAP>termlib.js home</TD>
<TD>|</TD>
<TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="faq.html">faq</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" WIDTH="700" ALIGN="center">
<TR><TD>
<H1>mass:werk termlib.js</H1>
</TD></TR>
<TR><TD CLASS="lh13">
The JavaScript library &quot;termlib.js&quot; provides a `Terminal' object, which
facillitates a simple and object oriented approach to generate and control a
terminal-like interface for web services.<BR><BR>
"termlib.js" features direct keyboard input and powerful output methods
for multiple and simultanious instances of the `Terminal' object.<BR><BR>
The library was written with the aim of simple usage and a maximum of compatibility
with minimal foot print in the global namespace.<BR><BR><BR>
A short example:<BR>
<PRE>
var term = new Terminal( {handler: termHandler} );
term.open();
function termHandler() {
this.newLine();
var line = this.lineBuffer;
if (line != &quot;&quot;) {
this.write(&quot;You typed: &quot;+line);
}
this.prompt();
}
</PRE>
</TD></TR>
<TR><TD CLASS="lh13">
<B>License</B><BR><BR>
This JavaScript-library is <U>free for private and academic use</U>.
Please include a readable copyright statement and a backlink to &lt;http://www.masswerk.at&gt; in the
web page. The library should always be accompanied by the &quot;readme.txt&quot; and the sample HTML-documents.<BR><BR>
The term &quot;private use&quot; includes any personal or non-commercial use, which is not related
to commercial activites, but excludes intranet, extranet and/or public net applications
that are related to any kind of commercial or profit oriented activity.<BR><BR>
For commercial use see &lt;<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>&gt; for contact information.
</TD></TR>
<TR><TD CLASS="lh13">
<B>Distribution</B><BR><BR>
This JavaScript-library may be distributed freely as long it is distributed together with the &quot;readme.txt&quot; and the sample HTML-documents and this document.<BR><BR>
Any changes to the library should be commented and be documented in the readme-file.<BR>
Any changes must be reflected in the `Terminal.version' string as &quot;Version.Subversion&nbsp;(compatibility)&quot;.
</TD></TR>
<TR><TD CLASS="lh13">
<B>Disclaimer</B><BR><BR>
This software is distributed AS IS and in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. The entire risk as to the quality and performance of the product is borne by the
user. No use of the product is authorized hereunder except under this disclaimer.
</TD></TR>
<TR><TD CLASS="lh13">
<B>History</B><BR><BR>
This library evolved from the terminal script &quot;TermApp&quot; ((c) N. Landsteiner 2003) and is in its
current form a down scaled spinn-off of the &quot;JS/UIX&quot; project. (JS/UIX is not a free&nbsp;software by now.)
c.f.: &lt;<A HREF="http://www.masswerk.at/jsuix/" TARGET="_blank">http://www.masswerk.at/jsuix</A>&gt;<BR><BR>
For version history: see the <A HREF="readme.txt">readme.txt</A>.
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
<B>Download</B><BR><BR>
Be sure to have read the license information and the disclamer and that you are willing to respect copyrights.<BR><BR>
<SPAN CLASS="prop">Download:</SPAN> <A HREF="termlib.zip">termlib.zip</A> (~ 40 KB, incl. docs)<BR><BR>
Current version is &quot;1.07 (original)&quot;.<BR>
The files are now provided with line breaks in format &lt;CRLF&gt;.<BR>
&nbsp;
</TD></TR>
<TR><TD CLASS="lh13">
<B>Author</B><BR><BR>
&copy; Norbert Landsteiner 2003-2005<BR>
mass:werk &#150; media environments<BR>
<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
Author's note:<BR>
Please do not contact me on questions of simple usage. There is an extensive documentation (readme.txt) including plenty of sample code that should provide all information you need.
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
<A HREF="#top">&gt; top of page</A>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;
</TD></TR>
</TABLE>
<DIV ID="termDiv" STYLE="position:absolute; top:20px; left:100px;"></DIV>
</BODY>
<HTML>
<HEAD>
<TITLE>mass:werk termlib</TITLE>
<STYLE TYPE="text/css">
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #cccccc;
}
.lh13 {
line-height: 13px;
}
.lh15 {
line-height: 15px;
}
pre {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #ccffaa;
line-height: 15px;
}
.prop {
font-family: courier,fixed,swiss,sans-serif;
color: #bbee99;
font-size: 12px;
line-height: 15px;
}
h1 {
font-family: courier,fixed,swiss,sans-serif;
font-size: 16px;
color: #cccccc;
}
a,a:link,a:visited {
text-decoration: none;
color: #77dd11;
}
a:hover {
text-decoration: underline;
color: #77dd11;
}
a:active {
text-decoration: underline;
color: #dddddd;
}
@media print {
body { background-color: #ffffff; }
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #000000;
}
.lh13 {
line-height: 13px;
}
.lh15 {
line-height: 15px;
}
pre,.prop {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #000000;
line-height: 15px;
}
h1 {
font-family: courier,fixed,swiss,sans-serif;
font-size: 16px;
color: #000000;
}
a,a:link,a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: underline;
color: #000000;
}
a:active {
text-decoration: underline;
color: #000000;
}
}
</STYLE>
</HEAD>
<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"
TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"><A NAME="top"></A>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">
<TR>
<TD NOWRAP>termlib.js home</TD>
<TD>|</TD>
<TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="faq.html">faq</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" WIDTH="700" ALIGN="center">
<TR><TD>
<H1>mass:werk termlib.js</H1>
</TD></TR>
<TR><TD CLASS="lh13">
The JavaScript library &quot;termlib.js&quot; provides a `Terminal' object, which
facillitates a simple and object oriented approach to generate and control a
terminal-like interface for web services.<BR><BR>
"termlib.js" features direct keyboard input and powerful output methods
for multiple and simultanious instances of the `Terminal' object.<BR><BR>
The library was written with the aim of simple usage and a maximum of compatibility
with minimal foot print in the global namespace.<BR><BR><BR>
A short example:<BR>
<PRE>
var term = new Terminal( {handler: termHandler} );
term.open();
function termHandler() {
this.newLine();
var line = this.lineBuffer;
if (line != &quot;&quot;) {
this.write(&quot;You typed: &quot;+line);
}
this.prompt();
}
</PRE>
</TD></TR>
<TR><TD CLASS="lh13">
<B>License</B><BR><BR>
This JavaScript-library is <U>free for private and academic use</U>.
Please include a readable copyright statement and a backlink to &lt;http://www.masswerk.at&gt; in the
web page. The library should always be accompanied by the &quot;readme.txt&quot; and the sample HTML-documents.<BR><BR>
The term &quot;private use&quot; includes any personal or non-commercial use, which is not related
to commercial activites, but excludes intranet, extranet and/or public net applications
that are related to any kind of commercial or profit oriented activity.<BR><BR>
For commercial use see &lt;<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>&gt; for contact information.
</TD></TR>
<TR><TD CLASS="lh13">
<B>Distribution</B><BR><BR>
This JavaScript-library may be distributed freely as long it is distributed together with the &quot;readme.txt&quot; and the sample HTML-documents and this document.<BR><BR>
Any changes to the library should be commented and be documented in the readme-file.<BR>
Any changes must be reflected in the `Terminal.version' string as &quot;Version.Subversion&nbsp;(compatibility)&quot;.
</TD></TR>
<TR><TD CLASS="lh13">
<B>Disclaimer</B><BR><BR>
This software is distributed AS IS and in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. The entire risk as to the quality and performance of the product is borne by the
user. No use of the product is authorized hereunder except under this disclaimer.
</TD></TR>
<TR><TD CLASS="lh13">
<B>History</B><BR><BR>
This library evolved from the terminal script &quot;TermApp&quot; ((c) N. Landsteiner 2003) and is in its
current form a down scaled spinn-off of the &quot;JS/UIX&quot; project. (JS/UIX is not a free&nbsp;software by now.)
c.f.: &lt;<A HREF="http://www.masswerk.at/jsuix/" TARGET="_blank">http://www.masswerk.at/jsuix</A>&gt;<BR><BR>
For version history: see the <A HREF="readme.txt">readme.txt</A>.
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
<B>Download</B><BR><BR>
Be sure to have read the license information and the disclamer and that you are willing to respect copyrights.<BR><BR>
<SPAN CLASS="prop">Download:</SPAN> <A HREF="termlib.zip">termlib.zip</A> (~ 40 KB, incl. docs)<BR><BR>
Current version is &quot;1.07 (original)&quot;.<BR>
The files are now provided with line breaks in format &lt;CRLF&gt;.<BR>
&nbsp;
</TD></TR>
<TR><TD CLASS="lh13">
<B>Author</B><BR><BR>
&copy; Norbert Landsteiner 2003-2005<BR>
mass:werk &#150; media environments<BR>
<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
Author's note:<BR>
Please do not contact me on questions of simple usage. There is an extensive documentation (readme.txt) including plenty of sample code that should provide all information you need.
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;<BR>
<A HREF="#top">&gt; top of page</A>
</TD></TR>
<TR><TD CLASS="lh13">
&nbsp;
</TD></TR>
</TABLE>
<DIV ID="termDiv" STYLE="position:absolute; top:20px; left:100px;"></DIV>
</BODY>
</HTML>

View File

@ -1,188 +1,188 @@
<HTML>
<HEAD>
<TITLE>termlib Multiple Terminal Test</TITLE>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
/*
multiple terminal test for termlib.js
(c) Norbert Landsteiner 2003-2005
mass:werk - media environments
<http://www.masswerk.at>
*/
var term=new Array();
var helpPage=[
'%CS%+r Terminal Help %-r%n',
' This is just a tiny test for multiple terminals.',
' use one of the following commands:',
' clear .... clear the terminal',
' exit ..... close the terminal (or <ESC>)',
' id ....... show terminal\'s id',
' switch ... switch to other terminal',
' help ..... show this help page',
' other input will be echoed to the terminal.',
' '
];
function termOpen(n) {
if (!term[n]) {
var y=(n==1)? 70: 280;
term[n]=new Terminal(
{
x: 220,
y: y,
rows: 12,
greeting: '%+r +++ Terminal #'+n+' ready. +++ %-r%nType "help" for help.%n',
id: n,
termDiv: 'termDiv'+n,
crsrBlinkMode: true,
handler: termHandler,
exitHandler: termExitHandler
}
);
if (term[n]) term[n].open();
}
else if (term[n].closed) {
term[n].open();
}
else {
term[n].focus();
}
}
function termHandler() {
// called on <CR> or <ENTER>
this.newLine();
var cmd=this.lineBuffer;
if (cmd!='') {
if (cmd=='switch') {
var other=(this.id==1)? 2:1;
termOpen(other);
}
else if (cmd=='clear') {
this.clear();
}
else if (cmd=='exit') {
this.close();
}
else if (cmd=='help') {
this.write(helpPage);
}
else if (cmd=='id') {
this.write('terminal id: '+this.id);
}
else {
this.type('You typed: '+cmd);
this.newLine();
}
}
this.prompt();
}
function termExitHandler() {
// optional handler called on exit
// activate other terminal if open
var other=(this.id==1)? 2:1;
if ((term[other]) && (term[other].closed==false)) term[other].focus();
}
//-->
</SCRIPT>
<STYLE TYPE="text/css">
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #cccccc;
}
.lh15 {
line-height: 15px;
}
.term {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #33d011;
background: none;
}
.termReverse {
color: #111111;
background: #33d011;
}
a,a:link,a:visited {
text-decoration: none;
color: #77dd11;
}
a:hover {
text-decoration: underline;
color: #77dd11;
}
a:active {
text-decoration: underline;
color: #dddddd;
}
a.termopen,a.termopen:link,a.termopen:visited {
text-decoration: none;
color: #77dd11;
background: none;
}
a.termopen:hover {
text-decoration: none;
color: #222222;
background: #77dd11;
}
a.termopen:active {
text-decoration: none;
color: #222222;
background: #dddddd;
}
</STYLE>
</HEAD>
<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"
TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">
<TR>
<TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>
<TD>|</TD>
<TD NOWRAP>multiple terminal test</TD>
<TD>|</TD>
<TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="faq.html">faq</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0">
<TR><TD NOWRAP>
Multiple Terminal Test<BR>&nbsp;
</TD></TR>
<TR><TD NOWRAP>
<A HREF="javascript:termOpen(1)" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 1'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal 1 &nbsp;</A>
</TD></TR>
<TR><TD NOWRAP>
<A HREF="javascript:termOpen(2)" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 2'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal 2 &nbsp;</A>
</TD></TR>
<TR><TD NOWRAP CLASS="lh15">
&nbsp;<BR>
(c) mass:werk,<BR>N. Landsteiner 2003-2005<BR>
<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>
</TD></TR>
</TABLE>
<DIV ID="termDiv1" STYLE="position:absolute; top:20px; left:100px;"></DIV>
<DIV ID="termDiv2" STYLE="position:absolute; top:20px; left:100px;"></DIV>
</BODY>
<HTML>
<HEAD>
<TITLE>termlib Multiple Terminal Test</TITLE>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
/*
multiple terminal test for termlib.js
(c) Norbert Landsteiner 2003-2005
mass:werk - media environments
<http://www.masswerk.at>
*/
var term=new Array();
var helpPage=[
'%CS%+r Terminal Help %-r%n',
' This is just a tiny test for multiple terminals.',
' use one of the following commands:',
' clear .... clear the terminal',
' exit ..... close the terminal (or <ESC>)',
' id ....... show terminal\'s id',
' switch ... switch to other terminal',
' help ..... show this help page',
' other input will be echoed to the terminal.',
' '
];
function termOpen(n) {
if (!term[n]) {
var y=(n==1)? 70: 280;
term[n]=new Terminal(
{
x: 220,
y: y,
rows: 12,
greeting: '%+r +++ Terminal #'+n+' ready. +++ %-r%nType "help" for help.%n',
id: n,
termDiv: 'termDiv'+n,
crsrBlinkMode: true,
handler: termHandler,
exitHandler: termExitHandler
}
);
if (term[n]) term[n].open();
}
else if (term[n].closed) {
term[n].open();
}
else {
term[n].focus();
}
}
function termHandler() {
// called on <CR> or <ENTER>
this.newLine();
var cmd=this.lineBuffer;
if (cmd!='') {
if (cmd=='switch') {
var other=(this.id==1)? 2:1;
termOpen(other);
}
else if (cmd=='clear') {
this.clear();
}
else if (cmd=='exit') {
this.close();
}
else if (cmd=='help') {
this.write(helpPage);
}
else if (cmd=='id') {
this.write('terminal id: '+this.id);
}
else {
this.type('You typed: '+cmd);
this.newLine();
}
}
this.prompt();
}
function termExitHandler() {
// optional handler called on exit
// activate other terminal if open
var other=(this.id==1)? 2:1;
if ((term[other]) && (term[other].closed==false)) term[other].focus();
}
//-->
</SCRIPT>
<STYLE TYPE="text/css">
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #cccccc;
}
.lh15 {
line-height: 15px;
}
.term {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #33d011;
background: none;
}
.termReverse {
color: #111111;
background: #33d011;
}
a,a:link,a:visited {
text-decoration: none;
color: #77dd11;
}
a:hover {
text-decoration: underline;
color: #77dd11;
}
a:active {
text-decoration: underline;
color: #dddddd;
}
a.termopen,a.termopen:link,a.termopen:visited {
text-decoration: none;
color: #77dd11;
background: none;
}
a.termopen:hover {
text-decoration: none;
color: #222222;
background: #77dd11;
}
a.termopen:active {
text-decoration: none;
color: #222222;
background: #dddddd;
}
</STYLE>
</HEAD>
<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"
TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">
<TR>
<TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>
<TD>|</TD>
<TD NOWRAP>multiple terminal test</TD>
<TD>|</TD>
<TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="faq.html">faq</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0">
<TR><TD NOWRAP>
Multiple Terminal Test<BR>&nbsp;
</TD></TR>
<TR><TD NOWRAP>
<A HREF="javascript:termOpen(1)" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 1'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal 1 &nbsp;</A>
</TD></TR>
<TR><TD NOWRAP>
<A HREF="javascript:termOpen(2)" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 2'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal 2 &nbsp;</A>
</TD></TR>
<TR><TD NOWRAP CLASS="lh15">
&nbsp;<BR>
(c) mass:werk,<BR>N. Landsteiner 2003-2005<BR>
<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>
</TD></TR>
</TABLE>
<DIV ID="termDiv1" STYLE="position:absolute; top:20px; left:100px;"></DIV>
<DIV ID="termDiv2" STYLE="position:absolute; top:20px; left:100px;"></DIV>
</BODY>
</HTML>

View File

@ -1,293 +1,293 @@
<HTML>
<HEAD>
<TITLE>termlib Sample Parser</TITLE>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib_parser.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
/*
test sample for termlib.js and termlib_parser.js
(c) Norbert Landsteiner 2005
mass:werk - media environments
<http://www.masswerk.at>
*/
var term;
var helpPage=[
'%CS%+r Terminal Help %-r%n',
' This is just a sample to demonstrate command line parsing.',
' ',
' Use one of the following commands:',
' clear [-a] .......... clear the terminal',
' option "a" also removes the status line',
' number -n<value> .... return value of option "n" (test for options)',
' repeat -n<value> .... repeats the first argument n times (another test)',
' login <username> .... sample login (test for raw mode)',
' exit ................ close the terminal (same as <ESC>)',
' help ................ show this help page',
' ',
' other input will be echoed to the terminal as a list of parsed arguments',
' in the format <argument index> <quoting level> "<parsed value>".',
' '
];
function termOpen() {
if (!term) {
term=new Terminal(
{
x: 220,
y: 70,
termDiv: 'termDiv',
ps: '[guest]$',
initHandler: termInitHandler,
handler: commandHandler
}
);
if (term) term.open();
}
else if (term.closed) {
term.open();
}
else {
term.focus();
}
}
function termInitHandler() {
// output a start up screen
this.write(
[
TermGlobals.center('####################################################', 80),
TermGlobals.center('# #', 80),
TermGlobals.center('# termlib.js - Sample Parser #', 80),
TermGlobals.center('# Input is echoed as a list of parsed arguments. #', 80),
TermGlobals.center('# #', 80),
TermGlobals.center('# Type "help" for commands. #', 80),
TermGlobals.center('# #', 80),
TermGlobals.center('# (c) N. Landsteiner 2005; www.masswerk.at #', 80),
TermGlobals.center('# #', 80),
TermGlobals.center('####################################################', 80),
'%n'
]
);
// set a double status line
this.statusLine('', 8,2); // just a line of strike
this.statusLine(' +++ This is just a test sample for command parsing. Type "help" for help. +++');
this.maxLines -= 2;
// and leave with prompt
this.prompt();
}
function commandHandler() {
this.newLine();
// check for raw mode first (should not be parsed)
if (this.rawMode) {
if (this.env.getPassword) {
// sample password handler (lineBuffer == stored username ?)
if (this.lineBuffer == this.env.username) {
this.user = this.env.username;
this.ps = '['+this.user+']>';
}
else {
this.type('Sorry.');
}
this.env.username = '';
this.env.getPassword = false;
}
// leave in normal mode
this.rawMode = false;
this.prompt();
return;
}
// normal command parsing
// just call the termlib_parser with a reference of the calling Terminal instance
// parsed arguments will be imported in this.argv,
// quoting levels per argument in this.argQL (quoting character or empty)
// cursor for arguments is this.argc (used by parserGetopt)
// => see 'termlib_parse.js' for configuration and details
parseLine(this);
if (this.argv.length == 0) {
// no commmand line input
}
else if (this.argQL[0]) {
// first argument quoted -> error
this.write("Syntax error: first argument quoted.");
}
else {
var cmd = this.argv[this.argc++];
/*
process commands now
1st argument: this.argv[this.argc]
*/
if (cmd == 'help') {
this.write(helpPage);
}
else if (cmd == 'clear') {
// get options
var opts = parserGetopt(this, 'aA');
if (opts.a) {
// discard status line on opt "a" or "A"
this.maxLines = this.conf.rows;
}
this.clear();
}
else if (cmd == 'number') {
// test for value options
var opts = parserGetopt(this, 'n');
if (opts.illegals.length) this.type('illegal option. usage: number -n<value>')
else if ((opts.n) && (opts.n.value != -1)) this.type('option value: '+opts.n.value)
else this.type('usage: number -n<value>');
}
else if (cmd == 'repeat') {
// another test for value options
var opts = parserGetopt(this, 'n');
if (opts.illegals.length) this.type('illegal option. usage: repeat -n<value> <string>')
else if ((opts.n) && (opts.n.value != -1)) {
// first normal argument is again this.argv[this.argc]
var s = this.argv[this.argc];
if (typeof s != 'undefined') {
// repeat this string n times
var a = [];
for (var i=0; i<opts.n.value; i++) a[a.length] = s;
this.type(a.join(' '));
}
}
else this.type('usage: repeat -n<value> <string>');
}
else if (cmd == 'login') {
// sample login (test for raw mode)
if ((this.argc == this.argv.length) || (this.argv[this.argc] == '')) {
this.type('usage: login <username>');
}
else {
this.env.getPassword = true;
this.env.username = this.argv[this.argc];
this.write('%+iSample login: repeat username as password.%-i%n');
this.type('password: ');
// exit in raw mode (blind input)
this.rawMode = true;
this.lock = false;
return;
}
}
else if (cmd == 'exit') {
this.close();
return;
}
else {
// for test purpose just output argv as list
// assemble a string of style-escaped lines and output it in more-mode
s=' INDEX QL ARGUMENT%n';
for (var i=0; i<this.argv.length; i++) {
s += TermGlobals.stringReplace('%', '%%',
TermGlobals.fillLeft(i, 6) +
TermGlobals.fillLeft((this.argQL[i])? this.argQL[i]:'-', 4) +
' "' + this.argv[i] + '"'
) + '%n';
}
this.write(s, 1);
return;
}
}
this.prompt();
}
//-->
</SCRIPT>
<STYLE TYPE="text/css">
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #cccccc;
}
.lh15 {
line-height: 15px;
}
.term {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #33d011;
background: none;
}
.termReverse {
color: #111111;
background: #33d011;
}
a,a:link,a:visited {
text-decoration: none;
color: #77dd11;
}
a:hover {
text-decoration: underline;
color: #77dd11;
}
a:active {
text-decoration: underline;
color: #dddddd;
}
a.termopen,a.termopen:link,a.termopen:visited {
text-decoration: none;
color: #77dd11;
background: none;
}
a.termopen:hover {
text-decoration: none;
color: #222222;
background: #77dd11;
}
a.termopen:active {
text-decoration: none;
color: #222222;
background: #dddddd;
}
</STYLE>
</HEAD>
<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"
TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">
<TR>
<TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>
<TD>|</TD>
<TD NOWRAP>sample parser</TD>
<TD>|</TD>
<TD NOWRAP><A HREF="faq.html">faq</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0">
<TR><TD NOWRAP>
Sample Parser Test<BR>&nbsp;
</TD></TR>
<TR><TD NOWRAP>
<A HREF="javascript:termOpen()" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 1'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal &nbsp;</A>
</TD></TR>
<TR><TD NOWRAP>
&nbsp;
</TD></TR>
<TR><TD NOWRAP CLASS="lh15">
&nbsp;<BR>
(c) mass:werk,<BR>N. Landsteiner 2003-2005<BR>
<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>
</TD></TR>
</TABLE>
<DIV ID="termDiv" STYLE="position:absolute;"></DIV>
</BODY>
<HTML>
<HEAD>
<TITLE>termlib Sample Parser</TITLE>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib_parser.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
/*
test sample for termlib.js and termlib_parser.js
(c) Norbert Landsteiner 2005
mass:werk - media environments
<http://www.masswerk.at>
*/
var term;
var helpPage=[
'%CS%+r Terminal Help %-r%n',
' This is just a sample to demonstrate command line parsing.',
' ',
' Use one of the following commands:',
' clear [-a] .......... clear the terminal',
' option "a" also removes the status line',
' number -n<value> .... return value of option "n" (test for options)',
' repeat -n<value> .... repeats the first argument n times (another test)',
' login <username> .... sample login (test for raw mode)',
' exit ................ close the terminal (same as <ESC>)',
' help ................ show this help page',
' ',
' other input will be echoed to the terminal as a list of parsed arguments',
' in the format <argument index> <quoting level> "<parsed value>".',
' '
];
function termOpen() {
if (!term) {
term=new Terminal(
{
x: 220,
y: 70,
termDiv: 'termDiv',
ps: '[guest]$',
initHandler: termInitHandler,
handler: commandHandler
}
);
if (term) term.open();
}
else if (term.closed) {
term.open();
}
else {
term.focus();
}
}
function termInitHandler() {
// output a start up screen
this.write(
[
TermGlobals.center('####################################################', 80),
TermGlobals.center('# #', 80),
TermGlobals.center('# termlib.js - Sample Parser #', 80),
TermGlobals.center('# Input is echoed as a list of parsed arguments. #', 80),
TermGlobals.center('# #', 80),
TermGlobals.center('# Type "help" for commands. #', 80),
TermGlobals.center('# #', 80),
TermGlobals.center('# (c) N. Landsteiner 2005; www.masswerk.at #', 80),
TermGlobals.center('# #', 80),
TermGlobals.center('####################################################', 80),
'%n'
]
);
// set a double status line
this.statusLine('', 8,2); // just a line of strike
this.statusLine(' +++ This is just a test sample for command parsing. Type "help" for help. +++');
this.maxLines -= 2;
// and leave with prompt
this.prompt();
}
function commandHandler() {
this.newLine();
// check for raw mode first (should not be parsed)
if (this.rawMode) {
if (this.env.getPassword) {
// sample password handler (lineBuffer == stored username ?)
if (this.lineBuffer == this.env.username) {
this.user = this.env.username;
this.ps = '['+this.user+']>';
}
else {
this.type('Sorry.');
}
this.env.username = '';
this.env.getPassword = false;
}
// leave in normal mode
this.rawMode = false;
this.prompt();
return;
}
// normal command parsing
// just call the termlib_parser with a reference of the calling Terminal instance
// parsed arguments will be imported in this.argv,
// quoting levels per argument in this.argQL (quoting character or empty)
// cursor for arguments is this.argc (used by parserGetopt)
// => see 'termlib_parse.js' for configuration and details
parseLine(this);
if (this.argv.length == 0) {
// no commmand line input
}
else if (this.argQL[0]) {
// first argument quoted -> error
this.write("Syntax error: first argument quoted.");
}
else {
var cmd = this.argv[this.argc++];
/*
process commands now
1st argument: this.argv[this.argc]
*/
if (cmd == 'help') {
this.write(helpPage);
}
else if (cmd == 'clear') {
// get options
var opts = parserGetopt(this, 'aA');
if (opts.a) {
// discard status line on opt "a" or "A"
this.maxLines = this.conf.rows;
}
this.clear();
}
else if (cmd == 'number') {
// test for value options
var opts = parserGetopt(this, 'n');
if (opts.illegals.length) this.type('illegal option. usage: number -n<value>')
else if ((opts.n) && (opts.n.value != -1)) this.type('option value: '+opts.n.value)
else this.type('usage: number -n<value>');
}
else if (cmd == 'repeat') {
// another test for value options
var opts = parserGetopt(this, 'n');
if (opts.illegals.length) this.type('illegal option. usage: repeat -n<value> <string>')
else if ((opts.n) && (opts.n.value != -1)) {
// first normal argument is again this.argv[this.argc]
var s = this.argv[this.argc];
if (typeof s != 'undefined') {
// repeat this string n times
var a = [];
for (var i=0; i<opts.n.value; i++) a[a.length] = s;
this.type(a.join(' '));
}
}
else this.type('usage: repeat -n<value> <string>');
}
else if (cmd == 'login') {
// sample login (test for raw mode)
if ((this.argc == this.argv.length) || (this.argv[this.argc] == '')) {
this.type('usage: login <username>');
}
else {
this.env.getPassword = true;
this.env.username = this.argv[this.argc];
this.write('%+iSample login: repeat username as password.%-i%n');
this.type('password: ');
// exit in raw mode (blind input)
this.rawMode = true;
this.lock = false;
return;
}
}
else if (cmd == 'exit') {
this.close();
return;
}
else {
// for test purpose just output argv as list
// assemble a string of style-escaped lines and output it in more-mode
s=' INDEX QL ARGUMENT%n';
for (var i=0; i<this.argv.length; i++) {
s += TermGlobals.stringReplace('%', '%%',
TermGlobals.fillLeft(i, 6) +
TermGlobals.fillLeft((this.argQL[i])? this.argQL[i]:'-', 4) +
' "' + this.argv[i] + '"'
) + '%n';
}
this.write(s, 1);
return;
}
}
this.prompt();
}
//-->
</SCRIPT>
<STYLE TYPE="text/css">
body,p,a,td {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #cccccc;
}
.lh15 {
line-height: 15px;
}
.term {
font-family: courier,fixed,swiss,sans-serif;
font-size: 12px;
color: #33d011;
background: none;
}
.termReverse {
color: #111111;
background: #33d011;
}
a,a:link,a:visited {
text-decoration: none;
color: #77dd11;
}
a:hover {
text-decoration: underline;
color: #77dd11;
}
a:active {
text-decoration: underline;
color: #dddddd;
}
a.termopen,a.termopen:link,a.termopen:visited {
text-decoration: none;
color: #77dd11;
background: none;
}
a.termopen:hover {
text-decoration: none;
color: #222222;
background: #77dd11;
}
a.termopen:active {
text-decoration: none;
color: #222222;
background: #dddddd;
}
</STYLE>
</HEAD>
<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"
TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">
<TR>
<TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>
<TD>|</TD>
<TD NOWRAP>sample parser</TD>
<TD>|</TD>
<TD NOWRAP><A HREF="faq.html">faq</A></TD>
<TD>|</TD>
<TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0">
<TR><TD NOWRAP>
Sample Parser Test<BR>&nbsp;
</TD></TR>
<TR><TD NOWRAP>
<A HREF="javascript:termOpen()" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 1'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal &nbsp;</A>
</TD></TR>
<TR><TD NOWRAP>
&nbsp;
</TD></TR>
<TR><TD NOWRAP CLASS="lh15">
&nbsp;<BR>
(c) mass:werk,<BR>N. Landsteiner 2003-2005<BR>
<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>
</TD></TR>
</TABLE>
<DIV ID="termDiv" STYLE="position:absolute;"></DIV>
</BODY>
</HTML>