brainfuck_scene_set_input.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "../brainfuck_i.h"
  2. void set_input_text_input_callback(void* context) {
  3. BFApp* app = context;
  4. view_dispatcher_send_custom_event(app->view_dispatcher, brainfuckCustomEventTextInputDone);
  5. }
  6. char tmpBuffer[64] = {};
  7. void brainfuck_scene_set_input_on_enter(void* context) {
  8. BFApp* app = context;
  9. TextInput* text_input = app->text_input;
  10. text_input_set_header_text(text_input, "Edit input buffer");
  11. text_input_set_result_callback(
  12. text_input,
  13. set_input_text_input_callback,
  14. app,
  15. tmpBuffer,
  16. 64,
  17. true);
  18. view_dispatcher_switch_to_view(app->view_dispatcher, brainfuckViewTextInput);
  19. }
  20. bool brainfuck_scene_set_input_on_event(void* context, SceneManagerEvent event) {
  21. BFApp* app = context;
  22. UNUSED(app);
  23. bool consumed = false;
  24. if(event.type == SceneManagerEventTypeCustom) {
  25. if(event.event == brainfuckCustomEventTextInputDone) {
  26. memcpy(app->inputBuffer, tmpBuffer, 64);
  27. scene_manager_next_scene(app->scene_manager, brainfuckSceneDevEnv);
  28. }
  29. }
  30. return consumed;
  31. }
  32. void brainfuck_scene_set_input_on_exit(void* context) {
  33. UNUSED(context);
  34. }