| 27 | ProgressBar* progress_bar_ptr; |
| 28 | |
| 29 | int |
| 30 | TclObjCommand_progress(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj* const*objv) |
| 31 | { |
| 32 | if (strcmp(Tcl_GetString(objv[1]), "update") == 0) { |
| 33 | if (clientData == nullptr || *(ProgressBar**)clientData == nullptr) { |
| 34 | return TCL_ERROR; |
| 35 | } |
| 36 | |
| 37 | std::string message = ""; |
| 38 | if (argc > 2) |
| 39 | message = Tcl_GetString(objv[2]); |
| 40 | |
| 41 | (*(ProgressBar**)clientData)->update(message); |
| 42 | return TCL_OK; |
| 43 | |
| 44 | } else if (strcmp(Tcl_GetString(objv[1]), "create") == 0) { |
| 45 | int steps = 100; |
| 46 | |
| 47 | if (argc > 2 && Tcl_GetIntFromObj(interp, objv[2], &steps) == TCL_ERROR) { |
| 48 | // Failed to read number of steps |
| 49 | } |
| 50 | |
| 51 | if (*(ProgressBar**)clientData != nullptr) { |
| 52 | delete *(ProgressBar**)clientData; |
| 53 | *(ProgressBar**)clientData = nullptr; |
| 54 | } |
| 55 | |
| 56 | ProgressBar *bar = new ProgressBar(steps); |
| 57 | bar->set_todo_char(L" "); // ━━━━━━━━━━╸━━━━━━━━━━━━━━━╸━━━━━━━━ |
| 58 | bar->set_done_char(L"█"); |
| 59 | bar->set_opening_char(L"|"); |
| 60 | bar->set_closing_char(L"|"); |
| 61 | |
| 62 | *(ProgressBar**)clientData = bar; |
| 63 | |
| 64 | return TCL_OK; |
| 65 | } |
| 66 | return TCL_ERROR; |
| 67 | } |
| 68 |
nothing calls this directly
no test coverage detected