Changeset 18101 for misc/runpugs

Show
Ignore:
Timestamp:
09/23/07 06:44:55 (14 months ago)
Author:
azawawi
Message:

[runpugs] added ':show' command to show 100< lines syntax highlighter examples
[runpugs] pugs_example.pl shows only things under svn.pugs.code/pugs/examples
[p6_syntax_hilite] project p6_syntax_highlighter is now moved here

Location:
misc/runpugs
Files:
20 added
5 modified

Legend:

Unmodified
Added
Removed
  • misc/runpugs/htdocs/runpugs/default_info.html

    r18094 r18101  
    77<dt><code>:tutorial</code></dt><dd>starts/stops the pugs tutorial mode</dd> 
    88<dt><code>:back</code>, <code>:next</code></dt><dd>back/forward one lesson</dd> 
     9<dt><code>:show</code></dt><dd>Shows small syntax highlighted examples from svn.pugscode.org</dd> 
    910<dt><code>help</code></dt><dd> displays the Pugs shell help same as <code>:h</code>)</dd> 
    1011<dt><code>clear</code></dt><dd>clears the web terminal (this command is not sent to the pugs shell).</dd> 
  • misc/runpugs/htdocs/runpugs/index.html

    r18095 r18101  
    66        <title>Run Perl 6 Now -- in your browser!</title> 
    77        <link rel="stylesheet" type="text/css" href="../runpugs.css"/> 
     8        <link type="text/css" rel="stylesheet" href="../p6_syntax_highlite/SyntaxHighlighter.css"></link> 
    89        <script type="text/javascript" src="jquery-1.2.min.js"></script> 
     10        <script type="text/javascript" src="../p6_syntax_highlite/js/shCore.min.js"></script> 
     11        <script type="text/javascript" src="../p6_syntax_highlite/js/shBrushPerl6.min.js"></script> 
     12        <script type="text/javascript" src="../p6_syntax_highlite/js/pugs_examples.js"></script> 
    913        <script type="text/javascript" src="runpugs.js"></script> 
    1014    </head> 
  • misc/runpugs/htdocs/runpugs/runpugs-min.js

    r18081 r18101  
    1 var debug=0;var histlist=new Array();var histentry=0;var sessionid=0;var reldev=0;var curpos=0;var cmd="";var prompt="pugs> ";var cmds=new Array();var theme="wb_theme";var fixedCharWidth;function showCursor(){var A=cmds.length;var B=(A==0)?"#d0":"#d"+(A-1);$(B).toggleClass("cursorOff");$(B).toggleClass("cursorOn");setTimeout("showCursor()",1000)}function moveCursor(){var B=-(cmd.length-curpos)*fixedCharWidth;var A="#d"+(cmds.length-1);$(A).css("left",B+"px")}function showCmd(){var A="#c"+(cmds.length-1);$(A).text(prompt+cmd)}function updateConsole(){$.each(cmds,function(C,E){if(C==0){$("#tt").empty()}var B=(E=="")?"&nbsp;":E;var D="<tr><td><pre id='c"+C+"' class='"+theme+"'>"+B+"</pre>";if(C==cmds.length-1){D+="<span id='d"+C+"' class='cursorOff'>&nbsp;</span>"}$("#tt").append(D+"</td></tr>")});var A=$("#termwin")[0].scrollHeight;$("#termwin").animate({scrollTop:A},"fast")}$(document).ready(function(){var A="Please wait while Pugs starts up...";$("#tt").empty();$("#tt").append("<tr><td><pre id='c0' class='wb_theme'>"+A+"</pre><span id='d0' class='cursorOff'>&nbsp;</span></td></tr>");fixedCharWidth=($("#c0")[0])?$("#c0")[0].offsetWidth/A.length:8;$("#theme").change(function(){$("pre").toggleClass(theme);theme=$("#theme").val();$("pre").toggleClass(theme)});$("#logo").slideDown(2000);showCursor();$(document).keydown(function(B){return onKeyDown(B)});$(document).keypress(function(B){return onKeyPress(B)});$(window).unload(function(){$.ajax({url:"/perl/runpugs.pl?sessionid="+sessionid+"&reldev=1&ia=1&cmd=%3Aq",async:true})});$("#hidden_iframe").append("<iframe src=\"/perl/runpugs.pl\" id=\"scratch\" name=\"scratch\" style=\"visibility:hidden\" width=\"700px\" height=\"1px\" onLoad=\"getreply()\"></iframe>")});function insert(D,C,E){var B=D.substring(0,E);var A=D.substring(E,D.length);return B+C+A}function focusOnCmd(B){$(B).focus();var A=$("#termwin")[0].scrollHeight;$("#termwin").animate({scrollTop:A},"fast")}function onKeyDown(D){if(D.ctrlKey||D.altKey||D.shiftKey){return true}var E=D.keyCode;focusOnCmd("#status");if(E==13){var B=document.terminal.cmd.value+cmd;var G=B.split(prompt);var F=G[G.length-1];if($.trim(F)!=""){histlist.push(F)}if(debug){alert("data to be sent: "+B)}frames["scratch"].document.getElementById("cmd").value=B;frames["scratch"].document.terminal.submit();cmd="";return false}else{if(E==8){if(curpos>0){curpos-=1;var A="";for(var C=0;C<cmd.length;C++){if(C!=curpos){A+=cmd.charAt(C)}}cmd=A;showCmd();debugKeys()}return false}else{if(E==38){hist_next();return false}else{if(E==40){hist_prev();return false}else{if(E==37){if(curpos>0){curpos--;moveCursor()}return false}else{if(E==39){if(curpos<cmd.length){curpos++;moveCursor()}return false}else{if(E==36){curpos=0;moveCursor();return false}else{if(E==35){curpos=cmd.length;moveCursor();return false}else{if(E==46){if(curpos>=0){var A="";for(var C=0;C<cmd.length;C++){if(C!=curpos){A+=cmd.charAt(C)}}cmd=A;showCmd();moveCursor();debugKeys()}return false}}}}}}}}}return true}function toAscii(C){var D="abcdefghijklmnopqrstuvwxyz";var B=" !\"#$%&'()*+'-./0123456789:;<=>?@"+D.toUpperCase()+"[\\]^_`"+D+"{|}~";var E=B.indexOf(C);var A=(E>-1)?(32+E):0;return A}function onKeyPress(B){if(B.ctrlKey||B.altKey){return }var C=B.keyCode;focusOnCmd("#status");if($.browser.msie||$.browser.opera||$.browser.safari){var A=String.fromCharCode(C);if(A>=" "){if(($.browser.opera&&(C<35||C>40))||$.browser.msie||$.browser.safari){cmd=insert(cmd,A,curpos);showCmd();curpos++;debugKeys(A)}}return false}else{if($.browser.mozilla&&C==0){var A=String.fromCharCode(B.charCode?B.charCode:B.keyCode);if(A>=" "){cmd=insert(cmd,A,curpos);showCmd();curpos++;debugKeys(A)}return false}}return true}function debugKeys(C){if(debug){var A="";for(var B=0;B<cmd.length;B++){var D=toAscii(cmd.charAt(B));A+=D+","}$("#status").text(((C)?("key = '"+C):"")+"', cmd = '"+cmd+"', cmd.length="+cmd.length+", ascii=("+A+")")}}function getreply(){scratchpad=frames["scratch"].document;var B=scratchpad.getElementById("cmd").value;histentry=histlist.length;sessionid=scratchpad.terminal.sessionid.value;document.terminal.cmd.value=B;if(scratchpad.terminal.prompt){var C=scratchpad.terminal.prompt.value;if(C&&C.length=="pugs> ".length){prompt=C}}var A=B.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");cmds=A.split(/\r\n|\n|\r/g);if(debug){alert("reply (unescaped): "+B)}updateConsole();cmd="";curpos=0;showCmd()}function hist_next(){if(histentry>=1){histentry--;cmd=histlist[histentry];curpos=cmd.length;showCmd();moveCursor()}return false}function hist_prev(){if(histentry<histlist.length-1){histentry++;cmd=histlist[histentry];curpos=cmd.length;showCmd();moveCursor()}}function set_version(){var A=document.terminal.reldev[0].checked;if(A==true){frames["scratch"].document.terminal.reldev[0].checked=true;frames["scratch"].document.terminal.reldev[1].checked=false}else{frames["scratch"].document.terminal.reldev[0].checked=false;frames["scratch"].document.terminal.reldev[1].checked=true}frames["scratch"].document.terminal.submit();$("#rel").blur();$("#dev").blur();focusOnCmd("#tt")} 
     1var debug=0;var histlist=new Array();var histentry=0;var sessionid=0;var reldev=0;var curpos=0;var cmd="";var prompt="pugs> ";var cmds=new Array();var theme="wb_theme";var fixedCharWidth;var tutorialMode=0;var slide=0;var FIRST_TUTORIAL_SLIDE=2;var slides=new Array("default_info.html","../p6_syntax_highlite/syntax_hilite.html","tutorial/01_helloworld.html","tutorial/02_vars.html","tutorial/03_iteration_array.html","tutorial/04_iteration_hash.html","tutorial/05_iteration_many.html","tutorial/06_conditionals.html","tutorial/07_junctions.html","tutorial/08_junctions_array.html","tutorial/09_chained_comparison.html","tutorial/10_io.html","tutorial/11_io_iteration.html","tutorial/12_io_reading.html","tutorial/13_lists_reduction.html","tutorial/14_lists_hyper.html","tutorial/15_lists_cross.html","tutorial/16_grammar.html","tutorial/17_final.html");function showCursor(){var A=cmds.length;var B=(A==0)?"#d0":"#d"+(A-1);$(B).toggleClass("cursorOff");$(B).toggleClass("cursorOn");setTimeout("showCursor()",1000)}function moveCursor(){var B=-(cmd.length-curpos)*fixedCharWidth;var A="#d"+(cmds.length-1);$(A).css("left",B+"px")}function showCmd(){var A="#c"+(cmds.length-1);$(A).text(prompt+cmd)}function updateConsole(){$.each(cmds,function(C,E){if(C==0){$("#tt").empty()}var B=(E=="")?"&nbsp;":E;var D="<tr><td><pre id='c"+C+"' class='"+theme+"'>"+B+"</pre>";if(C==cmds.length-1){D+="<span id='d"+C+"' class='cursorOff'>&nbsp;</span>"}$("#tt").append(D+"</td></tr>")});var A=$("#termwin")[0].scrollHeight;$("#termwin").animate({scrollTop:A},"fast")}$(document).ready(function(){var A="Please wait while Pugs starts up...";$("#tt").empty();$("#tt").append("<tr><td><pre id='c0' class='wb_theme'>"+A+"</pre><span id='d0' class='cursorOff'>&nbsp;</span></td></tr>");fixedCharWidth=($("#c0")[0])?$("#c0")[0].offsetWidth/A.length:8;$("#theme").change(function(){$("pre").toggleClass(theme);theme=$("#theme").val();$("pre").toggleClass(theme)});$("#logo").slideDown(2000);showCursor();$(document).keydown(function(B){return onKeyDown(B)});$(document).keypress(function(B){return onKeyPress(B)});$(window).unload(function(){$.ajax({url:"/perl/runpugs.pl?sessionid="+sessionid+"&reldev=1&ia=1&cmd=%3Aq",async:true})});loadSlide();$("#hidden_iframe").append("<iframe src=\"/perl/runpugs.pl\" id=\"scratch\" name=\"scratch\" style=\"visibility:hidden\" width=\"700px\" height=\"1px\" onLoad=\"getreply()\"></iframe>")});function loadSlide(){if(debug){alert("slide url to be loaded = '"+slides[slide]+"'")}$("#info").slideUp("fast");$.ajax({url:slides[slide],async:true,success:function(A){if(debug){alert("slide data received: "+A)}$("#info").html(A);$("#info").slideDown("slow")}})}function insert(D,C,E){var B=D.substring(0,E);var A=D.substring(E,D.length);return B+C+A}function focusOnCmd(B){$(B).focus();var A=$("#termwin")[0].scrollHeight;$("#termwin").animate({scrollTop:A},"fast")}function handleEnter(){var A=document.terminal.cmd.value+cmd;var D=A.split(prompt);var C=D[D.length-1];var B=$.trim(C);if(B!=""){histlist.push(C)}if(B==":tutorial"){tutorialMode=!tutorialMode;slide=(tutorialMode)?FIRST_TUTORIAL_SLIDE:0;loadSlide()}else{if(B==":back"||B==":next"){if(tutorialMode){if(B==":back"){slide--;if(slide<FIRST_TUTORIAL_SLIDE){slide=FIRST_TUTORIAL_SLIDE}loadSlide()}else{slide++;if(slide>=slides.length){slide--}loadSlide()}}}else{if(B==":show"){slide=1;loadSlide()}}}if(debug){alert("data to be sent: "+A)}frames["scratch"].document.getElementById("cmd").value=A;frames["scratch"].document.terminal.submit();cmd=""}function onKeyDown(C){if(C.ctrlKey||C.altKey||C.shiftKey){return true}var D=C.keyCode;focusOnCmd("#status");if(D==13){handleEnter();return false}else{if(D==8){if(curpos>0){curpos-=1;var A="";for(var B=0;B<cmd.length;B++){if(B!=curpos){A+=cmd.charAt(B)}}cmd=A;showCmd();debugKeys()}return false}else{if(D==38){hist_next();return false}else{if(D==40){hist_prev();return false}else{if(D==37){if(curpos>0){curpos--;moveCursor()}return false}else{if(D==39){if(curpos<cmd.length){curpos++;moveCursor()}return false}else{if(D==36){curpos=0;moveCursor();return false}else{if(D==35){curpos=cmd.length;moveCursor();return false}else{if(D==46){if(curpos>=0){var A="";for(var B=0;B<cmd.length;B++){if(B!=curpos){A+=cmd.charAt(B)}}cmd=A;showCmd();moveCursor();debugKeys()}return false}}}}}}}}}return true}function toAscii(C){var D="abcdefghijklmnopqrstuvwxyz";var B=" !\"#$%&'()*+'-./0123456789:;<=>?@"+D.toUpperCase()+"[\\]^_`"+D+"{|}~";var E=B.indexOf(C);var A=(E>-1)?(32+E):0;return A}function onKeyPress(B){if(B.ctrlKey||B.altKey){return }var C=B.keyCode;focusOnCmd("#status");if($.browser.msie||$.browser.opera||$.browser.safari){var A=String.fromCharCode(C);if(A>=" "){if(($.browser.opera&&(C<35||C>40))||$.browser.msie||$.browser.safari){cmd=insert(cmd,A,curpos);showCmd();curpos++;debugKeys(A)}}return false}else{if($.browser.mozilla&&C==0){var A=String.fromCharCode(B.charCode?B.charCode:B.keyCode);if(A>=" "){cmd=insert(cmd,A,curpos);showCmd();curpos++;debugKeys(A)}return false}}return true}function debugKeys(C){if(debug){var A="";for(var B=0;B<cmd.length;B++){var D=toAscii(cmd.charAt(B));A+=D+","}$("#status").text(((C)?("key = '"+C):"")+"', cmd = '"+cmd+"', cmd.length="+cmd.length+", ascii=("+A+")")}}function getreply(){scratchpad=frames["scratch"].document;var B=scratchpad.getElementById("cmd").value;histentry=histlist.length;sessionid=scratchpad.terminal.sessionid.value;document.terminal.cmd.value=B;if(scratchpad.terminal.prompt){var C=scratchpad.terminal.prompt.value;if(C&&C.length=="pugs> ".length){prompt=C}}var A=B.replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");cmds=A.split(/\r\n|\n|\r/g);if(debug){alert("reply (unescaped): "+B)}updateConsole();cmd="";curpos=0;showCmd()}function hist_next(){if(histentry>=1){histentry--;cmd=histlist[histentry];curpos=cmd.length;showCmd();moveCursor()}return false}function hist_prev(){if(histentry<histlist.length-1){histentry++;cmd=histlist[histentry];curpos=cmd.length;showCmd();moveCursor()}}function set_version(){var A=document.terminal.reldev[0].checked;if(A==true){frames["scratch"].document.terminal.reldev[0].checked=true;frames["scratch"].document.terminal.reldev[1].checked=false}else{frames["scratch"].document.terminal.reldev[0].checked=false;frames["scratch"].document.terminal.reldev[1].checked=true}frames["scratch"].document.terminal.submit();$("#rel").blur();$("#dev").blur();focusOnCmd("#tt")} 
  • misc/runpugs/htdocs/runpugs/runpugs.js

    r18095 r18101  
    1616var tutorialMode = 0; 
    1717var slide = 0; 
     18var FIRST_TUTORIAL_SLIDE = 2; 
    1819var slides = new Array( 
    1920    'default_info.html', 
     21    '../p6_syntax_highlite/syntax_hilite.html', 
    2022    'tutorial/01_helloworld.html', 
    2123    'tutorial/02_vars.html', 
     
    164166} 
    165167 
     168//handle ENTER key 
     169function handleEnter() { 
     170    var sessCmds=document.terminal.cmd.value + cmd; 
     171    var tmpCmds=sessCmds.split(prompt); 
     172    var tmpCmd=tmpCmds[tmpCmds.length-1]; 
     173    var trimTmpCmd = $.trim(tmpCmd); 
     174    if(trimTmpCmd != "") { 
     175        histlist.push(tmpCmd); 
     176    } 
     177 
     178    //for tutorial, back, next support 
     179    if(trimTmpCmd == ":tutorial") { 
     180        tutorialMode = !tutorialMode; 
     181        slide = (tutorialMode) ? FIRST_TUTORIAL_SLIDE : 0; 
     182        loadSlide(); 
     183    } else if (trimTmpCmd == ":back" || trimTmpCmd == ":next") { 
     184        if(tutorialMode) { 
     185            if(trimTmpCmd == ":back") { 
     186                slide--; 
     187                if(slide < FIRST_TUTORIAL_SLIDE) { 
     188                    slide = FIRST_TUTORIAL_SLIDE; 
     189                } 
     190                loadSlide(); 
     191            } else { 
     192                //next command 
     193                slide++; 
     194                if(slide >= slides.length) { 
     195                    slide--; 
     196                } 
     197                loadSlide(); 
     198            } 
     199        } 
     200    } else if(trimTmpCmd == ":show") { 
     201        //alert('showing examples....'); 
     202        slide = 1; 
     203        loadSlide(); 
     204    } 
     205    if(debug) { 
     206        alert("data to be sent: " + sessCmds); 
     207    } 
     208    frames['scratch'].document.getElementById("cmd").value=sessCmds; 
     209    frames['scratch'].document.terminal.submit();  
     210    cmd = ""; 
     211} 
     212 
    166213//$.keydown 
    167214function onKeyDown(event) { 
     
    177224    if(keyCode == 13) { 
    178225        //enter 
    179         var sessCmds=document.terminal.cmd.value + cmd; 
    180         var tmpCmds=sessCmds.split(prompt); 
    181         var tmpCmd=tmpCmds[tmpCmds.length-1]; 
    182         var trimTmpCmd = $.trim(tmpCmd); 
    183         if(trimTmpCmd != "") { 
    184             histlist.push(tmpCmd); 
    185         } 
    186  
    187         //for tutorial, back, next support 
    188         if(trimTmpCmd == ":tutorial") { 
    189             tutorialMode = !tutorialMode; 
    190             slide = (tutorialMode) ? 1 : 0; 
    191             loadSlide(); 
    192         } 
    193         if(trimTmpCmd == ":back" || trimTmpCmd == ":next") { 
    194             if(tutorialMode) { 
    195                 if(trimTmpCmd == ":back") { 
    196                     slide--; 
    197                     if(slide < 1) { 
    198                         slide = 1; 
    199                     } 
    200                     loadSlide(slide); 
    201                 } else { 
    202                     //next command 
    203                     slide++; 
    204                     if(slide >= slides.length) { 
    205                         slide--; 
    206                     } 
    207                     loadSlide(slide); 
    208                 } 
    209             } 
    210         } 
    211         if(debug) { 
    212             alert("data to be sent: " + sessCmds); 
    213         } 
    214         frames['scratch'].document.getElementById("cmd").value=sessCmds; 
    215         frames['scratch'].document.terminal.submit();  
    216         cmd = ""; 
     226        handleEnter(); 
    217227        return false; 
    218228         
  • misc/runpugs/htdocs/runpugs/tutorial/README

    r18094 r18101  
    22http://jnthn.net/papers/2007-ukuug-perl6programming-slides.pdf 
    33by Jonathan Worthington <jnthn at jnthn.net> 
     4 
     5 
     6Any comments welcomed, 
     7ahmad.zawawi [at] gmail.com