summaryrefslogtreecommitdiffstatshomepage
path: root/term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-02-25 11:37:05 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-02-25 11:37:05 +0000
commitc951a3baf41ca0fd6820e85f468a6d6f4a07a2f9 (patch)
treecc65b9407669dfef01c7ec9ab81fc1cd891904bb /term.c
parent41abdca0a25e1aa6d4a90432abb97b1f5d036ddf (diff)
downloadmandoc-c951a3baf41ca0fd6820e85f468a6d6f4a07a2f9.tar.gz
mandoc-c951a3baf41ca0fd6820e85f468a6d6f4a07a2f9.tar.zst
mandoc-c951a3baf41ca0fd6820e85f468a6d6f4a07a2f9.zip
All "low-hanging" macros implemented in term.c.
Diffstat (limited to 'term.c')
-rw-r--r--term.c138
1 files changed, 131 insertions, 7 deletions
diff --git a/term.c b/term.c
index e36dbd64..255b4e4e 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.16 2009/02/24 16:16:45 kristaps Exp $ */
+/* $Id: term.c,v 1.17 2009/02/25 11:37:05 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -48,7 +48,9 @@
#define TTYPE_CONFIG 13
#define TTYPE_CMD 14
#define TTYPE_INCLUDE 15
-#define TTYPE_NMAX 16
+#define TTYPE_SYMB 16
+#define TTYPE_SYMBOL 17
+#define TTYPE_NMAX 18
/*
* These define "styles" for element types, like command arguments or
@@ -72,7 +74,9 @@ const int ttypes[TTYPE_NMAX] = {
TERMP_UNDERLINE, /* TTYPE_EMPH */
TERMP_BOLD, /* TTYPE_CONFIG */
TERMP_BOLD, /* TTYPE_CMD */
- TERMP_BOLD /* TTYPE_INCLUDE */
+ TERMP_BOLD, /* TTYPE_INCLUDE */
+ TERMP_BOLD, /* TTYPE_SYMB */
+ TERMP_BOLD /* TTYPE_SYMBOL */
};
static int arg_hasattr(int, size_t,
@@ -102,6 +106,7 @@ DECL_POST(name);
DECL_PREPOST(termp_aq);
DECL_PREPOST(termp_ar);
+DECL_PREPOST(termp_bf);
DECL_PREPOST(termp_bd);
DECL_PREPOST(termp_bq);
DECL_PREPOST(termp_cd);
@@ -118,6 +123,7 @@ DECL_PREPOST(termp_ft);
DECL_PREPOST(termp_ic);
DECL_PREPOST(termp_in);
DECL_PREPOST(termp_it);
+DECL_PREPOST(termp_ms);
DECL_PREPOST(termp_nm);
DECL_PREPOST(termp_op);
DECL_PREPOST(termp_pa);
@@ -128,11 +134,13 @@ DECL_PREPOST(termp_sh);
DECL_PREPOST(termp_ss);
DECL_PREPOST(termp_sq);
DECL_PREPOST(termp_sx);
+DECL_PREPOST(termp_sy);
DECL_PREPOST(termp_va);
DECL_PREPOST(termp_vt);
DECL_PRE(termp_at);
DECL_PRE(termp_bsx);
+DECL_PRE(termp_bt);
DECL_PRE(termp_bx);
DECL_PRE(termp_ex);
DECL_PRE(termp_fx);
@@ -207,7 +215,7 @@ const struct termact __termacts[MDOC_MAX] = {
{ termp_aq_pre, termp_aq_post }, /* Aq */
{ termp_at_pre, NULL }, /* At */
{ NULL, NULL }, /* Bc */
- { NULL, NULL }, /* Bf */
+ { termp_bf_pre, termp_bf_post }, /* Bf */
{ termp_bq_pre, termp_bq_post }, /* Bo */
{ termp_bq_pre, termp_bq_post }, /* Bq */
{ termp_bsx_pre, NULL }, /* Bsx */
@@ -221,7 +229,7 @@ const struct termact __termacts[MDOC_MAX] = {
{ termp_em_pre, termp_em_post }, /* Em */
{ NULL, NULL }, /* Eo */
{ termp_fx_pre, NULL }, /* Fx */
- { NULL, NULL }, /* Ms */
+ { termp_ms_pre, termp_ms_post }, /* Ms */
{ NULL, NULL }, /* No */
{ termp_ns_pre, NULL }, /* Ns */
{ termp_nx_pre, NULL }, /* Nx */
@@ -241,7 +249,7 @@ const struct termact __termacts[MDOC_MAX] = {
{ termp_sq_pre, termp_sq_post }, /* Sq */
{ NULL, NULL }, /* Sm */
{ termp_sx_pre, termp_sx_post }, /* Sx */
- { NULL, NULL }, /* Sy */
+ { termp_sy_pre, termp_sy_post }, /* Sy */
{ NULL, NULL }, /* Tn */
{ termp_ux_pre, NULL }, /* Ux */
{ NULL, NULL }, /* Xc */
@@ -252,7 +260,7 @@ const struct termact __termacts[MDOC_MAX] = {
{ NULL, NULL }, /* Oc */
{ NULL, NULL }, /* Bk */
{ NULL, NULL }, /* Ek */
- { NULL, NULL }, /* Bt */
+ { termp_bt_pre, NULL }, /* Bt */
{ NULL, NULL }, /* Hf */
{ NULL, NULL }, /* Fr */
{ termp_ud_pre, NULL }, /* Ud */
@@ -793,6 +801,16 @@ termp_op_pre(DECL_ARGS)
/* ARGSUSED */
static int
+termp_bt_pre(DECL_ARGS)
+{
+
+ word(p, "is currently in beta test.");
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
termp_ud_pre(DECL_ARGS)
{
@@ -1431,6 +1449,8 @@ termp_fo_pre(DECL_ARGS)
} else if (MDOC_HEAD != node->type)
return(1);
+ /* XXX - groff shows only first parameter */
+
p->flags |= ttypes[TTYPE_FUNC_NAME];
for (n = node->child; n; n = n->next) {
assert(MDOC_TEXT == n->type);
@@ -1455,3 +1475,107 @@ termp_fo_post(DECL_ARGS)
}
+/* ARGSUSED */
+static int
+termp_bf_pre(DECL_ARGS)
+{
+ const struct mdoc_node *n;
+ const struct mdoc_block *b;
+
+ /* XXX - we skip over possible trailing HEAD tokens. */
+
+ if (MDOC_HEAD == node->type)
+ return(0);
+ else if (MDOC_BLOCK != node->type)
+ return(1);
+
+ b = &node->data.block;
+
+ if (NULL == (n = b->head->child)) {
+ if (arg_hasattr(MDOC_Emphasis, b->argc, b->argv))
+ p->flags |= ttypes[TTYPE_EMPH];
+ else if (arg_hasattr(MDOC_Symbolic, b->argc, b->argv))
+ p->flags |= ttypes[TTYPE_SYMB];
+
+ return(1);
+ }
+
+ assert(MDOC_TEXT == n->type);
+
+ if (0 == strcmp("Em", n->data.text.string))
+ p->flags |= ttypes[TTYPE_EMPH];
+ else if (0 == strcmp("Sy", n->data.text.string))
+ p->flags |= ttypes[TTYPE_SYMB];
+
+ return(1);
+}
+
+
+/* ARGSUSED */
+static void
+termp_bf_post(DECL_ARGS)
+{
+ const struct mdoc_node *n;
+ const struct mdoc_block *b;
+
+ if (MDOC_BLOCK != node->type)
+ return;
+
+ b = &node->data.block;
+
+ if (NULL == (n = b->head->child)) {
+ if (arg_hasattr(MDOC_Emphasis, b->argc, b->argv))
+ p->flags &= ~ttypes[TTYPE_EMPH];
+ else if (arg_hasattr(MDOC_Symbolic, b->argc, b->argv))
+ p->flags &= ~ttypes[TTYPE_SYMB];
+
+ return;
+ }
+
+ assert(MDOC_TEXT == n->type);
+
+ if (0 == strcmp("Emphasis", n->data.text.string))
+ p->flags &= ~ttypes[TTYPE_EMPH];
+ else if (0 == strcmp("Symbolic", n->data.text.string))
+ p->flags &= ~ttypes[TTYPE_SYMB];
+
+ return;
+}
+
+
+/* ARGSUSED */
+static int
+termp_sy_pre(DECL_ARGS)
+{
+
+ p->flags |= ttypes[TTYPE_SYMB];
+ return(1);
+}
+
+
+/* ARGSUSED */
+static void
+termp_sy_post(DECL_ARGS)
+{
+
+ p->flags &= ~ttypes[TTYPE_SYMB];
+}
+
+
+/* ARGSUSED */
+static int
+termp_ms_pre(DECL_ARGS)
+{
+
+ p->flags |= ttypes[TTYPE_SYMBOL];
+ return(1);
+}
+
+
+/* ARGSUSED */
+static void
+termp_ms_post(DECL_ARGS)
+{
+
+ p->flags &= ~ttypes[TTYPE_SYMBOL];
+}