main
Matthew Butterick 4 years ago
parent 17901a1032
commit 7e2e4c7cc1

@ -40,11 +40,13 @@
[elems (quad-elems q)] [elems (quad-elems q)]
[tag (quad-tag q)] [tag (quad-tag q)]
[attrs (quad-attrs q)] [attrs (quad-attrs q)]
[size (match (quad-tag q) [size (if (quad-ref q :anchor-parent)
[(== 'text eq?) (make-size-promise-for-string q (quad-ref q :string ""))] (pt 0 0)
[(== 'line eq?) (pt (abs (- (quad-ref q :x1) (quad-ref q :x2))) (match (quad-tag q)
(abs (- (quad-ref q :y1) (quad-ref q :y2))))] [(== 'text eq?) (make-size-promise-for-string q (quad-ref q :string ""))]
[_ (pt (quad-ref q :width 0) (quad-ref q :height 0))])] [(== 'line eq?) (pt (abs (- (quad-ref q :x1) (quad-ref q :x2)))
(abs (- (quad-ref q :y1) (quad-ref q :y2))))]
[_ (pt (quad-ref q :width 0) (quad-ref q :height 0))]))]
[draw-end (λ (q doc) [draw-end (λ (q doc)
(when (draw-debug-draw?) (when (draw-debug-draw?)
(draw-debug q doc "red" "red")))] (draw-debug q doc "red" "red")))]

@ -69,10 +69,12 @@
(find (vector-memq starting-q vec) 0 2)] (find (vector-memq starting-q vec) 0 2)]
[(== 'next eq?) ; search 1 ahead, but if starting-q is also pred, search 2 ahead [(== 'next eq?) ; search 1 ahead, but if starting-q is also pred, search 2 ahead
(find (vector-memq starting-q vec) maxidx (if (pred starting-q) 2 1))] (find (vector-memq starting-q vec) maxidx (if (pred starting-q) 2 1))]
[(? negative? count) ; search backward from end [(? number? count)
(find maxidx vidx (abs count))] (cond
[(? positive? count) ; seach forward [(negative? count) ; search backward from end
(find vidx maxidx count)] (find maxidx vidx (abs count))]
[else ; seach forward
(find vidx maxidx count)])]
[_ #false]))) [_ #false])))
(define next-maxidx (define next-maxidx
(cond (cond

Loading…
Cancel
Save