blob: 5d819efa883ed48916528e1c54ad052bf880f0ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package require pd_menucommands
namespace eval new-from-template {
variable template
variable defaultfolder [file join $::env(HOME) Documents]
}
proc ::new-from-template::paste_template {} {
variable template
variable defaultfolder
if { ! [file isdirectory $defaultfolder]} {set defaultfolder $::env(HOME)}
pdsend "pd filename [_ "new-from-template"] [enquote_path $defaultfolder]"
foreach line [split [read [open $template r]] "\n"] {
pdsend $line
}
pdsend "#X pop 1"
}
proc ::new-from-template::create {mymenu} {
variable template
set inserthere [$mymenu index [_ "Open"]]
$mymenu insert $inserthere command -label [_ "New from template"] \
-command {::new-from-template::paste_template}
set template \
[file join $::current_plugin_loadpath template.pd]
}
::new-from-template::create .menubar.file
|