[PD-cvs] pd/src desire.tk,1.1.2.297,1.1.2.298
Mathieu Bouchard
matju at users.sourceforge.net
Tue Aug 8 18:22:49 CEST 2006
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9272
Modified Files:
Tag: devel_0_39
desire.tk
Log Message:
fixed bugs in reading and writing of .pdrc
Index: desire.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v
retrieving revision 1.1.2.297
retrieving revision 1.1.2.298
diff -C2 -d -r1.1.2.297 -r1.1.2.298
*** desire.tk 8 Aug 2006 10:26:39 -0000 1.1.2.297
--- desire.tk 8 Aug 2006 16:22:47 -0000 1.1.2.298
***************
*** 4944,4954 ****
listbox $f.a.list -width 33 -height 10 -yscrollcommand "$f.a.yscroll set" \
-activestyle none -xscrollcommand "$f.a.xscroll set"
! foreach line $_($self:$name) {$f.a.list insert end $line}
! # save the listbox path at _($self:$name) instead
! set _($self:$name) $f.a.list
scrollbar $f.a.yscroll -command "$f.a.list yview"
scrollbar $f.a.xscroll -command "$f.a.list xview" -orient horizontal
! pack $f.a.xscroll -side bottom -fill x
pack $f.a.list -side left -fill both -expand 1
pack $f.a.yscroll -side left -fill y
--- 4944,4955 ----
listbox $f.a.list -width 33 -height 10 -yscrollcommand "$f.a.yscroll set" \
-activestyle none -xscrollcommand "$f.a.xscroll set"
! #foreach line $@$name {$f.a.list insert end $line}
! foreach line $_($self:$name) {$f.a.list insert end $line} ;# bug in objective.tcl
! # save the listbox path at @$name instead
! set @$name $f.a.list
scrollbar $f.a.yscroll -command "$f.a.list yview"
scrollbar $f.a.xscroll -command "$f.a.list xview" -orient horizontal
! pack $f.a.xscroll -side bottom -fill x
pack $f.a.list -side left -fill both -expand 1
pack $f.a.yscroll -side left -fill y
***************
*** 4960,4966 ****
entry $f.b.entry.add -width 15 -borderwidth 5 -relief ridge
! bind $f.b.entry.add <Return> "$self entry_set2listbox $f.a.list $f.b.entry.add"
pack $f.b.entry.add -side left
! button $f.b.entry.3 -command "$self entry_set2listbox $f.a.list $f.b.entry.add" -text "add" -width 6
balloon $f.b.entry.3 "add the name you typed to the list"
pack $f.b.entry.3 -side left
--- 4961,4967 ----
entry $f.b.entry.add -width 15 -borderwidth 5 -relief ridge
! bind $f.b.entry.add <Return> "$self lib_add $f"
pack $f.b.entry.add -side left
! button $f.b.entry.3 -command "$self lib_add $f" -text "add" -width 6
balloon $f.b.entry.3 "add the name you typed to the list"
pack $f.b.entry.3 -side left
***************
*** 5019,5023 ****
#catch {$f.label configure -width 45 -anchor e}
if {!$no_max_label} {
! catch {$f.label configure -width $_($self:max_label) -anchor e}
}
}
--- 5020,5024 ----
#catch {$f.label configure -width 45 -anchor e}
if {!$no_max_label} {
! catch {$f.label configure -width $_($self:max_label) -anchor e}
}
}
***************
*** 5186,5189 ****
--- 5187,5191 ----
def PagedDialog dir_select {listbox} {
set dir [tk_chooseDirectory -initialdir ~ -title "Choose a directory" -parent .$self]
+ if {$dir == ""} {return}
$listbox insert end $dir
$listbox yview end
***************
*** 5191,5199 ****
}
! def PagedDialog entry_set2listbox {listbox entry} {
set var [$entry get]
if {$var != ""} {$listbox insert end $var}
$listbox yview end
! focus .$self
}
--- 5193,5204 ----
}
! def PagedDialog lib_add {f} {
! set listbox $f.a.list
! set entry $f.b.entry.add
set var [$entry get]
if {$var != ""} {$listbox insert end $var}
$listbox yview end
! $entry delete 0 end
! focus $entry
}
***************
*** 5320,5325 ****
set fd [open $cmdline(rcfilename) "RDONLY CREAT"]
#set contents [split [string map {"\n" " "} [read $fd]] " "]
! set contents [split [read $fd] "\n"]
close $fd
foreach {type names} $pdrc_options {
switch $type {
--- 5325,5334 ----
set fd [open $cmdline(rcfilename) "RDONLY CREAT"]
#set contents [split [string map {"\n" " "} [read $fd]] " "]
! set contents {}
! foreach line [split [read $fd] "\n"] {
! if {[string index $line 0] != "#"} {lappend contents $line}
! }
close $fd
+ set contents [concat [join $contents " "]] ;# concat casts to list type (faster)
foreach {type names} $pdrc_options {
switch $type {
***************
*** 5334,5339 ****
set i 0
! foreach line $contents {
! foreach {op setting} $line {
if {![info exists pdrc_options_h($op)]} {
error "unknown option: $op"
--- 5343,5350 ----
set i 0
! while {$i < [llength $contents]} {
! set op [lindex $contents $i]
! puts "op ::: $op"
! if {[string length $op]==0} {break}
if {![info exists pdrc_options_h($op)]} {
error "unknown option: $op"
***************
*** 5341,5371 ****
mset {type name} $pdrc_options_h($op)
switch $type {
! folders {lappend @$name [lindex $line 1]}
! libraries {lappend @$name [lindex $line 1]}
! files {incr i; lappend @$name [lindex $contents $i]}
! radio {set @$name $line}
! #void {set @$name 1}
! default {set @$name [lindex $contents 1]}
! }
}
!
}
-
- #while {$i < [llength $contents]} {
- # set op [lindex $contents $i]
- # puts "op ::: $op"
- # if {[string length $op]==0} {break}
- # if {![info exists pdrc_options_h($op)]} {
- # error "unknown option: $op"
- # }
- # mset {type name} $pdrc_options_h($op)
- # switch $type {
- # folders {incr i; lappend @$name [lindex $contents $i]}
- # files {incr i; lappend @$name [lindex $contents $i]}
- # void {set @$name 1}
- # default {incr i; set @$name [lindex $contents $i]}
- # }
- # incr i
- #}
}
--- 5352,5364 ----
mset {type name} $pdrc_options_h($op)
switch $type {
! folders {incr i; lappend @$name [lindex $contents $i]}
! libraries {incr i; lappend @$name [lindex $contents $i]}
! files {incr i; lappend @$name [lindex $contents $i]}
! radio { set @$name [lindex $contents $i]}
! void { set @$name 1}
! default {incr i; set @$name [lindex $contents $i]}
}
! incr i
}
}
***************
*** 5373,5376 ****
--- 5366,5370 ----
global pdrc_options pdrc_options_h cmdline
set fd [open $cmdline(rcfilename) w]
+ #set fd stdout; puts "WOULD SAVE:"
foreach {type names} $pdrc_options {
switch $type {
***************
*** 5378,5397 ****
default {set name [lindex [split $names |] 0]}
}
! set v $@$name
switch $type {
! folders {foreach item [$v get 0 [$v size]] {puts $fd "$name $item"}}
! libraries {foreach item [$v get 0 [$v size]] {puts $fd "$name $item"}}
! #files {foreach x $v {puts $fd "$name $x"}}
! #void {if {[string length $v]} {if {$v} {puts $fd $name}}}
#radio {if {$v} {set t [lindex $names $v]; puts [split $t |]}}
! radio {puts $fd "$v"}
default {if {[string length $v]} {puts $fd "$name $v"}}
}
}
close $fd
}
def* ServerPrefsDialog default {} {
}
! def ServerPrefsDialog init {} {
global pdrc_options
$self read
--- 5372,5393 ----
default {set name [lindex [split $names |] 0]}
}
! #set v $@$name
! set v $_($self:$name) ;# bug in objective.tcl ?
switch $type {
! folders {foreach item $v {puts $fd "$name $item"}}
! libraries {foreach item $v {puts $fd "$name $item"}}
! #files {foreach item $v {puts $fd "$name $item"}}
! void {if {$v != ""} {if {$v} {puts $fd $name}}}
#radio {if {$v} {set t [lindex $names $v]; puts [split $t |]}}
! radio {puts $fd "$v"}
default {if {[string length $v]} {puts $fd "$name $v"}}
}
}
close $fd
+ # puts "THE END"
}
def* ServerPrefsDialog default {} {
}
! def* ServerPrefsDialog init {} {
global pdrc_options
$self read
More information about the Pd-cvs
mailing list