aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/plot/libplot/text.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-04-14 19:54:10 +0000
committerrsc <devnull@localhost>2004-04-14 19:54:10 +0000
commit4314729ddef28cb619ce97d50f0968ca24c93803 (patch)
tree3abd7849a10e842a57b1fd535f8278d22a6bf132 /src/cmd/plot/libplot/text.c
parent6e18e03e63942f7b0912bb91d0da02fd493af0af (diff)
downloadplan9port-4314729ddef28cb619ce97d50f0968ca24c93803.tar.gz
plan9port-4314729ddef28cb619ce97d50f0968ca24c93803.tar.bz2
plan9port-4314729ddef28cb619ce97d50f0968ca24c93803.zip
Add graph, plot
Diffstat (limited to 'src/cmd/plot/libplot/text.c')
-rw-r--r--src/cmd/plot/libplot/text.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/cmd/plot/libplot/text.c b/src/cmd/plot/libplot/text.c
new file mode 100644
index 00000000..530d5f96
--- /dev/null
+++ b/src/cmd/plot/libplot/text.c
@@ -0,0 +1,39 @@
+/*
+ t string Place the string so that its first character is
+ centered on the current point (default). If
+ string begins with `\C' (`\R'), it is centered
+ (right-adjusted) on the current point. A
+ backslash at the beginning of the string may be
+ escaped with another backslash.
+ */
+#include "mplot.h"
+void text(char *s){
+ register int kx, ky;
+ int centered, right, more;
+ char *ss;
+ ss=s;
+ for(;;){
+ centered=right=more=0;
+ if(*ss=='\\'){
+ ss++;
+ switch(*ss){
+ case 'C': centered++; ss++; break;
+ case 'R': right++; ss++; break;
+ case 'L': ss++; break;
+ case 'n': --ss; break;
+ }
+ }
+ for(s=ss;*ss!='\0';ss++)
+ if(ss[0]=='\\' && ss[1]=='n'){
+ more++;
+ break;
+ }
+ kx = SCX(e1->copyx);
+ ky = SCY(e1->copyy);
+ ky=m_text(kx, ky, s, ss, e1->foregr, centered, right);
+ if(!more)break;
+ e1->copyy = ( (double)(ky) - e1->bottom)/e1->scaley + e1->ymin + .5;
+ move(e1->copyx, e1->copyy);
+ ss+=2;
+ }
+}