(define (inside-postscript-p) (equal? (tree-label (cursor-tree)) 'postscript)) (texmacs-modes (inside-postscript% (inside-postscript-p))) ; Return true if 'str' si a "magnification": i.e. "[*,/]number" (define (magnification? str) (let ((s (string-trim-both str))) (if (or (string-starts? s "*") (string-starts? s "/")) (if (number? (string->number (string-tail s 1))) #t #f) #f))) (define (magnification->number magnstr) (let ((s (string-trim-both magnstr))) (cond ((string-starts? s "*") (if (number? (string->number (string-tail s 1))) (string->number (string-tail s 1)) #f)) ((string-starts? str "/") (if (number? (string->number (string-tail s 1))) (/ 1.0 (string->number (string-tail s 1))) #f)) (#t #f)))) ; Return the width of a postscript tree. (define (postscript-width ps-tree) (tree->string (tree-ref ps-tree 1))) ; Return the height of a postscript tree. (define (postscript-height ps-tree) (tree->string (tree-ref ps-tree 2))) ;set the scale width to 'w' (string) of a postscript tree. (define (postscript-set-width! ps-tree w) (tree-set! (tree-ref ps-tree) 1 w)) ;set the height to 'h' (string) of a postscript tree. (define (postscript-set-height! ps-tree h) (tree-set! (tree-ref ps-tree) 2 h)) ;scale the postscript width-scale by 's' (float) (define (postscript-scale-width! ps-tree s) (let* ((w (postscript-width ps-tree)) (nv w)) (cond ((equal? w "") (set! nv (string-concatenate (list "*" (float->string s))))) ((magnification? w) (set! nv (string-concatenate (list "*" (number->string (* s (magnification->number w))))))) ((length? w) (set! nv (length-mult s w)))) (postscript-set-width! ps-tree nv))) ; Scale the postscript height-scale by 's' (float) (define (postscript-scale-height! ps-tree s) (let* ((h (postscript-height ps-tree)) (nv h)) (cond ((equal? h "") (set! nv (string-concatenate (list "*" (float->string s))))) ((magnification? h) (set! nv (string-concatenate (list "*" (number->string (* s (magnification->number h))))))) ((length? h) (set! nv (length-mult s h)))) (postscript-set-height! ps-tree nv))) ; Scale the postscript height and width by 's' (float) (define (postscript-scale-size ps-tree s) (postscript-scale-width! ps-tree s) (postscript-scale-height! ps-tree s)) (kbd-map (:mode inside-postscript?) ("C--" (postscript-scale-size (cursor-tree) 0.9))) (kbd-map (:mode inside-postscript?) ("C-+" (postscript-scale-size (cursor-tree) 1.1)))
Archive powered by MHonArc 2.6.19.