NeoMutt  2024-11-14-138-ge5ca67
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
question.c File Reference

Ask the user a question. More...

#include "config.h"
#include <ctype.h>
#include <langinfo.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "gui/lib.h"
#include "color/lib.h"
#include "key/lib.h"
+ Include dependency graph for question.c:

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 -.
 
static enum QuadOption mw_yesorno (const char *prompt, enum QuadOption def, struct ConfigDef *cdef, GetChFlags flags)
 Ask the user a Yes/No question offering help -.
 
enum QuadOption query_yesorno (const char *prompt, enum QuadOption def)
 Ask the user a Yes/No question.
 
enum QuadOption query_yesorno_ignore_macro (const char *prompt, enum QuadOption def)
 Ask the user a Yes/No question ignoring the macro buffer.
 
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
  • Richard Russon
  • Gerrit RĂ¼sing

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 question.c.

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, GETCH_NO_FLAGS);
330}
static enum QuadOption mw_yesorno(const char *prompt, enum QuadOption def, struct ConfigDef *cdef, GetChFlags flags)
Ask the user a Yes/No question offering help -.
Definition: question.c:174
#define GETCH_NO_FLAGS
No flags are set.
Definition: lib.h:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ query_yesorno_ignore_macro()

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

Ask the user a Yes/No question ignoring the macro buffer.

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

Like query_yesorno but don't read from the macro events buffer.

Definition at line 340 of file question.c.

341{
342 return mw_yesorno(prompt, def, NULL, GETCH_IGNORE_MACRO);
343}
#define GETCH_IGNORE_MACRO
Don't use MacroEvents.
Definition: lib.h:52
+ 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 355 of file question.c.

357{
358 struct HashElem *he = cs_subset_create_inheritance(sub, name);
359 struct HashElem *he_base = cs_get_base(he);
360 ASSERT(DTYPE(he_base->type) == DT_BOOL);
361
362 intptr_t value = cs_subset_he_native_get(sub, he, NULL);
363 ASSERT(value != INT_MIN);
364
365 struct ConfigDef *cdef = he_base->data;
366 return mw_yesorno(prompt, def, cdef, GETCH_NO_FLAGS);
367}
struct HashElem * cs_get_base(struct HashElem *he)
Find the root Config Item.
Definition: set.c:160
#define ASSERT(COND)
Definition: signal2.h:58
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 379 of file question.c.

380{
381 struct HashElem *he = cs_subset_create_inheritance(sub, name);
382 struct HashElem *he_base = cs_get_base(he);
383 ASSERT(DTYPE(he_base->type) == DT_QUAD);
384
385 intptr_t value = cs_subset_he_native_get(sub, he, NULL);
386 ASSERT(value != INT_MIN);
387
388 if ((value == MUTT_YES) || (value == MUTT_NO))
389 return value;
390
391 struct ConfigDef *cdef = he_base->data;
392 enum QuadOption def = (value == MUTT_ASKYES) ? MUTT_YES : MUTT_NO;
393 return mw_yesorno(prompt, def, cdef, GETCH_NO_FLAGS);
394}
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: