home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * CMD3.C
- *
- * (C)Copyright 1988 by Matthew Dillon, All Rights Reserved
- *
- * SETFONT
- * IGNORECASE
- * SET
- * SETENV
- * UNSET
- * UNSETENV
- */
-
- #include "defs.h"
- #include <local/xmisc.h>
- #include <stdio.h>
-
- #define nomemory() { memoryfail = 1; }
-
- extern FONT *GetFont();
-
- /*
- * SETFONT font size
- */
-
- void
- do_setfont()
- {
- register FONT *font = GetFont(av[1], atoi(av[2]));
- register ED *ep = Ep;
- if (font) {
- if (ep->Font)
- CloseFont(ep->Font);
- ep->Font = font;
- SetFont(ep->Win->RPort, font);
- SetRast(ep->Win->RPort, 0);
- RefreshWindowFrame(ep->Win);
- set_window_params();
- text_redisplay();
- } else {
- title("Unable to find font");
- }
- }
-
- do_ignorecase()
- {
- register ED *ep = Ep;
-
- if (av[1][0]) {
- switch(av[1][1] & 0x1F) {
- case 'n'&0x1F:
- ep->IgnoreCase = 1;
- break;
- case 'f'&0x1F:
- ep->IgnoreCase = 0;
- break;
- case 'o'&0x1F:
- ep->IgnoreCase = 1 - ep->IgnoreCase;
- break;
- }
- if (ep->IgnoreCase)
- title("Case InSensitive");
- else
- title("Case Sensitive");
- }
- }
-
- /*
- * VARIABLE SUPPORT!
- */
-
- #define VARS struct _VARS
- VARS {
- MNODE Node;
- char *Name;
- char *Str;
- };
-
- static MLIST SList = { (MNODE *)&SList.mlh_Tail, NULL, (MNODE *)&SList.mlh_Head };
-
- void
- do_set()
- {
- register VARS *v;
-
- do_unset();
- if (v = malloc(sizeof(VARS))) {
- if (v->Name = malloc(strlen(av[1])+1)) {
- if (v->Str = malloc(strlen(av[2])+1)) {
- AddHead(&SList, v);
- strcpy(v->Name, av[1]);
- strcpy(v->Str , av[2]);
- return;
- }
- free(v->Name);
- }
- free(v);
- }
- nomemory();
- }
-
- do_setenv()
- {
- SetDEnv(av[1], av[2]);
- }
-
- do_unset()
- {
- register VARS *v;
-
- for (v = (VARS *)SList.mlh_Head; v->Node.mln_Succ; v = (VARS *)v->Node.mln_Succ) {
- if (strcmp(v->Name, av[1]) == 0) {
- Remove(v);
- free(v);
- free(v->Name);
- free(v->Str);
- break;
- }
- }
- }
-
- do_unsetenv()
- {
- register char *ptr = (char *)av[1];
- register char *tmp = malloc(4+strlen(ptr)+1);
-
- if (tmp) {
- strcpy(tmp, "ENV:");
- strcat(tmp, ptr);
- mountrequest(0);
- DeleteFile(tmp);
- mountrequest(1);
- free(tmp);
- }
- }
-
- /*
- * Search (1) internal list, (2) enviroment, (3) macros. The variable
- * is allocated with malloc(). NULL if not found. ENV: need not exist.
- */
-
- char *
- getvar(find)
- char *find;
- {
- register char *str = NULL;
- {
- register VARS *v;
-
- for (v = (VARS *)SList.mlh_Head; v->Node.mln_Succ; v = (VARS *)v->Node.mln_Succ) {
- if (strcmp(v->Name, find) == 0) {
- if (str = malloc(strlen(v->Str)+1)) {
- strcpy(str, v->Str);
- return(str);
- }
- }
- }
- }
-
- mountrequest(0);
- str = GetDEnv(find);
- mountrequest(1);
- if (str)
- return(str);
-
- if ((str = keyspectomacro(find)) || (str = menutomacro(find))) {
- register char *ptr = malloc(strlen(str)+1);
- if (ptr) {
- strcpy(ptr, str);
- return(ptr);
- }
- }
- return(NULL);
- }
-
-