(require "manual") (require "helper") (defun hulp () (let* ( (e1 (mapcar #'first (second %manual%))) (k1 (send text-item-proto :new "Parts")) (k2 (send text-item-proto :new "Chapters")) (k3 (send text-item-proto :new "Sections")) (l1 (send list-item-proto :new e1 :action #'(lambda (x) (if x (let* ( (k1 (send self :selection)) (d1 (send self :slot-value 'dialog)) (e1 (send d1 :slot-value 'items)) (l2 (second (second (first e1)))) (l3 (second (third (first e1)))) (v1 (second (elt (second %manual%) k1))) (rr (length v1)) ) (send l2 :clean) (send l3 :clean) (dotimes (i rr) (send l2 :set-text i (first (elt v1 i)))) ))))) (l2 (send list-item-proto :new (repeat "" 40) :action #'(lambda (x) (if x (let* ( (d1 (send self :slot-value 'dialog)) (e1 (send d1 :slot-value 'items)) (l1 (second (first (first e1)))) (l3 (second (third (first e1)))) (k1 (send l1 :selection)) (k2 (send self :selection)) (v1 (second (elt (second %manual%) k1))) (v2 (second (elt v1 k2))) (rr (length v2)) ) (if (= 1 rr) (find-and-show-string (elt (send self :slot-value 'list-data) k2))) (send l3 :clean) (dotimes (i rr) (send l3 :set-text i (elt v2 i))) ))))) (l3 (send list-item-proto :new (repeat "" 60) :action #'(lambda (x) (if x (let* ( (k3 (send self :selection)) (t3 (elt (send self :slot-value 'list-data) k3)) ) (find-and-show-string t3) ))))) (sr (send button-item-proto :new "Search" :action #'(lambda () (find-and-show-string (get-string-dialog "Give Me a String to Search For"))) )) (ap (send button-item-proto :new "Apropos" :action #'(lambda () (hulp-index (find-and-show-substring (get-string-dialog "Give Me a Substring to Search For")))) )) (in (send button-item-proto :new "Index" :action #'hulp-index)) (ok (send button-item-proto :new "Enough !" :action #'(lambda () (let ( (d1 (send self :slot-value 'dialog)) ) (send d1 :close))))) (cdiag (send dialog-proto :new (list (list (list k1 l1 in ap sr) (list k2 l2) (list k3 l3 ok))) :default-button ok :title "All the Help You Need")) ) )) (defun hulp-index (&optional (hh *symbol-list*)) (if hh (let* ( (ll (send list-item-proto :new hh :action #'(lambda (x) (if x (let* ( (kk (send self :selection)) (tt (elt (send self :slot-value 'list-data) kk)) ) (find-and-show-string tt) ))))) (ok (send button-item-proto :new "Enough !" :action #'(lambda () (send (send self :slot-value 'dialog) :close)))) (dd (send dialog-proto :new (list (list ll ok)) :default-button ok :title "Index")) ) ))) (defmeth list-item-proto :clean () (let* ( (x (send self :slot-value 'list-data)) (n (length x)) ) (send self :selection nil) (dotimes (i n) (send self :set-text i " ")) )) (defun find-and-show-string (x) (if (> (length x) 0) (if (position x *symbol-list* :test 'string-equal) (cond ((find :macintosh *features*) (mac-display-help x)) ((find :x11 *features*) (x11-display-help x))) (message-dialog "No Such Symbol")) )) (defun find-and-show-substring (x) (let* ( (parts (mapcar #'(lambda (a) (string-search x a)) *symbol-list*)) (show (which parts)) ) (if show (select *symbol-list* show) (message-dialog "No Such Substring")) )) (defun find-and-complete-substring (x) (let* ( (parts (mapcar #'(lambda (a) (search x a)) *symbol-list*)) (show (which (mapcar #'(lambda (a) (eq 0 a)) parts))) ) (case (length show) (0 (message-dialog "No Such Substring")) (1 (send (front-window) :cut-to-clip) (send (front-window) :paste-string (elt *symbol-list* (first show)))) ))) (defun mac-display-help (name) "Args: (name) Read in file containing help for name from the help library. Displays in a display-window-proto." (let* ( (fname (concatenate 'string xlisp::*default-path* "Help:" name)) (how (open fname :direction :probe)) (w (send display-window-proto :new :title name)) ) (if how (with-open-file (instream fname) (loop (if (peek-char nil instream) (progn (send w :paste-string (read-line instream)) (send w :paste-string (string #\Newline))) (return)))) (send w :paste-string "No help yet. Patience.")) )) (defun x11-display-help (name &key (pager "xless")) "Args: (name) Read in file containing help for name from the help library. Displays in an xterm window." (let* ( (fname (concatenate 'string xlisp::*default-path* "Help/" name)) (how (open fname :direction :probe)) ) (if how (system (concatenate 'string pager " -title " name " " fname " &"))) )) (if (find :macintosh *features*) (require "machulp"))