From cf87db164aa2401ec33a041d3969d6ccb1ef49d9 Mon Sep 17 00:00:00 2001 From: Matthieu Herrb Date: Sat, 25 Nov 2006 20:52:24 +0000 Subject: Importing from X.Org 7.2RC2 --- app/xgc/interpret.c | 348 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 348 insertions(+) create mode 100644 app/xgc/interpret.c (limited to 'app/xgc/interpret.c') diff --git a/app/xgc/interpret.c b/app/xgc/interpret.c new file mode 100644 index 000000000..9b05c55fb --- /dev/null +++ b/app/xgc/interpret.c @@ -0,0 +1,348 @@ +/* +** interpret.c +** +** interprets and executes lines in the Xgc syntax. +*/ +/* $XFree86: xc/programs/xgc/interpret.c,v 1.4 2002/01/07 20:38:30 dawes Exp $ */ + +#include +#include +#include +#include +#include "xgc.h" +#include "tile" + + +/* 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(const char *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(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); +} -- cgit v1.2.3