]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libbio/bvprint.c
rio: match background screen color format (thanks noam)
[plan9front.git] / sys / src / libbio / bvprint.c
1 #include        <u.h>
2 #include        <libc.h>
3 #include        <bio.h>
4
5 static int
6 fmtBflush(Fmt *f)
7 {
8         Biobufhdr *bp;
9
10         bp = f->farg;
11         bp->ocount = (char*)f->to - (char*)f->stop;
12         if(Bflush(bp) < 0)
13                 return 0;
14         f->stop = bp->ebuf;
15         f->to = (char*)f->stop + bp->ocount;
16         f->start = f->to;
17         return 1;
18 }
19
20 int
21 Bvprint(Biobufhdr *bp, char *fmt, va_list arg)
22 {
23         int n;
24         Fmt f;
25
26         f.runes = 0;
27         f.stop = bp->ebuf;
28         f.start = (char*)f.stop + bp->ocount;
29         f.to = f.start;
30         f.flush = fmtBflush;
31         f.farg = bp;
32         f.nfmt = 0;
33         f.args = arg;
34         n = dofmt(&f, fmt);
35         bp->ocount = (char*)f.to - (char*)f.stop;
36         return n;
37 }