1 |
commit: 34e1d52dfebe0758f3433ee5c7c2c625ca9b5411 |
2 |
Author: Sven Eden <sven.eden <AT> gmx <DOT> de> |
3 |
AuthorDate: Thu Jan 31 18:17:18 2013 +0000 |
4 |
Commit: Sven Eden <sven.eden <AT> gmx <DOT> de> |
5 |
CommitDate: Thu Jan 31 18:17:18 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=34e1d52d |
7 |
|
8 |
Renamed ufed-curses-debug.h, ufed-types.c and ufed-types.h to ufed-curses-debug.h, ufed-curses-types.c and ufed-curses-types.h to match the naming of the other files |
9 |
|
10 |
--- |
11 |
ufed-debug.h => ufed-curses-debug.h | 0 |
12 |
ufed-types.c => ufed-curses-types.c | 69 ++++++++++++++++++++++++++++------- |
13 |
ufed-types.h => ufed-curses-types.h | 28 ++++++++++++-- |
14 |
3 files changed, 79 insertions(+), 18 deletions(-) |
15 |
|
16 |
diff --git a/ufed-debug.h b/ufed-curses-debug.h |
17 |
similarity index 100% |
18 |
rename from ufed-debug.h |
19 |
rename to ufed-curses-debug.h |
20 |
|
21 |
diff --git a/ufed-types.c b/ufed-curses-types.c |
22 |
similarity index 85% |
23 |
rename from ufed-types.c |
24 |
rename to ufed-curses-types.c |
25 |
index 694ea29..7b208fa 100644 |
26 |
--- a/ufed-types.c |
27 |
+++ b/ufed-curses-types.c |
28 |
@@ -4,7 +4,7 @@ |
29 |
* Created on: 28.01.2013 |
30 |
* Author: Sven Eden |
31 |
*/ |
32 |
-#include "ufed-types.h" |
33 |
+#include "ufed-curses-types.h" |
34 |
#include "ufed-curses.h" |
35 |
#include <stdlib.h> |
36 |
#include <string.h> |
37 |
@@ -61,9 +61,9 @@ sFlag* addFlag (sFlag** root, const char* name, int line, int ndesc, const char |
38 |
ERROR_EXIT(-1, "Unable to allocate %lu bytes for %d sDesc_ structs\n", |
39 |
sizeof(sDesc) * ndesc, ndesc) |
40 |
|
41 |
- newFlag->forced = false; |
42 |
+ newFlag->globalForced = false; |
43 |
+ newFlag->globalMasked = false; |
44 |
newFlag->listline = line; |
45 |
- newFlag->masked = false; |
46 |
newFlag->name = strdup(name); |
47 |
newFlag->ndesc = ndesc; |
48 |
newFlag->next = NULL; |
49 |
@@ -128,9 +128,9 @@ size_t addFlagDesc (sFlag* flag, const char* pkg, const char* desc, const char s |
50 |
|
51 |
// Set flag mask and force status if this is a global and masked/forced description |
52 |
if (flag->desc[idx].isGlobal && ('+' == flag->desc[idx].stateMasked)) |
53 |
- flag->masked = true; |
54 |
+ flag->globalMasked = true; |
55 |
if (flag->desc[idx].isGlobal && ('+' == flag->desc[idx].stateForced)) |
56 |
- flag->forced = true; |
57 |
+ flag->globalForced = true; |
58 |
|
59 |
// Determine width: |
60 |
result += (flag->desc[idx].pkg ? strlen(flag->desc[idx].pkg) : 0) |
61 |
@@ -155,15 +155,7 @@ void addLineStats (const sFlag* flag, sListStats* stats) |
62 |
{ |
63 |
if (flag && stats) { |
64 |
for (int i = 0; i < flag->ndesc; ++i) { |
65 |
- // Masked is true if the flag is globally masked/forced |
66 |
- // and the description is not explicitly unmasked/unforced, |
67 |
- // or if the description is explicitly masked/forced. |
68 |
- if ( ('+' == flag->desc[i].stateMasked) |
69 |
- || ('+' == flag->desc[i].stateForced) |
70 |
- || ( (' ' == flag->desc[i].stateMasked) |
71 |
- && flag->masked ) |
72 |
- || ( (' ' == flag->desc[i].stateForced) |
73 |
- && flag->forced ) ) { |
74 |
+ if ( isDescMasked(flag, i) ) { |
75 |
if (flag->desc[i].isInstalled) |
76 |
++stats->lineCountMaskedInstalled; |
77 |
else |
78 |
@@ -252,6 +244,27 @@ int getFlagHeight (const sFlag* flag) |
79 |
} |
80 |
|
81 |
|
82 |
+/** @brief return true if a specific description line is force enabled |
83 |
+ * If @a flag is NULL, the result will be false. |
84 |
+ * @param[in] flag pointer to the flag to check. |
85 |
+ * @param[in] idx index of the description line to check. |
86 |
+ * @return true if the specific flag (global or local) is forced |
87 |
+ */ |
88 |
+bool isDescForced(const sFlag* flag, int idx) |
89 |
+{ |
90 |
+ bool result = false; |
91 |
+ |
92 |
+ if (flag && (idx < flag->ndesc)) { |
93 |
+ if ( ('+' == flag->desc[idx].stateForced) |
94 |
+ || ( (' ' == flag->desc[idx].stateForced) |
95 |
+ && flag->globalForced ) ) |
96 |
+ result = true; |
97 |
+ } |
98 |
+ |
99 |
+ return result; |
100 |
+} |
101 |
+ |
102 |
+ |
103 |
/** @brief return true if the flag description @a idx is ok to display. |
104 |
* If @a flag is NULL, the result will be false. |
105 |
* @param[in] flag pointer to the flag to check. |
106 |
@@ -278,6 +291,34 @@ bool isDescLegal (const sFlag* flag, int idx) |
107 |
return result; |
108 |
} |
109 |
|
110 |
+ |
111 |
+/** @brief return true if a specific description line is masked |
112 |
+ * If @a flag is NULL, the result will be false. |
113 |
+ * @param[in] flag pointer to the flag to check. |
114 |
+ * @param[in] idx index of the description line to check. |
115 |
+ * @return true if the specific flag (global or local) is masked |
116 |
+ */ |
117 |
+bool isDescMasked(const sFlag* flag, int idx) |
118 |
+{ |
119 |
+ bool result = false; |
120 |
+ |
121 |
+ // Note: Masked is true if the flag is globally masked/forced |
122 |
+ // and the description is not explicitly unmasked/unforced, |
123 |
+ // or if the description is explicitly masked/forced. |
124 |
+ if (flag && (idx < flag->ndesc)) { |
125 |
+ if ( ('+' == flag->desc[idx].stateMasked) |
126 |
+ || ('+' == flag->desc[idx].stateForced) |
127 |
+ || ( (' ' == flag->desc[idx].stateMasked) |
128 |
+ && flag->globalMasked ) |
129 |
+ || ( (' ' == flag->desc[idx].stateForced) |
130 |
+ && flag->globalForced ) ) |
131 |
+ result = true; |
132 |
+ } |
133 |
+ |
134 |
+ return result; |
135 |
+} |
136 |
+ |
137 |
+ |
138 |
/** @brief return true if this flag has at least one line to display. |
139 |
* This method checks the flag and its description line(s) |
140 |
* settings against the globally active filters. |
141 |
|
142 |
diff --git a/ufed-types.h b/ufed-curses-types.h |
143 |
similarity index 88% |
144 |
rename from ufed-types.h |
145 |
rename to ufed-curses-types.h |
146 |
index 9953b6a..cb02e85 100644 |
147 |
--- a/ufed-types.h |
148 |
+++ b/ufed-curses-types.h |
149 |
@@ -9,11 +9,29 @@ |
150 |
#define UFED_TYPES_H_INCLUDED 1 |
151 |
|
152 |
#ifdef HAVE_CONFIG_H |
153 |
-#include "config.h" |
154 |
+# include "config.h" |
155 |
#endif |
156 |
|
157 |
#include <curses.h> |
158 |
-#include "ufed-debug.h" |
159 |
+#include "ufed-curses-debug.h" |
160 |
+ |
161 |
+#ifdef HAVE_STDINT_H |
162 |
+# include <stdint.h> |
163 |
+// TODO : else branch |
164 |
+#endif |
165 |
+ |
166 |
+#ifdef HAVE_SYS_TYPES_H |
167 |
+# include <sys/types.h> |
168 |
+#endif |
169 |
+ |
170 |
+#ifndef bool |
171 |
+# ifdef HAVE__BOOL |
172 |
+# define bool _Bool |
173 |
+# else |
174 |
+# define bool int |
175 |
+# endif |
176 |
+#endif |
177 |
+ |
178 |
|
179 |
/* ============= |
180 |
* === enums === |
181 |
@@ -94,9 +112,9 @@ typedef struct sDesc_ { |
182 |
typedef struct sFlag_ { |
183 |
int currline; //!< The current line on the screen this flag starts |
184 |
sDesc* desc; //!< variable array of sDesc structs |
185 |
- bool forced; //!< true if the first global description is force enabled. |
186 |
+ bool globalForced; //!< true if the first global description is force enabled. |
187 |
+ bool globalMasked; //!< true if the first global description is mask enabled. |
188 |
int listline; //!< The fixed line within the full list this flag starts |
189 |
- bool masked; //!< true if the first global description is mask enabled. |
190 |
char* name; //!< Name of the flag or NULL for help lines |
191 |
int ndesc; //!< number of description lines |
192 |
struct |
193 |
@@ -149,7 +167,9 @@ size_t addFlagDesc (sFlag* flag, const char* pkg, const char* desc, const char |
194 |
void addLineStats (const sFlag* flag, sListStats* stats); |
195 |
void destroyFlag (sFlag** root, sFlag** flag); |
196 |
int getFlagHeight(const sFlag* flag); |
197 |
+bool isDescForced (const sFlag* flag, int idx); |
198 |
bool isDescLegal (const sFlag* flag, int idx); |
199 |
+bool isDescMasked (const sFlag* flag, int idx); |
200 |
bool isFlagLegal (const sFlag* flag); |
201 |
|
202 |
#endif /* UFED_TYPES_H_INCLUDED */ |