2015-07-06 15:29:02 -07:00
|
|
|
.\" Copyright (c) 2015 Eric Wheeler (eric@rewiv.com)
|
2015-07-02 12:52:49 -07:00
|
|
|
.\"
|
|
|
|
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
|
|
|
|
.\" This is free documentation; you can redistribute it and/or
|
|
|
|
.\" modify it under the terms of the GNU General Public License as
|
|
|
|
.\" published by the Free Software Foundation; either version 2 of
|
|
|
|
.\" the License, or (at your option) any later version.
|
|
|
|
.\"
|
|
|
|
.\" The GNU General Public License's references to "object code"
|
|
|
|
.\" and "executables" are to be interpreted as the output of any
|
|
|
|
.\" document formatting or typesetting system, including
|
|
|
|
.\" intermediate and printed output.
|
|
|
|
.\"
|
|
|
|
.\" This manual is distributed in the hope that it will be useful,
|
|
|
|
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
.\" GNU General Public License for more details.
|
|
|
|
.\"
|
|
|
|
.\" You should have received a copy of the GNU General Public
|
|
|
|
.\" License along with this manual; if not, see
|
|
|
|
.\" <http://www.gnu.org/licenses/>.
|
|
|
|
.\" %%%LICENSE_END
|
|
|
|
.\"
|
2015-07-06 15:29:02 -07:00
|
|
|
.\" 2015-07-06 eric@rewiv.com \- initial program
|
2015-07-02 12:52:49 -07:00
|
|
|
.\"
|
2015-07-06 15:29:02 -07:00
|
|
|
.TH pcprintf 3 2015-07-06 "LIBPIPECOLORS" "Using pcprintf to print colors"
|
2015-07-02 12:52:49 -07:00
|
|
|
.SH NAME
|
2015-07-06 15:29:02 -07:00
|
|
|
pcprintf,
|
|
|
|
pcsprintf \- convert pipecode (|10) to ansi colors
|
2015-07-02 12:52:49 -07:00
|
|
|
.SH SYNOPSIS
|
2015-07-06 06:59:54 -07:00
|
|
|
.B #include <pipecolors.h>
|
2015-07-02 12:52:49 -07:00
|
|
|
.sp
|
2015-07-07 15:09:36 -07:00
|
|
|
.B using namespace pipecolors;
|
|
|
|
.sp
|
2015-07-14 08:21:05 -07:00
|
|
|
.BI "int pcprintf(const char * " format ", ...);"
|
2015-07-02 12:52:49 -07:00
|
|
|
.br
|
2015-07-14 08:21:05 -07:00
|
|
|
.BI "int pcsprintf(char * " str ", const char * " format ", ...);"
|
2015-07-02 12:52:49 -07:00
|
|
|
.sp
|
|
|
|
.in -4n
|
|
|
|
.ad
|
|
|
|
.SH DESCRIPTION
|
|
|
|
The functions in the
|
2015-07-06 15:29:02 -07:00
|
|
|
.BR pcprintf ()
|
2015-07-02 12:52:49 -07:00
|
|
|
family produce output according to a
|
|
|
|
.I format
|
|
|
|
as described below.
|
|
|
|
.PP
|
2015-07-06 15:29:02 -07:00
|
|
|
.SS pcprintf ()
|
|
|
|
This function parses input exactly like
|
|
|
|
.BR printf (3)
|
|
|
|
the only difference is that it converts old renegade bbs style pipecodes (|10) to ansi sequences.
|
|
|
|
|
|
|
|
See NOTES.
|
2015-07-02 12:52:49 -07:00
|
|
|
.PP
|
2015-07-06 15:29:02 -07:00
|
|
|
.SS pcsprintf ()
|
|
|
|
This function parses input exactly like
|
|
|
|
.BR sprintf (3)
|
|
|
|
the only difference is that it converts old renegade bbs style pipecodes (|10) to ansi sequences.
|
2015-07-02 12:52:49 -07:00
|
|
|
|
|
|
|
See NOTES.
|
|
|
|
.SS Return value
|
|
|
|
Upon successful return, these functions return the number of characters
|
2015-07-06 15:29:02 -07:00
|
|
|
printed (excluding the null byte used to end output to strings and
|
|
|
|
.I including
|
|
|
|
the ansi color code e.g. \fBx1b[0;39m\fR).
|
2015-07-02 12:52:49 -07:00
|
|
|
|
|
|
|
If an output error is encountered, a negative value is returned.
|
|
|
|
.SS Format of the format string
|
|
|
|
|
2015-07-06 15:29:02 -07:00
|
|
|
See
|
|
|
|
.BR printf (3)
|
2015-07-02 12:52:49 -07:00
|
|
|
|
|
|
|
.SS The flag characters
|
2015-07-06 15:29:02 -07:00
|
|
|
See
|
|
|
|
.BR printf (3)
|
2015-07-02 12:52:49 -07:00
|
|
|
|
|
|
|
.SH CONFORMING TO
|
|
|
|
The
|
2015-07-06 15:29:02 -07:00
|
|
|
.BR pcprintf (),
|
2015-07-02 12:52:49 -07:00
|
|
|
and
|
2015-07-06 15:29:02 -07:00
|
|
|
.BR pcsprintf ()
|
|
|
|
functions conform to C99 as they essentially wrap
|
|
|
|
.BR printf (3)
|
2015-07-02 12:52:49 -07:00
|
|
|
and
|
2015-07-06 15:29:02 -07:00
|
|
|
.BR sprintf (3)
|
|
|
|
.
|
2015-07-02 12:52:49 -07:00
|
|
|
.SH NOTES
|
2015-07-06 15:29:02 -07:00
|
|
|
.BR pcprintf ()
|
2015-07-02 12:52:49 -07:00
|
|
|
and
|
2015-07-06 15:29:02 -07:00
|
|
|
.BR pcsprintf ()
|
|
|
|
use
|
|
|
|
.BR vasprintf (3)
|
|
|
|
to automatically allocate buffer memory.
|
2015-07-02 12:52:49 -07:00
|
|
|
|
|
|
|
.SH BUGS
|
2015-07-06 15:29:02 -07:00
|
|
|
See
|
|
|
|
.BR printf (3)
|
2015-07-02 12:52:49 -07:00
|
|
|
|
2015-07-06 15:29:02 -07:00
|
|
|
.SH EXAMPLE
|
2015-07-02 12:52:49 -07:00
|
|
|
.nf
|
2015-07-06 15:29:02 -07:00
|
|
|
#include <\fBcstdio\fR>
|
|
|
|
#include <\fBiostream\fR>
|
|
|
|
#include <\fBpipecolors.h\fR>
|
2015-07-02 12:52:49 -07:00
|
|
|
|
2015-07-06 15:29:02 -07:00
|
|
|
using \fBnamespace\fR pipecolors;
|
2015-07-02 12:52:49 -07:00
|
|
|
|
2015-07-06 15:29:02 -07:00
|
|
|
\fBint\fR main(\fBvoid\fR) {
|
2015-07-02 12:52:49 -07:00
|
|
|
|
2015-07-06 15:29:02 -07:00
|
|
|
\fBint\fR num = 5;
|
|
|
|
\fBconst char*\fR str = "My number is";
|
|
|
|
pcprintf("|02%s |10%d|39\\n", str, num);
|
2015-07-02 12:52:49 -07:00
|
|
|
|
2015-07-06 15:29:02 -07:00
|
|
|
\fBreturn\fR 0;
|
2015-07-02 12:52:49 -07:00
|
|
|
}
|
2015-07-06 15:29:02 -07:00
|
|
|
|
|
|
|
\fBOutput\fR "\fB[ESC]\fRx1b[0;32mMy number is \fB[ESC]\fRx1b[0;92m5\fB[ESC]\fRx1b[0;39m";
|
|
|
|
.P
|
|
|
|
This would print \fBMy Number is\fR in dark green and \fI5\fR in light green.
|
|
|
|
The final code \fB|39\fR resets to the default color.
|
2015-07-02 12:52:49 -07:00
|
|
|
.fi
|
|
|
|
.SH SEE ALSO
|
2015-07-07 15:09:36 -07:00
|
|
|
.BR libpipecolors (7),
|
2015-07-06 15:29:02 -07:00
|
|
|
.BR printf (3),
|
|
|
|
.BR sprintf (3),
|
|
|
|
.BR vprintf (3),
|
|
|
|
.BR vsprintf (3),
|
2015-07-02 12:52:49 -07:00
|
|
|
.BR asprintf (3),
|
2015-07-06 15:29:02 -07:00
|
|
|
.BR vasprintf (3)
|