| 145 | } |
| 146 | |
| 147 | void cmCursesMainForm::RePost() |
| 148 | { |
| 149 | // Create the fields to be passed to the form. |
| 150 | if (this->Form) { |
| 151 | unpost_form(this->Form); |
| 152 | free_form(this->Form); |
| 153 | this->Form = nullptr; |
| 154 | } |
| 155 | this->Fields.clear(); |
| 156 | if (this->AdvancedMode) { |
| 157 | this->NumberOfVisibleEntries = this->Entries.size(); |
| 158 | } else { |
| 159 | // If normal mode, count only non-advanced entries |
| 160 | this->NumberOfVisibleEntries = 0; |
| 161 | for (cmCursesCacheEntryComposite& entry : this->Entries) { |
| 162 | cmValue existingValue = |
| 163 | this->CMakeInstance->GetState()->GetCacheEntryValue(entry.GetValue()); |
| 164 | bool advanced = |
| 165 | this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool( |
| 166 | entry.GetValue(), "ADVANCED"); |
| 167 | if (!existingValue || (!this->AdvancedMode && advanced)) { |
| 168 | continue; |
| 169 | } |
| 170 | this->NumberOfVisibleEntries++; |
| 171 | } |
| 172 | } |
| 173 | // there is always one even if it is the dummy one |
| 174 | if (this->NumberOfVisibleEntries == 0) { |
| 175 | this->NumberOfVisibleEntries = 1; |
| 176 | } |
| 177 | // Assign the fields: 3 for each entry: label, new entry marker |
| 178 | // ('*' or ' ') and entry widget |
| 179 | this->Fields.reserve(3 * this->NumberOfVisibleEntries + 1); |
| 180 | |
| 181 | // Assign fields |
| 182 | for (cmCursesCacheEntryComposite& entry : this->Entries) { |
| 183 | cmValue existingValue = |
| 184 | this->CMakeInstance->GetState()->GetCacheEntryValue(entry.GetValue()); |
| 185 | bool advanced = |
| 186 | this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool( |
| 187 | entry.GetValue(), "ADVANCED"); |
| 188 | if (!existingValue || (!this->AdvancedMode && advanced)) { |
| 189 | continue; |
| 190 | } |
| 191 | this->Fields.push_back(entry.Label->Field); |
| 192 | this->Fields.push_back(entry.IsNewLabel->Field); |
| 193 | this->Fields.push_back(entry.Entry->Field); |
| 194 | } |
| 195 | // if no cache entries there should still be one dummy field |
| 196 | this->IsEmpty = this->Fields.empty(); |
| 197 | if (this->IsEmpty) { |
| 198 | this->Fields.push_back(this->EmptyCacheEntry->Label->Field); |
| 199 | this->Fields.push_back(this->EmptyCacheEntry->IsNewLabel->Field); |
| 200 | this->Fields.push_back(this->EmptyCacheEntry->Entry->Field); |
| 201 | this->NumberOfVisibleEntries = 1; |
| 202 | } |
| 203 | // Has to be null terminated. |
| 204 | this->Fields.push_back(nullptr); |
no test coverage detected