NeoMutt  2024-03-23-142-g2b2e76
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 327 of file question.c.

328{
329 return mw_yesorno(prompt, def, NULL);
330}
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:174
+ 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 342 of file question.c.

344{
345 struct HashElem *he = cs_subset_create_inheritance(sub, name);
346 struct HashElem *he_base = cs_get_base(he);
347 assert(DTYPE(he_base->type) == DT_BOOL);
348
349 intptr_t value = cs_subset_he_native_get(sub, he, NULL);
350 assert(value != INT_MIN);
351
352 struct ConfigDef *cdef = he_base->data;
353 return mw_yesorno(prompt, def, cdef);
354}
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:50
@ 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 366 of file question.c.

367{
368 struct HashElem *he = cs_subset_create_inheritance(sub, name);
369 struct HashElem *he_base = cs_get_base(he);
370 assert(DTYPE(he_base->type) == DT_QUAD);
371
372 intptr_t value = cs_subset_he_native_get(sub, he, NULL);
373 assert(value != INT_MIN);
374
375 if ((value == MUTT_YES) || (value == MUTT_NO))
376 return value;
377
378 struct ConfigDef *cdef = he_base->data;
379 enum QuadOption def = (value == MUTT_ASKYES) ? MUTT_YES : MUTT_NO;
380 return mw_yesorno(prompt, def, cdef);
381}
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:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function: