home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------------------ */
- /* Macro: CFGUPD.AML */
- /* Written by: nuText Systems */
- /* */
- /* Description: This macro saves the current configuration to */
- /* CONFIG.AML and COLOR.AML and recompiles the editor. */
- /* ------------------------------------------------------------------ */
-
- include bootpath "define.aml"
-
- // load CONFIG.AML
- file = bootpath "CONFIG.AML"
- if not loadbuf file then
- msgbox "Can't Open " + file "Error!"
- return
- end
-
- // do for each variable in CONFIG.AML
- loop
-
- // find the config variable
- length = find "^ *set" 'x'
- if length then
- right length
- nlength = find "[a-zA-Z0-9_]#" 'xl'
- if nlength then
-
- // get config variable name and current value
- varname = gettext (getcol) nlength
- value = lookup varname 'prf'
-
- right nlength
- if find "[~ ]" 'xl' then
- startcol = getcol
- if (find "//" 'rlg') and (find "[~ ]" 'xr') then
- endcol = getcol
- col startcol
-
- // delete the old value
- delchar endcol - startcol + 1
-
- // insert the new (current) value
- if not (sizeof value) then
- instext "''"
- elseif posnot "0-9" value then
- value = sub '\\' '\\\\' value
- value = sub '"' '\\"' value
- instext '"' + value + '"'
- else
- instext value
- end
- end
- end
- end
- else
- break
- end
- end
-
- // save the new CONFIG.AML
- if not (savebuf file) then
- msgbox "Error saving " + file "Error!"
- destroybuf
- return
- end
- destroybuf
-
-
- // function return the color name for a color attribute
- function attrname (attr)
- case attr
- when 0 "black" when 8 "darkgray"
- when 1 "blue" when 9 "brightblue"
- when 2 "green" when 10 "brightgreen"
- when 3 "cyan" when 11 "brightcyan"
- when 4 "red" when 12 "brightred"
- when 5 "magenta" when 13 "pink"
- when 6 "brown" when 14 "yellow"
- when 7 "gray" when 15 "white"
- end
- end
-
- // function to return foreground on background string for attr
- // (used to modify color.aml files)
- function fattrname (attr)
- (pad (attrname attr & 0fh) 13 'l') + "on " +
- (pad (attrname (attr & 0f0h) shr 4) 13 'l')
- end
-
-
- // load COLOR.AML
- file = bootpath "COLOR.AML"
- if not loadbuf file then
- msgbox "Can't Open " + file "Error!"
- return
- end
-
- // do for each palette item in COLOR.AML
- i = 1
- while i <= 100 do
- length = find "^ *color.*//" 'x'
- if length then
- col (getlinebeg)
- delchar length - (getcol - 1)
- instext "color " + (fattrname (getpalette i)) + "//"
- else
- break
- end
- i = i + 1
- end
-
- // save the new COLOR.AML
- if not (savebuf file) then
- msgbox "Error saving " + file "Error!"
- destroybuf
- return
- end
- destroybuf
-
- // recompile the editor
- if not regen then
- msgbox "Configuration has been saved."
- end
-
-