Plan cursor visibility in app core
This commit is contained in:
@@ -178,6 +178,10 @@ struct PlanKeyboardVisibilityArgs {
|
||||
bool visible = false;
|
||||
};
|
||||
|
||||
struct PlanCursorVisibilityArgs {
|
||||
bool visible = false;
|
||||
};
|
||||
|
||||
struct SimulateAppSessionArgs {
|
||||
bool has_canvas = true;
|
||||
bool new_document = false;
|
||||
@@ -547,6 +551,18 @@ const char* virtual_keyboard_action_name(pp::app::VirtualKeyboardAction action)
|
||||
return "hide-keyboard";
|
||||
}
|
||||
|
||||
const char* cursor_visibility_action_name(pp::app::CursorVisibilityAction action) noexcept
|
||||
{
|
||||
switch (action) {
|
||||
case pp::app::CursorVisibilityAction::show_cursor:
|
||||
return "show-cursor";
|
||||
case pp::app::CursorVisibilityAction::hide_cursor:
|
||||
return "hide-cursor";
|
||||
}
|
||||
|
||||
return "hide-cursor";
|
||||
}
|
||||
|
||||
pp::foundation::Result<float> parse_float_arg(std::string_view text)
|
||||
{
|
||||
float value = 0.0F;
|
||||
@@ -591,6 +607,7 @@ void print_help()
|
||||
<< " plan-picked-path [--path FILE]\n"
|
||||
<< " plan-display-file [--path FILE]\n"
|
||||
<< " plan-keyboard-visibility [--visible]\n"
|
||||
<< " plan-cursor-visibility [--visible]\n"
|
||||
<< " load-project --path FILE\n"
|
||||
<< " parse-layout --path FILE\n"
|
||||
<< " record-render [--width N] [--height N] [--exercise-clear]\n"
|
||||
@@ -2069,6 +2086,40 @@ int plan_keyboard_visibility(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_cursor_visibility_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
PlanCursorVisibilityArgs& args)
|
||||
{
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
const std::string_view key(argv[i]);
|
||||
if (key == "--visible") {
|
||||
args.visible = true;
|
||||
} else {
|
||||
return pp::foundation::Status::invalid_argument("unknown option");
|
||||
}
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
int plan_cursor_visibility(int argc, char** argv)
|
||||
{
|
||||
PlanCursorVisibilityArgs args;
|
||||
const auto status = parse_plan_cursor_visibility_args(argc, argv, args);
|
||||
if (!status.ok()) {
|
||||
print_error("plan-cursor-visibility", status.message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto decision = pp::app::plan_cursor_visibility(args.visible);
|
||||
std::cout << "{\"ok\":true,\"command\":\"plan-cursor-visibility\""
|
||||
<< ",\"state\":{\"visible\":" << json_bool(args.visible)
|
||||
<< "},\"decision\":\"" << cursor_visibility_action_name(decision)
|
||||
<< "\"}\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_export_target_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
@@ -4252,6 +4303,10 @@ int main(int argc, char** argv)
|
||||
return plan_keyboard_visibility(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "plan-cursor-visibility") {
|
||||
return plan_cursor_visibility(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "load-project") {
|
||||
return load_project(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user