Revision: 4810 http://sourceforge.net/p/vexi/code/4810 Author: clrg Date: 2015-08-05 10:27:35 +0000 (Wed, 05 Aug 2015) Log Message: ----------- Refactor/improve
Modified Paths: -------------- branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/codeline.t branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/codeview.t branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/linenumber.t branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/main.t Modified: branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/codeline.t =================================================================== --- branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/codeline.t 2015-08-05 10:26:10 UTC (rev 4809) +++ branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/codeline.t 2015-08-05 10:27:35 UTC (rev 4810) @@ -1,9 +1,5 @@ -<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" fontsize="large" vshrink="true"> +<vexi xmlns:ui="vexi://ui" xmlns="vexi"> + <ui:Box align="left" fontsize="large" vshrink="true"> font = .font["VeraMono.ttf"]; - </ui:box> + </ui:Box> </vexi> \ No newline at end of file Modified: branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/codeview.t =================================================================== --- branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/codeview.t 2015-08-05 10:26:10 UTC (rev 4809) +++ branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/codeview.t 2015-08-05 10:27:35 UTC (rev 4810) @@ -1,11 +1,19 @@ -<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="vexi.widget" xmlns:tutor="org.vexi.codetutor"> - <meta:doc> - <author>Charles Goodwin</author> - </meta:doc> +<vexi xmlns:ui="vexi://ui" + xmlns:tutor="org.vexi.codetutor" + xmlns="vexi.widget"> - <scrollpane align="top" autohide="true"> - <ui:box id="line" orient="vertical" shrink="true" /> - <ui:box id="code" orient="vertical" vshrink="true" /> + <scrollpane autohide="true"> + <ui:Box align="topright" fill="#e0e0e0" hshrink="true"> + <ui:Box id="line" minwidth="24" orient="vertical" shrink="true"> + <ui:Box height="3" /> + </ui:Box> + <ui:Box width="2" /> + </ui:Box> + <ui:Box align="top" fill="white" orient="vertical"> + <ui:Box height="3" /> + <ui:Box id="code" orient="vertical" vshrink="true" /> + <tutor:codeline text="-End of File-" textcolor="darkgray" /> + </ui:Box> thisbox.tabtext = arguments[1]; @@ -19,18 +27,21 @@ } { // constructor - var s = getStream(arguments[0], vexi[""]); - var samplestr = vexi.stream.utf8reader(s).all; - var strbyline = samplestr.split('\n'); - var len = strbyline.length; + const arg0 = arguments[0]; + const f = getStream(arg0, vexi[""]); + const samplestr = vexi.stream.utf8reader(f).all; + const strbyline = samplestr.split('\n'); + const 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); + const c = new tutor.codeline(); + const t = strbyline[i]; + c.text = t.length ? t : " "; + $code.add(c); + const l = new tutor.linenumber(); l.text = i; - $line[i] = l; + $line.add(l); } + location = arg0; } </scrollpane> Modified: branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/linenumber.t =================================================================== --- branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/linenumber.t 2015-08-05 10:26:10 UTC (rev 4809) +++ branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/linenumber.t 2015-08-05 10:27:35 UTC (rev 4810) @@ -1,9 +1,5 @@ -<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" fill="#e0e0e0" fontsize="large" textcolor="darkgray"> +<vexi xmlns:ui="vexi://ui" xmlns="vexi"> + <ui:Box align="right" fontsize="large" textcolor="darkgray" vshrink="true"> font = .font["VeraMono.ttf"]; - </ui:box> + </ui:Box> </vexi> \ No newline at end of file Modified: branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/main.t =================================================================== --- branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/main.t 2015-08-05 10:26:10 UTC (rev 4809) +++ branches/vexi3/org.vexi-vapp.codetutor/src_main/org/vexi/codetutor/main.t 2015-08-05 10:27:35 UTC (rev 4810) @@ -1,39 +1,36 @@ -<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="vexi.widget" - xmlns:util="vexi.util" xmlns:lay="vexi.layout" xmlns:tutor="org.vexi.codetutor"> - <meta:doc> - <author>Charles Goodwin</author> - </meta:doc> +<vexi xmlns:ui="vexi://ui" + xmlns:tutor="org.vexi.codetutor" + xmlns:util="vexi.util" + xmlns:lay="vexi.layout" + xmlns="vexi.widget"> <surface /> - <ui:box orient="vertical"> + <ui:Box orient="vertical"> <toolbar> <menu text="Application"> <menuitem text="Quit"> thisbox.action ++= function(v) { surface.frame.Close = true; return; } </menuitem> </menu> - <ui:box /> + <ui:Box /> </toolbar> <splitpane> <bevel form="down" fill="white" margin="5 0 5 5" hshrink="true" minwidth="150"> - <scrollpane autohide="true" orient="vertical" padding="5"> - <tree id="content" text="Tutorials" /> - <ui:box /> - </scrollpane> + <scrollpane id="index" align="top" autohide="true" orient="vertical" padding="5" /> </bevel> - <ui:box orient="vertical"> - <ui:box fill="#eeeeee" vshrink="true"> - <ui:box width="5" /> + <ui:Box orient="vertical"> + <ui:Box fill="#eeeeee" vshrink="true"> + <ui:Box width="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> + <ui:Box width="5" /> + <ui:Box layout="place"> + <ui:Box id="msg" /> + </ui:Box> + </ui:Box> <tabpane id="view" closeable="true" margin="10"> <tutor:about /> </tabpane> - </ui:box> + </ui:Box> </splitpane> //////// @@ -46,72 +43,82 @@ } $run.action ++= function(v) { - $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); - surface._Press1 ++= clearMessage; + const loc = $view.show.location; + $msg.text = "Opening: "+loc; + if (loc) { + vexi.thread = function() { + var c = util.virtualize..cloneVexi(); + var s = loc.split('.'); + var r = c[""]; + for (var i=0; s.length>i; i++) + r = r[s[i]]; + new r(); + surface.event._Press1 ++= clearMessage; + } } return; } $view.show ++= function(v) { cascade = v; - $run.enabled = v != null and v.canrun and v.stream != null; + $run.enabled = v != null and v.canrun; } //////// // tutorial tree loading - var cards = {}; + const cards = {}; - var openSample = function(v) { - var c = cards[trapee.stream]; + const openCode = function(v) { + const loc = trapee.location; + var c = cards[loc]; if (c == null) { - c = tutor.codeview(vexi.box, [trapee.stream, trapee.text]); - c.canrun = trapee.canrun; - c.stream = trapee.stream; - cards[trapee.stream] = c; + c = new tutor.codeview(loc, trapee.name); + c.canrun = true; + cards[loc] = c; } - if ($view.indexof(c)==-1) - $view[$view.numchildren] = c; + if (!$view.holds(c)) + $view.add(c); $view.show = c; return; } - var ts = vexi..tutorials; - for (var k in ts) { - 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(".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; - } - } - sample.canrun = o == tutorial; - o[index] = sample; + const addTemplate = function(location, template) { + const name = template.substring(0, template.length-2); + const code = new .link(); + code.text = name; + code.name = name; + code.icon = tutor.image.template; + code.location = location; + code.action ++= openCode; + return code; + } + + const processDir = function(dir, path, name) { + const node = new .tree(); + node.text = name; + for (var k,res in dir) { + // ignore hidden files + if (k.indexOf(".")==0) continue; + // identify if file is a template + const isTemplate = k.indexOf(".t") == k.length-2; + if (isTemplate) { + const template_path = path+"."+k.substring(0, k.length-2); + node.add(addTemplate(template_path, k)); + } else if (0 > k.indexOf(".")) { + const dir_path = path+"."+k; + const sub = callee(res, dir_path, k); + if (sub.numchildren) + node[0] = sub; + } } - $content[$content.numchildren] = tutorial; + return node; } + const tutorRoot = vexi..tutorials; + $index.add(processDir(tutorRoot, "tutorials", "Tutorials")); + vexi.ui.frame = thisbox; - </ui:box> + </ui:Box> </vexi> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn