Changeset 36072

Show
Ignore:
Timestamp:
12/05/09 20:07:13 (4 years ago)
Author:
hoge1e3
Message:
 
Location:
lang/haxe/Tonyu2
Files:
1 added
1 removed
8 modified

Legend:

Unmodified
Added
Removed
  • lang/haxe/Tonyu2/Project.hx

    r36059 r36072  
    6565        public var haxeDir(getHaxeDir,null):String ; 
    6666        public function getHaxeDir():String{ return home+"\\haxe";} 
    67         public function haxe2swf() { 
     67        public function haxe2swf():String { 
    6868                var c=new ide.HaxeC(haxeDir, name); 
    69                 c.compile(); 
     69                return c.compile(); 
    7070                /* 
    7171                neko.Sys.setCwd(haxeDir);            
     
    8181                neko.Sys.setCwd(home);    */ 
    8282        } 
    83         public function make() { 
     83        public function make():String { 
    8484                tonyu2haxe(); 
    85                 haxe2swf(); 
     85                var res=haxe2swf(); 
     86                return res; 
    8687        } 
    8788        public function new (home:String, name:String){ 
  • lang/haxe/Tonyu2/Projects/toste/Test.tonyu

    r36071 r36072  
    22 
    33x=0; 
     4y=200; 
    45while (x<200) { 
    56  x=x+1; 
     
    89  update(); 
    910} 
     11while (y>0) { 
     12  y=y-rnd(6);y=y+2; 
     13  update();   
     14} 
  • lang/haxe/Tonyu2/Projects/toste/haxe/Test.hx

    r36071 r36072  
    55      case 0: 
    66        x=0; 
     7        y=200; 
    78        state=1; 
    89      case 1: 
     
    2122        state=1; 
    2223      case 3: 
     24        state=5; 
     25      case 5: 
     26        if ((y>0)) { 
     27          state=6; 
     28        } else { 
     29          state=7; 
     30        } 
     31      case 6: 
     32        y=(y-rnd(6)); 
     33        y=(y+2); 
     34        state=8; 
     35        return; 
     36      case 8: 
     37        state=5; 
     38      case 7: 
    2339        terminateProc(); 
    2440        return; 
  • lang/haxe/Tonyu2/htdocs/Project.class.js

    r36070 r36072  
    11function procAjax(p) { 
     2        if (p==null) return function(){}; 
    23   return function (res) { 
    34     try { 
     
    1213        return ["div",{style:pos(x,y)},cont]; 
    1314} 
     15var curProject; 
     16shortcut.add("Ctrl+W",function(){curProject.saveTonyuSource()}); 
     17shortcut.add("F9",function(){curProject.makeRun()}); 
    1418//alert("P"); 
     19 
     20function dButton(onClick,caption) { 
     21        var b; 
     22        return b=tag("button",{onclick:function () { 
     23                b.target.disabled=true; 
     24                onClick(function () {b.target.disabled=false;}); 
     25        }},caption); 
     26} 
     27 
    1528Project =Class.create({ 
    1629        initialize: function (name) { 
     
    2134        open: function () { 
    2235                var t=this; 
     36                curProject=t; 
    2337                t.editor=tag("textarea",{rows:15 , cols:80}); 
    2438                t.fileList=tag("div",{style:pos(420,10)}); 
    2539                t.swfArea=tag("div",{style:pos(10,10)}); 
    26                 $tag("body").set([["div", "プロジェクト", t.name], 
     40                t.modifiedIndicator=tag("span"); 
     41                t.compileResult=tag("textarea",{rows:5 , cols:80}); 
     42                document.title=t.name +" - Tonyu System"; 
     43                $tag("body").set([ 
    2744                   t.swfArea, 
    2845                   t.fileList,  
    2946                   posDiv(500,10,[ 
    3047                        t.editor, 
    31                     ["button",{onclick:function(){t.saveTonyuSource()}},"SAVE"], 
    32                     ["button",{onclick:function(){t.run()}},"Run"], 
    33                         ["button",{onclick:function(){t.makeRun()}},"Make&Run"] 
     48                    dButton(function(e){t.saveTonyuSource(e)},"SAVE(Ctrl+W)"), 
     49                    dButton(function(e){t.run(e)},"Run"), 
     50                        dButton(function(e){t.makeRun(e)},"Make&Run(F9)"), 
     51                        t.modifiedIndicator,["br"], 
     52                        t.compileResult 
    3453                   ]) 
    3554                ]); 
    3655                attachIndentAdaptor(t.editor.target); 
     56                setInterval(function (){ 
     57                        t.updateModifiedIndicator(); 
     58                }, 50); 
    3759                t.listTonyuSource(); 
    3860        }, 
     
    6890                        t.editor.setAttr("value",res); 
    6991                        t.currentSourceName=name; 
     92                        t.savedCont=res; 
    7093                } 
    7194        }, 
    72         saveTonyuSourceAs: function (cl,cont) { 
     95        updateModifiedIndicator: function () { 
     96                var t=this; 
     97                t.modifiedIndicator.set(t.editorContentModified() ? "*" : ""); 
     98        }, 
     99        editorContentModified: function () { 
     100                var t=this; 
     101                return t.savedCont!=t.editor.getAttr("value"); 
     102        }, 
     103        saveTonyuSourceAs: function (cl,cont,next) { 
    73104                var t=this;      
    74105                new Ajax.Request( 
     
    77108                                method: 'POST',  
    78109                                parameters: {content: cont},  
    79                                 onComplete: procAjax(showResponse) 
     110                                onComplete: procAjax(next2) 
    80111                        }); 
    81                 function showResponse(res) { 
    82                         alert(res); 
     112                function next2(res) { 
     113                        if (res=="OK") { 
     114                                t.savedCont=cont; 
     115                                t.updateModifiedIndicator(); 
     116                                if (next!=null) next(); 
     117                        } 
    83118                } 
    84119        }, 
    85         saveTonyuSource: function () { 
     120        saveTonyuSource: function (next) { 
    86121                var t=this;      
    87122                //alert(t.currentSourceName); 
    88123                if (t.currentSourceName == null) return; 
    89                 t.saveTonyuSourceAs( t.currentSourceName, t.editor.getAttr("value") ); 
     124                t.saveTonyuSourceAs( t.currentSourceName, t.editor.getAttr("value"),next ); 
    90125        }, 
    91         make: function (afterMake) { 
     126        make: function (next) { 
    92127                var t=this;      
     128                t.swfArea.set("Compiling..."); 
    93129                new Ajax.Request( 
    94130                        t.homeURL+"/make" ,  
     
    96132                                method: 'GET',  
    97133                                parameters: {},  
    98                                 onComplete: procAjax(showResponse) 
     134                                onComplete: procAjax(next2) 
    99135                        }); 
    100                 function showResponse(res) { 
    101                         //alert(res); 
    102                         afterMake(res); 
     136                function next2(res) { 
     137                        t.compileResult.setAttr("value",res); 
     138                        if (next) next(res); 
    103139                } 
    104140        }, 
    105         makeRun: function () { 
     141        makeRun: function (next) { 
    106142                var t=this; 
    107                 t.make(function(res) { 
    108                     t.swfArea.set(res); 
    109                         setTimeout(function(){t.run();},10); 
    110                 }); 
     143                if (t.editorContentModified()) { 
     144                        t.saveTonyuSource(domake); 
     145                } else {domake();} 
     146                function domake() { 
     147                        t.make(function(res) { 
     148                                if (res.length<5) {       
     149                                        t.swfArea.set(res); 
     150                                        t.run(next); 
     151                                } else { 
     152                                        if (next) next(); 
     153                                } 
     154                                //setTimeout(function(){t.run();},10); 
     155                        }); 
     156                } 
    111157        }, 
    112         run: function () { 
     158        run: function (next) { 
    113159           var t=this; 
    114160                t.swfArea.set(swf(t.homeURL+"/swf")); 
     161                if (next) next(); 
    115162        } 
    116163}); 
  • lang/haxe/Tonyu2/htdocs/index.html

    r36070 r36072  
    55        <body id="body" onload="boot()">Please wait...</body> 
    66                <script src="htdocs/prototype.js"></script> 
     7                <script src="htdocs/shortcut.js"></script> 
    78                <script src="htdocs/indent.js"></script> 
    89                <script src="htdocs/TagBuilder.class.js"></script> 
  • lang/haxe/Tonyu2/ide/HaxeC.hx

    r36059 r36072  
    88                this.swfName=swfName; 
    99        } 
    10         public function compile() { 
     10        public function compile():String { 
    1111                var home=neko.Sys.getCwd(); 
    1212                neko.Sys.setCwd(dir);        
     
    2727                trace(haxePath+" "+args); 
    2828                var p=new neko.io.Process(haxePath,args); 
     29                var stderr=""; 
    2930                while (true) { 
    3031                        try { 
    3132                                var s=p.stderr.readLine(); 
     33                                stderr+=s; 
    3234                                trace(s); 
    3335                        } catch (e:haxe.io.Eof) {break;} 
     
    3537                p.close(); 
    3638                trace("setCWD "+home); 
    37                 neko.Sys.setCwd(home);     
     39                neko.Sys.setCwd(home);   
     40                        return stderr; 
    3841        } 
    3942        static public function init() { 
  • lang/haxe/Tonyu2/ide/ProjectProcessor.hx

    r36049 r36072  
    4040        } 
    4141        function make() { 
    42                 project.make(); 
    43                 res.content="Build end"; 
     42                var makeR=project.make(); 
     43                res.content=makeR; //"Build end"; 
    4444        }        
    4545        function tonyuSrc() {