diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 4a3755f..63fa75c 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -4792,4 +4792,13 @@ target_link_libraries(step656_test PRIVATE tree_sitter_javascript tree_sitter_typescript tree_sitter_java tree_sitter_rust tree_sitter_go) +add_executable(step657_test tests/step657_test.cpp) +target_include_directories(step657_test PRIVATE src) +target_link_libraries(step657_test PRIVATE + nlohmann_json::nlohmann_json + unofficial::tree-sitter::tree-sitter + tree_sitter_python tree_sitter_cpp tree_sitter_elisp + tree_sitter_javascript tree_sitter_typescript + tree_sitter_java tree_sitter_rust tree_sitter_go) + # Step 12: Dear ImGui shell scaffolding created (main.cpp exists but not built due to dependencies) diff --git a/editor/src/EnergyContextStatusModel.h b/editor/src/EnergyContextStatusModel.h new file mode 100644 index 0000000..cb490dc --- /dev/null +++ b/editor/src/EnergyContextStatusModel.h @@ -0,0 +1,28 @@ +#pragma once +// Step 657: Energy context status bar model + +#include + +struct EnergyContextState { + std::string mode = "Normal"; + int watts = 0; + int batteryPercent = 100; +}; + +class EnergyContextStatusModel { +public: + static std::string statusLabel(const EnergyContextState& e) { + if (e.mode == "Conservation") { + return "Conservation " + std::to_string(e.batteryPercent) + "%"; + } + return e.mode + " " + std::to_string(e.watts) + "W"; + } + + static bool shouldFlashOrange(const EnergyContextState& e) { + return e.mode == "Conservation" || e.batteryPercent < 30; + } + + static std::string promptContextLine(const EnergyContextState& e) { + return "energyState: " + statusLabel(e); + } +}; diff --git a/editor/tests/step657_test.cpp b/editor/tests/step657_test.cpp new file mode 100644 index 0000000..0acdbc5 --- /dev/null +++ b/editor/tests/step657_test.cpp @@ -0,0 +1,24 @@ +// Step 657: Energy context status bar (12 tests) + +#include "EnergyContextStatusModel.h" +#include +static int p=0,f=0; +#define T(n) { std::cout<<" "<<#n<<"... "; } +#define P() { std::cout<<"PASS\n"; ++p; } +#define F(m) { std::cout<<"FAIL: "<