2015-03-02 16:45:41 +00:00
|
|
|
/* $Id: term.h,v 1.111 2015/01/31 00:12:41 schwarze Exp $ */
|
2012-10-18 09:55:16 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
|
2014-11-22 18:08:25 +00:00
|
|
|
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
|
2012-10-18 09:55:16 +00:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum termenc {
|
|
|
|
TERMENC_ASCII,
|
|
|
|
TERMENC_LOCALE,
|
|
|
|
TERMENC_UTF8
|
|
|
|
};
|
|
|
|
|
|
|
|
enum termtype {
|
|
|
|
TERMTYPE_CHAR,
|
|
|
|
TERMTYPE_PS,
|
|
|
|
TERMTYPE_PDF
|
|
|
|
};
|
|
|
|
|
|
|
|
enum termfont {
|
|
|
|
TERMFONT_NONE = 0,
|
|
|
|
TERMFONT_BOLD,
|
|
|
|
TERMFONT_UNDER,
|
2014-01-31 19:59:03 +00:00
|
|
|
TERMFONT_BI,
|
2012-10-18 09:55:16 +00:00
|
|
|
TERMFONT__MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define TERM_MAXMARGIN 100000 /* FIXME */
|
|
|
|
|
2014-12-25 21:33:25 +00:00
|
|
|
struct termp;
|
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
typedef void (*term_margin)(struct termp *, const void *);
|
|
|
|
|
|
|
|
struct termp_tbl {
|
|
|
|
int width; /* width in fixed chars */
|
|
|
|
int decimal; /* decimal point position */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct termp {
|
|
|
|
enum termtype type;
|
|
|
|
struct rofftbl tbl; /* table configuration */
|
2014-12-02 07:34:06 +00:00
|
|
|
int synopsisonly; /* print the synopsis only */
|
2012-10-18 09:55:16 +00:00
|
|
|
int mdocstyle; /* imitate mdoc(7) output */
|
|
|
|
size_t defindent; /* Default indent for text. */
|
|
|
|
size_t defrmargin; /* Right margin of the device. */
|
2014-11-22 18:08:25 +00:00
|
|
|
size_t lastrmargin; /* Right margin before the last ll. */
|
2012-10-18 09:55:16 +00:00
|
|
|
size_t rmargin; /* Current right margin. */
|
|
|
|
size_t maxrmargin; /* Max right margin. */
|
2014-01-31 19:59:03 +00:00
|
|
|
size_t maxcols; /* Max size of buf. */
|
2012-10-18 09:55:16 +00:00
|
|
|
size_t offset; /* Margin offest. */
|
|
|
|
size_t tabwidth; /* Distance of tab positions. */
|
2014-01-31 19:59:03 +00:00
|
|
|
size_t col; /* Bytes in buf. */
|
2012-10-18 09:55:16 +00:00
|
|
|
size_t viscol; /* Chars on current line. */
|
2014-01-31 19:59:03 +00:00
|
|
|
size_t trailspace; /* See termp_flushln(). */
|
2012-10-18 09:55:16 +00:00
|
|
|
int overstep; /* See termp_flushln(). */
|
2014-01-31 19:59:03 +00:00
|
|
|
int skipvsp; /* Vertical space to skip. */
|
2012-10-18 09:55:16 +00:00
|
|
|
int flags;
|
|
|
|
#define TERMP_SENTENCE (1 << 1) /* Space before a sentence. */
|
|
|
|
#define TERMP_NOSPACE (1 << 2) /* No space before words. */
|
2014-01-31 19:59:03 +00:00
|
|
|
#define TERMP_NONOSPACE (1 << 3) /* No space (no autounset). */
|
|
|
|
#define TERMP_NBRWORD (1 << 4) /* Make next word nonbreaking. */
|
|
|
|
#define TERMP_KEEP (1 << 5) /* Keep words together. */
|
|
|
|
#define TERMP_PREKEEP (1 << 6) /* ...starting with the next one. */
|
|
|
|
#define TERMP_SKIPCHAR (1 << 7) /* Skip the next character. */
|
|
|
|
#define TERMP_NOBREAK (1 << 8) /* See term_flushln(). */
|
2014-11-22 18:08:25 +00:00
|
|
|
#define TERMP_BRIND (1 << 9) /* See term_flushln(). */
|
|
|
|
#define TERMP_DANGLE (1 << 10) /* See term_flushln(). */
|
|
|
|
#define TERMP_HANG (1 << 11) /* See term_flushln(). */
|
2014-12-02 07:34:06 +00:00
|
|
|
#define TERMP_NOSPLIT (1 << 12) /* Do not break line before .An. */
|
|
|
|
#define TERMP_SPLIT (1 << 13) /* Break line before .An. */
|
2014-12-25 21:33:25 +00:00
|
|
|
#define TERMP_NONEWLINE (1 << 14) /* No line break in nofill mode. */
|
2012-10-18 09:55:16 +00:00
|
|
|
int *buf; /* Output buffer. */
|
|
|
|
enum termenc enc; /* Type of encoding. */
|
2014-12-02 07:34:06 +00:00
|
|
|
const struct mchars *symtab; /* Character table. */
|
2012-10-18 09:55:16 +00:00
|
|
|
enum termfont fontl; /* Last font set. */
|
2015-03-02 16:45:41 +00:00
|
|
|
enum termfont *fontq; /* Symmetric fonts. */
|
|
|
|
int fontsz; /* Allocated size of font stack */
|
2012-10-18 09:55:16 +00:00
|
|
|
int fonti; /* Index of font stack. */
|
|
|
|
term_margin headf; /* invoked to print head */
|
|
|
|
term_margin footf; /* invoked to print foot */
|
|
|
|
void (*letter)(struct termp *, int);
|
|
|
|
void (*begin)(struct termp *);
|
|
|
|
void (*end)(struct termp *);
|
|
|
|
void (*endline)(struct termp *);
|
|
|
|
void (*advance)(struct termp *, size_t);
|
2014-11-22 18:08:25 +00:00
|
|
|
void (*setwidth)(struct termp *, int, size_t);
|
2012-10-18 09:55:16 +00:00
|
|
|
size_t (*width)(const struct termp *, int);
|
|
|
|
double (*hspan)(const struct termp *,
|
|
|
|
const struct roffsu *);
|
|
|
|
const void *argf; /* arg for headf/footf */
|
|
|
|
struct termp_ps *ps;
|
|
|
|
};
|
|
|
|
|
2014-12-25 21:33:25 +00:00
|
|
|
__BEGIN_DECLS
|
|
|
|
|
|
|
|
struct tbl_span;
|
|
|
|
struct eqn;
|
|
|
|
|
2014-12-02 07:34:06 +00:00
|
|
|
const char *ascii_uc2str(int);
|
|
|
|
|
2012-10-18 09:55:16 +00:00
|
|
|
void term_eqn(struct termp *, const struct eqn *);
|
|
|
|
void term_tbl(struct termp *, const struct tbl_span *);
|
|
|
|
void term_free(struct termp *);
|
|
|
|
void term_newln(struct termp *);
|
|
|
|
void term_vspace(struct termp *);
|
|
|
|
void term_word(struct termp *, const char *);
|
|
|
|
void term_flushln(struct termp *);
|
2014-11-22 18:08:25 +00:00
|
|
|
void term_begin(struct termp *, term_margin,
|
2012-10-18 09:55:16 +00:00
|
|
|
term_margin, const void *);
|
|
|
|
void term_end(struct termp *);
|
|
|
|
|
2014-11-22 18:08:25 +00:00
|
|
|
void term_setwidth(struct termp *, const char *);
|
2015-03-02 16:45:41 +00:00
|
|
|
int term_hspan(const struct termp *, const struct roffsu *);
|
|
|
|
int term_vspan(const struct termp *, const struct roffsu *);
|
2012-10-18 09:55:16 +00:00
|
|
|
size_t term_strlen(const struct termp *, const char *);
|
|
|
|
size_t term_len(const struct termp *, size_t);
|
|
|
|
|
|
|
|
void term_fontpush(struct termp *, enum termfont);
|
|
|
|
void term_fontpop(struct termp *);
|
2015-03-02 16:45:41 +00:00
|
|
|
void term_fontpopq(struct termp *, int);
|
2012-10-18 09:55:16 +00:00
|
|
|
void term_fontrepl(struct termp *, enum termfont);
|
|
|
|
void term_fontlast(struct termp *);
|
|
|
|
|
|
|
|
__END_DECLS
|