From e280948442d794a01b8749758aa83d24061eb233 Mon Sep 17 00:00:00 2001 From: ellson Date: Thu, 28 Aug 2008 12:08:28 +0000 Subject: [PATCH] Add support for \L substitution --- cmd/dot/dot.1 | 41 ++++++++++++++++++++++++++++------------- lib/common/labels.c | 26 ++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 15 deletions(-) diff --git a/cmd/dot/dot.1 b/cmd/dot/dot.1 index d39c69bfa..da4e90ebf 100644 --- a/cmd/dot/dot.1 +++ b/cmd/dot/dot.1 @@ -336,6 +336,7 @@ EPSF file to be automatically loaded for the node shape. \fBlabel=\fItext\fR where \fItext\fP may include escaped newlines \\\|n, \\\|l, or \\\|r for center, left, and right justified lines. The string '\\N' value will be replaced by the node name. +The string '\\G' value will be replaced by the graph name. Record labels may contain recursive box lists delimited by { | }. Port identifiers in labels are set off by angle brackets < >. In the graph file, use colon (such as, \fBnode0:port28\fR). @@ -400,8 +401,9 @@ This attribute is ignored by \fIbuiltin_polygons\fR. .PP \fBhref=\fI"url"\fR sets the url for the node in imagemap, PostScript and SVG files. -The substring '\\N' is substituted in the same manner as +The substrings '\\N' and '\\G' are substituted in the same manner as for the node label attribute. +Additionally the substring '\\L' is substituted with the node label string. .PP \fBURL=\fI"url"\fR ("URL" is a synonym for "href".) .PP @@ -412,15 +414,17 @@ for the URL. Setting it to "_graphviz" will open a new window if it doesn't already exist, or reuse it if it does. If the target string is empty, the default, then no target attribute is included in the output. -The substring '\\N' is substituted in the same manner as +The substrings '\\N' and '\\G' are substituted in the same manner as for the node label attribute. +Additionally the substring '\\L' is substituted with the node label string. .PP \fBtooltip=\fI"tooltip"\fR is a tooltip string for client\(hyside imagemaps and SVG, effective when nodes have a URL. The tooltip string defaults to be the same as the label string, but this attribute permits nodes without labels to still have tooltips thus permitting denser graphs. -The substring '\\N' is substituted in the same manner as +The substrings '\\N' and '\\G' are substituted in the same manner as for the node label attribute. +Additionally the substring '\\L' is substituted with the node label string. .PP \fB(circo\(hyspecific attributes)\fR @@ -448,6 +452,7 @@ edges are ignored for ordering nodes. If the substring '\\T' is found in a label it will be replaced by the tail_node name. If the substring '\\H' is found in a label it will be replaced by the head_node name. If the substring '\\E' value is found in a label it will be replaced by: tail_node_name\->head_node_name +If the substring '\\G' is found in a label it will be replaced by the graph name. or by: tail_node_name\-\-head_node_name for undirected graphs. .PP \fBfontsize=\fIn\fR sets the label type size to \fIn\fP points. @@ -469,8 +474,9 @@ parallel edges, one edge for each color. .PP \fBhref=\fI"url"\fR sets the url for the node in imagemap, PostScript and SVG files. -The substrings '\\T', '\\H', and '\\E' are substituted in the same manner as +The substrings '\\T', '\\H', '\\E' and '\\G' are substituted in the same manner as for the edge label attribute. +Additionally the substring '\\L' is substituted with the edge label string. .PP \fBURL=\fI"url"\fR ("URL" is a synonym for "href".) .PP @@ -478,14 +484,16 @@ for the edge label attribute. and SVG, effective when edges have a URL. If the target string is empty, the default, then no target attribute is included in the output. -The substrings '\\T', '\\H', and '\\E' are substituted in the same manner as +The substrings '\\T', '\\H', '\\E' and '\\G' are substituted in the same manner as for the edge label attribute. +Additionally the substring '\\L' is substituted with the edge label string. .PP \fBtooltip=\fI"tooltip"\fR is a tooltip string for client\(hyside imagemaps effective when edges have a URL. The tooltip string defaults to be the same as the edge label string. -The substrings '\\T', '\\H', and '\\E' are substituted in the same manner as +The substrings '\\T', '\\H', '\\E' and '\\G' are substituted in the same manner as for the edge label attribute. +Additionally the substring '\\L' is substituted with the edge label string. .PP \fBarrowhead,arrowtail=none, normal, inv, dot, odot, invdot, invodot, tee, empty, invempty, open, halfopen, diamond, odiamond, box, obox, crow\fP. @@ -496,12 +504,14 @@ inv_length=6,inv_width=7,dot_radius=2) \fBheadlabel,taillabel=string\fP for port labels. \fBlabelfontcolor\fP,\fBlabelfontname\fP,\fBlabelfontsize\fP for head and tail labels. -The substrings '\\T', '\\H', and '\\E' are substituted in the same manner as +The substrings '\\T', '\\H', '\\E' and '\\G' are substituted in the same manner as for the edge label attribute. +Additionally the substring '\\L' is substituted with the edge label string. .PP \fBheadhref=\fI"url"\fR sets the url for the head port in imagemap, PostScript and SVG files. -The substrings '\\T', '\\H', and '\\E' are substituted in the same manner as +The substrings '\\T', '\\H', '\\E' and '\\G' are substituted in the same manner as for the edge label attribute. +Additionally the substring '\\L' is substituted with the edge label string. .PP \fBheadURL=\fI"url"\fR ("headURL" is a synonym for "headhref".) .PP @@ -510,18 +520,21 @@ and SVG, effective when edge heads have a URL. The headtarget string is used to determine which window of the browser is used for the URL. If the headtarget string is empty, the default, then headtarget defaults to the same value as target for the edge. -The substrings '\\T', '\\H', and '\\E' are substituted in the same manner as +The substrings '\\T', '\\H', '\\E' and '\\G' are substituted in the same manner as for the edge label attribute. +Additionally the substring '\\L' is substituted with the edge label string. .PP \fBheadtooltip=\fI"tooltip"\fR is a tooltip string for client\(hyside imagemaps effective when head ports have a URL. The tooltip string defaults to be the same as the headlabel string. The substrings '\\T', '\\H', and '\\E' are substituted in the same manner as for the edge label attribute. +Additionally the substring '\\L' is substituted with the edge label string. .PP \fBtailhref=\fI"url"\fR sets the url for the tail port in imagemap, PostScript and SVG files. -The substrings '\\T', '\\H', and '\\E' are substituted in the same manner as +The substrings '\\T', '\\H', '\\E' and '\\G' are substituted in the same manner as for the edge label attribute. +Additionally the substring '\\L' is substituted with the edge label string. .PP \fBtailURL=\fI"url"\fR ("tailURL" is a synonym for "tailhref".) .PP @@ -530,14 +543,16 @@ and SVG, effective when edge tails have a URL. The tailtarget string is used to determine which window of the browser is used for the URL. If the tailtarget string is empty, the default, then tailtarget defaults to the same value as target for the edge. -The substrings '\\T', '\\H', and '\\E' are substituted in the same manner as +The substrings '\\T', '\\H', '\\E' and '\\G' are substituted in the same manner as for the edge label attribute. +Additionally the substring '\\L' is substituted with the edge label string. .PP \fBtailtooltip=\fI"tooltip"\fR is a tooltip string for client\(hyside imagemaps effective when tail ports have a URL. The tooltip string defaults to be the same as the taillabel string. -The substrings '\\T', '\\H', and '\\E' are substituted in the same manner as +The substrings '\\T', '\\H', '\\E' and '\\G' are substituted in the same manner as for the edge label attribute. +Additionally the substring '\\L' is substituted with the edge label string. .PP \fBlabeldistance\fP and \fPport_label_distance\fP set distance; also \fBlabelangle\fP (in degrees CCW) @@ -549,7 +564,7 @@ same port, using the average landing point. .PP \fBconstraint=false\fP causes an edge to be ignored for rank assignment. .PP -\fBlayer=\fIid\fR or \fIid:id\fR or "all" sets the edgess active layers. +\fBlayer=\fIid\fR or \fIid:id\fR or "all" sets the edge's active layers. The empty string means no layers (invisible). .PP diff --git a/lib/common/labels.c b/lib/common/labels.c index 0548411f7..560a00252 100644 --- a/lib/common/labels.c +++ b/lib/common/labels.c @@ -262,20 +262,31 @@ void emit_label(GVJ_t * job, emit_state_t emit_state, textlabel_t * lp) char *strdup_and_subst_obj(char *str, void *obj) { char c, *s, *p, *t, *newstr; - char *g_str = "\\G", *n_str = "\\N", *e_str = "\\E", *h_str = "\\H", *t_str = "\\T"; - int g_len = 2, n_len = 2, e_len = 2, h_len = 2, t_len = 2, newlen = 0; + char *g_str = "\\G", *n_str = "\\N", *e_str = "\\E", *h_str = "\\H", *t_str = "\\T", *l_str = "\\L"; + int g_len = 2, n_len = 2, e_len = 2, h_len = 2, t_len = 2, l_len, newlen = 0; + textlabel_t *tl; /* prepare substitution strings */ switch (agobjkind(obj)) { case AGGRAPH: g_str = ((graph_t *)obj)->name; g_len = strlen(g_str); + tl = GD_label((graph_t *)obj); + if (tl) { + l_str = tl->text; + if (str) l_len = strlen(l_str); + } break; case AGNODE: g_str = ((node_t *)obj)->graph->name; g_len = strlen(g_str); n_str = ((node_t *)obj)->name; n_len = strlen(n_str); + tl = ND_label((node_t *)obj); + if (tl) { + l_str = tl->text; + if (str) l_len = strlen(l_str); + } break; case AGEDGE: g_str = ((edge_t *)obj)->tail->graph->root->name; @@ -284,6 +295,11 @@ char *strdup_and_subst_obj(char *str, void *obj) t_len = strlen(t_str); h_str = ((edge_t *)obj)->head->name; h_len = strlen(h_str); + tl = ED_label((edge_t *)obj); + if (tl) { + l_str = tl->text; + if (str) l_len = strlen(l_str); + } if (((edge_t *)obj)->tail->graph->root->kind & AGFLAG_DIRECTED) e_str = "->"; else @@ -315,6 +331,9 @@ char *strdup_and_subst_obj(char *str, void *obj) case 'T': newlen += t_len; break; + case 'L': + newlen += t_len; + break; default: /* leave other escape sequences unmodified, e.g. \n \l \r */ newlen += 2; } @@ -346,6 +365,9 @@ char *strdup_and_subst_obj(char *str, void *obj) case 'H': for (t = h_str; (*p = *t++); p++); break; + case 'L': + for (t = l_str; (*p = *t++); p++); + break; default: /* leave other escape sequences unmodified, e.g. \n \l \r */ *p++ = '\\'; *p++ = c; -- 2.40.0