b5d34fef6610916dc89c85f83c0e1f719f6969c3 kate Mon Aug 31 20:13:15 2020 -0700 Add support for mouseOver (pattern) trackDb setting (initially to bigLolly). refs #26160 diff --git src/hg/lib/hui.c src/hg/lib/hui.c index c68a3b4..18345a7 100644 --- src/hg/lib/hui.c +++ src/hg/lib/hui.c @@ -9369,30 +9369,64 @@ struct slName *asColNames(struct asObject *as) // Get list of column names. { struct slName *list = NULL, *el; struct asColumn *col; for (col = as->columnList; col != NULL; col = col->next) { el = slNameNew(col->name); slAddHead(&list, el); } slReverse(&list); return list; } +static struct dyString *subMultiField(char *pattern, int fieldCount, + char *in[], char *out[]) +/* Substitute $in with out values in pattern */ +{ +int i; +struct dyString *s = newDyString(256), *d = NULL; +dyStringAppend(s, pattern); +for (i=0; i<fieldCount; ++i) + { + if (out[i]==NULL) + continue; + + // prefix field with $ + char *field = in[i]; + char *spec = needMem(strlen(field) + 2); + *spec = '$'; + strcpy(spec + 1, field); + + d = dyStringSub(s->string, spec, out[i]); + dyStringFree(&s); + freeMem(spec); + s = d; + d = NULL; + } +return s; +} + +char *replaceFieldInPattern(char *pattern, int fieldCount, char **fieldNames, char **fieldVals) +/* Replace $fieldName in pattern with value. Used in trackDb mouseOver setting */ +{ +struct dyString *ds = subMultiField(pattern, fieldCount, fieldNames, fieldVals); +return dyStringCannibalize(&ds); +} + static struct dyString *subMulti(char *orig, int subCount, char *in[], char *out[]) /* Perform multiple substitions on orig. */ { int i; struct dyString *s = newDyString(256), *d = NULL; dyStringAppend(s, orig); for (i=0; i<subCount; ++i) { fflush(stdout); if (out[i]==NULL) continue; d = dyStringSub(s->string, in[i], out[i]); dyStringFree(&s);