macro-debugger:
add tack/untack to normal context menu fix arrows bug, caused by bug in interval-map unstable/interval-map: fixed stupid update*! bug svn: r17346
This commit is contained in:
parent
f0b09a0842
commit
9c8ad7bb7f
|
@ -84,6 +84,11 @@
|
||||||
;; add-keymap : text snip
|
;; add-keymap : text snip
|
||||||
add-keymap))
|
add-keymap))
|
||||||
|
|
||||||
|
;; keymap/popup<%>
|
||||||
|
(define-interface keymap/popup<%> ()
|
||||||
|
(;; add-context-menu-items : popup-menu -> void
|
||||||
|
add-context-menu-items))
|
||||||
|
|
||||||
;; display<%>
|
;; display<%>
|
||||||
(define-interface display<%> ()
|
(define-interface display<%> ()
|
||||||
(;; refresh : -> void
|
(;; refresh : -> void
|
||||||
|
|
|
@ -4,75 +4,54 @@
|
||||||
unstable/gui/notify
|
unstable/gui/notify
|
||||||
"interfaces.ss"
|
"interfaces.ss"
|
||||||
"partition.ss")
|
"partition.ss")
|
||||||
(provide smart-keymap%
|
(provide syntax-keymap%)
|
||||||
syntax-keymap%)
|
|
||||||
|
|
||||||
(define smart-keymap%
|
(define keymap/popup%
|
||||||
(class keymap%
|
(class* keymap% (keymap/popup<%>)
|
||||||
(init editor)
|
(init editor)
|
||||||
|
(super-new)
|
||||||
(inherit add-function
|
(inherit add-function
|
||||||
map-function
|
map-function
|
||||||
chain-to-keymap)
|
chain-to-keymap)
|
||||||
|
|
||||||
(super-new)
|
(define/public (add-context-menu-items menu)
|
||||||
|
(void))
|
||||||
|
|
||||||
(define/public (get-context-menu%)
|
(map-function "rightbutton" "popup-context-menu")
|
||||||
smart-context-menu%)
|
(add-function "popup-context-menu"
|
||||||
|
|
||||||
(field (the-context-menu #f))
|
|
||||||
(set! the-context-menu (new (get-context-menu%)))
|
|
||||||
|
|
||||||
(map-function "rightbutton" "popup-context-window")
|
|
||||||
(add-function "popup-context-window"
|
|
||||||
(lambda (editor event)
|
(lambda (editor event)
|
||||||
(do-popup-context-window editor event)))
|
(popup-context-menu editor event)))
|
||||||
|
|
||||||
(chain-to-keymap (send editor get-keymap) #t)
|
(define/private (popup-context-menu editor event)
|
||||||
(send editor set-keymap this)
|
|
||||||
|
|
||||||
(define/private (do-popup-context-window editor event)
|
|
||||||
(define-values (x y)
|
(define-values (x y)
|
||||||
(send editor dc-location-to-editor-location
|
(send editor dc-location-to-editor-location
|
||||||
(send event get-x)
|
(send event get-x)
|
||||||
(send event get-y)))
|
(send event get-y)))
|
||||||
(define admin (send editor get-admin))
|
(define admin (send editor get-admin))
|
||||||
(send admin popup-menu the-context-menu x y))
|
(define menu (new popup-menu%))
|
||||||
|
(add-context-menu-items menu)
|
||||||
|
(send admin popup-menu menu x y))
|
||||||
|
|
||||||
))
|
;; FIXME: move out of constructor to use sites
|
||||||
|
(chain-to-keymap (send editor get-keymap) #t)
|
||||||
(define smart-context-menu%
|
(send editor set-keymap this)))
|
||||||
(class popup-menu%
|
|
||||||
(define on-demand-actions null)
|
|
||||||
(define/public (add-on-demand p)
|
|
||||||
(set! on-demand-actions (cons p on-demand-actions)))
|
|
||||||
|
|
||||||
(define/override (on-demand)
|
|
||||||
(super on-demand)
|
|
||||||
(for-each (lambda (p) (p)) on-demand-actions))
|
|
||||||
|
|
||||||
(super-new)))
|
|
||||||
|
|
||||||
(define syntax-keymap%
|
(define syntax-keymap%
|
||||||
(class smart-keymap%
|
(class keymap/popup%
|
||||||
(init-field controller
|
(init-field controller
|
||||||
config)
|
config)
|
||||||
|
|
||||||
(inherit add-function
|
(inherit add-function
|
||||||
map-function
|
map-function
|
||||||
call-function
|
call-function
|
||||||
chain-to-keymap)
|
chain-to-keymap)
|
||||||
(inherit-field the-context-menu)
|
|
||||||
(field [copy-menu #f]
|
|
||||||
[clear-menu #f]
|
|
||||||
[props-menu #f])
|
|
||||||
(super-new)
|
(super-new)
|
||||||
|
|
||||||
|
(define/private (selected-syntax)
|
||||||
|
(send controller get-selected-syntax))
|
||||||
|
|
||||||
;; Functionality
|
;; Functionality
|
||||||
|
|
||||||
(define/public (get-controller) controller)
|
(add-function "copy-syntax-as-text"
|
||||||
|
|
||||||
(add-function "copy-text"
|
|
||||||
(lambda (_ event)
|
(lambda (_ event)
|
||||||
(define stx (send controller get-selected-syntax))
|
(define stx (send controller get-selected-syntax))
|
||||||
(send the-clipboard set-clipboard-string
|
(send the-clipboard set-clipboard-string
|
||||||
|
@ -93,53 +72,24 @@
|
||||||
(lambda (i e)
|
(lambda (i e)
|
||||||
(send config set-props-shown? #f)))
|
(send config set-props-shown? #f)))
|
||||||
|
|
||||||
(define/private (selected-syntax)
|
(define/override (add-context-menu-items menu)
|
||||||
(send controller get-selected-syntax))
|
(new menu-item% (label "Copy") (parent menu)
|
||||||
|
(demand-callback
|
||||||
|
(lambda (i)
|
||||||
|
(send i enable (and (selected-syntax) #t))))
|
||||||
|
(callback
|
||||||
|
(lambda (i e)
|
||||||
|
(call-function "copy-syntax-as-text" i e))))
|
||||||
|
(new separator-menu-item% (parent menu))
|
||||||
|
(new menu-item%
|
||||||
|
(label "Clear selection")
|
||||||
|
(parent menu)
|
||||||
|
(demand-callback
|
||||||
|
(lambda (i)
|
||||||
|
(send i enable (and (selected-syntax) #t))))
|
||||||
|
(callback
|
||||||
|
(lambda (i e)
|
||||||
|
(call-function "clear-syntax-selection" i e))))
|
||||||
|
(menu-option/notify-box menu "View syntax properties"
|
||||||
|
(get-field props-shown? config)))))
|
||||||
|
|
||||||
(define/public (add-menu-items)
|
|
||||||
(set! copy-menu
|
|
||||||
(new menu-item% (label "Copy") (parent the-context-menu)
|
|
||||||
(demand-callback
|
|
||||||
(lambda (i)
|
|
||||||
(send i enable (and (selected-syntax) #t))))
|
|
||||||
(callback
|
|
||||||
(lambda (i e)
|
|
||||||
(call-function "copy-text" i e)))))
|
|
||||||
(add-separator)
|
|
||||||
(set! clear-menu
|
|
||||||
(new menu-item%
|
|
||||||
(label "Clear selection")
|
|
||||||
(parent the-context-menu)
|
|
||||||
(demand-callback
|
|
||||||
(lambda (i)
|
|
||||||
(send i enable (and (selected-syntax) #t))))
|
|
||||||
(callback
|
|
||||||
(lambda (i e)
|
|
||||||
(call-function "clear-syntax-selection" i e)))))
|
|
||||||
(set! props-menu
|
|
||||||
(menu-option/notify-box the-context-menu
|
|
||||||
"View syntax properties"
|
|
||||||
(get-field props-shown? config))
|
|
||||||
#;
|
|
||||||
(new menu-item%
|
|
||||||
(label "Show syntax properties")
|
|
||||||
(parent the-context-menu)
|
|
||||||
(demand-callback
|
|
||||||
(lambda (i)
|
|
||||||
(if (send config get-props-shown?)
|
|
||||||
(send i set-label "Hide syntax properties")
|
|
||||||
(send i set-label "Show syntax properties"))))
|
|
||||||
(callback
|
|
||||||
(lambda (i e)
|
|
||||||
(if (send config get-props-shown?)
|
|
||||||
(call-function "hide-syntax-properties" i e)
|
|
||||||
(call-function "show-syntax-properties" i e))))))
|
|
||||||
(void))
|
|
||||||
|
|
||||||
(define/public (add-separator)
|
|
||||||
(new separator-menu-item% (parent the-context-menu)))
|
|
||||||
|
|
||||||
;; Initialize menu
|
|
||||||
|
|
||||||
(add-menu-items)
|
|
||||||
))
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require scheme/list
|
(require scheme/list
|
||||||
scheme/class
|
scheme/class
|
||||||
|
@ -6,7 +5,8 @@
|
||||||
drscheme/arrow
|
drscheme/arrow
|
||||||
framework/framework
|
framework/framework
|
||||||
unstable/interval-map
|
unstable/interval-map
|
||||||
unstable/gui/notify)
|
unstable/gui/notify
|
||||||
|
"interfaces.ss")
|
||||||
|
|
||||||
(provide text:hover<%>
|
(provide text:hover<%>
|
||||||
text:hover-drawings<%>
|
text:hover-drawings<%>
|
||||||
|
@ -118,10 +118,11 @@
|
||||||
(invalidate-bitmap-cache 0.0 0.0 +inf.0 +inf.0)))
|
(invalidate-bitmap-cache 0.0 0.0 +inf.0 +inf.0)))
|
||||||
|
|
||||||
(define/public (add-hover-drawing start end draw [tack-box (box #f)])
|
(define/public (add-hover-drawing start end draw [tack-box (box #f)])
|
||||||
(interval-map-cons*! drawings-list
|
(let ([drawing (make-drawing start end draw tack-box)])
|
||||||
start (add1 end)
|
(interval-map-cons*! drawings-list
|
||||||
(make-drawing start end draw tack-box)
|
start (add1 end)
|
||||||
null))
|
drawing
|
||||||
|
null)))
|
||||||
|
|
||||||
(define/public (delete-all-drawings)
|
(define/public (delete-all-drawings)
|
||||||
(interval-map-remove! drawings-list -inf.0 +inf.0))
|
(interval-map-remove! drawings-list -inf.0 +inf.0))
|
||||||
|
@ -145,6 +146,7 @@
|
||||||
(define text:tacking-mixin
|
(define text:tacking-mixin
|
||||||
(mixin (text:basic<%> text:hover-drawings<%>) ()
|
(mixin (text:basic<%> text:hover-drawings<%>) ()
|
||||||
(inherit get-canvas
|
(inherit get-canvas
|
||||||
|
get-keymap
|
||||||
get-position-drawings)
|
get-position-drawings)
|
||||||
(inherit-field hover-position)
|
(inherit-field hover-position)
|
||||||
(super-new)
|
(super-new)
|
||||||
|
@ -171,14 +173,16 @@
|
||||||
|
|
||||||
(define/private (make-tack/untack-menu)
|
(define/private (make-tack/untack-menu)
|
||||||
(define menu (new popup-menu%))
|
(define menu (new popup-menu%))
|
||||||
|
(define keymap (get-keymap))
|
||||||
(new menu-item% (label "Tack")
|
(new menu-item% (label "Tack")
|
||||||
(parent menu)
|
(parent menu)
|
||||||
(callback
|
(callback (lambda _ (tack))))
|
||||||
(lambda _ (tack))))
|
|
||||||
(new menu-item% (label "Untack")
|
(new menu-item% (label "Untack")
|
||||||
(parent menu)
|
(parent menu)
|
||||||
(callback
|
(callback (lambda _ (untack))))
|
||||||
(lambda _ (untack))))
|
(when (is-a? keymap keymap/popup<%>)
|
||||||
|
(new separator-menu-item% (parent menu))
|
||||||
|
(send keymap add-context-menu-items menu))
|
||||||
menu)
|
menu)
|
||||||
|
|
||||||
(define/private (tack)
|
(define/private (tack)
|
||||||
|
|
|
@ -32,8 +32,7 @@
|
||||||
(class s:syntax-keymap%
|
(class s:syntax-keymap%
|
||||||
(init-field: (macro-stepper widget<%>))
|
(init-field: (macro-stepper widget<%>))
|
||||||
(inherit-field config
|
(inherit-field config
|
||||||
controller
|
controller)
|
||||||
the-context-menu)
|
|
||||||
(inherit add-function
|
(inherit add-function
|
||||||
call-function)
|
call-function)
|
||||||
|
|
||||||
|
@ -59,29 +58,23 @@
|
||||||
|
|
||||||
;; Menu
|
;; Menu
|
||||||
|
|
||||||
(inherit add-separator)
|
(define/override (add-context-menu-items menu)
|
||||||
|
(super add-context-menu-items menu)
|
||||||
|
(new separator-menu-item% (parent menu))
|
||||||
|
(new menu-item% (label "Show selected identifier") (parent menu)
|
||||||
|
(demand-callback
|
||||||
|
(lambda (i)
|
||||||
|
(send i enable (identifier? (send controller get-selected-syntax)))))
|
||||||
|
(callback
|
||||||
|
(lambda (i e)
|
||||||
|
(call-function "hiding:show-macro" i e))))
|
||||||
|
(new menu-item% (label "Hide selected identifier") (parent menu)
|
||||||
|
(demand-callback
|
||||||
|
(lambda (i)
|
||||||
|
(send i enable (identifier? (send controller get-selected-syntax)))))
|
||||||
|
(callback
|
||||||
|
(lambda (i e) (call-function "hiding:hide-macro" i e)))))))
|
||||||
|
|
||||||
(define/override (add-menu-items)
|
|
||||||
(super add-menu-items)
|
|
||||||
(add-separator)
|
|
||||||
(set! show-macro
|
|
||||||
(new menu-item% (label "Show selected identifier") (parent the-context-menu)
|
|
||||||
(callback (lambda (i e)
|
|
||||||
(call-function "hiding:show-macro" i e)))))
|
|
||||||
(set! hide-macro
|
|
||||||
(new menu-item% (label "Hide selected identifier") (parent the-context-menu)
|
|
||||||
(callback (lambda (i e)
|
|
||||||
(call-function "hiding:hide-macro" i e)))))
|
|
||||||
(enable/disable-hide/show #f)
|
|
||||||
(void))
|
|
||||||
|
|
||||||
(define/private (enable/disable-hide/show ?)
|
|
||||||
(send show-macro enable ?)
|
|
||||||
(send hide-macro enable ?))
|
|
||||||
|
|
||||||
(send: controller s:controller<%> listen-selected-syntax
|
|
||||||
(lambda (stx)
|
|
||||||
(enable/disable-hide/show (identifier? stx))))))
|
|
||||||
|
|
||||||
(define stepper-syntax-widget%
|
(define stepper-syntax-widget%
|
||||||
(class s:widget%
|
(class s:widget%
|
||||||
|
|
|
@ -59,21 +59,20 @@
|
||||||
;; (Also need to insert missing intervals)
|
;; (Also need to insert missing intervals)
|
||||||
;; Main loop:
|
;; Main loop:
|
||||||
(let loop ([start start] [ix (skip-list-iterate-least/>=? s start)])
|
(let loop ([start start] [ix (skip-list-iterate-least/>=? s start)])
|
||||||
(cond [ix
|
(let ([ixstart (and ix (skip-list-iterate-key s ix))])
|
||||||
;; First do leading gap, [ start, key(ix) )
|
(cond [(and ix (<? ixstart end))
|
||||||
(let ([ixstart (and ix (skip-list-iterate-key s ix))])
|
;; First do leading gap, [ start, key(ix) )
|
||||||
(when (<? start ixstart)
|
(when (<? start ixstart)
|
||||||
(skip-list-set! s start (cons ixstart (force updated-defaultp))))
|
(skip-list-set! s start (cons ixstart (force updated-defaultp))))
|
||||||
;; Then interval, [ ixstart, end(ix) )
|
;; Then interval, [ ixstart, end(ix) )
|
||||||
(when (<? ixstart end)
|
(let ([ixvalue (skip-list-iterate-value s ix)])
|
||||||
(let ([ixvalue (skip-list-iterate-value s ix)])
|
(skip-list-iterate-set-value! s ix
|
||||||
(skip-list-iterate-set-value! s ix
|
(cons (car ixvalue) (updater (cdr ixvalue))))
|
||||||
(cons (car ixvalue) (updater (cdr ixvalue))))
|
(loop (car ixvalue) (skip-list-iterate-next s ix)))]
|
||||||
(loop (car ixvalue) (skip-list-iterate-next s ix)))))]
|
[else
|
||||||
[else
|
;; Do gap, [ start, end )
|
||||||
;; Do gap, [ start, end )
|
(when (<? start end)
|
||||||
(when (<? start end)
|
(skip-list-set! s start (cons end (force updated-defaultp))))])))))
|
||||||
(skip-list-set! s start (cons end (force updated-defaultp))))]))))
|
|
||||||
|
|
||||||
|
|
||||||
(define (interval-map-cons*! im start end obj [default null])
|
(define (interval-map-cons*! im start end obj [default null])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user