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 display-note-infos {} {
197 global note_infos note_missings notes
199 set nmissing [llength $note_missings]
200 debug "display-note-infos $nmissing [array size notes]"
202 if {[llength $note_infos]} {
203 set tiny "[llength $note_infos] warning(s)"
204 } elseif {$nmissing && [array size notes]} {
205 set tiny "$nmissing missing"
212 foreach info $note_infos {
213 manyset $info lno vid name island description
214 append infodata "vessel"
215 append infodata " $vid"
216 if {[string length $name]} { append infodata " $name" }
217 if {[string length $island]} { append infodata " ($island)" }
218 append infodata ": " $description "\n"
222 if {[string length $infodata]} { append infodata "\n" }
223 append infodata "$nmissing vessel(s) not mentioned in notes:\n"
225 foreach info [lsort $note_missings] {
226 manyset $info island name vid
227 if {[string compare $island $last_island]} {
228 append infodata "# $island:\n"
229 set last_island $island
231 append infodata [format "%-9d %-29s =\n" $vid $name]
235 parser-control-failed-core .cp.ctrl.notes notes \
238 "[llength $note_infos] warning(s);\
239 $nmissing vessel(s) missing" \
240 "Full description of warnings and missing vessels:" \
244 #---------- vessel properties ----------
246 proc vesselclasses-init {} {
247 global vc_game2code vc_code2abbrev vc_code2full vc_codes
252 longship dm ls Longship
253 baghlah em bg Baghlah
254 merchbrig fm mb {Merchant Brig}
255 warbrig gm wb {War Brig}
257 warfrig im wf {War Frigate}
258 merchgal jm mg {Merchant Galleon}
259 grandfrig km gf {Grand Frigate}
262 foreach {game code abbrev full} $vcl {
263 lappend vc_codes $code
264 set vc_game2code($game) $code
265 set vc_code2abbrev($code) $abbrev
266 set vc_code2full($code) $full
267 image create bitmap ship-icon/$abbrev -file icons/$abbrev.xbm
271 proc code2abbrev-lock {lockown} {
272 manyset [split $lockown ""] lock notown
273 append abbrev [lindex {* + -} $lock]
274 append abbrev [lindex {= - ?} [regsub {\D} $notown 2]]
277 proc canvas-horiz-stack {xvar y bind type args} {
279 upvar 1 canvas canvas
280 set id [eval $canvas create $type $x $y $args]
281 set bbox [$canvas bbox $id]
282 set x [lindex $bbox 2]
283 $canvas bind $id <ButtonPress> $bind
287 proc code2canvas {code canvas x yvar qty qtylen bind} {
288 global vc_code2abbrev
291 manyset [split $code _] inport class subclass lockown xabbrev
296 append qty [lindex {? {}} $inport]
297 set qty [format "%${qtylen}s" $qty]
299 set qtyid [canvas-horiz-stack stackx $y $bind \
300 text -anchor nw -font fixed -text $qty]
303 canvas-horiz-stack stackx [expr {$y+2}] $bind \
304 image -anchor nw -image ship-icon/$vc_code2abbrev($class)
307 canvas-horiz-stack stackx $y $bind \
308 text -anchor nw -font fixed -text \
309 "$subclass[code2abbrev-lock $lockown]$xabbrev"
311 set bbox [$canvas bbox $qtyid]
312 set ny [lindex $bbox 3]
313 set bid [$canvas create rectangle \
318 $canvas lower $bid $qtyid
320 $canvas bind $bid <ButtonPress> $bind
323 proc show-report-decode {code} {
326 manyset [split $code _] inport classcode subclass lockown xabbrev
327 manyset [split $lockown ""] lock notown
329 report-set inport [lindex {{At Sea} {In port}} $inport]
330 report-set class $vc_code2full($classcode)
332 switch -exact $subclass {
333 {} { report-set subclass {Ordinary} }
334 F { report-set subclass {"Frost class"} }
335 default { report-set subclass "Subclass \"$subclass\"" }
338 report-set lock [lindex {
339 {Battle ready} {Unlocked} {Locked}
342 switch -exact $notown {
343 0 { report-set own "Yours" }
344 1 { report-set own "Other pirate's" }
345 U { report-set own "Owner not known" }
346 M { report-set own "Missing from notes" }
347 default { report-set own "?? $notown" }
350 if {[string length $xabbrev]} {
351 report-set xabbrev "Notes flags: $xabbrev"
353 report-set xabbrev "No flags in notes"
357 #---------- filtering ----------
361 proc filter-values/size {} { global vc_codes; return $vc_codes }
362 proc filter-icon/size {code} {
363 upvar #0 vc_code2abbrev($code) abb
364 return ship-icon/$abb
366 proc filter-default/size {code} { return 1 }
367 proc filter-says-yes/size {codel} {
368 set sizecode [lindex $codel 1]
369 upvar #0 filter_size($sizecode) yes
373 proc filter-values/lockown {} {
376 lappend vals "$lv$ov"
381 proc filter-map/lockown {lockown} { return [code2abbrev-lock $lockown] }
382 proc filter-default/lockown {lockown} {
383 return [regexp {^[01]|^2[^1]} $lockown]
385 proc filter-says-yes/lockown {codel} {
386 set lockown [lindex $codel 3]
387 regsub -all {\D} $lockown X lockown
388 upvar #0 filter_lockown($lockown) yes
392 proc filter-validate/xabbre {re} {
396 regsub {^.*:\s*} $emsg {} emsg
397 regsub {^.*(.{30})$} $emsg {\1} emsg
402 proc filter-says-yes/xabbre {codel} {
404 set xabbrev [lindex $codel 4]
405 return [regexp -- $filter_xabbre $xabbrev]
408 proc filter-tickbox-flip {fil} {
409 upvar #0 filter_$fil vars
410 set values [filter-values/$fil]
411 foreach val $values {
412 set vars($val) [expr {!$vars($val)}]
417 proc make-tickbox-filter {fil label rows inrow} {
418 upvar #0 filter_$fil vars
419 set fw [make-filter tickbox $fil $label frame]
420 set values [filter-values/$fil]
421 set nvalues [llength $values]
423 set inrow [expr {($nvalues + $rows) / $rows}]
425 set noicons [catch { info args filter-icon/$fil }]
426 for {set ix 0} {$ix < $nvalues} {incr ix} {
427 set val [lindex $values $ix]
428 set vars($val) [filter-default/$fil $val]
429 checkbutton $fw.$ix -variable filter_${fil}($val) \
430 -font fixed -command redraw-needed
432 $fw.$ix configure -image [filter-icon/$fil $val] -height 16
434 $fw.$ix configure -text [filter-map/$fil $val]
436 grid configure $fw.$ix -sticky sw \
437 -row [expr {$ix / $inrow}] \
438 -column [expr {$ix % $inrow}]
440 button $fw.invert -text flip -command [list filter-tickbox-flip $fil] \
442 grid configure $fw.invert -sticky se \
443 -row [expr {$rows-1}] \
444 -column [expr {$inrow-1}]
447 proc entry-filter-changed {fw fil n1 n2 op} {
449 upvar #0 filter_$fil realvar
450 upvar #0 filterentered_$fil entryvar
451 global def_background
452 debug "entry-filter-changed $fw $fil $entryvar"
454 set error [filter-validate/$fil $entryvar]
455 if {[string length $error]} {
456 $fw.error configure -text $error -foreground white -background red
458 $fw.error configure -text { } -background $def_background
459 set realvar $entryvar
463 puts stderr "FILTER CHECK ERROR $emsg $errorInfo"
467 proc make-entry-filter {fil label def} {
468 global filterentered_$fil
469 upvar #0 filter_$fil realvar
471 set fw [make-filter entry $fil $label frame]
472 entry $fw.entry -textvariable filterentered_$fil
474 glset def_background [$fw.error cget -background]
475 trace add variable filterentered_$fil write \
476 [list entry-filter-changed $fw $fil]
477 pack $fw.entry $fw.error -side top -anchor w
480 proc make-filter {kind fil label ekind} {
482 label .filter.lab_$fil -text $label -justify left
485 set nfilters [llength $filters]
486 grid configure .filter.lab_$fil -row $nfilters -column 0 -sticky nw -pady 4
487 grid configure .filter.$fil -row $nfilters -column 1 -sticky w -pady 3
491 proc make-filters {} {
492 make-tickbox-filter size Size 2 0
493 make-tickbox-filter lockown "Lock/\nowner" 2 6
494 make-entry-filter xabbre "Flags\n regexp" {}
497 proc filters-say-yes {code} {
499 debug "filters-say-yes $code"
500 foreach fil $filters {
501 if {![filter-says-yes/$fil [split $code _]]} { return 0 }
506 #---------- loading and parsing the clipboard (vessel locations) ----------
509 global pirate notes_used note_missings newnotes
513 lappend codel [errexpect-arrayget-boolean vi inPort]
515 set gameclass [errexpect-arrayget vi vesselClass]
516 upvar #0 vc_game2code($gameclass) class
517 if {![info exists class]} { errexpect-error "unexpected vesselClass"}
520 set subclass [errexpect-arrayget vi vesselSubclass]
521 switch -exact $subclass {
522 null { lappend codel {} }
523 icy { lappend codel F }
524 default { lappend codel ($subclass) }
527 switch -exact [errexpect-arrayget vi isLocked]/[ \
528 errexpect-arrayget vi isBattleReady] {
529 true/false { set lock 2 }
530 false/false { set lock 1 }
531 false/true { set lock 0 }
532 default { errexpect-error "unexpected isLocked/isBattleReady" }
535 set vid [errexpect-arrayget vi vesselId]
536 upvar #0 notes($vid) note
537 set realname [errexpect-arrayget vi vesselName]
538 set island [errexpect-arrayget vi islandName]
542 if {[info exists note]} {
543 manyset $note lno notename owner xabbrev
544 if {[string compare -nocase $realname $notename]} {
545 note-info $lno $vid $realname $island \
546 "notes say name is $notename"
548 if {[string length $owner]} {
549 if {![string compare $owner $pirate]} {
557 append abbrev $xabbrev
558 set notes_used($vid) 1
562 lappend note_missings [list $island $realname $vid]
565 lappend codel "$lock$notown" $xabbrev
566 lappend newnotes [list $vid $realname $owner $xabbrev]
567 set kk "$island [join $codel _]"
568 upvar #0 found($kk) k
569 lappend k [list $vid $realname]
571 debug "CODED $kk $vid $realname"
575 proc parse-clipboard {} {
576 global clipboard found notes notes_used newnotes
578 catch { unset found }
579 catch { unset notes_used }
581 glset note_missings {}
585 set itemre { (\w+) = ([^=]*) }
586 set manyitemre "^\\\[ $itemre ( (?: ,\\ $itemre)* ) \\]\$"
590 foreach l [split $clipboard "\n"] {
592 errexpect-setline $lno $l
593 if {![string length $l]} continue
596 if {![regexp -expanded $manyitemre $l dummy \
597 thiskey thisval rhs]} {
598 errexpect-error "badly formatted"
600 set vi($thiskey) $thisval
601 if {![string length $rhs]} break
602 regsub {^, } $rhs {} rhs
608 if {[llength $newnotes]} {
609 foreach vid [lsort [array names notes]] {
610 if {![info exists notes_used($vid)]} {
611 manyset $notes($vid) lno notename
612 note-info $lno $vid $notename {} \
613 "vessel in notes no longer found"
619 proc load-clipboard-file {fn} {
621 glset clipboard [read $f]
626 #---------- loading and parsing the chart ----------
630 debug "FETCHING CHART"
631 set chart [eval exec $scraper [list | perl -we {
636 yppedia_chart_parse(\*STDIN, (new IO::File ">/dev/null"),
637 sub { sprintf "%d %d", @_; },
638 sub { printf "archlabel %d %d %s\n", @_; },
639 sub { printf "island %s %s\n", @_; },
640 sub { printf "league %s %s %s.\n", @_; },
641 sub { printf STDERR "warning: %s: incomprehensible: %s", @_; }
643 STDOUT->error and die $!;
652 return [expr {$c * $scale}]
655 proc chart-got/archlabel {args} { }
656 proc chart-got/island {x y args} {
657 # debug "ISLE $x $y $args"
658 global canvas isleloc
659 set isleloc($args) [list $x $y]
661 # $canvas create oval \
662 # [expr {[coord $x] - $sz}] [expr {[coord $y] - $sz}] \
663 # [expr {[coord $x] + $sz}] [expr {[coord $y] + $sz}] \
665 $canvas create text [coord $x] [coord $y] \
666 -text $args -anchor s
668 proc chart-got/league {x1 y1 x2 y2 kind} {
669 # debug "LEAGUE $x1 $y1 $x2 $y2 $kind"
671 set l [$canvas create line \
672 [coord $x1] [coord $y1] \
673 [coord $x2] [coord $y2]]
674 if {![string compare $kind .]} {
675 $canvas itemconfigure $l -dash .
679 proc redraw-needed {} {
681 debug "REDRAW NEEDED"
682 if {[info exists redraw_after]} return
683 set redraw_after [after 250 draw]
687 global chart found isleloc canvas redraw_after
689 catch { after cancel $redraw_after }
690 catch { unset redraw_after }
694 foreach l [split $chart "\n"] {
695 # debug "CHART-GOT $l"
696 set proc [lindex $l 0]
697 eval chart-got/$proc [lrange $l 1 end]
700 set lastislandname {}
701 foreach key [lsort [array names found]] {
702 set c [llength $found($key)]
703 # debug "SHOWING $key $c"
704 regexp {^(.*) (\S+)$} $key dummy islandname code
706 if {![filters-say-yes $code]} continue
708 if {[string compare $lastislandname $islandname]} {
709 manyset $isleloc($islandname) x y
712 set lastislandname $islandname
716 if {$c > 1} { set qty [format %d $c] } else { set qty {} }
717 code2canvas $code $canvas $x y $qty 2 \
718 [list show-report $islandname $code]
722 panner::updatecanvas-bbox .cp.ctrl.pan
726 #---------- parser error reporting ----------
728 proc parser-control-create {w base invokebuttontext etl_title} {
730 button $w.do -text $invokebuttontext -command invoke_$base
732 frame $w.resframe -width 120 -height 32
733 button $w.resframe.res -text {} -anchor nw \
734 -padx 1 -pady 1 -borderwidth 0 -justify left
735 glset deffont_$base [$w.resframe.res cget -font]
736 place $w.resframe.res -relx 0.5 -y 0 -anchor n
739 pack $w.resframe -side top -expand y -fill both
744 wm title $eb "where-vessels - $etl_title"
746 label $eb.title -text $etl_title
747 pack $eb.title -side top
749 button $eb.close -text Close -command [list wm withdraw $eb]
750 pack $eb.close -side bottom
752 frame $eb.emsg -bd 2 -relief groove
753 label $eb.emsg.lab -text "Error:"
754 text $eb.emsg.text -height 1
755 pack $eb.emsg.text -side bottom
756 pack $eb.emsg.lab -side left
758 pack $eb.emsg -side top -pady 2
760 frame $eb.text -bd 2 -relief groove
761 pack $eb.text -side bottom -pady 2
765 text $eb.text.text -width 85 \
766 -xscrollcommand [list $eb.text.xscroll set] \
767 -yscrollcommand [list $eb.text.yscroll set]
768 $eb.text.text tag configure error \
769 -background red -foreground white
771 scrollbar $eb.text.xscroll -orient horizontal \
772 -command [list $eb.text.text xview]
773 scrollbar $eb.text.yscroll -orient vertical \
774 -command [list $eb.text.text yview]
776 grid configure $eb.text.lab -row 0 -column 0 -sticky w
777 grid configure $eb.text.text -row 1 -column 0
778 grid configure $eb.text.yscroll -sticky ns -row 1 -column 1
779 grid configure $eb.text.xscroll -sticky ew -row 2 -column 0
782 proc parser-control-ok-core {w base background show} {
783 debug "parser-control-ok-core $w $base $background $show"
784 upvar #0 deffont_$base deffont
785 $w.resframe.res configure \
786 -background $background -disabledforeground black -font $deffont \
787 -state disabled -command {} \
790 proc parser-control-ok {w base show} {
791 parser-control-ok-core $w $base green $show
793 proc parser-control-none {w base show} {
794 parser-control-ok-core $w $base blue $show
796 proc parser-control-failed-core {w base foreground background smallfont
797 tiny summary fulldesc fulldata} {
798 debug "parser-control-failed-core $w $base $summary $fulldesc"
799 upvar #0 deffont_$base deffont
802 $eb.emsg.text delete 0.0 end
803 $eb.emsg.text insert end $summary
805 $eb.text.lab configure -text $fulldesc
806 $eb.text.text delete 0.0 end
807 $eb.text.text insert end $fulldata
809 regsub -all {.{18}} $tiny "&\n" ewrap
817 $w.resframe.res configure \
818 -background $background -foreground $foreground -font $font \
819 -state normal -command [list wm deiconify $eb] \
823 proc parser-control-failed-expected {w base emsg lno ei fulldesc newdata} {
826 set line [lindex [split $ei "\n"] 0]
827 debug "parser-control-failed-expected: $w $base: $lno: $emsg\n $line"
829 parser-control-failed-core $w $base \
831 "err: [string trim $emsg]: \"$line\"" \
832 "at line $lno: $emsg" \
835 $eb.text.text tag add error $lno.0 $lno.end
836 $eb.text.text see $lno.0
838 proc parser-control-failed-unexpected {w base emsg ei} {
840 parser-control-failed-core $w $base \
842 $emsg $emsg "Details and stack trace:" $ei
845 proc reparse {base varname old fulldesc okshow noneshow parse ok} {
846 upvar #0 $varname var
847 manyset [errexpect-catch {
849 if {[string length [string trim $var]]} {
850 parser-control-ok .cp.ctrl.$base $base $okshow
852 parser-control-none .cp.ctrl.$base $base $noneshow
854 }] failed emsg lno ei
856 parser-control-failed-expected .cp.ctrl.$base $base \
857 $emsg $lno $ei $fulldesc $var
865 #---------- main user interface ----------
867 proc widgets-setup {} {
868 global canvas debug pirate ocean
870 wm geometry . 1024x480
871 wm title . "where-vessels - $pirate on the $ocean ocean"
875 frame .f -border 1 -relief groove
878 pack $canvas -expand 1 -fill both
879 pack .f -expand 1 -fill both -side left
881 #----- control panels and filter -----
884 frame .filter -relief groove -bd 2
885 pack .cp .filter -side top
887 label .filter.title -text Filter
888 grid configure .filter.title -row 0 -column 0 -columnspan 2
890 #----- control panel -----
893 pack .cp.ctrl -side left -anchor n
895 debug "BBOX [$canvas bbox all]"
897 panner::canvas-scroll-bbox .f.c
898 panner::create .cp.ctrl.pan .f.c 120 120 $debug
900 pack .cp.ctrl.pan -side top -pady 10 -padx 5
902 pack .cp.ctrl.zoom -side top
904 button .cp.ctrl.zoom.out -text - -font {Courier 16} -command {zoom /2}
905 button .cp.ctrl.zoom.in -text + -font {Courier 16} -command {zoom *2}
906 pack .cp.ctrl.zoom.out .cp.ctrl.zoom.in -side left
908 parser-control-create .cp.ctrl.acquire \
910 "Clipboard parsing error" \
912 pack .cp.ctrl.acquire -side top -pady 2
914 parser-control-create .cp.ctrl.notes \
915 notes "Reload notes" \
916 "Vessel notes loading report" \
918 pack .cp.ctrl.notes -side top -pady 2
920 #----- decoding etc. report -----
923 pack .cp.report -side left -anchor n
925 label .cp.report.island -text { }
927 canvas .cp.report.abbrev -width 1 -height 15
929 frame .cp.report.code
930 label .cp.report.code.lab -text Code:
931 glset report_code { }
932 entry .cp.report.code.code -state readonly \
933 -textvariable report_code -width 15
934 pack .cp.report.code.lab .cp.report.code.code -side left
935 frame .cp.report.details -bd 2 -relief groove -padx 2 -pady 2
937 listbox .cp.report.list -height 5
939 pack .cp.report.island .cp.report.abbrev .cp.report.details \
940 .cp.report.list .cp.report.code -side top
941 pack configure .cp.report.details -fill x
943 foreach sw {inport class subclass lock own xabbrev} {
944 label .cp.report.details.$sw -text { }
945 pack .cp.report.details.$sw -side top -anchor w
949 proc report-set {sw val} { .cp.report.details.$sw configure -text $val }
951 proc show-report {islandname code} {
952 .cp.report.island configure -text $islandname
954 .cp.report.abbrev delete all
956 code2canvas $code .cp.report.abbrev 5 y {} 0 {}
957 manyset [.cp.report.abbrev bbox all] minx dummy maxx dummy
958 .cp.report.abbrev configure -width [expr {$maxx-$minx+4}]
960 glset report_code $code
961 show-report-decode $code
963 set kk "$islandname $code"
964 upvar #0 found($kk) k
966 .cp.report.list delete 0 end
969 manyset $entry vid name
970 .cp.report.list insert end $name
976 set nscale [expr "\$scale $extail"]
977 debug "ZOOM $scale $nscale"
978 if {$nscale < 1 || $nscale > 200} return
983 proc invoke_acquire {} {
984 global clipboard errorInfo
988 set clipboard [clipboard get]
990 parser-control-failed-unexpected .cp.ctrl.acquire acquire \
991 $emsg "fetching clipboard:\n\n$errorInfo"
996 clipboard $old "Clipboard contents:" { acquired ok } { no vessels } {
1004 proc invoke_notes {} {
1005 global notes_data errorInfo notes_loc
1011 parser-control-failed-unexpected .cp.ctrl.notes notes \
1012 $emsg "loading $notes_loc:\n\n$errorInfo"
1017 notes_data $old "Vessel notes:" "loaded ok" { no notes } {
1026 #---------- main program ----------
1032 httpclientsetup where-vessels
1038 if {[catch { parse-clipboard } emsg]} {
1039 puts stderr "$emsg\n$errorInfo"
1042 after idle invoke_notes