Last active
December 11, 2020 10:22
-
-
Save Metaxal/f961cb32d4ef38d2e35c38dbaf559614 to your computer and use it in GitHub Desktop.
How to augment the syntax to make DrRacket display information in a tooltip–LIVE! (without even saving the file!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
;;; License: [MIT](http://opensource.org/licenses/MIT) | |
;;; Adapted from: https://github.com/samth/fancy-app | |
(begin-for-syntax | |
(define (make-tooltip stx id msg) | |
(define pos (syntax-position id)) | |
(define span (syntax-span id)) | |
(syntax-property | |
stx | |
'mouse-over-tooltips | |
(and pos span (vector id (sub1 pos) (sub1 (+ pos span)) msg))))) | |
(define-syntax (FOO stx) | |
(syntax-case stx () | |
[(_ id) | |
(make-tooltip #'(display 'id) | |
#'id | |
(format "Identifier: ~a" (syntax-e #'id)))])) | |
(FOO yo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also look at the
char-span
example at the end of the docs onmouse-over-tooltips
: