Function: math-comp-simplify-term
math-comp-simplify-term is a byte-compiled function defined in
calccomp.el.gz.
Signature
(math-comp-simplify-term C)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calccomp.el.gz
(defun math-comp-simplify-term (c)
(cond ((stringp c)
(math-comp-add-string c math-comp-hpos math-comp-vpos)
(setq math-comp-hpos (+ math-comp-hpos (length c))))
((memq (car c) '(set break))
nil)
((eq (car c) 'horiz)
(while (setq c (cdr c))
(math-comp-simplify-term (car c))))
((memq (car c) '(vleft vcent vright))
(let* ((math-comp-vpos (+ (- math-comp-vpos (nth 1 c))
(1- (math-comp-ascent (nth 2 c)))))
(widths (mapcar 'math-comp-width (cdr (cdr c))))
(maxwid (apply 'max widths))
(bias (cond ((eq (car c) 'vleft) 0)
((eq (car c) 'vcent) 1)
(t 2))))
(setq c (cdr c))
(while (setq c (cdr c))
(if (eq (car-safe (car c)) 'rule)
(let* ((sep (nth 1 (car c)))
(rule-width (ceiling
(* maxwid (string-pixel-width "-"))
(string-pixel-width (char-to-string sep)))))
(math-comp-add-string (make-string rule-width sep)
math-comp-hpos math-comp-vpos))
(let ((math-comp-hpos (+ math-comp-hpos (/ (* bias (- maxwid
(car widths)))
2))))
(math-comp-simplify-term (car c))))
(and (cdr c)
(setq math-comp-vpos (+ math-comp-vpos
(+ (math-comp-descent (car c))
(math-comp-ascent (nth 1 c))))
widths (cdr widths))))
(setq math-comp-hpos (+ math-comp-hpos maxwid))))
((eq (car c) 'supscr)
(let* ((asc (or 1 (math-comp-ascent (nth 1 c))))
(desc (math-comp-descent (nth 2 c)))
(oldh (prog1
math-comp-hpos
(math-comp-simplify-term (nth 1 c))))
(math-comp-vpos (- math-comp-vpos (+ asc desc))))
(math-comp-simplify-term (nth 2 c))
(if math-comp-sel-hpos
(math-comp-add-string-sel oldh
(- math-comp-vpos
-1
(math-comp-ascent (nth 2 c)))
(- math-comp-hpos oldh)
(math-comp-height c)))))
((eq (car c) 'subscr)
(let* ((asc (math-comp-ascent (nth 2 c)))
(desc (math-comp-descent (nth 1 c)))
(oldv math-comp-vpos)
(oldh (prog1
math-comp-hpos
(math-comp-simplify-term (nth 1 c))))
(math-comp-vpos (+ math-comp-vpos (+ asc desc))))
(math-comp-simplify-term (nth 2 c))
(if math-comp-sel-hpos
(math-comp-add-string-sel oldh oldv
(- math-comp-hpos oldh)
(math-comp-height c)))))
((eq (car c) 'tag)
(cond ((eq (nth 1 c) math-comp-selected)
(let ((math-comp-highlight (not calc-show-selections)))
(math-comp-simplify-term (nth 2 c))))
((eq (nth 1 c) t)
(let ((math-comp-highlight nil))
(math-comp-simplify-term (nth 2 c))))
(t (let ((math-comp-tag c))
(math-comp-simplify-term (nth 2 c))))))))