Changeset 701

Show
Ignore:
Timestamp:
07/25/07 02:44:24 (1 year ago)
Author:
Gregor
Message:

Now creates default content for new files.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • other/dps/trunk/dsssps/components.d

    r700 r701  
    22 
    33import tango.io.Console; 
     4import tango.io.File; 
    45 
    56import tango.sys.Environment; 
     
    1718} 
    1819 
     20/// A component for files 
    1921class CompFile : Component { 
    2022    /// Create with a given filename 
     
    4042} 
    4143 
     44/// A component for files which can be dsss-build'd 
    4245class CompFileBuild : CompFile { 
    4346    this(char[] name) { super(name); } 
     
    7073        // FIXME 
    7174        (new DPSProcessWindow("dsss build " ~ fname ~ " -v")).Show(true); 
     75    } 
     76} 
     77 
     78/// Component for potentially new files 
     79class CompFileNew : CompFile { 
     80    this(char[] name) { super(name); } 
     81 
     82    override void activate(wxTreeCtrl tree, wxEvent e) 
     83    { 
     84        // generate the module name 
     85        char[] mod = name.dup; 
     86        foreach (i, c; mod) { 
     87            if (c == '/') { 
     88                mod[i] = '.'; 
     89            } else if (c == '.') { 
     90                // end 
     91                mod = mod[0..i]; 
     92                break; 
     93            } 
     94        } 
     95 
     96        // then fill out the basic file 
     97        (new File(name)).write("module " ~ mod ~ ";\n"); 
     98 
     99        // now edit it 
     100        super.activate(tree, e); 
    72101    } 
    73102} 
  • other/dps/trunk/dsssps/dps.d

    r700 r701  
    134134                        tree.AppendItem(notfound, 
    135135                            file, 1, -1, 
    136                             new CompFile(file)); 
     136                            new CompFileNew(file)); 
    137137                    } 
    138138                }