macro-stepper: added step count

also removed some dead code (warnings)

original commit: 5673d7b877a4ebbf2f0ec390c97bac92d678da41
This commit is contained in:
Ryan Culpepper 2010-06-30 15:38:23 -06:00
parent 5a58b97f12
commit 9cb5f4756d
4 changed files with 25 additions and 8 deletions

View File

@ -24,7 +24,8 @@
cursor->list
cursor:prefix->list
cursor:suffix->list)
cursor:suffix->list
cursor-count)
(define-struct cursor (vector count position)
#:mutable)

View File

@ -62,6 +62,7 @@
(get-raw-deriv
get-deriv-hidden?
get-step-index
get-step-count
invalidate-synth!
invalidate-steps!

View File

@ -14,7 +14,6 @@
"interfaces.ss"
"prefs.ss"
"extensions.ss"
"warning.ss"
"hiding-panel.ss"
"term-record.ss"
"step-display.ss"
@ -103,7 +102,6 @@
(define/public (get-controller) sbc)
(define/public (get-view) sbview)
(define/public (get-step-displayer) step-displayer)
(define/public (get-warnings-area) warnings-area)
(define/public (get-macro-hiding-prefs) macro-hiding-prefs)
(define/public (reset-primary-partition)
@ -129,9 +127,7 @@
(stretchable-height #f)
(alignment '(left center))
(style '(deleted))))
(define warnings-area (new stepper-warnings% (parent area)))
(define: sbview sb:syntax-browser<%>
(new stepper-syntax-widget%
(parent area)
@ -206,7 +202,16 @@
(navigate-to (sub1 step))]
[(equal? value "end")
(navigate-to-end)])))))))
(define nav:step-count
(new message%
(label "")
(parent extra-navigator)
(auto-resize #t)
(stretchable-width #f)
(stretchable-height #f)))
(send nav:text set-value "")
(listen-current-step-index
(lambda (n)
(send nav:text set-value
@ -388,9 +393,15 @@
;; refresh : -> void
(define/public (refresh)
(send warnings-area clear)
(when (focused-term)
(send: (focused-term) term-record<%> on-get-focus))
(send nav:step-count set-label "")
(let ([term (focused-term)])
(when term
(let ([step-count (send: term term-record<%> get-step-count)])
(when step-count
;; +1 for end of expansion "step"
(send nav:step-count set-label (format "of ~s" (add1 step-count)))))))
(update))
(define/private (foci x) (if (list? x) x (list x)))

View File

@ -207,7 +207,11 @@
(and (get-steps) (not (cursor:at-end? (get-steps)))))
(define/public-final (get-step-index)
(and (get-steps) (cursor-position (get-steps))))
(let ([steps (get-steps)])
(and steps (cursor-position steps))))
(define/public-final (get-step-count)
(let ([steps (get-steps)])
(and steps (cursor-count steps))))
(define/public-final (navigate-to-start)
(cursor:move-to-start (get-steps))