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 >
Wrap
Text File
|
1995-01-14
|
3KB
|
146 lines
;; Allow the user to set/examine system variables
;; C Durland Public Domain
;; Last mod: 12/92, 1/93, 9/93
(include me.mh)
(list sys-list)
(defun
get-sysvar
{
(string svar)
(check-name-of-sysvar
(svar (complete CC_LIST "Get system variable: " sys-list)) TRUE)
(msg "Current value of " svar " is " (sys-var svar))
}
set-sysvar ; [(string svar-name)][(string value)]
{
(string svar old-value new-value)
(check-name-of-sysvar
(svar (complete CC_LIST "Set system variable: " sys-list)) TRUE)
(old-value (concat (sys-var svar)))
(new-value (ask "Value of " svar " is " old-value
". New value: "))
(if (or
(== "" new-value)
(== old-value
(concat (sys-var svar (name-to-value svar new-value)))))
{
(msg "Value of " svar " is " old-value
". New value: [Not changed]")
(done)
})
}
name-to-value (string sysvar vname) HIDDEN
{
(switch vname
"hard" 0
"off" 0
"on" 1
default
(cond
(or (== "text-color" sysvar)
(== "modeline-color" sysvar)
(== "cursor-color" sysvar)
(== "cursor-shape" sysvar))
vname
TRUE
(if (re-string "[0-9]+" vname)
(convert-to NUMBER vname)
{
(msg "\"" vname "\" is not a valid sysvar value!")
(halt)
})))
}
sys-var (string name) HIDDEN ;; [int value]
{
(floc (name) (push-args 1))
}
make-sysvar-list MAIN HIDDEN
{
(insert-object sys-list 1
"HELP"
"beeper" ;; all this because beep is a strange sysvar
"case-fold-search"
"complete-key"
"cursor-color"
"cursor-shape"
"horizontal-scroll"
"modeline-color"
"overstrike"
"screen-length"
"screen-width"
"tab-stops"
"text-color"
"word-wrap"
)
}
check-name-of-sysvar (string name) (bool complain)
{
(int j)
(for (j 0) (< j (length-of sys-list)) (+= j 1)
(if (== name (extract-element sys-list j)) { TRUE (done) }))
(if complain
{
(msg '"' name "\" is not the name of a system variable!")
(halt)
})
FALSE
}
)
(defun
sysvars
{
(query-menu 0 (floc sysvars-do-it)
">Global Variables"
(concat "case-fold-search " (sv-bool "case-fold-search"))
(concat "overstrike ...... " (sv-bool "overstrike"))
" "
(concat "HELP ............ " (sv-bool "HELP"))
(concat "beeper .......... " (sv-bool1 "beeper"))
(concat "complete-key .... " (complete-key))
(concat "horizontal-scroll " (horizontal-scroll))
" "
(concat "screen-length ... " (screen-length))
(concat "screen-width .... " (screen-width))
(concat "modeline-color .. " (modeline-color))
(concat "text-color ...... " (text-color))
"-"
(concat ">Local to " (buffer-name -1))
(concat "tab-stops ....... " (sv-tab "tab-stops"))
(concat "word-wrap ....... " (sv-bool1 "word-wrap"))
)
}
sv-bool (string name) HIDDEN
{
(if (== 0 (sys-var name)) "Off" "On")
}
sv-bool1 (string name) HIDDEN
{
(if (== 0 (sys-var name)) "Off" (concat (sys-var name)))
}
sv-tab HIDDEN
{
(if (== 0 (tab-stops)) "Hard" (concat (tab-stops)))
}
sysvars-do-it (int n)(string name) HIDDEN
{
(if (re-string '[Ha-z][-a-zELP]+' name)
{
(set-sysvar (get-matched "&"))
;; return stop
;;????redraw -> (hoho)
})
;; return continue
}
)