mag_text_input.h 2.4 KB

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