Changeset 9602


Ignore:
Timestamp:
May 27, 2008, 1:04:34 AM (11 years ago)
Author:
gz
Message:

toplevel command/inspector tweaks:

  • Export ccl::@
  • add *default-integer-command* to allow support for commands that are integers, used by inspector
  • try to interpret otherwise-unbound/unfbound toplevel expressions as commands
  • TTY-INSPECTOR changes:

-- New command :Q exits call to inspect regardless of current nesting level.
-- :POP now reshows the object being returned to
-- just typing an integer <n> is the same as (:I <n>)
-- refer to CCL:@ in description of :show, just so it's mentioned somewhere.

Location:
branches/working-0711/ccl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-1/l1-readloop-lds.lisp

    r9582 r9602  
    4545(define-toplevel-command
    4646    :global y (&optional p) "Yield control of terminal-input to process
    47 whose name or ID matches <p>, or to any process if <p> is null"
     47   whose name or ID matches <p>, or to any process if <p> is null"
    4848    (%%yield-terminal-to (if p (find-process p))))      ;may be nil
    4949
     
    117117
    118118(define-toplevel-command :global ? () "help"
     119  (format t "~&The following toplevel commands are available:")
     120  (when *default-integer-command*
     121    (format t "~& <n>  ~8Tthe same as (~s <n>)" (car *default-integer-command*)))
    119122  (dolist (g *active-toplevel-commands*)
    120123    (dolist (c (cdr g))
     
    124127        (if args
    125128          (format t "~& (~S~{ ~A~}) ~8T~A" command args doc)
    126           (format t "~& ~S  ~8T~A" command doc))))))
     129          (format t "~& ~S  ~8T~A" command doc)))))
     130  (format t "~&Any other form is evaluated and its results are printed out."))
    127131
    128132
     
    242246(%use-toplevel-commands :global)
    243247
     248(defparameter *toplevel-commands-dwim* t "If true, tries to interpret otherwise-erroneous toplevel
     249expressions as commands")
     250
     251(defvar *default-integer-command* nil
     252  "If non-nil, should be (keyword  min max)), causing integers between min and max to be
     253  interpreted as (keyword integer)")
     254
    244255(defun check-toplevel-command (form)
     256  (when (and *default-integer-command*
     257             (integerp form)
     258             (<= (cadr *default-integer-command*) form (caddr *default-integer-command*)))
     259    (setq form `(,(car *default-integer-command*) ,form)))
    245260  (let* ((cmd (if (consp form) (car form) form))
    246261         (args (if (consp form) (cdr form))))
    247     (if (keywordp cmd)
     262    (when (or (keywordp cmd)
     263              (and *toplevel-commands-dwim*
     264                   (non-nil-symbol-p cmd)
     265                   (not (if (consp form) (fboundp cmd) (boundp cmd)))
     266                   ;; Use find-symbol so don't make unneeded keywords.
     267                   (setq cmd (find-symbol (symbol-name cmd) :keyword))))
     268      (when (eq cmd :help) (setq cmd :?))
    248269      (dolist (g *active-toplevel-commands*)
    249         (when
    250             (let* ((pair (assoc cmd (cdr g))))
    251               (if pair
    252                 (progn (apply (cadr pair) args)
    253                        t)))
    254           (return t))))))
     270        (let* ((pair (assoc cmd (cdr g))))
     271          (when pair
     272            (apply (cadr pair) args)
     273            (return t)))))))
    255274
    256275(defparameter *quit-on-eof* nil)
  • branches/working-0711/ccl/lib/ccl-export-syms.lisp

    r9578 r9602  
    2323     local
    2424     set-local
     25     @
    2526     *elements-per-buffer*
    2627     save-application
  • branches/working-0711/ccl/lib/describe.lisp

    r7624 r9602  
    17521752
    17531753(defvar *inspector-ui* ())
     1754(defvar *previous-inspector-ui* nil)
    17541755
    17551756(defclass inspector-ui ()
     
    18011802(ccl::define-toplevel-command
    18021803    :tty-inspect pop ()
    1803     "exit current inspector"
     1804    "exit current inspector level"
    18041805    (invoke-restart 'exit-inspector))
     1806
     1807(ccl::define-toplevel-command
     1808    :tty-inspect q ()
     1809    "exit inspector"
     1810  (invoke-restart 'end-inspect))
     1811
    18051812
    18061813(ccl::define-toplevel-command
    18071814    :tty-inspect show ()
    1808     "re-show currently inspected object"
     1815    "re-show currently inspected object (the value of CCL:@)"
    18091816    (ui-present *inspector-ui*))
    18101817
     
    18511858
    18521859(defmethod ui-interact ((ui inspector-tty-ui))
    1853   (let* ((level (inspector-ui-level ui)))
     1860  (let* ((level (inspector-ui-level ui))
     1861         (ccl::*default-integer-command* `(:i 0 ,(1- (compute-line-count (inspector-ui-inspector ui))))))
    18541862    (restart-case
    18551863     (ccl:with-terminal-input
     
    18601868                                   (format stream "~&Inspect> ")
    18611869                                   (format stream "~&Inspect ~d> " level))))))
    1862      (exit-inspector () (terpri *debug-io*)))))
     1870      (exit-inspector () ;
     1871        (if *previous-inspector-ui*
     1872          (ui-present *previous-inspector-ui*)
     1873          (terpri *debug-io*))))))
    18631874
    18641875(defmethod inspector-ui-inspect-nth ((ui inspector-tty-ui) n)
     
    18781889
    18791890(defmethod inspector-ui-inspect ((ui inspector-ui))
    1880   (let* ((*inspector-ui* ui))
     1891  (let* ((*previous-inspector-ui* *inspector-ui*)
     1892         (*inspector-ui* ui))
    18811893    (ui-initialize ui)
    18821894    (ui-present ui)
     
    18891901                                         :level 0)))
    18901902
    1891 (defglobal *default-inspector-ui-creation-function* 'tty-inspect)
     1903(defparameter *default-inspector-ui-creation-function* 'tty-inspect)
    18921904       
    18931905
    18941906(defun inspect (thing)
    18951907  (let* ((ccl::@ thing))
    1896     (funcall *default-inspector-ui-creation-function* thing)))
    1897 
     1908    (restart-case (funcall *default-inspector-ui-creation-function* thing)
     1909      (end-inspect () thing))))
Note: See TracChangeset for help on using the changeset viewer.