Skip to content

Commit 7866fd6

Browse files
committed
add curved arrows to check syntax
1 parent bf2ba33 commit 7866fd6

File tree

1 file changed

+34
-3
lines changed
  • drracket-core-lib/drracket/private/syncheck

1 file changed

+34
-3
lines changed

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

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,13 +1231,30 @@ If the namespace does not, they are colored the unbound color.
12311231
(when (update-latent-arrows mouse-x mouse-y)
12321232
(start-arrow-draw-timer syncheck-arrow-delay)))
12331233
(let ([draw-arrow2
1234-
(λ (arrow)
1234+
(λ (arrow
1235+
#:x-min [var-arrow-end-x-min #f]
1236+
#:x-max [var-arrow-end-x-max #f])
1237+
;; care only about end-x!
12351238
(define-values (start-x start-y end-x end-y)
12361239
(get-arrow-poss arrow))
12371240
(unless (and (= start-x end-x)
12381241
(= start-y end-y))
1242+
(define smaller-x (min start-x end-x))
1243+
(define larger-x (max start-x end-x))
1244+
(define %age
1245+
(cond
1246+
[(and var-arrow-end-x-min var-arrow-end-x-max)
1247+
(define base-%age
1248+
(/ (- end-x var-arrow-end-x-min)
1249+
(- var-arrow-end-x-max var-arrow-end-x-min)))
1250+
(if (< (var-arrow-start-pos-left arrow)
1251+
(var-arrow-end-pos-left arrow))
1252+
base-%age
1253+
(- base-%age))]
1254+
[else #f]))
12391255
(drracket:arrow:draw-arrow dc start-x start-y end-x end-y dx dy
1240-
#:pen-width 2)
1256+
#:pen-width 2
1257+
#:%age %age)
12411258
(when (and (var-arrow? arrow) (not (var-arrow-actual? arrow)))
12421259
(define old-font (send dc get-font))
12431260
(send dc set-font
@@ -1289,6 +1306,18 @@ If the namespace does not, they are colored the unbound color.
12891306
cursor-text)
12901307
(define arrow-records-at-cursor (fetch-arrow-records cursor-text cursor-pos))
12911308
(define tail-arrows '())
1309+
(define arrows-count (- (length (filter var-arrow? arrow-records-at-cursor)) 1))
1310+
(define-values (var-arrow-end-x-min var-arrow-end-x-max)
1311+
(for/fold ([x-min #f]
1312+
[x-max #f])
1313+
([(ele _) (in-hash current-matching-identifiers)])
1314+
1315+
(match-define (list end-text pos-left pos-right) ele)
1316+
(define-values (end-x end-y)
1317+
(find-poss end-text pos-left pos-right 1/2 1/2))
1318+
(values (if x-min (min x-min end-x) end-x)
1319+
(if x-max (max x-max end-x) end-x))))
1320+
12921321
(when arrow-records-at-cursor
12931322
(for ([ele (in-list arrow-records-at-cursor)])
12941323
(cond [(var-arrow? ele)
@@ -1297,7 +1326,9 @@ If the namespace does not, they are colored the unbound color.
12971326
(send dc set-brush (get-untacked-brush)))
12981327
(begin (send dc set-pen (get-templ-pen))
12991328
(send dc set-brush (get-untacked-brush))))
1300-
(draw-arrow2 ele)]
1329+
(draw-arrow2 ele
1330+
#:x-min var-arrow-end-x-min
1331+
#:x-max var-arrow-end-x-max)]
13011332
[(tail-arrow? ele)
13021333
(set! tail-arrows (cons ele tail-arrows))])))
13031334

0 commit comments

Comments
 (0)