NeoMutt  2024-02-01-35-geee02f
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
lib.h File Reference

Ask the user a question. More...

#include "config/lib.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int mw_multi_choice (const char *prompt, const char *letters)
 Offer the user a multiple choice question -.
 
enum QuadOption query_yesorno (const char *prompt, enum QuadOption def)
 Ask the user a Yes/No question.
 
enum QuadOption query_yesorno_help (const char *prompt, enum QuadOption def, struct ConfigSubset *sub, const char *name)
 Ask the user a Yes/No question offering help.
 
enum QuadOption query_quadoption (const char *prompt, struct ConfigSubset *sub, const char *name)
 Ask the user a quad-question.
 

Detailed Description

Ask the user a question.

Authors
  • Pietro Cerutti
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file lib.h.

Function Documentation

◆ query_yesorno()

enum QuadOption query_yesorno ( const char *  prompt,
enum QuadOption  def 
)

Ask the user a Yes/No question.

Parameters
promptPrompt
defDefault answer, e.g. MUTT_YES
Return values
enumQuadOption, Selection made

Wrapper for mw_yesorno().

Definition at line 334 of file question.c.

335{
336 return mw_yesorno(prompt, def, NULL);
337}
static enum QuadOption mw_yesorno(const char *prompt, enum QuadOption def, struct ConfigDef *cdef)
Ask the user a Yes/No question offering help -.
Definition: question.c:181
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ query_yesorno_help()

enum QuadOption query_yesorno_help ( const char *  prompt,
enum QuadOption  def,
struct ConfigSubset sub,
const char *  name 
)

Ask the user a Yes/No question offering help.

Parameters
promptPrompt
defDefault answer, e.g. MUTT_YES
subConfig Subset
nameName of controlling config variable
Return values
enumQuadOption, Selection made

Wrapper for mw_yesorno().

Definition at line 349 of file question.c.

351{
352 struct HashElem *he = cs_subset_create_inheritance(sub, name);
353 struct HashElem *he_base = cs_get_base(he);
354 assert(DTYPE(he_base->type) == DT_BOOL);
355
356 intptr_t value = cs_subset_he_native_get(sub, he, NULL);
357 assert(value != INT_MIN);
358
359 struct ConfigDef *cdef = he_base->data;
360 return mw_yesorno(prompt, def, cdef);
361}
struct HashElem * cs_get_base(struct HashElem *he)
Find the root Config Item.
Definition: set.c:160
Definition: set.h:64
The item stored in a Hash Table.
Definition: hash.h:43
int type
Type of data stored in Hash Table, e.g. DT_STRING.
Definition: hash.h:44
void * data
User-supplied data.
Definition: hash.h:46
intptr_t cs_subset_he_native_get(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Natively get the value of a HashElem config item.
Definition: subset.c:258
struct HashElem * cs_subset_create_inheritance(const struct ConfigSubset *sub, const char *name)
Create a Subset config item (inherited)
Definition: subset.c:208
#define DTYPE(t)
Definition: types.h:49
@ DT_BOOL
boolean option
Definition: types.h:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ query_quadoption()

enum QuadOption query_quadoption ( const char *  prompt,
struct ConfigSubset sub,
const char *  name 
)

Ask the user a quad-question.

Parameters
promptMessage to show to the user
subConfig Subset
nameName of controlling config variable
Return values
QuadOptionResult, e.g. MUTT_NO

If the config variable is set to 'yes' or 'no', the function returns immediately. Otherwise, the job is delegated to mw_yesorno().

Definition at line 373 of file question.c.

374{
375 struct HashElem *he = cs_subset_create_inheritance(sub, name);
376 struct HashElem *he_base = cs_get_base(he);
377 assert(DTYPE(he_base->type) == DT_QUAD);
378
379 intptr_t value = cs_subset_he_native_get(sub, he, NULL);
380 assert(value != INT_MIN);
381
382 if ((value == MUTT_YES) || (value == MUTT_NO))
383 return value;
384
385 struct ConfigDef *cdef = he_base->data;
386 enum QuadOption def = (value == MUTT_ASKYES) ? MUTT_YES : MUTT_NO;
387 return mw_yesorno(prompt, def, cdef);
388}
QuadOption
Possible values for a quad-option.
Definition: quad.h:36
@ MUTT_NO
User answered 'No', or assume 'No'.
Definition: quad.h:38
@ MUTT_ASKYES
Ask the user, defaulting to 'Yes'.
Definition: quad.h:41
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:39
@ DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function: