2 # show your vessels on a map
4 # This is part of ypp-sc-tools, a set of third-party tools for assisting
5 # players of Yohoho Puzzle Pirates.
7 # Copyright (C) 2009 Ian Jackson <ijackson@chiark.greenend.org.uk>
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
23 # are used without permission. This program is not endorsed or
24 # sponsored by Three Rings.
32 #---------- general utilities ----------
37 if {$debug} { puts "DEBUG $m" }
41 puts stderr "where-vessels: bad usage: $m"
50 #---------- expecting certain errors ----------
52 proc errexpect-setline {lno line} {
53 glset errexpect_lno $lno
54 glset errexpect_line $line
57 proc errexpect-error {m} {
58 global errexpect_line errexpect_lno
59 error $m "$errexpect_line\n" [list YARRG-ERREXPECT $errexpect_lno]
62 proc errexpect-arrayget {arrayvar key} {
64 upvar 1 ${arrayvar}($key) v
65 if {[info exists v]} { return $v }
66 errexpect-error "undefined $key"
69 proc errexpect-arrayget-boolean {arrayvar key} {
70 switch -exact [uplevel 1 [list errexpect-arrayget $arrayvar $key]] {
73 default { errexpect-error "unexpected $key" }
77 proc errexpect-catch {code} {
78 global errorInfo errorCode
82 debug "ERREXPECT CATCH |$rc|$rv|$errorCode|$errorInfo|"
83 if {$rc==1 && ![string compare YARRG-ERREXPECT [lindex $errorCode 0]]} {
84 return [list 1 $rv [lindex $errorCode 1] $errorInfo]
88 return -code $rc -errorinfo $errorInfo -errorcode $errorCode $rv
92 #---------- argument parsing ----------
96 if {$ai >= [llength $argv]} {
97 badusage "option [lindex $argv [expr {$ai-1}]] needs a value"
99 set v [lindex $argv $ai]
104 set notes_loc vessel-notes
105 set scraper {./yppedia-ocean-scraper --chart}
112 while {[regexp {^\-} [set arg [lindex $argv $ai]]]} {
114 switch -exact -- $arg {
116 --pirate { glset pirate [string totitle [nextarg]] }
117 --ocean { glset ocean [string totitle [nextarg]] }
118 --clipboard-file { load-clipboard-file [nextarg] }
119 --local-html-dir { lappend scraper --local-html-dir=[nextarg] }
120 --notes { glset notes_loc [nextarg] }
121 --debug { incr debug }
122 default { badusage "unknown option $arg" }
125 set argv [lrange $argv $ai end]
126 if {[llength $argv]} { badusage "non-option args not allowed" }
129 proc argdefaults {} {
130 global ocean notes_loc pirate scraper
131 if {![info exists ocean] || ![info exists pirate]} {
132 set cmd {./yarrg --find-window-only --quiet}
133 if {[info exists ocean]} { lappend cmd --ocean $ocean }
134 if {[info exists pirate]} { lappend cmd --pirate $pirate }
135 manyset [split [eval exec $cmd] " "] ocean pirate
137 lappend scraper $ocean
141 #---------- loading and parsing the vessel notes ----------
144 global notes_loc notes_data
145 if {[regexp {^\w+\:} $notes_loc]} {
147 debug "FETCHING NOTES $notes_loc"
148 set req [::http::geturl $notes_loc]
149 switch -glob [::http::status $req].[::http::ncode $req] {
151 ok.* { error "retrieving vessel-notes: [::http::code $req]" }
152 * { error "Retrieving vessel-notes: [::http::error $req]" }
154 set newdata [::http::data $req]
157 debug "READING NOTES $notes_loc"
158 set vn [open $notes_loc]
159 set newdata [read $vn]
162 set notes_data $newdata
165 proc parse-notes {} {
166 global notes_data notes
167 catch { unset notes }
170 foreach l [split $notes_data "\n"] {
172 errexpect-setline $lno $l
173 set l [string trim $l]
174 if {![string length $l]} continue
175 if {[regexp {^\#} $l]} continue
176 if {![regexp -expanded \
177 {^ (\d+) (?: \s+([^=]*?) )? \s* =
179 (?: \s+ (\S+) )?)? $} \
180 $l dummy vid vname owner note]} {
181 errexpect-error "badly formatted"
183 set vname [string trim $vname]
184 if {[info exists notes($vid)]} {
185 errexpect-error "duplicate vesselid $vid"
187 set notes($vid) [list $lno $vname $owner $note]
191 proc note-info {lno vid name island description} {
193 lappend note_infos [list $lno $vid $name $island $description]
196 proc canvas-horiz-stack {xvar y type args} {
199 set id [eval $canvas create $type $x $y $args]
200 set bbox [$canvas bbox $id]
201 set x [lindex $bbox 2]
205 proc display-note-infos {} {
206 global note_infos note_missings notes
208 set nmissing [llength $note_missings]
209 debug "display-note-infos $nmissing [array size notes]"
211 if {[llength $note_infos]} {
212 set tiny "[llength $note_infos] warning(s)"
213 } elseif {$nmissing && [array size notes]} {
214 set tiny "$nmissing missing"
221 foreach info $note_infos {
222 manyset $info lno vid name island description
223 append infodata "vessel"
224 append infodata " $vid"
225 if {[string length $name]} { append infodata " $name" }
226 if {[string length $island]} { append infodata " ($island)" }
227 append infodata ": " $description "\n"
231 if {[string length $infodata]} { append infodata "\n" }
232 append infodata "$nmissing vessel(s) not mentioned in notes:\n"
234 foreach info [lsort $note_missings] {
235 manyset $info island name vid
236 if {[string compare $island $last_island]} {
237 append infodata "# $island:\n"
238 set last_island $island
240 append infodata [format "%-9d %-29s =\n" $vid $name]
244 parser-control-failed-core .cp.ctrl.notes notes \
247 "[llength $note_infos] warning(s);\
248 $nmissing vessel(s) missing" \
249 "Full description of warnings and missing vessels:" \
253 #---------- vessel properties ----------
255 proc vesselclasses-init {} {
256 global vc_game2code vc_code2abbrev vc_code2full vc_codes
261 longship dm ls Longship
262 baghlah em bg Baghlah
263 merchbrig fm mb {Merchant Brig}
264 warbrig gm wb {War Brig}
266 warfrig im wf {War Frigate}
267 merchgal jm mg {Merchant Galleon}
268 grandfrig km gf {Grand Frigate}
271 foreach {game code abbrev full} $vcl {
272 lappend vc_codes $code
273 set vc_game2code($game) $code
274 set vc_code2abbrev($code) $abbrev
275 set vc_code2full($code) $full
276 image create bitmap ship-icon/$abbrev -file iconsdir/$abbrev.xbm
280 proc code2abbrev-lock {lockown} {
281 manyset [split $lockown ""] lock notown
282 append abbrev [lindex {* + -} $lock]
283 append abbrev [lindex {= - ?} [regsub {\D} $notown 2]]
286 proc code2abbrev {code} {
287 global vc_code2abbrev
289 manyset [split $code _] inport class subclass lockown xabbrev
292 append abbrev [lindex {? {}} $inport]
293 append abbrev $vc_code2abbrev($class)
294 append abbrev $subclass
295 append abbrev [code2abbrev-lock $lockown]
296 append abbrev $xabbrev
298 debug "CODE2ABBREV $code $abbrev"
302 proc show-report-decode {code} {
305 manyset [split $code _] inport classcode subclass lockown xabbrev
306 manyset [split $lockown ""] lock notown
308 report-set inport [lindex {{At Sea} {In port}} $inport]
309 report-set class $vc_code2full($classcode)
311 switch -exact $subclass {
312 {} { report-set subclass {Ordinary} }
313 F { report-set subclass {"Frost class"} }
314 default { report-set subclass "Subclass \"$subclass\"" }
317 report-set lock [lindex {
318 {Battle ready} {Unlocked} {Locked}
321 switch -exact $notown {
322 0 { report-set own "Yours" }
323 1 { report-set own "Other pirate's" }
324 U { report-set own "Owner not known" }
325 M { report-set own "Missing from notes" }
326 default { report-set own "?? $notown" }
329 if {[string length $xabbrev]} {
330 report-set xabbrev "Notes flags: $xabbrev"
332 report-set xabbrev "No flags in notes"
336 #---------- filtering ----------
340 proc filter-values/size {} { global vc_codes; return $vc_codes }
341 proc filter-map/size {code} { upvar #0 vc_code2abbrev($code) abb; return $abb }
342 proc filter-default/size {code} { return 1 }
343 proc filter-says-yes/size {codel} {
344 set sizecode [lindex $codel 1]
345 upvar #0 filter_size($sizecode) yes
349 proc filter-values/lockown {} {
352 lappend vals "$lv$ov"
357 proc filter-map/lockown {lockown} { return [code2abbrev-lock $lockown] }
358 proc filter-default/lockown {lockown} {
359 return [regexp {^[01]|^2[^1]} $lockown]
361 proc filter-says-yes/lockown {codel} {
362 set lockown [lindex $codel 3]
363 regsub -all {\D} $lockown X lockown
364 upvar #0 filter_lockown($lockown) yes
368 proc filter-validate/xabbre {re} {
372 regsub {^.*:\s*} $emsg {} emsg
373 regsub {^.*(.{30})$} $emsg {\1} emsg
378 proc filter-says-yes/xabbre {codel} {
380 set xabbrev [lindex $codel 4]
381 return [regexp -- $filter_xabbre $xabbrev]
384 proc filter-tickbox-flip {fil} {
385 upvar #0 filter_$fil vars
386 set values [filter-values/$fil]
387 foreach val $values {
388 set vars($val) [expr {!$vars($val)}]
393 proc make-tickbox-filter {fil label rows inrow} {
394 upvar #0 filter_$fil vars
395 set fw [make-filter tickbox $fil $label frame]
396 set values [filter-values/$fil]
397 set nvalues [llength $values]
399 set inrow [expr {($nvalues + $rows) / $rows}]
402 for {set ix 0} {$ix < $nvalues} {incr ix} {
403 set val [lindex $values $ix]
404 set vars($val) [filter-default/$fil $val]
405 checkbutton $fw.$ix -variable filter_${fil}($val) \
406 -text [filter-map/$fil $val] -font fixed \
407 -command redraw-needed
408 grid configure $fw.$ix -sticky sw \
409 -row [expr {$ix / $inrow}] \
410 -column [expr {$ix % $inrow}]
412 button $fw.invert -text flip -command [list filter-tickbox-flip $fil] \
414 grid configure $fw.invert -sticky se \
415 -row [expr {$rows-1}] \
416 -column [expr {$inrow-1}]
419 proc entry-filter-changed {fw fil n1 n2 op} {
421 upvar #0 filter_$fil realvar
422 upvar #0 filterentered_$fil entryvar
423 global def_background
424 debug "entry-filter-changed $fw $fil $entryvar"
426 set error [filter-validate/$fil $entryvar]
427 if {[string length $error]} {
428 $fw.error configure -text $error -foreground white -background red
430 $fw.error configure -text { } -background $def_background
431 set realvar $entryvar
435 puts stderr "FILTER CHECK ERROR $emsg $errorInfo"
439 proc make-entry-filter {fil label def} {
440 global filterentered_$fil
441 upvar #0 filter_$fil realvar
443 set fw [make-filter entry $fil $label frame]
444 entry $fw.entry -textvariable filterentered_$fil
446 glset def_background [$fw.error cget -background]
447 trace add variable filterentered_$fil write \
448 [list entry-filter-changed $fw $fil]
449 pack $fw.entry $fw.error -side top -anchor w
452 proc make-filter {kind fil label ekind} {
454 label .filter.lab_$fil -text $label -justify left
457 set nfilters [llength $filters]
458 grid configure .filter.lab_$fil -row $nfilters -column 0 -sticky nw -pady 4
459 grid configure .filter.$fil -row $nfilters -column 1 -sticky w -pady 3
463 proc make-filters {} {
464 make-tickbox-filter size Size 2 0
465 make-tickbox-filter lockown "Lock/\nowner" 2 6
466 make-entry-filter xabbre "Flags\n regexp" {}
469 proc filters-say-yes {code} {
471 debug "filters-say-yes $code"
472 foreach fil $filters {
473 if {![filter-says-yes/$fil [split $code _]]} { return 0 }
478 #---------- loading and parsing the clipboard (vessel locations) ----------
481 global pirate notes_used note_missings newnotes
485 lappend codel [errexpect-arrayget-boolean vi inPort]
487 set gameclass [errexpect-arrayget vi vesselClass]
488 upvar #0 vc_game2code($gameclass) class
489 if {![info exists class]} { errexpect-error "unexpected vesselClass"}
492 set subclass [errexpect-arrayget vi vesselSubclass]
493 switch -exact $subclass {
494 null { lappend codel {} }
495 icy { lappend codel F }
496 default { lappend codel ($subclass) }
499 switch -exact [errexpect-arrayget vi isLocked]/[ \
500 errexpect-arrayget vi isBattleReady] {
501 true/false { set lock 2 }
502 false/false { set lock 1 }
503 false/true { set lock 0 }
504 default { errexpect-error "unexpected isLocked/isBattleReady" }
507 set vid [errexpect-arrayget vi vesselId]
508 upvar #0 notes($vid) note
509 set realname [errexpect-arrayget vi vesselName]
510 set island [errexpect-arrayget vi islandName]
514 if {[info exists note]} {
515 manyset $note lno notename owner xabbrev
516 if {[string compare -nocase $realname $notename]} {
517 note-info $lno $vid $realname $island \
518 "notes say name is $notename"
520 if {[string length $owner]} {
521 if {![string compare $owner $pirate]} {
529 append abbrev $xabbrev
530 set notes_used($vid) 1
534 lappend note_missings [list $island $realname $vid]
537 lappend codel "$lock$notown" $xabbrev
538 lappend newnotes [list $vid $realname $owner $xabbrev]
539 set kk "$island [join $codel _]"
540 upvar #0 found($kk) k
541 lappend k [list $vid $realname]
543 debug "CODED $kk $vid $realname"
547 proc parse-clipboard {} {
548 global clipboard found notes notes_used newnotes
550 catch { unset found }
551 catch { unset notes_used }
553 glset note_missings {}
557 set itemre { (\w+) = ([^=]*) }
558 set manyitemre "^\\\[ $itemre ( (?: ,\\ $itemre)* ) \\]\$"
562 foreach l [split $clipboard "\n"] {
564 errexpect-setline $lno $l
565 if {![string length $l]} continue
568 if {![regexp -expanded $manyitemre $l dummy \
569 thiskey thisval rhs]} {
570 errexpect-error "badly formatted"
572 set vi($thiskey) $thisval
573 if {![string length $rhs]} break
574 regsub {^, } $rhs {} rhs
580 if {[llength $newnotes]} {
581 foreach vid [lsort [array names notes]] {
582 if {![info exists notes_used($vid)]} {
583 manyset $notes($vid) lno notename
584 note-info $lno $vid $notename {} \
585 "vessel in notes no longer found"
591 proc load-clipboard-file {fn} {
593 glset clipboard [read $f]
598 #---------- loading and parsing the chart ----------
602 debug "FETCHING CHART"
603 set chart [eval exec $scraper [list | perl -we {
608 yppedia_chart_parse(\*STDIN, (new IO::File ">/dev/null"),
609 sub { sprintf "%d %d", @_; },
610 sub { printf "archlabel %d %d %s\n", @_; },
611 sub { printf "island %s %s\n", @_; },
612 sub { printf "league %s %s %s.\n", @_; },
613 sub { printf STDERR "warning: %s: incomprehensible: %s", @_; }
615 STDOUT->error and die $!;
624 return [expr {$c * $scale}]
627 proc chart-got/archlabel {args} { }
628 proc chart-got/island {x y args} {
629 # debug "ISLE $x $y $args"
630 global canvas isleloc
631 set isleloc($args) [list $x $y]
633 # $canvas create oval \
634 # [expr {[coord $x] - $sz}] [expr {[coord $y] - $sz}] \
635 # [expr {[coord $x] + $sz}] [expr {[coord $y] + $sz}] \
637 $canvas create text [coord $x] [coord $y] \
638 -text $args -anchor s
640 proc chart-got/league {x1 y1 x2 y2 kind} {
641 # debug "LEAGUE $x1 $y1 $x2 $y2 $kind"
643 set l [$canvas create line \
644 [coord $x1] [coord $y1] \
645 [coord $x2] [coord $y2]]
646 if {![string compare $kind .]} {
647 $canvas itemconfigure $l -dash .
651 proc redraw-needed {} {
653 debug "REDRAW NEEDED"
654 if {[info exists redraw_after]} return
655 set redraw_after [after 250 draw]
659 global chart found isleloc canvas redraw_after
660 global vc_code2abbrev
662 catch { after cancel $redraw_after }
663 catch { unset redraw_after }
667 foreach l [split $chart "\n"] {
668 # debug "CHART-GOT $l"
669 set proc [lindex $l 0]
670 eval chart-got/$proc [lrange $l 1 end]
673 set lastislandname {}
674 foreach key [lsort [array names found]] {
675 set c [llength $found($key)]
676 # debug "SHOWING $key $c"
677 regexp {^(.*) (\S+)$} $key dummy islandname code
679 if {![filters-say-yes $code]} continue
681 set abbrev [code2abbrev $code]
683 if {[string compare $lastislandname $islandname]} {
684 manyset $isleloc($islandname) x y
687 set lastislandname $islandname
691 regsub -all {[0-9]} $text {} text
693 set qty [format "%2d" $c]
695 set qty [format " " $c]
698 regsub {[a-z][a-z]} $text {} text
702 set tid [canvas-horiz-stack stackx $y \
703 text -anchor nw -font fixed -text $qty]
705 canvas-horiz-stack stackx [expr {$y+2}] \
706 image -anchor nw -image ship-icon/$vc_code2abbrev([lindex [split $code _] 1])
708 canvas-horiz-stack stackx $y \
709 text -anchor nw -font fixed -text $text
711 set bbox [$canvas bbox $tid]
712 set ny [lindex $bbox 3]
714 set bid [$canvas create rectangle \
719 $canvas lower $bid $tid
721 $canvas bind $tid <ButtonPress> [list show-report $islandname $code]
722 $canvas bind $bid <ButtonPress> [list show-report $islandname $code]
723 manyset $bbox dummy dummy dummy y
727 panner::updatecanvas-bbox .cp.ctrl.pan
731 #---------- parser error reporting ----------
733 proc parser-control-create {w base invokebuttontext etl_title} {
735 button $w.do -text $invokebuttontext -command invoke_$base
737 frame $w.resframe -width 120 -height 32
738 button $w.resframe.res -text {} -anchor nw \
739 -padx 1 -pady 1 -borderwidth 0 -justify left
740 glset deffont_$base [$w.resframe.res cget -font]
741 place $w.resframe.res -relx 0.5 -y 0 -anchor n
744 pack $w.resframe -side top -expand y -fill both
749 wm title $eb "where-vessels - $etl_title"
751 label $eb.title -text $etl_title
752 pack $eb.title -side top
754 button $eb.close -text Close -command [list wm withdraw $eb]
755 pack $eb.close -side bottom
757 frame $eb.emsg -bd 2 -relief groove
758 label $eb.emsg.lab -text "Error:"
759 text $eb.emsg.text -height 1
760 pack $eb.emsg.text -side bottom
761 pack $eb.emsg.lab -side left
763 pack $eb.emsg -side top -pady 2
765 frame $eb.text -bd 2 -relief groove
766 pack $eb.text -side bottom -pady 2
770 text $eb.text.text -width 85 \
771 -xscrollcommand [list $eb.text.xscroll set] \
772 -yscrollcommand [list $eb.text.yscroll set]
773 $eb.text.text tag configure error \
774 -background red -foreground white
776 scrollbar $eb.text.xscroll -orient horizontal \
777 -command [list $eb.text.text xview]
778 scrollbar $eb.text.yscroll -orient vertical \
779 -command [list $eb.text.text yview]
781 grid configure $eb.text.lab -row 0 -column 0 -sticky w
782 grid configure $eb.text.text -row 1 -column 0
783 grid configure $eb.text.yscroll -sticky ns -row 1 -column 1
784 grid configure $eb.text.xscroll -sticky ew -row 2 -column 0
787 proc parser-control-ok-core {w base background show} {
788 debug "parser-control-ok-core $w $base $background $show"
789 upvar #0 deffont_$base deffont
790 $w.resframe.res configure \
791 -background $background -disabledforeground black -font $deffont \
792 -state disabled -command {} \
795 proc parser-control-ok {w base show} {
796 parser-control-ok-core $w $base green $show
798 proc parser-control-none {w base show} {
799 parser-control-ok-core $w $base blue $show
801 proc parser-control-failed-core {w base foreground background smallfont
802 tiny summary fulldesc fulldata} {
803 debug "parser-control-failed-core $w $base $summary $fulldesc"
804 upvar #0 deffont_$base deffont
807 $eb.emsg.text delete 0.0 end
808 $eb.emsg.text insert end $summary
810 $eb.text.lab configure -text $fulldesc
811 $eb.text.text delete 0.0 end
812 $eb.text.text insert end $fulldata
814 regsub -all {.{18}} $tiny "&\n" ewrap
822 $w.resframe.res configure \
823 -background $background -foreground $foreground -font $font \
824 -state normal -command [list wm deiconify $eb] \
828 proc parser-control-failed-expected {w base emsg lno ei fulldesc newdata} {
831 set line [lindex [split $ei "\n"] 0]
832 debug "parser-control-failed-expected: $w $base: $lno: $emsg\n $line"
834 parser-control-failed-core $w $base \
836 "err: [string trim $emsg]: \"$line\"" \
837 "at line $lno: $emsg" \
840 $eb.text.text tag add error $lno.0 $lno.end
841 $eb.text.text see $lno.0
843 proc parser-control-failed-unexpected {w base emsg ei} {
845 parser-control-failed-core $w $base \
847 $emsg $emsg "Details and stack trace:" $ei
850 proc reparse {base varname old fulldesc okshow noneshow parse ok} {
851 upvar #0 $varname var
852 manyset [errexpect-catch {
854 if {[string length [string trim $var]]} {
855 parser-control-ok .cp.ctrl.$base $base $okshow
857 parser-control-none .cp.ctrl.$base $base $noneshow
859 }] failed emsg lno ei
861 parser-control-failed-expected .cp.ctrl.$base $base \
862 $emsg $lno $ei $fulldesc $var
870 #---------- main user interface ----------
872 proc widgets-setup {} {
873 global canvas debug pirate ocean
875 wm geometry . 1024x480
876 wm title . "where-vessels - $pirate on the $ocean ocean"
880 frame .f -border 1 -relief groove
883 pack $canvas -expand 1 -fill both
884 pack .f -expand 1 -fill both -side left
886 #----- control panels and filter -----
889 frame .filter -relief groove -bd 2
890 pack .cp .filter -side top
892 label .filter.title -text Filter
893 grid configure .filter.title -row 0 -column 0 -columnspan 2
895 #----- control panel -----
898 pack .cp.ctrl -side left -anchor n
900 debug "BBOX [$canvas bbox all]"
902 panner::canvas-scroll-bbox .f.c
903 panner::create .cp.ctrl.pan .f.c 120 120 $debug
905 pack .cp.ctrl.pan -side top -pady 10 -padx 5
907 pack .cp.ctrl.zoom -side top
909 button .cp.ctrl.zoom.out -text - -font {Courier 16} -command {zoom /2}
910 button .cp.ctrl.zoom.in -text + -font {Courier 16} -command {zoom *2}
911 pack .cp.ctrl.zoom.out .cp.ctrl.zoom.in -side left
913 parser-control-create .cp.ctrl.acquire \
915 "Clipboard parsing error" \
917 pack .cp.ctrl.acquire -side top -pady 2
919 parser-control-create .cp.ctrl.notes \
920 notes "Reload notes" \
921 "Vessel notes loading report" \
923 pack .cp.ctrl.notes -side top -pady 2
925 #----- decoding etc. report -----
928 pack .cp.report -side left -anchor n
930 label .cp.report.island -text { }
932 frame .cp.report.abbrev -background black
933 glset report_abbrev { }
934 entry .cp.report.abbrev.abbrev -state readonly \
935 -textvariable report_abbrev \
936 -borderwidth 0 -relief flat -width 0 \
937 -highlightbackground white \
938 -readonlybackground white -foreground black
939 pack .cp.report.abbrev.abbrev -side left -padx 1 -pady 1
941 frame .cp.report.code
942 label .cp.report.code.lab -text Code:
943 glset report_code { }
944 entry .cp.report.code.code -state readonly \
945 -textvariable report_code -width 15
946 pack .cp.report.code.lab .cp.report.code.code -side left
947 frame .cp.report.details -bd 2 -relief groove -padx 2 -pady 2
949 listbox .cp.report.list -height 5
951 pack .cp.report.island .cp.report.abbrev .cp.report.details \
952 .cp.report.list .cp.report.code -side top
953 pack configure .cp.report.details -fill x
955 foreach sw {inport class subclass lock own xabbrev} {
956 label .cp.report.details.$sw -text { }
957 pack .cp.report.details.$sw -side top -anchor w
961 proc report-set {sw val} { .cp.report.details.$sw configure -text $val }
963 proc show-report {islandname code} {
964 .cp.report.island configure -text $islandname
965 glset report_code $code
966 glset report_abbrev [code2abbrev $code]
968 show-report-decode $code
970 set kk "$islandname $code"
971 upvar #0 found($kk) k
973 .cp.report.list delete 0 end
976 manyset $entry vid name
977 .cp.report.list insert end $name
983 set nscale [expr "\$scale $extail"]
984 debug "ZOOM $scale $nscale"
985 if {$nscale < 1 || $nscale > 200} return
990 proc invoke_acquire {} {
991 global clipboard errorInfo
995 set clipboard [clipboard get]
997 parser-control-failed-unexpected .cp.ctrl.acquire acquire \
998 $emsg "fetching clipboard:\n\n$errorInfo"
1003 clipboard $old "Clipboard contents:" { acquired ok } { no vessels } {
1011 proc invoke_notes {} {
1012 global notes_data errorInfo notes_loc
1018 parser-control-failed-unexpected .cp.ctrl.notes notes \
1019 $emsg "loading $notes_loc:\n\n$errorInfo"
1024 notes_data $old "Vessel notes:" "loaded ok" { no notes } {
1033 #---------- main program ----------
1039 httpclientsetup where-vessels
1045 if {[catch { parse-clipboard } emsg]} {
1046 puts stderr "$emsg\n$errorInfo"
1049 after idle invoke_notes