/* ** interpret.c ** ** interprets and executes lines in the Xgc syntax. */ #include #include #include #include "xgc.h" #include "tile" void change_text(); void GC_change_function(); void GC_change_foreground(); void GC_change_background(); void GC_change_linewidth(); void GC_change_linestyle(); void GC_change_capstyle(); void GC_change_joinstyle(); void GC_change_fillstyle(); void GC_change_fillrule(); void GC_change_arcmode(); void GC_change_dashlist(); void GC_change_planemask(); void GC_change_font(); void change_test(); void change_percent(); extern void update_dashlist(); extern void update_planemask(); extern void update_slider(); extern void select_button(); extern void run_test(); extern void print_if_recording(); extern XgcStuff TestStuff; extern XgcStuff FunctionStuff; extern XgcStuff LinestyleStuff; extern XgcStuff CapstyleStuff; extern XgcStuff JoinstyleStuff; extern XgcStuff FillstyleStuff; extern XgcStuff FillruleStuff; extern XgcStuff ArcmodeStuff; extern XStuff X; extern ChoiceDesc *GCdescs[]; extern ChoiceDesc *testchoicedesc; extern Widget test; extern Widget GCform; extern Widget foregroundtext; extern Widget backgroundtext; extern Widget linewidthtext; extern Widget fonttext; extern Widget dashlistchoice; extern Widget planemaskchoice; extern Widget testchoiceform; extern int fildes[2]; extern FILE *outend; extern FILE *yyin; /* interpret(string) ** ----------------- ** Takes string, which is a line written in the xgc syntax, figures ** out what it means, and passes the buck to the right procedure. ** That procedure gets called with feedback set to FALSE; interpret() ** is only called if the user is selecting things interactively. ** ** This procedure will go away when I can figure out how to make yacc ** and lex read from strings as well as files. */ void interpret(string) String string; { char word1[20], word2[80]; int i; sscanf(string,"%s",word1); if (!strcmp(word1,"run")) run_test(); else { sscanf(string,"%s %s",word1,word2); print_if_recording(string); /* So word1 is the first word on the line and word2 is the second. Now the fun begins... */ if (!strcmp(word1,TestStuff.choice.text)) { for (i=0;i XXX_XXX_ => [3,1,3,1] */ void GC_change_dashlist(dashlist,feedback) int dashlist; Boolean feedback; { char dasharray[DASHLENGTH]; /* what we're gonna pass to XSetDashes */ int dashnumber = 0; /* which element of dasharray we're currently modifying */ int i; /* which bit of the dashlist we're on */ int state = 1; /* whether the list bit we checked was on (1) or off (0) */ /* Initialize the dasharray */ for (i = 0; i < DASHLENGTH; ++i) dasharray[i] = 0; if (dashlist == 0) return; /* having no dashes at all is bogus */ /* XSetDashes expects the dashlist to start with an on bit, so if it ** doesn't, we keep on rotating it until it does */ while (!(dashlist&1)) dashlist /= 2; /* Go through all the bits in dashlist, and update the dasharray ** accordingly */ for (i = 0; i < DASHLENGTH; ++i) { /* the following if statements checks to see if the bit we're looking ** at as the same on or offness as the one before it (state). If ** so, we increment the length of the current dash. */ if (((dashlist&1< 100) return; X.percent = (float) percent / 100.0; if (feedback) update_slider(percent); }