MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / TclObjCommand_progress

Function TclObjCommand_progress

SRC/runtime/commands/utilities/progress.cpp:29–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27ProgressBar* progress_bar_ptr;
28
29int
30TclObjCommand_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

Callers

nothing calls this directly

Calls 5

set_todo_charMethod · 0.80
set_done_charMethod · 0.80
set_opening_charMethod · 0.80
set_closing_charMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected