aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-08-16 13:54:06 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-08-16 13:54:06 +0000
commit31f17a62e510f4e0732d1c76e7a56a1a69506dc6 (patch)
tree3ebfa16f389b97a4bfa5988b198dad27b59d3fb5 /term.c
parent44573b326d6604f3025f17909863711b17011d5f (diff)
downloadmandoc-31f17a62e510f4e0732d1c76e7a56a1a69506dc6.tar.gz
mandoc-31f17a62e510f4e0732d1c76e7a56a1a69506dc6.tar.zst
mandoc-31f17a62e510f4e0732d1c76e7a56a1a69506dc6.zip
Implement the \*(.T predefined string (interpolate device name)
by allowing the preprocessor to pass it through to the formatters. Used for example by the groff_char(7) manual page.
Diffstat (limited to 'term.c')
-rw-r--r--term.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/term.c b/term.c
index f67fcf9d..0b722289 100644
--- a/term.c
+++ b/term.c
@@ -1,7 +1,7 @@
-/* $Id: term.c,v 1.274 2017/07/28 14:25:48 schwarze Exp $ */
+/* $Id: term.c,v 1.275 2018/08/16 13:54:06 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -525,6 +525,16 @@ term_word(struct termp *p, const char *word)
else if (*word == '\0')
p->flags |= (TERMP_NOSPACE | TERMP_NONEWLINE);
continue;
+ case ESCAPE_DEVICE:
+ if (p->type == TERMTYPE_PDF)
+ encode(p, "pdf", 3);
+ else if (p->type == TERMTYPE_PS)
+ encode(p, "ps", 2);
+ else if (p->enc == TERMENC_ASCII)
+ encode(p, "ascii", 5);
+ else
+ encode(p, "utf8", 4);
+ continue;
case ESCAPE_HORIZ:
if (*seq == '|') {
seq++;
@@ -860,6 +870,21 @@ term_strlen(const struct termp *p, const char *cp)
sz += cond_width(p, uc, &skip);
}
continue;
+ case ESCAPE_DEVICE:
+ if (p->type == TERMTYPE_PDF) {
+ rhs = "pdf";
+ rsz = 3;
+ } else if (p->type == TERMTYPE_PS) {
+ rhs = "ps";
+ rsz = 2;
+ } else if (p->enc == TERMENC_ASCII) {
+ rhs = "ascii";
+ rsz = 5;
+ } else {
+ rhs = "utf8";
+ rsz = 4;
+ }
+ break;
case ESCAPE_SKIPCHAR:
skip = 1;
continue;