jwz@teak.berkeley.edu (Jamie Zawinski) (10/14/89)
The following code will display an approximation of the US national debt
in the wholine. This (rather large) number will be displayed in the
file-state sheet when there are no open files, and it will update about
once a second. Setting the variable *WHOLINE-DISPLAY-NATIONAL-DEBT*
to NIL will make it go away (just the number, not the debt).
-- Jamie "Yow, am I socially conscious yet?" Zawinski
PS: I don't think it creates any garbage, since bignum consing happens
on the PDL, and this code reuses the string that is drawn.
PPS: There is little chance of this working on a microexplorer.
;;; -*- Mode:Lisp Syntax:Common-Lisp; Package:USER; -*-
;;; File "NATIONAL-DEBT".
;;; Display a running total of the US national debt in the wholine.
;;; Inspired by a similar program for the Amiga by Ron Charlton.
;;; Numbers come from the Survey of Current Business, 1989.
;;;
;;; 9 Oct 89 Jamie Zawinski Created.
(defconstant DEC-31-88-NATIONAL-DEBT 2707284000000
"The US National Debt as of Dec 31, 1988.")
(defconstant DEC-31-88-NATIONAL-DEBT-DELTA 7673.015L0
"The rate of increase of the US National Debt as of Dec 31, 1988 (in dollars per second).")
(defun national-debt-at (universal-time)
(let* ((dec-31-88 #.(encode-universal-time 0 0 24 31 12 1988))
(seconds-since-then (- universal-time dec-31-88))
(delta-since-then (truncate (* DEC-31-88-NATIONAL-DEBT-DELTA
seconds-since-then))))
(+ DEC-31-88-NATIONAL-DEBT delta-since-then)))
(defvar *wholine-national-debt-string*
(make-array 21 :element-type 'string-char :fill-pointer 0)
"A string which is reused when computing the national debt.")
(defvar *wholine-display-national-debt* t
"Whether the wholine file-state sheet should display the current US national debt when there is nothing else to show.")
(profile:define-profile-variable *wholine-display-national-debt* (:ucl)
:cvv-type :boolean)
(defmethod (tv:who-line-file-sheet :after :update) ()
"Display the national debt, if nothing else is there."
(declare (optimize (speed 3))) ; Turn on format-optimization.
(when (and *wholine-display-national-debt*
(eq tv:who-line-item-state 'tv:null))
(let ((string *wholine-national-debt-string*))
(declare (string string))
(setf (fill-pointer string) 1)
(setf (schar string 0) #\$)
(format string "~:D"
(the integer (national-debt-at (get-universal-time))))
(send self :clear-screen)
(send self :string-out-explicit string
(- (tv:sheet-inside-width) (send self :string-length string))))))