home *** CD-ROM | disk | FTP | other *** search
- /* SetCon
- * by
- * Phil Dietz -- NCEMRSoft 1993
- *
- * USAGE: SetCon FORE/N,BACK/N,CLEAR/S,BOLD/S,FAINT/S,ITALIC/S,
- * UNDER/S,REVERSE/S,CONCEAL/S,RESTORE/S,RESET/S
- *
- * FORE # - sets forground color from color0 to color9
- * BACK # - sets background color from color0 to color9
- * CLEAR - clears the screen
- * BOLD - sets bold
- * FAINT - sets faint
- * ITALIC - sets italic
- * UNDER - sets underline
- * REVERSE - sets reverse
- * CONCEAL - sets conceal (warning invisible!)
- * RESTORE - (DEFAULT) restores to the last style/SGR
- * 'SetCon RESTORE' is the same as just 'SetCon'.
- * RESET - resets the style to the bootup style
- *
- * SUMMARY: Sets the style for the current console/shell.
- * In WB3.0, SetCon will also store your custom style as the
- * default SGR/shell style so clears and resets
- * won't erase your fav. settings!!
- *
- * REQUIREMENTS: WB2.0 version 37
- * WB3.0 to use SGR setting option
- *
- * NOTES: This program is PURE so it can be made RESIDENT.
- * If you cant see what you are typing, try 'setcon reset'
- * or just type ESCc
- *
- */
-
- #include <stdio.h>
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <dos/dos.h>
- #include <dos/dosextens.h>
- #include <dos/rdargs.h>
- #include <libraries/dos.h>
- #include <libraries/dosextens.h>
- #include <devices/conunit.h>
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <clib/dos_protos.h>
- #include <clib/exec_protos.h>
-
- #define RESTORE "\33[0m"
- #define TEMPLATE "FORE/N,BACK/N,CLEAR/S,BOLD/S,FAINT/S,ITALIC/S,UNDER/S,REVERSE/S,CONCEAL/S,RESTORE/S,RESET/S\n"
- #define NUM 11
-
- static char *ver="$VER: SetCon (19.5.93) by Phil Dietz";
-
- static char *style[NUM]={
- "\33[3xm", /* Initial forgorund string */
- "\33[4xm", /* Initial background string */
- "\14", /* Clear */
- "\33[1m", /* Bold */
- "\33[2m", /* Faint */
- "\33[3m", /* Italic */
- "\33[4m", /* Underline */
- "\33[7m", /* Reverse video */
- "\33[8m", /* Concealed mode */
- RESTORE, /* Restore from last SGR */
- "\33c" /* Reset all style and colors */
- };
-
- int __oslibversion=37; /* SAS/C var. to prevent <KS37 from running */
-
- main()
- {
- struct RDArgs *rd;
- LONG *args;
- int i=0;
-
- args=(LONG *)AllocMem(NUM*4,MEMF_PUBLIC | MEMF_CLEAR); /* Get array */
- rd=ReadArgs(TEMPLATE,args,NULL); /* Parse args */
-
- PutStr(RESTORE); /* RESTORE to default style */
-
- for(;i<NUM;i++) /* Scan args and print strings */
- if(args[i])
- {
- if(i<2) /* Replace x in style with ASCII number */
- style[i][3]=*((LONG *)args[i])+48;
- PutStr(style[i]);
- }
-
- PutStr("\33[ s"); /* Set default style/SGR in WB3.0 */
- /* which is harmless in WB2.0 */
- Flush(Output()); /* Flush the output to the CON: */
- FreeArgs(rd); /* Free the readargs structure */
- FreeMem(args,NUM*4); /* Free memory for flag stuff */
- }
-