Revision: 3057 http://vexi.svn.sourceforge.net/vexi/?rev=3057&view=rev Author: clrg Date: 2008-08-09 22:09:40 +0000 (Sat, 09 Aug 2008)
Log Message: ----------- Code tutor enhancements Modified Paths: -------------- trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/codeline.t trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/codeview.t trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/linenumber.t trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/main.t Modified: trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/codeline.t =================================================================== --- trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/codeline.t 2008-08-09 22:06:18 UTC (rev 3056) +++ trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/codeline.t 2008-08-09 22:09:40 UTC (rev 3057) @@ -1,7 +1,9 @@ -<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="vexi.font"> +<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="vexi"> <meta:doc> <author>Charles Goodwin</author> </meta:doc> - <ui:box align="left" fill="white" vshrink="true" font=":.VeraMono" /> + <ui:box align="left" fill="white" fontsize="large" vshrink="true"> + font = .font["VeraMono.ttf"]; + </ui:box> </vexi> \ No newline at end of file Modified: trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/codeview.t =================================================================== --- trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/codeview.t 2008-08-09 22:06:18 UTC (rev 3056) +++ trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/codeview.t 2008-08-09 22:09:40 UTC (rev 3057) @@ -3,35 +3,35 @@ <author>Charles Goodwin</author> </meta:doc> - <ui:box autohide="true"> + <scrollpane autohide="true"> <ui:box id="line" orient="vertical" align="top" shrink="true" /> <ui:box id="code" orient="vertical" align="top" vshrink="true" /> thisbox.tabtext = arguments[1]; + /** recursively build a stream from a given string */ var getStream = function(str, stream) { var dot = str.indexOf("."); - if (dot==-1) { - // FIXME: unclone() required - return vexi.unclone(stream)[str+".t"]; - } + // reached the template to display + if (dot==-1) return vexi.unclone(stream)[str+".t"]; + // still moving through directories return callee(str.substring(dot+1), stream[str.substring(0, dot)]); } - var s = getStream(arguments[0], vexi[""]); - var samplestr = vexi.stream.parse.utf8(s); - vexi.log.info("stream: "+s); - vexi.log.info("content: "+samplestr.substring(0, 100)); - var strbyline = samplestr.split('\n'); - var len = strbyline.length; - for (var i=0; len>i; i++) { - var c = tutor.codeline(vexi.box); - c.text = strbyline[i]; - $code[i] = c; - var l = tutor.linenumber(vexi.box); - l.text = i; - $line[i] = l; + { // constructor + var s = getStream(arguments[0], vexi[""]); + var samplestr = vexi.stream.parse.utf8(s); + var strbyline = samplestr.split('\n'); + var len = strbyline.length; + for (var i=0; len>i; i++) { + var c = tutor.codeline(vexi.box); + c.text = strbyline[i]; + $code[i] = c; + var l = tutor.linenumber(vexi.box); + l.text = i; + $line[i] = l; + } } - </ui:box> + </scrollpane> </vexi> \ No newline at end of file Modified: trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/linenumber.t =================================================================== --- trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/linenumber.t 2008-08-09 22:06:18 UTC (rev 3056) +++ trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/linenumber.t 2008-08-09 22:09:40 UTC (rev 3057) @@ -1,7 +1,9 @@ -<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="vexi.font"> +<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="vexi"> <meta:doc> <author>Charles Goodwin</author> </meta:doc> - <ui:box align="right" vshrink="true" font=":.VeraMono" fill="#e0e0e0" textcolor="darkgray" /> + <ui:box align="right" vshrink="true" fill="#e0e0e0" fontsize="large" textcolor="darkgray"> + font = .font["VeraMono.ttf"]; + </ui:box> </vexi> \ No newline at end of file Modified: trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/main.t =================================================================== --- trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/main.t 2008-08-09 22:06:18 UTC (rev 3056) +++ trunk/apps/org.vexi.codetutor/src/org/vexi/codetutor/main.t 2008-08-09 22:09:40 UTC (rev 3057) @@ -24,10 +24,13 @@ <ui:box orient="vertical"> <ui:box fill="#eeeeee" vshrink="true"> <ui:box width="5" /> - <button id="run" margin="10 5" text="Run Code" /> - <ui:box minwidth="5" /> + <button id="run" enabled="false" margin="10 5" text="Run Code" /> + <ui:box width="5" /> + <ui:box layout="place"> + <ui:box id="msg" /> + </ui:box> </ui:box> - <tabpane id="view" margin="10"> + <tabpane id="view" closeable="true" margin="10"> <tutor:about /> </tabpane> </ui:box> @@ -36,22 +39,29 @@ //////// // run button behaviour + var clearMessage = function(v) { + cascade = v; + $msg.text = ""; + trapee[trapname] --= callee; + } + $run.action ++= function(v) { - vexi.log.info("opening: "+$view.show.stream); + $msg.text = "Opening: "+$view.show.stream; if ($view.show.stream) vexi.thread = function() { var c = util.virtualize..cloneVexi(); var s = $view.show.stream.split('.'); var r = c[""]; for (var i=0; s.length>i; i++) r = r[s[i]]; - { r(vexi.box); } + r(vexi.box); + surface._Press1 ++= clearMessage; } return; } $view.show ++= function(v) { cascade = v; - $run.enabled = v != null and v.stream != null; + $run.enabled = v != null and v.canrun and v.stream != null; } //////// @@ -63,10 +73,12 @@ var c = cards[trapee.stream]; if (c == null) { c = tutor.codeview(vexi.box, [trapee.stream, trapee.text]); + c.canrun = trapee.canrun; c.stream = trapee.stream; cards[trapee.stream] = c; + } + if ($view.indexof(c)==-1) $view[$view.numchildren] = c; - } $view.show = c; return; } @@ -76,19 +88,25 @@ if (k.indexOf(".svn")!=-1) continue; var tutorial = .tree(vexi.box); tutorial.text = k; + tutorial[0] = .tree(vexi.box); + tutorial[0].text = "Includes"; for (var s in ts[k]) { - if (s.indexOf("sample")==0) { - var sample = .tree(vexi.box); - sample.text = s; - sample.stream = "tutorials."+k+"."+s.substring(0, s.length-2); - sample.iconfill = tutor.image.template; - sample.DoubleClick1 ++= openSample; - var index = tutorial.numchildren; - for (var j=0; tutorial.numchildren>j; j++) { - if (tutorial[j].text>s) { index = j; break; } + if (s.indexOf(".t")==-1) continue; + var sample = .tree(vexi.box); + sample.text = s; + sample.stream = "tutorials."+k+"."+s.substring(0, s.length-2); + sample.iconfill = tutor.image.template; + sample.DoubleClick1 ++= openSample; + var o = s.indexOf("sample")==0 ? tutorial : tutorial[0]; + var index = o.numchildren; + for (var j=0; o.numchildren>j; j++) { + if (o[j].text>s) { + index = j; + break; } - tutorial[index] = sample; } + sample.canrun = o == tutorial; + o[index] = sample; } $content[$content.numchildren] = tutorial; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn