Просмотр исходного кода

fix: build fails on the latest Momentum Dev and Unleashed Dev (#242) (#243)

Alexander Kopachov 1 год назад
Родитель
Сommit
781cb64036

+ 7 - 1
cli/cli_helpers.h

@@ -2,6 +2,12 @@
 
 #include <stdio.h>
 
+#if __has_include(<cli/cli_ansi.h>)
+#include <cli/cli_ansi.h>
+#else
+#include "../lib/polyfills/cli_ansi.h"
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -62,4 +68,4 @@ extern "C" {
 
 #ifdef __cplusplus
 }
-#endif
+#endif

+ 4 - 4
cli/cli_shared_methods.c

@@ -34,13 +34,13 @@ void totp_cli_force_close_app(FuriMessageQueue* event_queue) {
 bool totp_cli_read_line(Cli* cli, FuriString* out_str, bool mask_user_input) {
     uint8_t c;
     while(cli_read(cli, &c, 1) == 1) {
-        if(c == CliSymbolAsciiEsc) {
+        if(c == CliKeyEsc) {
             // Some keys generating escape-sequences
             // We need to ignore them as we care about alpha-numerics only
             uint8_t c2;
             cli_read_timeout(cli, &c2, 1, 0);
             cli_read_timeout(cli, &c2, 1, 0);
-        } else if(c == CliSymbolAsciiETX) {
+        } else if(c == CliKeyETX) {
             cli_nl(cli);
             return false;
         } else if(
@@ -53,13 +53,13 @@ bool totp_cli_read_line(Cli* cli, FuriString* out_str, bool mask_user_input) {
             }
             fflush(stdout);
             furi_string_push_back(out_str, c);
-        } else if(c == CliSymbolAsciiBackspace || c == CliSymbolAsciiDel) {
+        } else if(c == CliKeyBackspace || c == CliKeyDEL) {
             size_t out_str_size = furi_string_size(out_str);
             if(out_str_size > 0) {
                 TOTP_CLI_DELETE_LAST_CHAR();
                 furi_string_left(out_str, out_str_size - 1);
             }
-        } else if(c == CliSymbolAsciiCR) {
+        } else if(c == CliKeyCR) {
             cli_nl(cli);
             break;
         }

+ 4 - 4
cli/plugins/delete/delete.c

@@ -56,10 +56,10 @@ static void handle(PluginState* plugin_state, FuriString* args, Cli* cli) {
         char user_pick;
         do {
             user_pick = tolower(cli_getc(cli));
-        } while(user_pick != 'y' && user_pick != 'n' && user_pick != CliSymbolAsciiCR &&
-                user_pick != CliSymbolAsciiETX && user_pick != CliSymbolAsciiEsc);
+        } while(user_pick != 'y' && user_pick != 'n' && user_pick != CliKeyCR &&
+                user_pick != CliKeyETX && user_pick != CliKeyEsc);
 
-        confirmed = user_pick == 'y' || user_pick == CliSymbolAsciiCR;
+        confirmed = user_pick == 'y' || user_pick == CliKeyCR;
     }
 
     if(confirmed) {
@@ -92,4 +92,4 @@ static const FlipperAppPluginDescriptor plugin_descriptor = {
 
 const FlipperAppPluginDescriptor* totp_cli_delete_plugin_ep() {
     return &plugin_descriptor;
-}
+}

+ 4 - 4
cli/plugins/pin/pin.c

@@ -42,7 +42,7 @@ static bool totp_cli_read_pin(Cli* cli, uint8_t* pin, uint8_t* pin_length) {
     uint8_t c;
     *pin_length = 0;
     while(cli_read(cli, &c, 1) == 1) {
-        if(c == CliSymbolAsciiEsc) {
+        if(c == CliKeyEsc) {
             uint8_t c2;
             uint8_t c3;
             if(cli_read_timeout(cli, &c2, 1, 0) == 1 && cli_read_timeout(cli, &c3, 1, 0) == 1 &&
@@ -55,17 +55,17 @@ static bool totp_cli_read_pin(Cli* cli, uint8_t* pin, uint8_t* pin_length) {
                     fflush(stdout);
                 }
             }
-        } else if(c == CliSymbolAsciiETX) {
+        } else if(c == CliKeyETX) {
             TOTP_CLI_DELETE_CURRENT_LINE();
             TOTP_CLI_PRINTF_INFO("Cancelled by user\r\n");
             return false;
-        } else if(c == CliSymbolAsciiBackspace || c == CliSymbolAsciiDel) {
+        } else if(c == CliKeyBackspace || c == CliKeyDEL) {
             if(*pin_length > 0) {
                 *pin_length = *pin_length - 1;
                 pin[*pin_length] = 0;
                 TOTP_CLI_DELETE_LAST_CHAR();
             }
-        } else if(c == CliSymbolAsciiCR) {
+        } else if(c == CliKeyCR) {
             cli_nl(cli);
             break;
         }

+ 28 - 0
lib/polyfills/cli_ansi.h

@@ -0,0 +1,28 @@
+// Just a temporary polyfill until this cli/cli_ansi.h spread across all the FW and brances
+#pragma once
+
+typedef enum {
+    CliKeyUnrecognized = 0,
+
+    CliKeySOH = 0x01,
+    CliKeyETX = 0x03,
+    CliKeyEOT = 0x04,
+    CliKeyBell = 0x07,
+    CliKeyBackspace = 0x08,
+    CliKeyTab = 0x09,
+    CliKeyLF = 0x0A,
+    CliKeyCR = 0x0D,
+    CliKeyETB = 0x17,
+    CliKeyEsc = 0x1B,
+    CliKeyUS = 0x1F,
+    CliKeySpace = 0x20,
+    CliKeyDEL = 0x7F,
+
+    CliKeySpecial = 0x80,
+    CliKeyLeft,
+    CliKeyRight,
+    CliKeyUp,
+    CliKeyDown,
+    CliKeyHome,
+    CliKeyEnd,
+} CliKey;

+ 0 - 1
ui/scenes/add_new_token/totp_input_text.c

@@ -36,7 +36,6 @@ void totp_input_text(Gui* gui, const char* header_text, InputTextResult* result)
         INPUT_BUFFER_SIZE,
         true);
 
-    view_dispatcher_enable_queue(view_dispatcher);
     view_dispatcher_add_view(view_dispatcher, 0, text_input_get_view(text_input));
 
     view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen);