+proc hide-path {seq} {
+ upvar \#0 map-$seq map
+ set tl .map-$seq
+ $tl.map delete path
+ unset map(path)
+ foreach i {2 3 11} {
+ $tl.menu.path entryconfigure $i -state disabled
+ }
+}
+
+proc path-to-text {seq} {
+ upvar \#0 map-$seq map
+ set t {}
+ foreach n $map(path) {
+ append t [world-summary $n] "\n"
+ }
+ return $t
+}
+
+proc save-path {seq} {
+ set file [tk_getSaveFile -initialfile "path" -title "Save path"]
+ if {[string equal $file ""]} { return }
+ if {[catch { write-file $file [path-to-text $seq] auto } err]} {
+ moan $err
+ }
+}
+
+proc list-path {seq} {
+ upvar \#0 map-$seq map
+ set tl .map-$seq.path
+ if {[winfo exists $tl]} {
+ # raise $tl
+ } else {
+ toplevel $tl
+ wm title $tl "Path listing"
+ scrollbar $tl.hscr -orient horizontal -command [list $tl.text xview]
+ scrollbar $tl.vscr -orient vertical -command [list $tl.text yview]
+ text $tl.text -wrap none -width 80 -height 20 \
+ -xscrollcommand [list $tl.hscr set] \
+ -yscrollcommand [list $tl.vscr set]
+ grid configure $tl.text -row 0 -column 0 -sticky nsew
+ grid configure $tl.hscr -row 1 -column 0 -sticky ew
+ grid configure $tl.vscr -row 0 -column 1 -sticky ns
+ grid rowconfigure $tl 0 -weight 1
+ grid columnconfigure $tl 0 -weight 1
+ }
+ $tl.text configure -state normal
+ $tl.text delete 1.0 end
+ $tl.text insert end [path-to-text $seq]
+ $tl.text configure -state disabled
+}
+
+proc load-path {seq} {
+ upvar \#0 map-$seq map
+ set tl .map-$seq
+ set file [tk_getOpenFile -title "Load path"]
+ if {[catch {
+ set f [open $file]
+ set path {}
+ while {[gets $f line] >= 0} {
+ if {[regexp {^\s*(\#|$)} $line]} { continue }
+ if {[regexp {\m[0-9a-f]{12}\M} $line p]} {
+ } else {
+ set p [parse-planet-spec $map(galaxy) [lindex $line 0]]
+ if {[string equal $p ""]} {
+ error "unrecognized path line `$line'"
+ }
+ }
+ lappend path $p
+ }
+ if {![in-galaxy-p $map(galaxy) $path]} {
+ error "not all worlds in this galaxy"
+ }
+ close $f
+ } err]} {
+ catch { close $f }
+ moan $err
+ return
+ }
+ set map(path) $path
+ foreach i {2 3 11} {
+ $tl.menu.path entryconfigure $i -state normal
+ }
+ show-path $seq
+}
+