diff options
author | 2013-09-10 22:42:38 +0200 | |
---|---|---|
committer | 2013-09-10 22:42:38 +0200 | |
commit | 8dc2052a4bbdcfbb5c54c1374e27b95d107ab644 (patch) | |
tree | dab51b65a0c135380b88b89a6f4643788f2a6425 | |
parent | ufed.pl: Added a constant for easier setting on how to start the curses inter... (diff) | |
download | ufed-8dc2052a4bbdcfbb5c54c1374e27b95d107ab644.tar.gz ufed-8dc2052a4bbdcfbb5c54c1374e27b95d107ab644.tar.bz2 ufed-8dc2052a4bbdcfbb5c54c1374e27b95d107ab644.zip |
types: Changed enums to explicit numbers and added values to sKey to hold a seaprate name and up to three explanations.
-rw-r--r-- | ufed-curses-types.c | 7 | ||||
-rw-r--r-- | ufed-curses-types.h | 48 |
2 files changed, 38 insertions, 17 deletions
diff --git a/ufed-curses-types.c b/ufed-curses-types.c index 7e72967..4ca2516 100644 --- a/ufed-curses-types.c +++ b/ufed-curses-types.c @@ -4,11 +4,18 @@ * Created on: 28.01.2013 * Author: Sven Eden */ + + #include "ufed-curses-types.h" #include "ufed-curses.h" #include <stdlib.h> #include <string.h> +/* internal zero index sentry, replaces + * NULL argument for idx in MAKE_KEY + */ +int IDX_NULL_SENTRY = 0; + /* external members */ extern eMask e_mask; extern eScope e_scope; diff --git a/ufed-curses-types.h b/ufed-curses-types.h index 3f04650..450d6a3 100644 --- a/ufed-curses-types.h +++ b/ufed-curses-types.h @@ -42,17 +42,17 @@ * @brief determine whether to display the original/alternative description **/ typedef enum eDesc_ { - eDesc_ori, - eDesc_alt + eDesc_ori = 0, + eDesc_alt = 1 } eDesc; /** @enum eMask_ * @brief determine which flags are shown concerning masked status **/ typedef enum eMask_ { - eMask_unmasked, - eMask_both, - eMask_masked + eMask_unmasked = 0, + eMask_masked = 1, + eMask_both = 2 } eMask; @@ -60,8 +60,8 @@ typedef enum eMask_ { * @brief determine whether package lists are shown left or right of the description **/ typedef enum eOrder_ { - eOrder_left, - eOrder_right + eOrder_left = 0, + eOrder_right = 1 } eOrder; @@ -69,9 +69,9 @@ typedef enum eOrder_ { * @brief determine whether global, local or all flags are listed **/ typedef enum eScope_ { - eScope_all, - eScope_global, - eScope_local + eScope_all = 0, + eScope_global = 1, + eScope_local = 2 } eScope; @@ -79,9 +79,9 @@ typedef enum eScope_ { * @brief determine whether installed, not installed or all packages are listed **/ typedef enum eState_ { - eState_all, - eState_installed, - eState_notinstalled + eState_all = 0, + eState_installed = 1, + eState_notinstalled = 2 } eState; @@ -154,12 +154,26 @@ typedef struct sListStats_ { * @brief describe one main control key **/ typedef struct sKey_ { - int key; //!< curses key or -1 if no key shall be used - const char *descr; //!< Help text to display - size_t length; //!< length of the description - int row; //!< On which row this key is to be displayed, 0 or 1 + int key; //!< curses key or -1 if no key shall be used + const char *name; //!< The name of the key, like "Esc" or "F10" + size_t name_len; //!< length of the name + const char *desc[3]; //!< Help text to display, index is the relevant enum + size_t desc_len; //!< length of the (longest) description + int *idx; //!< index of descr to currently show (points to the relevant enum) + int row; //!< On which row this key is to be displayed, 0 or 1 } sKey; +/// Helper macro to initialize sKey entries +extern int IDX_NULL_SENTRY; +#define MAKE_KEY(key, name, d1, d2, d3, idx, row) { \ + key, \ + name, \ + sizeof(name), \ + { d1, d2, d3 }, \ + max(max(sizeof(d1), sizeof(d2)), sizeof(d3)), \ + NULL != (idx) ? idx : &IDX_NULL_SENTRY, \ + row \ +} /** @struct sWindow_ * @brief describe one curses window dimensions |