aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-07-17 22:38:29 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-07-17 22:38:29 +0000
commit7221f76a236baf4056bfe1c909f3c978a4a94349 (patch)
treeeed560ed48c0b821fddc22bf6623153f70031431 /mdoc_term.c
parente1c3bf5030411d1b27f5509c2027238b63c1a49e (diff)
downloadmandoc-7221f76a236baf4056bfe1c909f3c978a4a94349.tar.gz
mandoc-7221f76a236baf4056bfe1c909f3c978a4a94349.tar.zst
mandoc-7221f76a236baf4056bfe1c909f3c978a4a94349.zip
Initial, still somewhat experimental implementation to leverage
less(1) -T and :t ctags(1)-like functionality to jump to the definitions of various terms inside manual pages. To be polished in the tree, so bear with me and report issues. Technically, if less(1) is used as a pager, information is collected by the mdoc(7) terminal formatter, first stored using the ohash library, then ultimately written to a temporary file which is passed to less via -T. No change intended for other output formatters or when running without a pager. Based on an idea from Kristaps using feedback from many, in particular phessler@ nicm@ millert@ halex@ doug@ kspillner@ deraadt@.
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index be170bf5..d8a8ff3f 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.319 2015/04/18 17:53:21 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.320 2015/07/17 22:38:29 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -34,6 +34,7 @@
#include "mdoc.h"
#include "out.h"
#include "term.h"
+#include "tag.h"
#include "main.h"
struct termpair {
@@ -117,6 +118,7 @@ static int termp_skip_pre(DECL_ARGS);
static int termp_sm_pre(DECL_ARGS);
static int termp_sp_pre(DECL_ARGS);
static int termp_ss_pre(DECL_ARGS);
+static int termp_tag_pre(DECL_ARGS);
static int termp_under_pre(DECL_ARGS);
static int termp_ud_pre(DECL_ARGS);
static int termp_vt_pre(DECL_ARGS);
@@ -145,7 +147,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_bold_pre, NULL }, /* Cm */
{ NULL, NULL }, /* Dv */
{ NULL, NULL }, /* Er */
- { NULL, NULL }, /* Ev */
+ { termp_tag_pre, NULL }, /* Ev */
{ termp_ex_pre, NULL }, /* Ex */
{ termp_fa_pre, NULL }, /* Fa */
{ termp_fd_pre, termp_fd_post }, /* Fd */
@@ -1049,6 +1051,7 @@ static int
termp_fl_pre(DECL_ARGS)
{
+ termp_tag_pre(p, pair, meta, n);
term_fontpush(p, TERMFONT_BOLD);
term_word(p, "\\-");
@@ -1330,6 +1333,7 @@ static int
termp_bold_pre(DECL_ARGS)
{
+ termp_tag_pre(p, pair, meta, n);
term_fontpush(p, TERMFONT_BOLD);
return(1);
}
@@ -2252,3 +2256,19 @@ termp_under_pre(DECL_ARGS)
term_fontpush(p, TERMFONT_UNDER);
return(1);
}
+
+static int
+termp_tag_pre(DECL_ARGS)
+{
+
+ if (n->child != NULL &&
+ n->child->type == ROFFT_TEXT &&
+ n->prev == NULL &&
+ (n->parent->tok == MDOC_It ||
+ (n->parent->tok == MDOC_Xo &&
+ n->parent->parent->prev == NULL &&
+ n->parent->parent->parent->tok == MDOC_It)) &&
+ ! tag_get(n->child->string, 0))
+ tag_put(n->child->string, 0, p->line);
+ return(1);
+}