Blob


1 /*
2 t string Place the string so that its first character is
3 centered on the current point (default). If
4 string begins with `\C' (`\R'), it is centered
5 (right-adjusted) on the current point. A
6 backslash at the beginning of the string may be
7 escaped with another backslash.
8 */
9 #include "mplot.h"
10 void text(char *s){
11 register int kx, ky;
12 int centered, right, more;
13 char *ss;
14 ss=s;
15 for(;;){
16 centered=right=more=0;
17 if(*ss=='\\'){
18 ss++;
19 switch(*ss){
20 case 'C': centered++; ss++; break;
21 case 'R': right++; ss++; break;
22 case 'L': ss++; break;
23 case 'n': --ss; break;
24 }
25 }
26 for(s=ss;*ss!='\0';ss++)
27 if(ss[0]=='\\' && ss[1]=='n'){
28 more++;
29 break;
30 }
31 kx = SCX(e1->copyx);
32 ky = SCY(e1->copyy);
33 ky=m_text(kx, ky, s, ss, e1->foregr, centered, right);
34 if(!more)break;
35 e1->copyy = ( (double)(ky) - e1->bottom)/e1->scaley + e1->ymin + .5;
36 move(e1->copyx, e1->copyy);
37 ss+=2;
38 }
39 }