wifi_marauder_text_input.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. #include <gui/view.h>
  3. #include "wifi_marauder_validators.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /** Text input anonymous structure */
  8. typedef struct WIFI_TextInput WIFI_TextInput;
  9. typedef void (*WIFI_TextInputCallback)(void* context);
  10. typedef bool (*WIFI_TextInputValidatorCallback)(const char* text, FuriString* error, void* context);
  11. /** Allocate and initialize text input
  12. *
  13. * This text input is used to enter string
  14. *
  15. * @return WIFI_TextInput instance
  16. */
  17. WIFI_TextInput* wifi_text_input_alloc();
  18. /** Deinitialize and free text input
  19. *
  20. * @param text_input WIFI_TextInput instance
  21. */
  22. void wifi_text_input_free(WIFI_TextInput* text_input);
  23. /** Clean text input view Note: this function does not free memory
  24. *
  25. * @param text_input Text input instance
  26. */
  27. void wifi_text_input_reset(WIFI_TextInput* text_input);
  28. /** Get text input view
  29. *
  30. * @param text_input WIFI_TextInput instance
  31. *
  32. * @return View instance that can be used for embedding
  33. */
  34. View* wifi_text_input_get_view(WIFI_TextInput* text_input);
  35. /** Set text input result callback
  36. *
  37. * @param text_input WIFI_TextInput instance
  38. * @param callback callback fn
  39. * @param callback_context callback context
  40. * @param text_buffer pointer to YOUR text buffer, that we going
  41. * to modify
  42. * @param text_buffer_size YOUR text buffer size in bytes. Max string
  43. * length will be text_buffer_size-1.
  44. * @param clear_default_text clear text from text_buffer on first OK
  45. * event
  46. */
  47. void wifi_text_input_set_result_callback(
  48. WIFI_TextInput* text_input,
  49. WIFI_TextInputCallback callback,
  50. void* callback_context,
  51. char* text_buffer,
  52. size_t text_buffer_size,
  53. bool clear_default_text);
  54. void wifi_text_input_set_validator(
  55. WIFI_TextInput* text_input,
  56. WIFI_TextInputValidatorCallback callback,
  57. void* callback_context);
  58. void wifi_text_input_set_minimum_length(WIFI_TextInput* text_input, size_t minimum_length);
  59. WIFI_TextInputValidatorCallback wifi_text_input_get_validator_callback(WIFI_TextInput* text_input);
  60. void* wifi_text_input_get_validator_callback_context(WIFI_TextInput* text_input);
  61. /** Set text input header text
  62. *
  63. * @param text_input WIFI_TextInput instance
  64. * @param text text to be shown
  65. */
  66. void wifi_text_input_set_header_text(WIFI_TextInput* text_input, const char* text);
  67. #ifdef __cplusplus
  68. }
  69. #endif