text_input.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. #include "text_input.h"
  2. #include "cligui_main_i.h"
  3. void text_input_result_callback(void* ctx) {
  4. CliguiApp* app = ctx;
  5. char* data = app->text_input_store;
  6. size_t len = strlen(data);
  7. for(size_t i = 0; i < len; i++) {
  8. if(data[i] >= 0x41 && data[i] <= 0x5A) {
  9. // Char is uppercase
  10. data[i] += 0x20;
  11. }
  12. }
  13. furi_stream_buffer_send(app->data->streams.app_tx, data, len, FuriWaitForever);
  14. furi_stream_buffer_send(app->data->streams.app_tx, "\r\n", 2, FuriWaitForever);
  15. data[0] = 0;
  16. view_dispatcher_switch_to_view(app->view_dispatcher, ViewConsoleOutput);
  17. app->data->state = ViewConsoleOutput;
  18. }
  19. void text_input_input_handler(CliguiApp* app, InputEvent* event) {
  20. if(event->type == InputTypeShort && event->key == InputKeyBack) {
  21. // view_dispatcher_switch_to_view(app->view_dispatcher, ViewConsoleOutput);
  22. // app->data->state = ViewConsoleOutput;
  23. size_t len = strlen(app->text_input_store);
  24. app->text_input_store[len] = ' ';
  25. app->text_input_store[len + 1] = 0;
  26. }
  27. if(event->type == InputTypeLong &&
  28. (event->key == InputKeyLeft || event->key == InputKeyRight)) {
  29. view_dispatcher_switch_to_view(app->view_dispatcher, ViewConsoleOutput);
  30. app->data->state = ViewConsoleOutput;
  31. }
  32. }