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