<commit_before>(define (default-click . args) #f)
(define (default-evaluate name vars) #f)
(define env (the-environment))

(define-structure
  (window (constructor silently-make-window (#!optional name)))
  (name (string-append "window-" (number->string (get-id))) read-only #t)
  (click-handler default-click)
  (points '())
  (paths '()))

(define (evaluate-expr expr variables)
  (cond ((number? expr) expr)
        ((symbol? expr) (cadr (assq expr variables)))
        ((list? expr) (eval `(let ,variables ,(simplify expr)) env))))

(define (default-window-evaluate window variables)
  (let ((points (map (lambda (point) (point-evaluate point variables)) (window-points window)))
        (paths (map (lambda (path) (path-evaluate path variables)) (window-paths window))))
    (send (dict->json `((name ,(window-name window))
                        (points ,points)
                        (paths ,paths))))))

(define (make-window #!optional name push)
  (define window (silently-make-window name))
  (defhandler 'window-click
    (lambda (name x y button) ((window-click-handler window) x y button))
    (lambda (name) (string=? name (window-name window))))
  (defhandler 'window-evaluate
    (lambda (name variables) (default-window-evaluate window variables))
    (lambda (name) (string=? name (window-name window))))
  (if push (update window))
  window)

(define (window-add-point! window point)
  (set-window-points! window (cons point (window-points window))))

(define (window-add-path! window path)
  (set-window-paths! window (cons path (window-paths window))))

(define (window->json window #!optional actions)
  (dict->json `((name ,(window-name window))
                (points ,(window-points window))
                (paths ,(window-paths window))
                (actions ,actions))))

(define (update window . actions)
  (send (window->json window actions) #t))

(define (clear-window window)
  (set-window-paths! window '())
  (set-window-points! window '())
  (update window "clear"))
(define (scale-window window) (update window "scale"))
(define (close-window window) (update window "close"))


(define window-evaluate (make-generic-operator 2 'window-evaluate default-evaluate))

(define window-click (make-generic-operator 4 'window-click default-click))
(defhandler json window->json window?)<commit_msg>updated graphics message passing on scheme<commit_after>(define (default-click . args) #f)
(define (default-evaluate name vars) #f)
(define env (the-environment))

(define-structure
  (window (constructor silently-make-window (#!optional name)))
  (name (string-append "window-" (number->string (get-id))) read-only #t)
  (click-handler default-click)
  (points '())
  (paths '()))

(define (evaluate-expr expr variables)
  (cond ((number? expr) expr)
        ((symbol? expr) (cadr (assq expr variables)))
        ((list? expr) (eval `(let ,variables ,(simplify expr)) env))))

(define (default-window-evaluate window variables)
  (let ((points (map (lambda (point) (point-evaluate point variables)) (window-points window)))
        (paths (map (lambda (path) (path-evaluate path variables)) (window-paths window))))
    (send (dict->json `((name ,(window-name window))
                        (points ,points)
                        (paths ,paths))))))

(define (make-window #!optional name push)
  (define window (silently-make-window name))
  (defhandler 'window-click
    (lambda (name x y button) ((window-click-handler window) x y button))
    (lambda (name) (string=? name (window-name window))))
  (defhandler 'window-evaluate
    (lambda (name variables) (default-window-evaluate window variables))
    (lambda (name) (string=? name (window-name window))))
  (if push (update window))
  window)

(define (window-add-point! window point)
  (set-window-points! window (cons point (window-points window))))

(define (window-add-path! window path)
  (set-window-paths! window (cons path (window-paths window))))

(define (window->json window #!optional actions)
  (dict->json `((name ,(window-name window))
                (type ,svg)
                (points ,(window-points window))
                (paths ,(window-paths window))
                (actions ,actions))))

(define (update window . actions)
  (send (window->json window actions) #t))

(define (clear-window window)
  (set-window-paths! window '())
  (set-window-points! window '())
  (update window "clear"))
(define (scale-window window) (update window "scale"))
(define (close-window window) (update window "close"))


(define window-evaluate (make-generic-operator 2 'window-evaluate default-evaluate))

(define window-click (make-generic-operator 4 'window-click default-click))
(defhandler json window->json window?)
{'fraction_non_alphanumeric': 0.15900910438280755, 'fraction_numerical': 0.0008469193309337286, 'mean_word_length': 3.8302658486707566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5289510', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1364, 'n_words': 432}