| 2247 | } |
| 2248 | |
| 2249 | void CsvApplication::deleteMacroCB(Fl_Widget *, void *data) { |
| 2250 | addDelParamType *addDelParam = (addDelParamType *)data; |
| 2251 | std::string macroToBeDeleted; |
| 2252 | Fl_Browser *macroList = std::get<0>(*addDelParam); |
| 2253 | Fl_Text_Editor *sourceEditor = std::get<1>(*addDelParam); |
| 2254 | std::string confirmationStr; |
| 2255 | int deletedListIndex = 0; |
| 2256 | for(int i=1; i <= macroList->size(); ++i) { |
| 2257 | if( macroList->selected(i) ) { |
| 2258 | macroToBeDeleted = macroList->text(i); |
| 2259 | deletedListIndex = i; |
| 2260 | break; |
| 2261 | } |
| 2262 | } |
| 2263 | confirmationStr = "Really delete macro '" + macroToBeDeleted + "'?"; |
| 2264 | int choice = myFlChoice("Confirmation", confirmationStr, {"Yes", "No"}); |
| 2265 | if( choice == 0 ) { |
| 2266 | if( macros.entryExists(macroToBeDeleted.c_str()) ) { |
| 2267 | macros.deleteEntry(macroToBeDeleted.c_str()); |
| 2268 | } |
| 2269 | if( macroList->size() > 0 ) { |
| 2270 | updateMacroBrowserList(macroList, deletedListIndex); |
| 2271 | if( deletedListIndex < 1 || deletedListIndex > macroList->size() ) { |
| 2272 | deletedListIndex = macroList->size(); |
| 2273 | } |
| 2274 | if( macroList->size() > 0 ) { |
| 2275 | std::string newSelectedMacroName = macroList->text(deletedListIndex); |
| 2276 | selectMacroBrowserEntry(macroList, newSelectedMacroName); |
| 2277 | app.lastSelectedMacro = deletedListIndex; |
| 2278 | app.lastChoosenMacroName = newSelectedMacroName; |
| 2279 | Fl_Text_Buffer *buffer = sourceEditor->buffer(); |
| 2280 | if( buffer ) { |
| 2281 | std::string source = app.getPreference(¯os, newSelectedMacroName, ""); |
| 2282 | buffer->text( source.c_str() ); |
| 2283 | } |
| 2284 | } else { |
| 2285 | sourceEditor->hide(); |
| 2286 | } |
| 2287 | } else { |
| 2288 | sourceEditor->hide(); |
| 2289 | } |
| 2290 | } |
| 2291 | } |
| 2292 | |
| 2293 | |
| 2294 | void CsvApplication::updateMacroBrowserList(Fl_Browser *macroList, int selected) { |
nothing calls this directly
no test coverage detected