home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / me34src.zip / me3 / mutt / builtin / sysvar.mut < prev    next >
Text File  |  1995-01-14  |  3KB  |  146 lines

  1.   ;; Allow the user to set/examine system variables
  2.   ;; C Durland    Public Domain
  3.   ;; Last mod: 12/92, 1/93, 9/93
  4.  
  5. (include me.mh)
  6.  
  7. (list sys-list)
  8.  
  9. (defun
  10.   get-sysvar
  11.   {
  12.     (string svar)
  13.  
  14.     (check-name-of-sysvar
  15.     (svar (complete CC_LIST "Get system variable: " sys-list)) TRUE)
  16.     (msg "Current value of " svar " is " (sys-var svar))
  17.   }
  18.   set-sysvar ; [(string svar-name)][(string value)]
  19.   {
  20.     (string svar old-value new-value)
  21.  
  22.     (check-name-of-sysvar
  23.     (svar (complete CC_LIST "Set system variable: " sys-list)) TRUE)
  24.  
  25.     (old-value (concat (sys-var svar)))
  26.     (new-value (ask "Value of " svar " is " old-value
  27.            ".  New value: "))
  28.     (if (or
  29.       (== "" new-value)
  30.       (== old-value
  31.           (concat (sys-var svar (name-to-value svar new-value)))))
  32.       {
  33.     (msg "Value of " svar " is " old-value
  34.        ".  New value: [Not changed]")
  35.     (done)
  36.       })
  37.   }
  38.   name-to-value (string sysvar vname) HIDDEN
  39.   {
  40.     (switch vname
  41.       "hard"    0
  42.       "off"    0
  43.       "on"    1
  44.       default
  45.     (cond
  46.       (or (== "text-color"       sysvar)
  47.           (== "modeline-color" sysvar)
  48.           (== "cursor-color"   sysvar)
  49.           (== "cursor-shape"   sysvar))
  50.         vname
  51.       TRUE
  52.         (if (re-string "[0-9]+" vname)
  53.           (convert-to NUMBER vname)
  54.           {
  55.         (msg "\"" vname "\" is not a valid sysvar value!")
  56.         (halt)
  57.           })))
  58.   }
  59.   sys-var (string name) HIDDEN    ;; [int value]
  60.   {
  61.     (floc (name) (push-args 1))
  62.   }
  63.   make-sysvar-list MAIN HIDDEN
  64.   {
  65.     (insert-object sys-list 1
  66.       "HELP"
  67.       "beeper"        ;; all this because beep is a strange sysvar
  68.       "case-fold-search"
  69.       "complete-key"    
  70.       "cursor-color"
  71.       "cursor-shape"
  72.       "horizontal-scroll"
  73.       "modeline-color"    
  74.       "overstrike"    
  75.       "screen-length"    
  76.       "screen-width"    
  77.       "tab-stops"    
  78.       "text-color"    
  79.       "word-wrap"    
  80.     )
  81.   }
  82.   check-name-of-sysvar (string name) (bool complain)
  83.   {
  84.     (int j)
  85.  
  86.     (for (j 0) (< j (length-of sys-list)) (+= j 1)
  87.     (if (== name (extract-element sys-list j)) { TRUE (done) }))
  88.  
  89.     (if complain
  90.       {
  91.     (msg '"' name "\" is not the name of a system variable!")
  92.     (halt)
  93.       })
  94.  
  95.     FALSE
  96.   }
  97. )
  98.  
  99. (defun
  100.   sysvars
  101.   {
  102.     (query-menu 0 (floc sysvars-do-it)
  103.       ">Global Variables"
  104.       (concat "case-fold-search  "    (sv-bool  "case-fold-search"))
  105.       (concat "overstrike ...... "    (sv-bool  "overstrike"))
  106.       " "
  107.       (concat "HELP ............ "    (sv-bool  "HELP"))
  108.       (concat "beeper .......... "    (sv-bool1 "beeper"))
  109.       (concat "complete-key .... "    (complete-key))
  110.       (concat "horizontal-scroll "    (horizontal-scroll))
  111.       " "
  112.       (concat "screen-length ... "    (screen-length))
  113.       (concat "screen-width .... "    (screen-width))
  114.       (concat "modeline-color .. "    (modeline-color))
  115.       (concat "text-color ...... "    (text-color))
  116.       "-"
  117.       (concat ">Local to " (buffer-name -1))
  118.       (concat "tab-stops ....... "    (sv-tab   "tab-stops"))
  119.       (concat "word-wrap ....... "    (sv-bool1 "word-wrap"))
  120.     )
  121.   }
  122.   sv-bool (string name) HIDDEN
  123.   {
  124.     (if (== 0 (sys-var name)) "Off" "On")
  125.   }
  126.   sv-bool1 (string name) HIDDEN
  127.   {
  128.     (if (== 0 (sys-var name)) "Off" (concat (sys-var name)))
  129.   }
  130.   sv-tab HIDDEN
  131.   {
  132.     (if (== 0 (tab-stops)) "Hard" (concat (tab-stops)))
  133.   }
  134.   sysvars-do-it (int n)(string name) HIDDEN
  135.   {
  136.     (if (re-string '[Ha-z][-a-zELP]+' name)
  137.       {
  138.     (set-sysvar (get-matched "&"))
  139.  
  140. ;; return stop
  141. ;;????redraw -> (hoho)
  142.       })
  143. ;; return continue
  144.   }
  145. )
  146.