Skip to content

Commit a963ac2

Browse files
committed
adjust check syntax so that it draws curved arrows
1 parent bf2ba33 commit a963ac2

File tree

1 file changed

+49
-4
lines changed
  • drracket-core-lib/drracket/private/syncheck

1 file changed

+49
-4
lines changed

drracket-core-lib/drracket/private/syncheck/gui.rkt

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,8 @@ If the namespace does not, they are colored the unbound color.
410410
highlight-range unhighlight-range
411411
paragraph-end-position first-line-currently-drawn-specially?
412412
line-end-position position-line
413-
syncheck:add-docs-range syncheck:add-require-candidate get-padding)
413+
syncheck:add-docs-range syncheck:add-require-candidate get-padding
414+
get-extent)
414415

415416
;; arrow-records : (U #f hash[text% => arrow-record])
416417
;; arrow-record = interval-map[(listof arrow-entry)]
@@ -1231,13 +1232,43 @@ If the namespace does not, they are colored the unbound color.
12311232
(when (update-latent-arrows mouse-x mouse-y)
12321233
(start-arrow-draw-timer syncheck-arrow-delay)))
12331234
(let ([draw-arrow2
1234-
(λ (arrow)
1235+
(λ (arrow
1236+
#:x-min [var-arrow-end-x-min #f]
1237+
#:x-max [var-arrow-end-x-max #f])
1238+
;; care only about end-x!
12351239
(define-values (start-x start-y end-x end-y)
12361240
(get-arrow-poss arrow))
12371241
(unless (and (= start-x end-x)
12381242
(= start-y end-y))
1243+
(define smaller-x (min start-x end-x))
1244+
(define larger-x (max start-x end-x))
1245+
(define %age
1246+
(cond
1247+
[(and var-arrow-end-x-min var-arrow-end-x-max)
1248+
(define base-%age
1249+
(/ (- end-x var-arrow-end-x-min)
1250+
(- var-arrow-end-x-max var-arrow-end-x-min)))
1251+
(if (< (var-arrow-start-pos-left arrow)
1252+
(var-arrow-end-pos-left arrow))
1253+
base-%age
1254+
(- base-%age))]
1255+
[else #f]))
1256+
(define max-width-for-arrow
1257+
(let ()
1258+
(define admin (get-admin))
1259+
(cond
1260+
[admin
1261+
(define wb (box 0))
1262+
(get-extent wb #f)
1263+
(unbox wb)]
1264+
[else #f])))
12391265
(drracket:arrow:draw-arrow dc start-x start-y end-x end-y dx dy
1240-
#:pen-width 2)
1266+
#:pen-width 2
1267+
#:%age %age
1268+
#:bb (list 0
1269+
#f
1270+
max-width-for-arrow
1271+
#f))
12411272
(when (and (var-arrow? arrow) (not (var-arrow-actual? arrow)))
12421273
(define old-font (send dc get-font))
12431274
(send dc set-font
@@ -1289,6 +1320,18 @@ If the namespace does not, they are colored the unbound color.
12891320
cursor-text)
12901321
(define arrow-records-at-cursor (fetch-arrow-records cursor-text cursor-pos))
12911322
(define tail-arrows '())
1323+
(define arrows-count (- (length (filter var-arrow? arrow-records-at-cursor)) 1))
1324+
(define-values (var-arrow-end-x-min var-arrow-end-x-max)
1325+
(for/fold ([x-min #f]
1326+
[x-max #f])
1327+
([(ele _) (in-hash current-matching-identifiers)])
1328+
1329+
(match-define (list end-text pos-left pos-right) ele)
1330+
(define-values (end-x end-y)
1331+
(find-poss end-text pos-left pos-right 1/2 1/2))
1332+
(values (if x-min (min x-min end-x) end-x)
1333+
(if x-max (max x-max end-x) end-x))))
1334+
12921335
(when arrow-records-at-cursor
12931336
(for ([ele (in-list arrow-records-at-cursor)])
12941337
(cond [(var-arrow? ele)
@@ -1297,7 +1340,9 @@ If the namespace does not, they are colored the unbound color.
12971340
(send dc set-brush (get-untacked-brush)))
12981341
(begin (send dc set-pen (get-templ-pen))
12991342
(send dc set-brush (get-untacked-brush))))
1300-
(draw-arrow2 ele)]
1343+
(draw-arrow2 ele
1344+
#:x-min var-arrow-end-x-min
1345+
#:x-max var-arrow-end-x-max)]
13011346
[(tail-arrow? ele)
13021347
(set! tail-arrows (cons ele tail-arrows))])))
13031348

0 commit comments

Comments
 (0)