Abstract out popup management.
This commit is contained in:
parent
46b984a94b
commit
e59a84dc96
|
@ -3,7 +3,7 @@
|
|||
(require racket/string racket/class racket/gui/base
|
||||
unstable/sequence unstable/pretty)
|
||||
|
||||
(provide format-message make-color-table)
|
||||
(provide popup-callback make-color-table)
|
||||
|
||||
(define (format-message stxs+msgs)
|
||||
(string-join (for/list ([(stx msg) (in-pairs stxs+msgs)])
|
||||
|
@ -14,6 +14,21 @@
|
|||
msg))
|
||||
"\n\n"))
|
||||
|
||||
(define ((popup-callback stxs+msgs) ed start end)
|
||||
(define text (new text%))
|
||||
(define win (new dialog%
|
||||
[label "Performance Report"]
|
||||
[width 500]
|
||||
[height 300]))
|
||||
(define editor-canvas
|
||||
(new editor-canvas% [parent win] [editor text]
|
||||
[style '(no-hscroll)]))
|
||||
(send text auto-wrap #t)
|
||||
(send text insert-port (open-input-string
|
||||
(format-message stxs+msgs)))
|
||||
(send text lock #t)
|
||||
(send win show #t))
|
||||
|
||||
(define lowest-badness-color (make-object color% "pink"))
|
||||
(define highest-badness-color (make-object color% "red"))
|
||||
;; the higher the badness, the closer to red the highlight should be
|
||||
|
|
|
@ -52,21 +52,7 @@
|
|||
(vector-ref color-table
|
||||
(missed-opt-report-entry-badness l)))])
|
||||
(send this highlight-range start end color)
|
||||
(send this set-clickback start end
|
||||
(lambda (ed start end)
|
||||
(define text (new text%))
|
||||
(define win (new dialog%
|
||||
[label "Performance Report"]
|
||||
[width 500]
|
||||
[height 300]))
|
||||
(define editor-canvas
|
||||
(new editor-canvas% [parent win] [editor text]
|
||||
[style '(no-hscroll)]))
|
||||
(send text auto-wrap #t)
|
||||
(send text insert-port (open-input-string
|
||||
(format-message stxs+msgs)))
|
||||
(send text lock #t)
|
||||
(send win show #t)))
|
||||
(send this set-clickback start end (popup-callback stxs+msgs))
|
||||
;; record highlights to undo them later
|
||||
(cons (list start end color)
|
||||
;; missed optimizations have irritants, circle them
|
||||
|
|
Loading…
Reference in New Issue
Block a user