MCPcopy Create free account
hub / github.com/VictorGordan/opengl-tutorials / ExecCommand

Function ExecCommand

ImGUI GLFW Tutorial/imgui/imgui_demo.cpp:6458–6498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6456 }
6457
6458 void ExecCommand(const char* command_line)
6459 {
6460 AddLog("# %s\n", command_line);
6461
6462 // Insert into history. First find match and delete it so it can be pushed to the back.
6463 // This isn't trying to be smart or optimal.
6464 HistoryPos = -1;
6465 for (int i = History.Size - 1; i >= 0; i--)
6466 if (Stricmp(History[i], command_line) == 0)
6467 {
6468 free(History[i]);
6469 History.erase(History.begin() + i);
6470 break;
6471 }
6472 History.push_back(Strdup(command_line));
6473
6474 // Process command
6475 if (Stricmp(command_line, "CLEAR") == 0)
6476 {
6477 ClearLog();
6478 }
6479 else if (Stricmp(command_line, "HELP") == 0)
6480 {
6481 AddLog("Commands:");
6482 for (int i = 0; i < Commands.Size; i++)
6483 AddLog("- %s", Commands[i]);
6484 }
6485 else if (Stricmp(command_line, "HISTORY") == 0)
6486 {
6487 int first = History.Size - 10;
6488 for (int i = first > 0 ? first : 0; i < History.Size; i++)
6489 AddLog("%3d: %s\n", i, History[i]);
6490 }
6491 else
6492 {
6493 AddLog("Unknown command: '%s'\n", command_line);
6494 }
6495
6496 // On command input, we scroll to bottom even if AutoScroll==false
6497 ScrollToBottom = true;
6498 }
6499
6500 // In C++11 you'd be better off using lambdas for this sort of forwarding callbacks
6501 static int TextEditCallbackStub(ImGuiInputTextCallbackData* data)

Callers 1

DrawFunction · 0.85

Calls 3

eraseMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected