Plan keyboard visibility in app core
This commit is contained in:
@@ -174,6 +174,10 @@ struct PlanDisplayFileArgs {
|
||||
std::string path;
|
||||
};
|
||||
|
||||
struct PlanKeyboardVisibilityArgs {
|
||||
bool visible = false;
|
||||
};
|
||||
|
||||
struct SimulateAppSessionArgs {
|
||||
bool has_canvas = true;
|
||||
bool new_document = false;
|
||||
@@ -531,6 +535,18 @@ const char* display_file_action_name(pp::app::DisplayFileAction action) noexcept
|
||||
return "ignore-empty-path";
|
||||
}
|
||||
|
||||
const char* virtual_keyboard_action_name(pp::app::VirtualKeyboardAction action) noexcept
|
||||
{
|
||||
switch (action) {
|
||||
case pp::app::VirtualKeyboardAction::show_keyboard:
|
||||
return "show-keyboard";
|
||||
case pp::app::VirtualKeyboardAction::hide_keyboard:
|
||||
return "hide-keyboard";
|
||||
}
|
||||
|
||||
return "hide-keyboard";
|
||||
}
|
||||
|
||||
pp::foundation::Result<float> parse_float_arg(std::string_view text)
|
||||
{
|
||||
float value = 0.0F;
|
||||
@@ -574,6 +590,7 @@ void print_help()
|
||||
<< " plan-share-file [--path FILE]\n"
|
||||
<< " plan-picked-path [--path FILE]\n"
|
||||
<< " plan-display-file [--path FILE]\n"
|
||||
<< " plan-keyboard-visibility [--visible]\n"
|
||||
<< " load-project --path FILE\n"
|
||||
<< " parse-layout --path FILE\n"
|
||||
<< " record-render [--width N] [--height N] [--exercise-clear]\n"
|
||||
@@ -2018,6 +2035,40 @@ int plan_display_file(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_keyboard_visibility_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
PlanKeyboardVisibilityArgs& 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_keyboard_visibility(int argc, char** argv)
|
||||
{
|
||||
PlanKeyboardVisibilityArgs args;
|
||||
const auto status = parse_plan_keyboard_visibility_args(argc, argv, args);
|
||||
if (!status.ok()) {
|
||||
print_error("plan-keyboard-visibility", status.message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto decision = pp::app::plan_virtual_keyboard(args.visible);
|
||||
std::cout << "{\"ok\":true,\"command\":\"plan-keyboard-visibility\""
|
||||
<< ",\"state\":{\"visible\":" << json_bool(args.visible)
|
||||
<< "},\"decision\":\"" << virtual_keyboard_action_name(decision)
|
||||
<< "\"}\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp::foundation::Status parse_plan_export_target_args(
|
||||
int argc,
|
||||
char** argv,
|
||||
@@ -4197,6 +4248,10 @@ int main(int argc, char** argv)
|
||||
return plan_display_file(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "plan-keyboard-visibility") {
|
||||
return plan_keyboard_visibility(argc, argv);
|
||||
}
|
||||
|
||||
if (command == "load-project") {
|
||||
return load_project(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user