From 9dc561903c091d47de40734858a9c8e6fe7a7c75 Mon Sep 17 00:00:00 2001 From: Teemu Murtola Date: Fri, 7 May 2010 15:03:17 +0200 Subject: [PATCH] Minor improvements to selection help. There is a new 'help all' command that prints out all the available help pages at once, excluding help for individual keywords. Output is now also wrapped at 79 characters for the subtopic list. --- src/gmxlib/selection/selhelp.c | 47 ++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/src/gmxlib/selection/selhelp.c b/src/gmxlib/selection/selhelp.c index ed3e58bf61..2494ba402b 100644 --- a/src/gmxlib/selection/selhelp.c +++ b/src/gmxlib/selection/selhelp.c @@ -57,6 +57,7 @@ static const char *help_common[] = { "described under \"syntax\". Available keywords can be found under", "\"keywords\", and concrete examples under \"examples\".", "Other subtopics give more details on certain aspects.", + "\"help all\" prints the help for all subtopics.", }; static const char *help_arithmetic[] = { @@ -180,7 +181,7 @@ static const char *help_limits[] = { "selections (e.g., [TT]g_angle[tt] requires the index group to be made", "of groups of three or four atoms).", "For such programs, it is up to the user to provide a proper selection", - "expression that always returns such positions.[PAR]", + "expression that always returns such positions.", }; static const char *help_positions[] = { @@ -290,15 +291,15 @@ static const char *help_syntax[] = { }; static const t_selection_help_item helpitems[] = { - {NULL, asize(help_common), help_common}, - {"arithmetic", asize(help_arithmetic),help_arithmetic}, - {"cmdline", asize(help_cmdline), help_cmdline}, - {"evaluation", asize(help_eval), help_eval}, - {"examples", asize(help_examples), help_examples}, - {"keywords", asize(help_keywords), help_keywords}, - {"limitations", asize(help_limits), help_limits}, - {"positions", asize(help_positions), help_positions}, - {"syntax", asize(help_syntax), help_syntax}, + {NULL, asize(help_common), help_common}, + {"cmdline", asize(help_cmdline), help_cmdline}, + {"syntax", asize(help_syntax), help_syntax}, + {"positions", asize(help_positions), help_positions}, + {"arithmetic", asize(help_arithmetic), help_arithmetic}, + {"keywords", asize(help_keywords), help_keywords}, + {"evaluation", asize(help_eval), help_eval}, + {"limitations", asize(help_limits), help_limits}, + {"examples", asize(help_examples), help_examples}, }; /*! \brief @@ -357,7 +358,7 @@ print_keyword_list(struct gmx_ana_selcollection_t *sc, e_selvalue_t type, void _gmx_sel_print_help(struct gmx_ana_selcollection_t *sc, const char *topic) { - const t_selection_help_item *item = 0; + const t_selection_help_item *item = NULL; int i; /* Find the item for the topic */ @@ -365,6 +366,19 @@ _gmx_sel_print_help(struct gmx_ana_selcollection_t *sc, const char *topic) { item = &helpitems[0]; } + else if (strcmp(topic, "all") == 0) + { + for (i = 0; i < asize(helpitems); ++i) + { + item = &helpitems[i]; + _gmx_sel_print_help(sc, item->topic); + if (i != asize(helpitems) - 1) + { + fprintf(stderr, "\n\n"); + } + } + return; + } else { for (i = 1; i < asize(helpitems); ++i) @@ -372,6 +386,7 @@ _gmx_sel_print_help(struct gmx_ana_selcollection_t *sc, const char *topic) if (strncmp(helpitems[i].topic, topic, strlen(topic)) == 0) { item = &helpitems[i]; + break; } } } @@ -403,10 +418,20 @@ _gmx_sel_print_help(struct gmx_ana_selcollection_t *sc, const char *topic) /* Special handling of certain pages */ if (!topic) { + int len = 0; + /* Print the subtopics on the main page */ fprintf(stderr, "\nAvailable subtopics:\n"); for (i = 1; i < asize(helpitems); ++i) { + int len1 = strlen(helpitems[i].topic) + 2; + + len += len1; + if (len > 79) + { + fprintf(stderr, "\n"); + len = len1; + } fprintf(stderr, " %s", helpitems[i].topic); } fprintf(stderr, "\n"); -- 2.11.4.GIT