PageRenderTime 63ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/pvs-sbcl-5.0/wish/pvs-support.tcl

#
TCL | 1985 lines | 1815 code | 113 blank | 57 comment | 42 complexity | e5d955f695e7276ea993a7604956087f MD5 | raw file
Possible License(s): AGPL-3.0, MPL-2.0, GPL-2.0
  1. # -*- Mode: Tcl -*-
  2. # pvs-support.tcl --
  3. # Author : Carl Witty with mods by Sam Owre
  4. # Created On : Thu Apr 27 02:27:14 1995
  5. # Last Modified By: Sam Owre
  6. # Last Modified On: Thu May 4 19:04:20 1995
  7. # Update Count : 14
  8. # Status : Alpha test
  9. # $Id: pvs-support.tcl 4775 2006-08-03 07:03:34Z owre $
  10. # --------------------------------------------------------------------
  11. # PVS
  12. # Copyright (C) 2006, SRI International. All Rights Reserved.
  13. # This program is free software; you can redistribute it and/or
  14. # modify it under the terms of the GNU General Public License
  15. # as published by the Free Software Foundation; either version 2
  16. # of the License, or (at your option) any later version.
  17. # This program is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU General Public License for more details.
  21. # You should have received a copy of the GNU General Public License
  22. # along with this program; if not, write to the Free Software
  23. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  24. # --------------------------------------------------------------------
  25. wm withdraw .
  26. set mono 0
  27. proc emacs-eval {arg} {
  28. puts stdout ":pvs-eval $arg :end-pvs-eval"
  29. gets stdin
  30. }
  31. proc emacs-evaln {arg} {
  32. puts stdout ":pvs-evaln $arg :end-pvs-evaln"
  33. }
  34. proc pvs-send {arg} {
  35. emacs-evaln [format {(pvs-send '%s)} $arg]
  36. }
  37. proc pvs-send-and-wait {arg} {
  38. emacs-eval [format {(pvs-send-and-wait '%s)} $arg]
  39. }
  40. proc create-dag {win} {
  41. upvar #0 dag-$win dag
  42. catch {unset dag}
  43. set dag(items) {}
  44. bind $win <Destroy> "+delete-all-dag-items $win"
  45. }
  46. proc dag-bind-move {win suffix modifier button update} {
  47. upvar #0 dag-$win dag
  48. $win bind dag-item <$modifier-$button> \
  49. "dag-motion-click $win %x %y {$suffix}"
  50. $win bind dag-item <$modifier-B$button-Motion> \
  51. "dag-motion-drag $win %x %y $update"
  52. }
  53. proc dag-motion-click {win x y suffix} {
  54. upvar #0 dag-$win dag
  55. global moving
  56. catch {unset moving}
  57. set dag(oldX) $x
  58. set dag(oldY) $y
  59. set dag(drag_path) $dag(idtotag,[$win find withtag current])
  60. $win dtag selected
  61. $win addtag selected withtag $dag(drag_path)$suffix
  62. foreach id [$win find withtag selected] {
  63. catch {
  64. set moving($dag(idtotag,$id)) 1
  65. }
  66. }
  67. }
  68. proc dag-motion-drag {win x y update} {
  69. upvar #0 dag-$win dag
  70. global moving
  71. set dx [expr $x-$dag(oldX)]
  72. set dy [expr $y-$dag(oldY)]
  73. $win move selected $dx $dy
  74. set dag(oldX) $x
  75. set dag(oldY) $y
  76. foreach tag [array names moving] {
  77. incr dag(topx,$tag) $dx
  78. incr dag(topy,$tag) $dy
  79. incr dag(botx,$tag) $dx
  80. incr dag(boty,$tag) $dy
  81. }
  82. update-lines-to $win $dag(drag_path)
  83. if {$update=={both}} {
  84. update-lines-from $win $dag(drag_path)
  85. }
  86. }
  87. proc dag-add-item {win tag succs linetags} {
  88. upvar #0 dag-$win dag
  89. # Warning...this isn't updated by deletes.
  90. set dag(items) [concat $dag(items) $tag]
  91. set dag(succs,$tag) $succs
  92. foreach item [$win find withtag $tag] {
  93. if {![string match *dagline* [$win gettags $item]]} {
  94. set dag(idtotag,$item) $tag
  95. $win addtag dag-item withtag $item
  96. }
  97. }
  98. set bbox [$win bbox $tag.real]
  99. set dag(anchor,$tag) [list [expr -[lindex $bbox 0]] \
  100. [expr -[lindex $bbox 1]]]
  101. # Give these initial values (it doesn't matter what)
  102. set dag(topx,$tag) 0
  103. set dag(botx,$tag) 0
  104. set dag(topy,$tag) 0
  105. set dag(boty,$tag) 0
  106. foreach s $succs {
  107. # In my opinion, on the X11R6 server, width 0 lines look better
  108. # than width 1 lines.
  109. set lineid \
  110. [$win create line 0 0 0 0 \
  111. -tags "$s dagline$tag,$s dagline.from$tag dagline.to$s dagline $linetags" \
  112. -fill [get-option displayforeground] \
  113. -width 0]
  114. set dag(linefrom,$lineid) $tag
  115. set dag(lineto,$lineid) $s
  116. }
  117. }
  118. proc delete-all-dag-items {win} {
  119. upvar #0 dag-$win dag
  120. foreach i [array names dag] {
  121. if {[string match destroy,* $i]} {
  122. eval $dag($i)
  123. }
  124. }
  125. }
  126. proc dag-delete-item {win tag suffix} {
  127. upvar #0 dag-$win dag
  128. $win delete $tag$suffix
  129. if {$suffix=={}} {
  130. if {[info exists dag(destroy,$tag)]} {
  131. eval $dag(destroy,$tag)
  132. }
  133. }
  134. }
  135. proc dag-add-destroy-cb {win tag cb} {
  136. upvar #0 dag-$win dag
  137. if {[info exists dag(destroy,$tag)]} {
  138. set dag(destroy,$tag) [concat $cb ";" $dag(destroy,$tag)]
  139. } else {
  140. set dag(destroy,$tag) $cb
  141. }
  142. }
  143. proc dag-delete-subtree {win tag {suffix .real}} {
  144. upvar #0 dag-$win dag
  145. set succs {}
  146. catch {set succs $dag(succs,$tag)}
  147. foreach i $succs {
  148. dag-delete-subtree $win $i {}
  149. }
  150. dag-delete-item $win $tag $suffix
  151. }
  152. proc move-dag-item {win tag x y} {
  153. upvar #0 dag-$win dag
  154. set bbox [$win bbox $tag.real]
  155. set anchor $dag(anchor,$tag)
  156. set curx [expr [lindex $bbox 0]+[lindex $anchor 0]]
  157. set cury [expr [lindex $bbox 1]+[lindex $anchor 1]]
  158. $win move $tag [expr $x-$curx] [expr $y-$cury]
  159. set dag(topx,$tag) $x
  160. set dag(topy,$tag) [expr $y-1]
  161. set dag(botx,$tag) $x
  162. set dag(boty,$tag) [expr $y+1+[lindex $bbox 3]-[lindex $bbox 1]]
  163. update-lines-to $win $tag
  164. update-lines-from $win $tag
  165. }
  166. proc update-lines-to {win tag} {
  167. foreach id [$win find withtag dagline.to$tag] {
  168. update-line $win $id
  169. }
  170. }
  171. proc update-lines-from {win tag} {
  172. foreach id [$win find withtag dagline.from$tag] {
  173. update-line $win $id
  174. }
  175. }
  176. proc update-line {win id} {
  177. upvar #0 dag-$win dag
  178. $win coords $id \
  179. $dag(botx,$dag(linefrom,$id)) \
  180. $dag(boty,$dag(linefrom,$id)) \
  181. $dag(topx,$dag(lineto,$id)) \
  182. $dag(topy,$dag(lineto,$id))
  183. }
  184. proc dag-layout {win top} {
  185. upvar #0 dag-$win dag
  186. set dag(layout) "dag-layout $win $top"
  187. foreach item $dag(items) {
  188. set dag(level,$item) 0
  189. }
  190. set maxlev 0
  191. set change 1
  192. while {$change} {
  193. set change 0
  194. foreach item $dag(items) {
  195. set lev $dag(level,$item)
  196. foreach succ $dag(succs,$item) {
  197. if {$dag(level,$succ)<=$lev} {
  198. set dag(level,$succ) [expr 1+$lev]
  199. set change 1
  200. if {$lev==$maxlev} {
  201. incr maxlev
  202. }
  203. }
  204. }
  205. }
  206. }
  207. set y 0
  208. for {set lev 0} {$lev<=$maxlev} {incr lev} {
  209. set wd -[get-option xSep $win]
  210. set ht 0
  211. foreach item $dag(items) {
  212. if {$dag(level,$item)==$lev} {
  213. set bbox [$win bbox $item.real]
  214. set w [expr [lindex $bbox 2]-[lindex $bbox 0]]
  215. set h [expr [lindex $bbox 3]-[lindex $bbox 1]]
  216. incr wd [get-option xSep $win]
  217. incr wd $w
  218. if {$h>$ht} {
  219. set ht $h
  220. }
  221. }
  222. }
  223. set x [expr -int($wd/2)]
  224. foreach item $dag(items) {
  225. if {$dag(level,$item)==$lev} {
  226. set bbox [$win bbox $item.real]
  227. set w [expr [lindex $bbox 2]-[lindex $bbox 0]]
  228. move-dag-item $win $item [expr $x+int($w/2)] $y
  229. incr x [get-option xSep $win]
  230. incr x $w
  231. }
  232. }
  233. incr y [get-option ySep $win]
  234. incr y $ht
  235. }
  236. }
  237. proc dagwin-layout {win} {
  238. upvar #0 dag-$win dag
  239. eval $dag(layout)
  240. canvas-set-scroll $win 1
  241. }
  242. proc tree-layout {win top} {
  243. upvar #0 dag-$win dag
  244. set dag(layout) "tree-layout $win $top"
  245. update-widths $win $top
  246. move-tree $win $top
  247. }
  248. proc update-widths {win tag} {
  249. upvar #0 dag-$win dag
  250. set bbox [$win bbox $tag.real]
  251. set width [expr [lindex $bbox 2]-[lindex $bbox 0]]
  252. set kw -[get-option xSep $win]
  253. foreach sub $dag(succs,$tag) {
  254. update-widths $win $sub
  255. incr kw $dag(width,$sub)
  256. incr kw [get-option xSep $win]
  257. }
  258. set dag(width,$tag) [expr {$kw>$width?$kw:$width}]
  259. }
  260. proc move-tree {win tag {x 0} {y 0}} {
  261. upvar #0 dag-$win dag
  262. move-dag-item $win $tag $x $y
  263. set bbox [$win bbox $tag.real]
  264. set kw -[get-option xSep $win]
  265. foreach succ $dag(succs,$tag) {
  266. incr kw $dag(width,$succ)
  267. incr kw [get-option xSep $win]
  268. }
  269. set curx [expr round($x-$kw/2)]
  270. foreach succ $dag(succs,$tag) {
  271. move-tree $win $succ \
  272. [expr $curx+$dag(width,$succ)/2] \
  273. [expr [get-option ySep $win]+[lindex $bbox 3]]
  274. incr curx $dag(width,$succ)
  275. incr curx [get-option xSep $win]
  276. }
  277. }
  278. # Support for Proof windows
  279. proc ancestors {path top {suffix {}}} {
  280. if {$path==$top} {
  281. return $path$suffix
  282. } else {
  283. regexp {^(.*)\.([^.]+)$} $path whole pre post
  284. return [concat $path$suffix [ancestors $pre $top $suffix]]
  285. }
  286. }
  287. proc kids {path nkids} {
  288. set kids {}
  289. for {set i 0} {$i<$nkids} {incr i} {
  290. lappend kids $path.$i
  291. }
  292. return $kids
  293. }
  294. proc delete-proof-subtree {name theory relpath} {
  295. set proofwin .proof.u_$theory-$name-i.fr.c
  296. set path $theory-$name-i-$relpath
  297. catch {move-dag-item $proofwin $path 0 0}
  298. dag-delete-subtree $proofwin $path
  299. }
  300. proc proof-num-children {name theory path kids interactive} {
  301. if {$interactive} {
  302. set fullpath $theory-$name-i-$path
  303. } else {
  304. set fullpath $theory-$name-$path
  305. }
  306. global $fullpath
  307. set ${fullpath}(kids) $kids
  308. catch {unset ${fullpath}(rule)}
  309. catch {unset ${fullpath}(done)}
  310. catch {unset ${fullpath}(tcc)}
  311. }
  312. proc proof-rule {name theory path rule interactive} {
  313. if {$interactive} {
  314. set fullpath $theory-$name-i-$path
  315. } else {
  316. set fullpath $theory-$name-$path
  317. }
  318. global $fullpath
  319. set ${fullpath}(rule) $rule
  320. }
  321. proc proof-sequent {name theory path seqlabel sequent} {
  322. set fullpath $theory-$name-i-$path
  323. global $fullpath
  324. set ${fullpath}(seqlabel) $seqlabel
  325. set ${fullpath}(sequent) $sequent
  326. }
  327. proc proof-done {name theory path interactive} {
  328. if {$interactive} {
  329. set pwin .proof.u_$theory-$name-i.fr.c
  330. set fullpath $theory-$name-i-$path
  331. } else {
  332. set pwin .proof.u_$theory-$name.fr.c
  333. set fullpath $theory-$name-$path
  334. }
  335. global $fullpath
  336. set ${fullpath}(done) 1
  337. my-foreground $pwin $fullpath [get-option doneColor]
  338. }
  339. proc proof-tcc {path} {
  340. global $path
  341. set ${path}(tcc) 1
  342. }
  343. proc proof-show {name theory path interactive} {
  344. global env
  345. if {$interactive} {
  346. set proofwin .proof.u_$theory-$name-i.fr.c
  347. set top $theory-$name-i-top
  348. set fullpath $theory-$name-i-$path
  349. } else {
  350. set proofwin .proof.u_$theory-$name.fr.c
  351. set top $theory-$name-top
  352. set fullpath $theory-$name-$path
  353. }
  354. global $fullpath
  355. set seq \
  356. [$proofwin create bitmap 0 0 \
  357. -bitmap @$env(PVSPATH)/wish/sequent.xbm \
  358. -tags "$fullpath.sequent $fullpath $fullpath.real sequent [ancestors $fullpath $top .desc]" \
  359. -anchor n \
  360. -foreground [get-option displayforeground]]
  361. if [info exists ${fullpath}(rule)] {
  362. set bbox [$proofwin bbox $seq]
  363. set seqbot [lindex $bbox 3]
  364. set ysep [get-option ySep $proofwin]
  365. # I don't know why it happens, but sometimes get-option returns {}
  366. # here. get-option works fine after this function.
  367. if {$ysep == {}} {
  368. set ysep 5
  369. }
  370. set linebot [expr $seqbot+$ysep]
  371. set rule [set ${fullpath}(rule)]
  372. if {[string index $rule 0] == "+"} {
  373. set rule [string range $rule 1 end]
  374. set rulebitmap "gray25"
  375. } else {
  376. set rulebitmap ""
  377. }
  378. set alen [get-option abbrevLen]
  379. if $alen {
  380. if {[string length $rule]>$alen} {
  381. if {[regexp {^[^ ]* } $rule whole]} {
  382. set rule "$whole...)"
  383. }
  384. }
  385. }
  386. set ${fullpath}(rule_abbr) $rule
  387. set anc [ancestors $fullpath $top .desc]
  388. $proofwin create line 0 $seqbot 0 $linebot \
  389. -tags "$fullpath.line $fullpath $fullpath.real $anc" \
  390. -fill [get-option displayforeground]
  391. $proofwin create text 0 $linebot -text $rule \
  392. -font [get-option displayfont] \
  393. -tags "$fullpath.rule $fullpath $fullpath.real rule $anc" \
  394. -anchor n \
  395. -fill [get-option displayforeground] -stipple $rulebitmap
  396. }
  397. dag-add-item $proofwin $fullpath [kids $fullpath [set ${fullpath}(kids)]] [ancestors $fullpath $top .desc]
  398. dag-add-destroy-cb $proofwin $fullpath "global $fullpath; catch {unset $fullpath}"
  399. if [info exists ${fullpath}(done)] {
  400. my-foreground $proofwin $fullpath [get-option doneColor]
  401. } elseif [info exists ${fullpath}(tcc)] {
  402. my-foreground $proofwin $fullpath [get-option tccColor]
  403. }
  404. }
  405. proc get-full-rule {proofwin top} {
  406. global pathtorlabel
  407. upvar #0 dag-$proofwin dag
  408. set path $dag(idtotag,[$proofwin find withtag current])
  409. global $path
  410. # permit popups also for fully displayed proof commands
  411. # to enable easy copying
  412. #
  413. # if {![string compare [set ${path}(rule)] [set ${path}(rule_abbr)]]} {
  414. # return
  415. # }
  416. for {set label 1} {[winfo exists .rule$label]} {incr label} {
  417. }
  418. if [info exists pathtorlabel($path)] {
  419. set rulelab $pathtorlabel($path)
  420. if {! [winfo ismapped .rule$rulelab.rule]} {
  421. wm deiconify .rule$rulelab.rule
  422. } else {
  423. wm iconify .rule$rulelab.rule
  424. wm deiconify .rule$rulelab.rule
  425. }
  426. return
  427. }
  428. set pathtorlabel($path) $label
  429. set rulewin .rule$label.rule
  430. set bbox [$proofwin bbox $path.rule]
  431. set x [lindex $bbox 2]
  432. set y [expr round(([lindex $bbox 1]+[lindex $bbox 3])/2)]
  433. $proofwin create text $x $y -anchor w \
  434. -tags "$path $path.rlabel $path.rlabel$label rlabel [ancestors $path $top .desc] rlabel.$label" \
  435. -text $label
  436. update-color $proofwin $path $path.rlabel$label
  437. frame .rule$label
  438. toplevel $rulewin -class Command
  439. frame $rulewin.fr
  440. pack $rulewin.fr -expand yes -fill both
  441. text $rulewin.fr.text -bd 2 -relief raised
  442. $rulewin.fr.text insert end [set ${path}(rule)]
  443. set height [lindex [split [$rulewin.fr.text index end] .] 0]
  444. set wd 0
  445. for {set i 1} {$i<=$height} {incr i} {
  446. set linewd [lindex [split [$rulewin.fr.text index "$i.0 lineend"] .] 1]
  447. if {$linewd>$wd} {set wd $linewd}
  448. }
  449. $rulewin.fr.text config -height $height -width $wd -state disabled -wrap none
  450. pack $rulewin.fr.text -expand yes -fill both
  451. # mark the hotkey D and bind the hotkeys d and q to this button
  452. button $rulewin.dismiss -text Dismiss -underline 0 -command "destroy $rulewin"
  453. bind $rulewin <Alt-d> "$rulewin.dismiss invoke; break"
  454. bind $rulewin <Key-q> "$rulewin.dismiss invoke"
  455. # add a second cut button (hotkey c) that sets the selection
  456. # with the complete proof command
  457. button $rulewin.cut -text "Cut all" -underline 0 \
  458. -command "$rulewin.fr.text tag add sel 0.0 end"
  459. bind $rulewin <Alt-c> "$rulewin.cut invoke"
  460. # pack both buttons
  461. pack $rulewin.dismiss $rulewin.cut -side left -padx 2 -pady 2
  462. bind $rulewin <Destroy> "+catch {$proofwin delete $path.rlabel$label}"
  463. bind $rulewin <Destroy> "+catch {unset pathtorlabel($path)}"
  464. bind $rulewin <Destroy> "+after 1 {catch {destroy .rule$label}}"
  465. wm iconname $rulewin {PVS command}
  466. wm title $rulewin "Command $label [set ${path}(rule_abbr)]"
  467. set next [lindex [set dag(succs,$path)] 0]
  468. dag-add-destroy-cb $proofwin $next "catch {destroy $rulewin}"
  469. }
  470. # send proof cmd to emacs and run it on current goal
  471. proc run-pvs-command {cmd} {
  472. regsub -all {"} $cmd {\\\"} cmd2
  473. # " -> this comment is for emacs syntaxhighlighting
  474. set command "(if pvs-in-checker \
  475. (progn \
  476. (switch-to-lisp t t) \
  477. (goto-char (point-max)) \
  478. (insert \"$cmd2\") \
  479. (return-ilisp)))"
  480. emacs-evaln $command
  481. }
  482. # produce the popup menu on rules,
  483. # bound to right-click's on a proof-command occurs
  484. proc rule-menu {x y proofwin top interactive} {
  485. upvar #0 dag-$proofwin dag
  486. set path $dag(idtotag,[$proofwin find withtag current])
  487. global $path
  488. set cmd [set ${path}(rule)]
  489. if {$interactive} {
  490. $proofwin.rulemenu entryconfigure 2 -command "run-pvs-command {$cmd}"
  491. }
  492. tk_popup $proofwin.rulemenu $x $y
  493. }
  494. # copy the proof cmd into the primary selection
  495. proc rule-select {proofwin top} {
  496. upvar #0 dag-$proofwin dag
  497. set path $dag(idtotag,[$proofwin find withtag current])
  498. global $path
  499. global current_selection
  500. set current_selection [set ${path}(rule)]
  501. selection own $proofwin
  502. }
  503. # proc get-current-sequent {proofwin} {
  504. # upvar #0 dag-$proofwin dag
  505. #
  506. # set path $dag(idtotag,[$proofwin find withtag current])
  507. #
  508. # set lisp_path [path-to-lisp-path $path]
  509. #
  510. # set file [lindex [pvs-send-and-wait "(request-sequent '($lisp_path))"] 0]
  511. # source $file
  512. # exec rm -f $file
  513. # }
  514. proc undo-to-sequent {proofwin} {
  515. upvar #0 dag-$proofwin dag
  516. set path $dag(idtotag,[$proofwin find withtag current])
  517. set lisp_path [path-to-lisp-path $path]
  518. set file [lindex [pvs-send-and-wait "(undo-to-sequent '($lisp_path))"] 0]
  519. source $file
  520. exec rm -f $file
  521. }
  522. proc show-sequent {proofwin top} {
  523. global pathtolabel
  524. upvar #0 dag-$proofwin dag
  525. set path $dag(idtotag,[$proofwin find withtag current])
  526. global $path
  527. set seq_label [set ${path}(seqlabel)]
  528. set text [set ${path}(sequent)]
  529. for {set label 1} {[winfo exists .sequent$label]} {incr label} {
  530. }
  531. if [info exists pathtolabel($path)] {
  532. set seqlab $pathtolabel($path)
  533. if {! [winfo ismapped .sequent$seqlab.sequent]} {
  534. wm deiconify .sequent$seqlab.sequent
  535. } else {
  536. wm iconify .sequent$seqlab.sequent
  537. wm deiconify .sequent$seqlab.sequent
  538. }
  539. return
  540. }
  541. set seqwin .sequent$label.sequent
  542. set bbox [$proofwin bbox $path.sequent]
  543. set x [lindex $bbox 2]
  544. set y [expr round(([lindex $bbox 1]+[lindex $bbox 3])/2)]
  545. $proofwin create text $x $y -anchor w \
  546. -tags "$path $path.label $path.label$label label [ancestors $path $top .desc] label.$label" \
  547. -text $label
  548. update-color $proofwin $path $path.label$label
  549. frame .sequent$label
  550. toplevel $seqwin -class Sequent -borderwidth 2
  551. frame $seqwin.fr
  552. pack $seqwin.fr -expand yes -fill both
  553. text $seqwin.fr.text -bd 2 -relief raised -height 2 -width 80 -setgrid true
  554. set text [string range $text 1 [expr [string length $text]-2]]
  555. $seqwin.fr.text insert end $text
  556. set height [lindex [split [$seqwin.fr.text index end] .] 0]
  557. $seqwin.fr.text config -state disabled
  558. if {$height>5} {
  559. scrollbar $seqwin.fr.s -command "$seqwin.fr.text yview"
  560. $seqwin.fr.text config -yscrollcommand "$seqwin.fr.s set"
  561. pack $seqwin.fr.s -fill y -side right
  562. wm minsize $seqwin 80 2
  563. wm maxsize $seqwin 2000 2000
  564. if {$height>[get-option maxHeight]} {
  565. set height [get-option maxHeight]
  566. }
  567. } else {
  568. wm minsize $seqwin 80 $height
  569. wm maxsize $seqwin 2000 2000
  570. }
  571. #in the following, many keybindings are added
  572. # => the goal is to make every button and menu
  573. # accessable with the keyboard
  574. # if possible a letter is underlined on a button
  575. # the keybinding will be Alt+underlined_key
  576. pack $seqwin.fr.text -expand yes -fill both
  577. button $seqwin.dismiss -text Dismiss -bd 2 -command "destroy .sequent$label" -underline 0
  578. bind $seqwin <Alt-d> "$seqwin.dismiss invoke; break"
  579. pack $seqwin.dismiss -side left -padx 2 -pady 2
  580. button $seqwin.print -text "Print" -bd 2 -command "print-text $seqwin.fr.text" -underline 0
  581. bind $seqwin <Alt-p> "$seqwin.print invoke"
  582. pack $seqwin.print -side left -padx 2 -pady 2
  583. button $seqwin.stick -text Stick -bd 2 -command "stick $seqwin $path" -underline 2
  584. bind $seqwin <Alt-i> "$seqwin.stick invoke"
  585. pack $seqwin.stick -side left -padx 2 -pady 2
  586. button $seqwin.help -text Help -bd 2 -command "help-sequent" -underline 0
  587. bind $seqwin <Alt-h> "$seqwin.help invoke"
  588. pack $seqwin.help -side right -padx 2 -pady 2
  589. bind $seqwin <Destroy> "catch {$proofwin delete $path.label$label}"
  590. bind $seqwin <Destroy> "+catch {unset pathtolabel($path)}"
  591. bind $seqwin <Destroy> "+after 1 {destroy-sequent $seqwin}"
  592. wm geometry $seqwin 80x$height
  593. wm iconname $seqwin {PVS sequent}
  594. wm title $seqwin "Sequent $label ($seq_label)"
  595. catch {unset sticky_seqs($seqwin)}
  596. dag-add-destroy-cb $proofwin $path "destroy-sequent $seqwin"
  597. set pathtolabel($path) $label
  598. }
  599. proc print-text {textwin} {
  600. set text [$textwin get 1.0 end]
  601. exec cat << $text | lpr
  602. }
  603. proc stick {win path} {
  604. global sticky_seqs $win pathtolabel
  605. catch {unset pathtolabel($path)}
  606. set sticky_seqs($win) 1
  607. pack forget $win.stick
  608. }
  609. proc destroy-sequent {win} {
  610. global sticky_seqs $win
  611. if {! [info exists sticky_seqs($win)]} {
  612. if {[winfo exists $win]} {
  613. catch {destroy [winfo parent $win]}
  614. }
  615. }
  616. }
  617. proc path-to-lisp-path {path} {
  618. lrange [split $path .] 1 end
  619. }
  620. proc my-foreground {win tag color} {
  621. if {[string match @* $color]} {
  622. if {![string match */* $color]} {
  623. global env
  624. set color @$env(PVSPATH)/wish/[string range $color 1 end].xbm
  625. }
  626. my-config $win line $tag -fill black
  627. my-config $win line $tag -stipple $color
  628. my-config $win text $tag -fill black
  629. my-config $win text $tag -stipple $color
  630. } else {
  631. my-config $win bitmap $tag -foreground $color
  632. my-config $win line $tag -stipple {}
  633. my-config $win line $tag -fill $color
  634. my-config $win text $tag -stipple {}
  635. my-config $win text $tag -fill $color
  636. }
  637. }
  638. proc update-color {proofwin path tag} {
  639. global $path curpath
  640. if [info exists ${path}(done)] {
  641. my-foreground $proofwin $tag [get-option doneColor]
  642. return
  643. }
  644. if {[info exists curpath]} {
  645. if {$path==$curpath} {
  646. my-foreground $proofwin $tag [get-option currentColor]
  647. $proofwin addtag current-subgoal withtag $tag
  648. return
  649. }
  650. }
  651. set seqid [$proofwin find withtag $path.sequent]
  652. set tags [$proofwin gettags $seqid]
  653. foreach t $tags {
  654. if {$t=={current-subgoal}} {
  655. my-foreground $proofwin $tag [get-option ancestorColor]
  656. $proofwin addtag current-subgoal withtag $tag
  657. return
  658. }
  659. }
  660. if [info exists ${path}(tcc)] {
  661. my-foreground $proofwin $tag [get-option tccColor]
  662. return
  663. }
  664. my-foreground $proofwin $tag [get-option displayforeground]
  665. }
  666. proc my-config {win type tag opt val} {
  667. foreach id [$win find withtag $tag] {
  668. if {[$win type $id]==$type} {
  669. $win itemconfig $id $opt $val
  670. }
  671. }
  672. }
  673. proc layout-proof {name theory interactive} {
  674. if {$interactive} {
  675. set proofwin .proof.u_$theory-$name-i.fr.c
  676. set top $theory-$name-i-top
  677. } else {
  678. set proofwin .proof.u_$theory-$name.fr.c
  679. set top $theory-$name-top
  680. }
  681. tree-layout $proofwin $top
  682. canvas-set-scroll $proofwin
  683. }
  684. proc canvas-set-scroll {win {recenter 0}} {
  685. global tk_version
  686. set allbbox [$win bbox all]
  687. set allbbox [lreplace $allbbox 1 1 [expr [lindex $allbbox 1]-10]]
  688. set allbbox [lreplace $allbbox 3 3 [expr [lindex $allbbox 3]+10]]
  689. $win config -scrollregion $allbbox
  690. update idletasks
  691. set winwid [winfo width $win]
  692. set bboxwid [expr [lindex $allbbox 2]-[lindex $allbbox 0]]
  693. set margin [expr ($winwid-$bboxwid)/2]
  694. if {$recenter} {
  695. if {$tk_version >= 4.0} {
  696. $win xview scroll [expr -$margin] units
  697. } else {
  698. set den [lindex [$win config -scrollincrement] 4]
  699. $win xview [expr -$margin / $den]
  700. }
  701. }
  702. }
  703. proc proof-current {name theory relpath} {
  704. global tk_version
  705. global curpath
  706. set proofwin .proof.u_$theory-$name-i.fr.c
  707. set ptop $theory-$name-i-top
  708. set path $theory-$name-i-$relpath
  709. if {[info exists curpath]} {
  710. $proofwin delete current-circle
  711. $proofwin dtag current-subgoal
  712. set ancs [ancestors $curpath $ptop]
  713. unset curpath
  714. foreach tag $ancs {
  715. update-color $proofwin $tag $tag
  716. }
  717. }
  718. if {$relpath!={}} {
  719. foreach tag [ancestors $path $ptop] {
  720. $proofwin addtag current-subgoal withtag $tag
  721. }
  722. my-foreground $proofwin current-subgoal [get-option ancestorColor]
  723. my-foreground $proofwin $path [get-option currentColor]
  724. set bbox [$proofwin bbox $path.real]
  725. regexp {^(.*).c} $proofwin whole fr
  726. set hscroll $fr.bottom.hscroll
  727. set vscroll $fr.vscroll
  728. set hget [$hscroll get]
  729. set vget [$vscroll get]
  730. if {$tk_version >= 4.0} {
  731. set units [lindex [$proofwin config -xscrollincrement] 4]
  732. } else {
  733. set units [lindex [$proofwin config -scrollincrement] 4]
  734. }
  735. # allbbox is the size of the entire proof tree
  736. set allbbox [lindex [$proofwin config -scrollregion] 4]
  737. set width [winfo width $proofwin]
  738. set height [winfo height $proofwin]
  739. if {$tk_version >= 4.0} {
  740. set hdiff [expr [lindex $allbbox 2] - [lindex $allbbox 0]]
  741. set vdiff [expr [lindex $allbbox 3] - [lindex $allbbox 1]]
  742. set left [expr [lindex $hget 0]*$hdiff + [lindex $allbbox 0]]
  743. set top [expr [lindex $vget 0]*$vdiff + [lindex $allbbox 1]]
  744. } else {
  745. set left [expr $units*[lindex $hget 2]+[lindex $allbbox 0]]
  746. set top [expr $units*[lindex $vget 2]+[lindex $allbbox 1]]
  747. }
  748. set right [expr $left+$width]
  749. set bottom [expr $top+$height]
  750. if {$tk_version >= 4.0} {
  751. if {$height >= $vdiff} {
  752. $proofwin yview moveto 0
  753. } elseif {[lindex $bbox 3]+10>$top} {
  754. set e [expr double([lindex $bbox 3]+10 - [lindex $allbbox 1] - $height)/$vdiff]
  755. $proofwin yview moveto $e
  756. } elseif {[lindex $bbox 1]-10<$bottom} {
  757. set e [expr double([lindex $bbox 3]+10 - [lindex $allbbox 1] - $height)/$vdiff]
  758. $proofwin yview moveto $e
  759. }
  760. if {$width >= $hdiff} {
  761. $proofwin xview moveto -0.5
  762. } elseif {[lindex $bbox 2]+10>$right} {
  763. set e [expr ([lindex $bbox 2] + 10 - [lindex $allbbox 0] - (.5 * $width))/$hdiff]
  764. $proofwin xview moveto $e
  765. } elseif {[lindex $bbox 0]-10<$left} {
  766. set e [expr double([lindex $bbox 2]+ 10 - [lindex $allbbox 0] - (.5 * $width))/$hdiff]
  767. $proofwin xview moveto $e
  768. }
  769. } else {
  770. if {[lindex $bbox 3]+10>$bottom} {
  771. set e [expr ([lindex $bbox 3]+10-$height-[lindex $allbbox 1])/$units]
  772. $proofwin yview $e
  773. } elseif {[lindex $bbox 1]-10<$top} {
  774. set e [expr ([lindex $bbox 1]-10-[lindex $allbbox 1])/$units]
  775. $proofwin yview $e
  776. }
  777. }
  778. if {$tk_version >= 4.0} {
  779. if {[lindex $bbox 2]+10>$right} {
  780. set e [expr ([lindex $bbox 2] + 10 - [lindex $allbbox 0] - (.5 * $width))/$hdiff]
  781. $proofwin xview moveto $e
  782. } elseif {[lindex $bbox 0]-10<$left} {
  783. set e [expr double([lindex $bbox 2]+ 10 - [lindex $allbbox 0] - (.5 * $width))/$hdiff]
  784. $proofwin xview moveto $e
  785. }
  786. } else {
  787. if {[lindex $bbox 2]+10>$right} {
  788. set e [expr ([lindex $bbox 2]+10-$width-[lindex $allbbox 0])/$units]
  789. $proofwin xview $e
  790. } elseif {[lindex $bbox 0]-10<$left} {
  791. set e [expr ([lindex $bbox 0]-10-[lindex $allbbox 0])/$units]
  792. $proofwin xview $e
  793. }
  794. }
  795. set pwid [expr [lindex $bbox 2]-[lindex $bbox 0]]
  796. set phit [expr [lindex $bbox 3]-[lindex $bbox 1]]
  797. if {[parse-bool [get-option circleCurrent]]} {
  798. $proofwin create oval \
  799. [expr [lindex $bbox 0]-$pwid/2.8] \
  800. [expr [lindex $bbox 1]-$phit/2.8] \
  801. [expr [lindex $bbox 2]+$pwid/2.8] \
  802. [expr [lindex $bbox 3]+$phit/2.8] \
  803. -tags "$path $path.outline current-circle [ancestors $path $ptop .desc]" \
  804. -outline [get-option currentColor] \
  805. -width 2
  806. }
  807. set curpath $path
  808. }
  809. }
  810. proc clear-message {top} {
  811. if [winfo exists $top] {
  812. $top.message config -text ""
  813. }
  814. }
  815. proc show-message {top text} {
  816. $top.message config -text $text
  817. after 5000 "clear-message $top"
  818. }
  819. proc gen-ps {top psfile landscape A4} {
  820. global canvcolors
  821. set w $top.fr.c
  822. set bbox [$w bbox all]
  823. set ht [max 792 [expr [lindex $bbox 3]-[lindex $bbox 1]]]
  824. set wd [max 595 [expr [lindex $bbox 2]-[lindex $bbox 0]]]
  825. $w postscript \
  826. -file $psfile \
  827. -x [lindex $bbox 0] \
  828. -width $wd \
  829. -y [lindex $bbox 1] \
  830. -height $ht \
  831. -pagewidth [expr {$A4 ? "595p" : "612p"}] \
  832. -rotate [expr {$landscape ? "yes" : "no"}]
  833. show-message $top "Saved PS to $psfile"
  834. }
  835. proc setup-dag-win {title icon PSname win_name class} {
  836. global tk_version
  837. reset-options
  838. catch {destroy $win_name}
  839. if {$tk_version >= 4.0} {
  840. set top [toplevel $win_name -width 400 -height 400 \
  841. -class $class -bd 2 -relief raised]
  842. } else {
  843. set top [toplevel $win_name -geometry 400x400 \
  844. -class $class -bd 2 -relief raised]
  845. }
  846. set geom [get-option geometry $top]
  847. if {$geom != {}} {
  848. wm geometry $top $geom
  849. }
  850. pack propagate $top 0
  851. wm title $top $title
  852. wm iconname $top $icon
  853. wm minsize $top 100 100
  854. wm maxsize $top 10000 10000
  855. set fr [frame $top.fr]
  856. pack $fr -expand yes -fill both
  857. set sbwidth 15
  858. frame $fr.bottom -width $sbwidth
  859. if {$tk_version >= 4.0} {
  860. set c [canvas $fr.c -height 1 -width 1 -bd 1 -relief sunken \
  861. -xscrollcommand "$fr.bottom.hscroll set" \
  862. -yscrollcommand "$fr.vscroll set" \
  863. -xscrollincrement 1 -yscrollincrement 1 \
  864. -highlightthickness 4]
  865. } else {
  866. set c [canvas $fr.c -height 1 -width 1 -bd 1 -relief sunken \
  867. -xscrollcommand "$fr.bottom.hscroll set" \
  868. -yscrollcommand "$fr.vscroll set" \
  869. -scrollincrement 1]
  870. }
  871. create-dag $c
  872. if {$tk_version >= 4.0} {
  873. frame $fr.bottom.right -height 18 -width 18 -bd 3 -relief flat
  874. scrollbar $fr.vscroll -width $sbwidth -bd 1 -relief sunken \
  875. -elementborderwidth 3 -highlightthickness 4 \
  876. -command "$c yview"
  877. scrollbar $fr.bottom.hscroll -width $sbwidth -bd 1 -relief sunken \
  878. -elementborderwidth 3 -highlightthickness 4 \
  879. -command "$c xview" -orient horiz
  880. } else {
  881. frame $fr.bottom.right -height 18 -width 25 -bd 3 -relief flat
  882. scrollbar $fr.vscroll -width $sbwidth -bd 2 -relief sunken \
  883. -command "$c yview"
  884. scrollbar $fr.bottom.hscroll -width $sbwidth -bd 2 -relief sunken \
  885. -command "$c xview" -orient horiz
  886. }
  887. # this makes the mouse wheel work for scrolling
  888. # ideally it should scroll one unit and
  889. # the scroll unit should be adjusted,
  890. # however, the positioning code does not tolerate
  891. # changing the scroll unit
  892. bind $c <Button-5> "$c yview scroll 50 units"
  893. bind $c <Button-4> "$c yview scroll -50 units"
  894. bind $c <Shift-Button-5> "$c xview scroll 50 units"
  895. bind $c <Shift-Button-4> "$c xview scroll -50 units"
  896. pack $fr.bottom -side bottom -fill x
  897. pack $fr.bottom.right -side right
  898. if {$tk_version >= 4.0} {
  899. pack $fr.bottom.hscroll -side bottom -fill x
  900. pack $fr.vscroll -side right -fill y
  901. pack $c -expand yes -fill both
  902. } else {
  903. pack $fr.bottom.hscroll -side bottom -fill x -padx 4 -pady 4
  904. pack $fr.vscroll -side right -fill y -padx 4 -pady 4
  905. pack $c -expand yes -fill both -padx 4 -pady 4
  906. }
  907. label $top.message -text ""
  908. pack $top.message -fill x -side bottom
  909. if {$tk_version >= 4.0} {
  910. # mark the hotkey D and bind the hotkeys Alt-d and q to this button
  911. button $top.dismiss -bd 3 -highlightthickness 2 -relief raised \
  912. -padx 4 -pady 4 \
  913. -text "Dismiss" -command "destroy $win_name" -underline 0
  914. } else {
  915. button $top.dismiss -bd 3 \
  916. -padx 4 -pady 4 \
  917. -text "Dismiss" -command "destroy $win_name" -underline 0
  918. }
  919. bind $top <Alt-d> "$top.dismiss invoke;break"
  920. bind $top <Key-q> "$top.dismiss invoke"
  921. pack $top.dismiss -side left -padx 4 -pady 2
  922. if {$tk_version >= 4.0} {
  923. menubutton $top.ps -bd 3 -highlightthickness 2 -relief raised \
  924. -padx 4 -pady 5 \
  925. -text "Gen PS" -menu $top.ps.menu -underline 4
  926. } else {
  927. menubutton $top.ps -bd 3 \
  928. -padx 4 -pady 5 \
  929. -text "Gen PS" -menu $top.ps.menu -relief raised -underline 4
  930. }
  931. menu $top.ps.menu
  932. $top.ps.menu add command -label "Portrait (Letter)" -command "gen-ps $top $PSname 0 0"
  933. $top.ps.menu add command -label "Landscape (Letter)" -command "gen-ps $top $PSname 1 0"
  934. $top.ps.menu add command -label "Portrait (A4)" -command "gen-ps $top $PSname 0 1"
  935. $top.ps.menu add command -label "Landscape (A4)" -command "gen-ps $top $PSname 1 1"
  936. pack $top.ps -side left -padx 4 -pady 2
  937. if {$tk_version >= 4.0} {
  938. button $top.help -bd 3 -highlightthickness 2 -relief raised \
  939. -padx 4 -pady 4 \
  940. -text "Help" -command "help-$class" -underline 0
  941. } else {
  942. button $top.help -bd 3 -relief raised \
  943. -padx 4 -pady 4 \
  944. -text "Help" -command "help-$class" -underline 0
  945. }
  946. bind $top <Alt-h> "$top.help invoke"
  947. pack $top.help -side right -padx 4 -pady 2
  948. if {$tk_version >= 4.0} {
  949. menubutton $top.conf -bd 3 -highlightthickness 2 -relief raised \
  950. -padx 4 -pady 5 \
  951. -text Config -menu $top.conf.menu -underline 0
  952. } else {
  953. menubutton $top.conf -bd 3 -relief raised \
  954. -padx 4 -pady 5 \
  955. -text Config -menu $top.conf.menu -underline 0
  956. }
  957. pack $top.conf -side right -padx 4 -pady 2
  958. menu $top.conf.menu
  959. $top.conf.menu add cascade -label "Horiz. Separation" \
  960. -menu $top.conf.menu.sepx
  961. $top.conf.menu add cascade -label "Vert. Separation" \
  962. -menu $top.conf.menu.sepy
  963. menu $top.conf.menu.sepx
  964. menu $top.conf.menu.sepy
  965. foreach i {5 10 20 50 100 200} {
  966. if {$tk_version >= 4.0} {
  967. $top.conf.menu.sepx add command -label $i \
  968. -command "option add Pvs$top*xSep $i; dagwin-layout $c"
  969. $top.conf.menu.sepy add command -label $i \
  970. -command "option add Pvs$top*ySep $i; dagwin-layout $c"
  971. } else {
  972. $top.conf.menu.sepx add command -label $i \
  973. -command "option add Tk$top*xSep $i; dagwin-layout $c"
  974. $top.conf.menu.sepy add command -label $i \
  975. -command "option add Tk$top*ySep $i; dagwin-layout $c"
  976. }
  977. }
  978. if {$tk_version >= 4.0} {
  979. $top.conf.menu.sepx add command -label Custom... \
  980. -command "make-setter $top x"
  981. $top.conf.menu.sepy add command -label Custom... \
  982. -command "make-setter $top y"
  983. } else {
  984. $top.conf.menu.sepx add command -label Custom... \
  985. -command "make-setter $top x"
  986. $top.conf.menu.sepy add command -label Custom... \
  987. -command "make-setter $top y"
  988. }
  989. set-dag-window-options $win_name
  990. return $c
  991. }
  992. proc make-setter {top orient} {
  993. global tk_version
  994. set win $top.${orient}Sep
  995. catch {destroy $win}
  996. toplevel $win -class Setter
  997. if {$orient=={x}} {
  998. wm title $win "Horizontal separation"
  999. wm iconname $win "Horiz sep"
  1000. } else {
  1001. wm title $win "Vertical separation"
  1002. wm iconname $win "Vert sep"
  1003. }
  1004. label $win.lab -text Separation:
  1005. pack $win.lab -side left
  1006. entry $win.ent -width 10 -relief sunken
  1007. if {$tk_version >= 4.0} {
  1008. bind $win.ent <Return> "option add Pvs$top*${orient}Sep \[%W get\]; dagwin-layout $top.fr.c; destroy $win"
  1009. } else {
  1010. bind $win.ent <Return> "option add Tk$top*${orient}Sep \[%W get\]; dagwin-layout $top.fr.c; destroy $win"
  1011. }
  1012. pack $win.ent -side left
  1013. focus $win.ent
  1014. }
  1015. # Proof Command Support
  1016. proc show-proof-commands {commands} {
  1017. show-prover-commands $commands
  1018. }
  1019. proc show-prover-commands {commands} {
  1020. global tk_version
  1021. set win .prover-commands
  1022. catch {destroy $win}
  1023. reset-options
  1024. toplevel $win -relief flat
  1025. wm maxsize $win 2000 2000
  1026. set geom [get-option geometry $win]
  1027. if {$geom != {}} {
  1028. wm geometry $win $geom
  1029. }
  1030. frame $win.fr
  1031. # underline and bind hotkey d
  1032. button $win.fr.dismiss -text Dismiss -bd 3 -command "destroy $win" -underline 0
  1033. bind $win <Alt-d> "$win.fr.dismiss invoke; break"
  1034. pack $win.fr.dismiss -side left -padx 2 -pady 2
  1035. # underline and bind hotkey h
  1036. button $win.fr.help -text Help -bd 3 -command "help-commands-window" -underline 0
  1037. bind $win <Alt-h> "$win.fr.help invoke"
  1038. pack $win.fr.help -side right -padx 2 -pady 2
  1039. pack $win.fr -side bottom -padx 2 -pady 2 -fill x
  1040. if {$tk_version >= 4.0} {
  1041. scrollbar $win.scrollbar -command "$win.text yview" -width 15 \
  1042. -elementborderwidth 3 -highlightthickness 4 -bd 1 -relief sunken
  1043. } else {
  1044. scrollbar $win.scrollbar -command "$win.text yview" -width 15 \
  1045. -bd 2 -relief sunken
  1046. }
  1047. if {$tk_version >= 4.0} {
  1048. pack $win.scrollbar -side right -fill y
  1049. } else {
  1050. pack $win.scrollbar -side right -fill y -padx 4 -pady 4
  1051. }
  1052. if {$tk_version >= 4.0} {
  1053. listbox $win.text -selectmode single -bd 1 -relief sunken \
  1054. -height 25 -width 27 -highlightthickness 4 \
  1055. -font [get-option displayfont] \
  1056. -yscrollcommand "$win.scrollbar set"
  1057. } else {
  1058. listbox $win.text -bd 1 -relief sunken -geometry 25x27 \
  1059. -font [get-option displayfont] \
  1060. -yscrollcommand "$win.scrollbar set"
  1061. }
  1062. bind $win.text <Enter> "focus %W"
  1063. bind $win.text <Motion> "prover-command-select %W %y"
  1064. if {$tk_version >= 4.0} {
  1065. bind $win.text <Leave> "%W selection clear 0 end"
  1066. } else {
  1067. bind $win.text <Leave> "%W select clear"
  1068. }
  1069. if {$tk_version >= 4.0} {
  1070. bind $win.text <Button-1> {
  1071. send-command %W %y
  1072. break
  1073. }
  1074. } else {
  1075. bind $win.text <Button-1> "send-command %W %y"
  1076. }
  1077. bind $win.text <Shift-Button-1> "nop"
  1078. bind $win.text <B1-Motion> "nop"
  1079. bind $win.text <Shift-B1-Motion> "nop"
  1080. bind $win.text <Button-2> "help-command %W %y"
  1081. bind $win.text <B2-Motion> "nop"
  1082. bind $win.text <Button-3> "help-strategy %W %y"
  1083. if {$tk_version >= 4.0} {
  1084. bind $win.text <space> {
  1085. prover-commands-page-down %y
  1086. break
  1087. }
  1088. } else {
  1089. bind $win.text <space> "prover-commands-page-down %y"
  1090. }
  1091. bind $win.text d "prover-commands-page-down %y"
  1092. bind $win.text <Delete> "prover-commands-page-up %y"
  1093. bind $win.text u "prover-commands-page-up %y"
  1094. bind $win.text c "send-command %W %y"
  1095. bind $win.text h "help-command %W %y"
  1096. bind $win.text s "help-strategy %W %y"
  1097. if {$tk_version < 4.0} {
  1098. tk_listboxSingleSelect $win.text
  1099. }
  1100. pack $win.text -side left -fill both -expand 1 -padx 4 -pady 4
  1101. foreach cmd $commands {
  1102. $win.text insert end $cmd
  1103. }
  1104. set-prover-commands-options
  1105. wm iconname $win {PVS Prover Commands}
  1106. wm title $win "PVS Prover Commands"
  1107. }
  1108. proc set-prover-commands-options {} {
  1109. set-prover-commands-windowbackground [get-option windowbackground]
  1110. set-prover-commands-displaybackground [get-option displaybackground]
  1111. set-prover-commands-displayforeground [get-option displayforeground]
  1112. set-prover-commands-activedisplaybackground \
  1113. [get-option activedisplaybackground]
  1114. set-prover-commands-activedisplayforeground \
  1115. [get-option activedisplayforeground]
  1116. set-prover-commands-displayfont [get-option displayfont]
  1117. set-prover-commands-buttonbackground [get-option buttonbackground]
  1118. set-prover-commands-buttonforeground [get-option buttonforeground]
  1119. set-prover-commands-activebuttonbackground \
  1120. [get-option activebuttonbackground]
  1121. set-prover-commands-activebuttonforeground \
  1122. [get-option activebuttonforeground]
  1123. set-prover-commands-troughcolor [get-option troughcolor]
  1124. set-prover-commands-buttonfont [get-option buttonfont]
  1125. }
  1126. proc set-prover-commands-windowbackground {color} {
  1127. global tk_version
  1128. .prover-commands config -background $color
  1129. .prover-commands.fr config -background $color
  1130. if {$tk_version >= 4.0} {
  1131. .prover-commands.text config -highlightbackground $color
  1132. .prover-commands.text config -highlightcolor $color
  1133. .prover-commands.scrollbar config -highlightbackground $color
  1134. }
  1135. }
  1136. proc set-prover-commands-displaybackground {color} {
  1137. .prover-commands.text config -background $color
  1138. }
  1139. proc set-prover-commands-displayforeground {color} {
  1140. .prover-commands.text config -foreground $color
  1141. }
  1142. proc set-prover-commands-activedisplaybackground {color} {
  1143. .prover-commands.text config -selectbackground $color
  1144. }
  1145. proc set-prover-commands-activedisplayforeground {color} {
  1146. .prover-commands.text config -selectforeground $color
  1147. }
  1148. proc set-prover-commands-displayfont {font} {
  1149. .prover-commands.text config -font $font
  1150. }
  1151. proc set-prover-commands-buttonbackground {color} {
  1152. global tk_version
  1153. if {$tk_version >= 4.0} {
  1154. .prover-commands.scrollbar config -background $color
  1155. } else {
  1156. .prover-commands.scrollbar config -foreground $color
  1157. }
  1158. foreach btn [winfo children .prover-commands.fr] {
  1159. $btn config -background $color
  1160. }
  1161. }
  1162. proc set-prover-commands-buttonforeground {color} {
  1163. foreach btn [winfo children .prover-commands.fr] {
  1164. $btn config -foreground $color
  1165. }
  1166. }
  1167. proc set-prover-commands-activebuttonbackground {color} {
  1168. global tk_version
  1169. if {$tk_version >= 4.0} {
  1170. .prover-commands.scrollbar config -activebackground $color
  1171. }
  1172. foreach btn [winfo children .prover-commands.fr] {
  1173. $btn config -activebackground $color
  1174. }
  1175. }
  1176. proc set-prover-commands-activebuttonforeground {color} {
  1177. foreach btn [winfo children .prover-commands.fr] {
  1178. $btn config -activeforeground $color
  1179. }
  1180. }
  1181. proc set-prover-commands-troughcolor {color} {
  1182. global tk_version
  1183. if {$tk_version >= 4.0} {
  1184. .prover-commands.scrollbar config -troughcolor $color
  1185. foreach btn [winfo children .prover-commands.fr] {
  1186. $btn config -highlightbackground $color
  1187. }
  1188. } else {
  1189. .prover-commands.scrollbar config -background $color
  1190. }
  1191. }
  1192. proc set-prover-commands-buttonfont {font} {
  1193. foreach btn [winfo children .prover-commands.fr] {
  1194. $btn config -font $font
  1195. }
  1196. }
  1197. proc prover-command-select {win y} {
  1198. global tk_version
  1199. if {$tk_version >= 4.0} {
  1200. $win selection clear 0 end
  1201. $win selection set [$win nearest $y]
  1202. } else {
  1203. $win select from [$win nearest $y]
  1204. }
  1205. }
  1206. proc prover-commands-page-down {y} {
  1207. global tk_version
  1208. set val [.prover-commands.scrollbar get]
  1209. if {$tk_version >= 4.0} {
  1210. set first [lindex $val 0]
  1211. set last [lindex $val 1]
  1212. set nfirst $last
  1213. set nlast [expr $last + $last - $first]
  1214. if {$nlast > 1.0} {
  1215. .prover-commands.text yview moveto 1.0
  1216. } else {
  1217. .prover-commands.text yview moveto $nfirst
  1218. }
  1219. prover-command-select .prover-commands.text $y
  1220. } else {
  1221. set v0 [lindex $val 0]
  1222. set v1 [lindex $val 1]
  1223. set v2 [lindex $val 2]
  1224. set v3 [lindex $val 3]
  1225. set nv3 [min $v3 [expr $v0 - $v1]]
  1226. set cur [lindex [.prover-commands.text curselection] 0]
  1227. set ny [expr $nv3 + $cur - $v2]
  1228. .prover-commands.scrollbar set $v0 $v1 $nv3 [expr $nv3 + $v1 -1]
  1229. .prover-commands.text yview $nv3
  1230. .prover-commands.text select from $ny
  1231. }
  1232. }
  1233. proc prover-commands-page-up {y} {
  1234. global tk_version
  1235. set val [.prover-commands.scrollbar get]
  1236. if {$tk_version >= 4.0} {
  1237. set first [lindex $val 0]
  1238. set last [lindex $val 1]
  1239. set nfirst [expr $first - ($last - $first)]
  1240. if {$nfirst < 0.0} {
  1241. .prover-commands.text yview moveto 0.0
  1242. } else {
  1243. .prover-commands.text yview moveto $nfirst
  1244. }
  1245. prover-command-select .prover-commands.text $y
  1246. } else {
  1247. set v0 [lindex $val 0]
  1248. set v1 [lindex $val 1]
  1249. set v2 [lindex $val 2]
  1250. set v3 [lindex $val 3]
  1251. set nv2 [max 0 [expr $v2 - $v1 + 1]]
  1252. set cur [lindex [.prover-commands.text curselection] 0]
  1253. set ny [expr $cur - $v2 + $nv2]
  1254. .prover-commands.scrollbar set $v0 $v1 $nv2 [expr $nv2 + $v1 - 1]
  1255. .prover-commands.text yview [expr $nv2]
  1256. .prover-commands.text select from $ny
  1257. }
  1258. }
  1259. proc send-command {win y} {
  1260. set index [$win nearest $y]
  1261. set cmd [$win get $index]
  1262. emacs-evaln "(progn (switch-to-lisp t t) \
  1263. (goto-char (point-max)) (pvs-prover-any-command \"$cmd\"))"
  1264. }
  1265. proc help-command {win y} {
  1266. set index [$win nearest $y]
  1267. set cmd [$win get $index]
  1268. emacs-evaln "(help-pvs-prover-command \"$cmd\")"
  1269. }
  1270. proc help-strategy {win y} {
  1271. set index [$win nearest $y]
  1272. set cmd [$win get $index]
  1273. emacs-evaln "(help-pvs-prover-strategy \"$cmd\")"
  1274. }
  1275. proc show-declaration {id width height decl} {
  1276. set win .declaration-$id
  1277. catch {destroy $win}
  1278. toplevel $win -relief raised -bd 2
  1279. text $win.text -width $width -height $height
  1280. $win.text insert end $decl
  1281. button $win.dismiss -text Dismiss -command "destroy $win"
  1282. # bind hotkey d
  1283. bind $win <Alt-d> "$win.dismiss invoke; break"
  1284. pack $win.text -side top
  1285. pack $win.dismiss -side left -padx 2 -pady 2
  1286. wm iconname $win {PVS Declaration}
  1287. wm title $win "Declaration $id"
  1288. }
  1289. # Theory hierarchy support
  1290. proc module-hierarchy {name file directory dag} {
  1291. catch {frame .theory-hierarchy}
  1292. # put the u_ in in case $name starts with an uppercase letter
  1293. set thwin .theory-hierarchy.u_$name
  1294. set win \
  1295. [setup-dag-win \
  1296. "Theory hierarchy for $name in $directory$file" \
  1297. "Theory Hierarchy" \
  1298. $directory${name}_hier.ps \
  1299. $thwin \
  1300. TheoryHierarchy]
  1301. dag-bind-move $win {} Control 1 both
  1302. $win bind :theory <Enter> "module-highlight $win"
  1303. $win bind :theory <Leave> "module-unhighlight $win"
  1304. $win bind :theory <1> "select-theory $win"
  1305. foreach item $dag {
  1306. set th [lindex $item 0]
  1307. set succs [lindex $item 1]
  1308. $win create text 0 0 -text $th -tags "$th $th.real :theory" -anchor n
  1309. dag-add-item $win $th $succs {}
  1310. }
  1311. $win lower dagline
  1312. dag-layout $win $name
  1313. canvas-set-scroll $win 1
  1314. }
  1315. proc select-theory {win} {
  1316. upvar #0 dag-$win dag
  1317. set id [$win find withtag current]
  1318. set item $dag(idtotag,$id)
  1319. emacs-eval "(find-theory \"$item\")"
  1320. }
  1321. proc module-highlight {win} {
  1322. upvar #0 dag-$win dag
  1323. global tk_version
  1324. global mono
  1325. set id [$win find withtag current]
  1326. set item $dag(idtotag,$id)
  1327. $win dtag :hier_highlight
  1328. $win addtag :hier_highlight withtag $item
  1329. $win addtag :hier_highlight withtag dagline.to$item
  1330. $win addtag :hier_highlight withtag dagline.from$item
  1331. if {$tk_version >= 4.0} {
  1332. if {[winfo depth .]==1 || $mono} {
  1333. my-foreground $win :hier_highlight @gray
  1334. } else {
  1335. my-foreground $win :hier_highlight \
  1336. [get-option activedisplayforeground]
  1337. }
  1338. } else {
  1339. if {[tk colormodel .]!={color} || $mono} {
  1340. my-foreground $win :hier_highlight @gray
  1341. } else {
  1342. my-foreground $win :hier_highlight \
  1343. [get-option activedisplayforeground]
  1344. }
  1345. }
  1346. }
  1347. proc module-unhighlight {win} {
  1348. my-foreground $win :hier_highlight [get-option displayforeground]
  1349. }
  1350. # Called from wish.lisp to set up a proof
  1351. proc setup-proof {name theory directory counter interactive} {
  1352. global curpath
  1353. catch {frame .proof}
  1354. if {$interactive} {
  1355. set win .proof.u_$theory-$name-i
  1356. set top $theory-$name-i-top
  1357. } else {
  1358. set win .proof.u_$theory-$name
  1359. set top $theory-$name-top
  1360. }
  1361. set pw \
  1362. [setup-dag-win \
  1363. "Proof of $name in $theory" \
  1364. "PVS Proof" \
  1365. $directory${theory}_$name.ps \
  1366. $win \
  1367. Proof]
  1368. if {$interactive} {
  1369. if {[info exists curpath]} {
  1370. unset curpath
  1371. }
  1372. set proofwin $pw
  1373. }
  1374. dag-bind-move $pw .desc Control 1 to
  1375. dag-bind-move $pw {} Control 2 both
  1376. if {$interactive} {
  1377. $pw bind sequent <1> "show-sequent $pw $top"
  1378. } else {
  1379. set text "Sequent is only available for interactive proofs"
  1380. $pw bind sequent <1> "show-message $win \"$text\""
  1381. }
  1382. # generate a contextmenu that will appear, when the right mouse
  1383. # button is pressed on a rule
  1384. # item two is changed later for interactive proofs, see rule-menu
  1385. menu $pw.rulemenu
  1386. $pw.rulemenu add command -label "Rule Window" \
  1387. -command "get-full-rule $pw $top" \
  1388. -underline 5
  1389. $pw.rulemenu add command -label "Run" -underline 0 \
  1390. -command "show-message $win \"Only available for \
  1391. interactive proofs\""
  1392. $pw.rulemenu add command -label "Select" -underline 0 \
  1393. -command "rule-select $pw $top"
  1394. # set the selection handler for dealing with the primary selection
  1395. selection handle $pw {handle-selection}
  1396. $pw bind rule <1> "get-full-rule $pw $top"
  1397. $pw bind rule <3> "rule-menu %X %Y $pw $top $interactive"
  1398. bind $pw <Destroy> "+pvs-send {(stop-displaying-proof $counter)}"
  1399. bind $pw <Destroy> {+
  1400. foreach kid [winfo children .] {
  1401. if {[string match .sequent* $kid]} {
  1402. destroy $kid
  1403. }
  1404. }
  1405. }
  1406. }
  1407. # this is the selection handler
  1408. # the other function, which is used for selecting rules is
  1409. # rule-select defined above
  1410. proc handle-selection {offset max} {
  1411. global current_selection
  1412. return [string range $current_selection $offset [expr $offset + $max - 1]]
  1413. }
  1414. proc reset-options {} {
  1415. global tk_version
  1416. global mono
  1417. option clear
  1418. if {$tk_version >= 4.0} {
  1419. set pvs [winfo name .]
  1420. option add $pvs.displayfont 7x13bold startupFile
  1421. option add $pvs.buttonfont 6x10 startupFile
  1422. if {[winfo depth .] > 1 && !$mono} {
  1423. option add $pvs.windowbackground wheat startupFile
  1424. option add $pvs.displaybackground white startupFile
  1425. option add $pvs.displayforeground black startupFile
  1426. option add $pvs.activedisplaybackground black startupFile
  1427. option add $pvs.activedisplayforeground steelblue startupFile
  1428. option add $pvs.buttonbackground lightblue startupFile
  1429. option add $pvs.buttonforeground black startupFile
  1430. option add $pvs.activebuttonbackground steelblue startupFile
  1431. option add $pvs.activebuttonforeground white startupFile
  1432. option add $pvs.troughcolor sienna3 startupFile
  1433. # sequent colors
  1434. option add $pvs.currentColor DarkOrchid startupFile
  1435. option add $pvs.circleCurrent yes startupFile
  1436. option add $pvs.tccColor green4 startupFile
  1437. option add $pvs.doneColor blue startupFile
  1438. option add $pvs.ancestorColor firebrick startupFile
  1439. } else {
  1440. option add $pvs.windowbackground white startupFile
  1441. option add $pvs.displaybackground white startupFile
  1442. option add $pvs.displayforeground black startupFile
  1443. option add $pvs.activedisplaybackground black startupFile
  1444. option add $pvs.activedisplayforeground @gray startupFile
  1445. option add $pvs.buttonbackground white startupFile
  1446. option add $pvs.buttonforeground black startupFile
  1447. option add $pvs.activebuttonbackground black startupFile
  1448. option add $pvs.activebuttonforeground white startupFile
  1449. option add $pvs.troughcolor black startupFile
  1450. # sequent colors
  1451. option add $pvs.currentColor black startupFile
  1452. option add $pvs.circleCurrent yes startupFile
  1453. option add $pvs.tccColor black startupFile
  1454. option add $pvs.doneColor @gray startupFile
  1455. option add $pvs.ancestorColor black startupFile
  1456. }
  1457. option add $pvs.abbrevLen 35 startupFile
  1458. option add $pvs.maxHeight 30 startupFile
  1459. option add $pvs*proof*xSep 10 startupFile
  1460. option add $pvs*proof*ySep 20 startupFile
  1461. option add $pvs*theory-hierarchy*xSep 50 startupFile
  1462. option add $pvs*theory-hierarchy*ySep 100 startupFile
  1463. } else {
  1464. option add Tk.displayfont 7x13bold startupFile
  1465. option add Tk.buttonfont 6x10 startupFile
  1466. if {[tk colormodel .]=={color} && !$mono} {
  1467. option add Tk.windowbackground wheat startupFile
  1468. option add Tk.displaybackground white startupFile
  1469. option add Tk.displayforeground black startupFile
  1470. option add Tk.activedisplaybackground mediumslateblue startupFile
  1471. option add Tk.activedisplayforeground steelblue startupFile
  1472. option add Tk.buttonbackground lightblue startupFile
  1473. option add Tk.buttonforeground black startupFile
  1474. option add Tk.activebuttonbackground steelblue startupFile
  1475. option add Tk.activebuttonforeground white startupFile
  1476. option add Tk.troughcolor sienna3 startupFile
  1477. # sequent colors
  1478. option add Tk.currentColor DarkOrchid startupFile
  1479. option add Tk.circleCurrent yes startupFile
  1480. option add Tk.tccColor green4 startupFile
  1481. option add Tk.doneColor blue startupFile
  1482. option add Tk.ancestorColor firebrick startupFile
  1483. } else {
  1484. option add Tk.windowbackground white startupFile
  1485. option add Tk.displaybackground white startupFile
  1486. option add Tk.displayforeground black startupFile
  1487. option add Tk.activedisplaybackground black startupFile
  1488. option add Tk.activedisplayforeground @gray startupFile
  1489. option add Tk.buttonbackground white startupFile
  1490. option add Tk.buttonforeground black startupFile
  1491. option add Tk.activebuttonbackground black startupFile
  1492. option add Tk.activebuttonforeground white startupFile
  1493. option add Tk.troughcolor black startupFile
  1494. # sequent colors
  1495. option add Tk.currentColor black startupFile
  1496. option add Tk.circleCurrent yes startupFile
  1497. option add Tk.tccColor black startupFile
  1498. option add Tk.doneColor @gray startupFile
  1499. option add Tk.ancestorColor black startupFile
  1500. }
  1501. option add Tk.abbrevLen 35 startupFile
  1502. option add Tk.maxHeight 30 startupFile
  1503. option add Tk*proof*xSep 10 startupFile
  1504. option add Tk*proof*ySep 20 startupFile
  1505. option add Tk*theory-hierarchy*xSep 50 startupFile
  1506. option add Tk*theory-hierarchy*ySep 100 startupFile
  1507. }
  1508. }
  1509. proc get-option {opt {win .}} {
  1510. set cap [string toupper [string range $opt 0 0]][string range $opt 1 end]
  1511. option get [resource-window $win] $opt $cap
  1512. }
  1513. proc set-dag-window-options {win} {
  1514. set-dag-window-windowbackground $win [get-option windowbackground]
  1515. set-dag-window-displaybackground $win [get-option displaybackground]
  1516. set-dag-window-buttonbackground $win [get-option buttonbackground]
  1517. set-dag-window-buttonforeground $win [get-option buttonforeground]
  1518. set-dag-window-activebuttonbackground $win [get-option activebuttonbackground]
  1519. set-dag-window-activebuttonforeground $win [get-option activebuttonforeground]
  1520. set-dag-window-troughcolor $win [get-option troughcolor]
  1521. set-dag-window-buttonfont $win [get-option buttonfont]
  1522. }
  1523. proc set-dag-window-windowbackground {win color} {
  1524. global tk_version
  1525. $win config -background $color
  1526. $win.fr config -background $color
  1527. $win.fr.bottom config -background $color
  1528. $win.fr.bottom.right config -background $color
  1529. $win.message config -background $color
  1530. if {$tk_version >= 4.0} {
  1531. $win.fr.c config -highlightbackground $color
  1532. $win.fr.bottom.hscroll config -highlightbackground $color
  1533. $win.fr.vscroll config -highlightbackground $color
  1534. }
  1535. }
  1536. proc set-dag-window-displaybackground {win color} {
  1537. $win.fr.c config -background $color
  1538. }
  1539. proc set-dag-window-buttonbackground {win color} {
  1540. global tk_version
  1541. if {$tk_version >= 4.0} {
  1542. $win.fr.vscroll config -background $color
  1543. $win.fr.bottom.hscroll config -background $color
  1544. } else {
  1545. $win.fr.vscroll config -foreground $color
  1546. $win.fr.bottom.hscroll config -foreground $color
  1547. }
  1548. foreach ch [winfo children $win] {
  1549. set cl [winfo class $ch]
  1550. if {$cl == "Button" || $cl == "Menubutton"} {
  1551. $ch config -background $color
  1552. }
  1553. }
  1554. }
  1555. proc set-dag-window-buttonforeground {win color} {
  1556. foreach ch [winfo children $win] {
  1557. set cl [winfo class $ch]
  1558. if {$cl == "Button" || $cl == "Menubutton"} {
  1559. $ch config -foreground $color
  1560. }
  1561. }
  1562. }
  1563. proc set-dag-window-activebuttonbackground {win color} {
  1564. global tk_version
  1565. if {$tk_version >= 4.0} {
  1566. $win.fr.vscroll config -activebackground $color
  1567. $win.fr.bottom.hscroll config -activebackground $color
  1568. }
  1569. foreach ch [winfo children $win] {
  1570. set cl [winfo class $ch]
  1571. if {$cl == "Button" || $cl == "Menubutton"} {
  1572. $ch config -activebackground $color
  1573. }
  1574. }
  1575. }
  1576. proc set-dag-window-activebuttonforeground {win color} {
  1577. foreach ch [winfo children $win] {
  1578. set cl [winfo class $ch]
  1579. if {$cl == "Button" || $cl == "Menubutton"} {
  1580. $ch config -activeforeground $color
  1581. }
  1582. }
  1583. }
  1584. proc set-dag-window-troughcolor {win color} {
  1585. global tk_version
  1586. if {$tk_version >= 4.0} {
  1587. $win.fr.vscroll config -troughcolor $color
  1588. $win.fr.bottom.hscroll config -troughcolor $color
  1589. foreach ch [winfo children $win] {
  1590. set cl [winfo class $ch]
  1591. if {$cl == "Button" || $cl == "Menubutton"} {
  1592. $ch config -highlightbackground $color
  1593. }
  1594. }
  1595. } else {
  1596. $win.fr.vscroll config -background $color
  1597. $win.fr.bottom.hscroll config -background $color
  1598. }
  1599. }
  1600. proc set-dag-window-buttonfont {win font} {
  1601. foreach ch [winfo children $win] {
  1602. set cl [winfo class $ch]
  1603. if {$cl == "Button" || $cl == "Menubutton"} {
  1604. $ch config -font $font
  1605. }
  1606. }
  1607. }
  1608. proc parse-bool {str} {
  1609. set val 0
  1610. catch {
  1611. if "{$str}" {
  1612. set val 1
  1613. }
  1614. }
  1615. return $val
  1616. }
  1617. proc help-Proof {} {
  1618. set win .proverhelp
  1619. catch {destroy $win}
  1620. toplevel $win -relief raised -bd 2
  1621. message $win.text -aspect 390 -text "This is a proof display. The turnstiles represent sequents, and are connected by proof commands.
  1622. The mouse has the following bindings:
  1623. Left on turnstile - display the corresponding sequent
  1624. Left on rule - display the rule in its own window
  1625. C-Left on turnstile or rule - moves the subtree rooted at that pair
  1626. C-Middle on turnstile or rule - moves the turnstile/rule pair only
  1627. mouse wheel - move the viewport vertically
  1628. shift mouse wheel - move the viewport horizontally
  1629. Right on rule - context menu with the following options
  1630. Rule Window - display the rule in its own window
  1631. Run - rerun this proof command on the current goal
  1632. Select - copy command to the primary selection
  1633. Buttons that have an underscored letter, can be invoked via Alt-x,
  1634. where x is the corresponding letter.
  1635. Apart from the underscored letters there is the following key binding:
  1636. q - dismiss the window "
  1637. button $win.dismiss -text Dismiss -command "destroy $win" -underline 0
  1638. bind $win <Alt-d> "$win.dismiss invoke; break"
  1639. pack $win.text -side top
  1640. pack $win.dismiss -side left -padx 2 -pady 2
  1641. wm iconname $win {PVS help prooftree}
  1642. wm title $win "Prooftree Help"
  1643. }
  1644. proc help-TheoryHierarchy {} {
  1645. set win .hierarchyhelp
  1646. catch {destroy $win}
  1647. toplevel $win -relief raised -bd 2
  1648. message $win.text -aspect 390 -text "This is a theory hierarchy display. Each name represents a theory, and the arcs represent IMPORTINGs between theories, where the imported theory is below the importing theory.
  1649. The mouse has the following bindings:
  1650. Left on theory name - display that theory in an Emacs buffer
  1651. C-Left on theory name - moves the name"
  1652. # underline and bind d
  1653. button $win.dismiss -text Dismiss -command "destroy $win" -underline 0
  1654. bind $win <Alt-d> "$win.dismiss invoke; break"
  1655. pack $win.text -side top
  1656. pack $win.dismiss -side left -padx 2 -pady 2
  1657. wm iconname $win {PVS help hierarchy}
  1658. wm title $win "Theory Hierarchy Help"
  1659. }
  1660. proc help-sequent {} {
  1661. set win .sequenthelp
  1662. catch {destroy $win}
  1663. toplevel $win -relief raised -bd 2
  1664. message $win.text -aspect 390 -text "This is a sequent display.
  1665. The titlebar should give a sequent number along with the formula name.
  1666. The sequent number is associated with the corresponding number next to
  1667. one of the sequents of the proof tree; it may not be visible.
  1668. The Dismiss button removes the sequent window. The window is also
  1669. removed when the proof tree is modified so that the associated sequent
  1670. no longer exists. The Stick button causes the sequent to remain even in
  1671. this case. When the stick button is depressed, it disappears. All buttons
  1672. can be invoked via mouse or via Alt-hotkey, where hotkey is the underscored
  1673. letter on the button."
  1674. # underline and bind d
  1675. button $win.dismiss -text Dismiss -command "destroy $win" -underline 0
  1676. bind $win <Alt-d> "$win.dismiss invoke; break"
  1677. pack $win.text -side top
  1678. pack $win.dismiss -side left -padx 2 -pady 2
  1679. wm iconname $win {PVS help sequent}
  1680. wm title $win "Sequent Help"
  1681. }
  1682. proc help-commands-window {} {
  1683. set win .commands-help
  1684. catch {destroy $win}
  1685. toplevel $win -relief raised -bd 2
  1686. message $win.text -aspect 390 -text \
  1687. "This displays all of the prover commands, including user-defined ones.
  1688. The following mouse and key bindings are available:
  1689. Alt-x - invoke the button, which has letter \"x\" underscored
  1690. Space, d - page down
  1691. Delete, u - page up
  1692. Left, c - sends selected command to the prover window
  1693. Middle, h - provides help for selected command
  1694. Right, s - provides strategy description for selected command"
  1695. # underline and bind d
  1696. button $win.dismiss -text Dismiss -command "destroy $win" -underline 0
  1697. bind $win <Alt-d> "$win.dismiss invoke; break"
  1698. pack $win.text -side top
  1699. pack $win.dismiss -side left -padx 2 -pady 2
  1700. wm iconname $win {PVS Command Help}
  1701. wm title $win "Prover Command Help"
  1702. }
  1703. proc nop {} {
  1704. }
  1705. proc min {x y} {
  1706. if {$x < $y} then {return $x} else {return $y}
  1707. }
  1708. proc max {x y} {
  1709. if {$x < $y} then {return $y} else {return $x}
  1710. }
  1711. proc allinfo {win} {
  1712. ppr $win
  1713. foreach c [winfo children $win] {
  1714. allinfo $c
  1715. }
  1716. }
  1717. proc ppr {win} {
  1718. puts "\n$win"
  1719. foreach opt [$win config] {
  1720. puts " $opt"
  1721. }
  1722. }
  1723. proc tkcatch {script {varname novar}} {
  1724. global $varname
  1725. catch {rename tkerror tkerror.orig}
  1726. proc tkerror {err} {error $err}
  1727. set value [eval catch {$script} $varname]
  1728. rename tkerror {}
  1729. catch {rename tkerror.orig tkerror}
  1730. return $value
  1731. }
  1732. proc resource-window {path} {
  1733. if {$path == "."} {
  1734. return $path
  1735. } elseif {[winfo parent $path] == "."} {
  1736. return $path
  1737. } else {
  1738. resource-window [winfo parent $path]
  1739. }
  1740. }