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

chore: minor refactoring changes

alex.kopachov 9 месяцев назад
Родитель
Сommit
6a2813e366

+ 2 - 0
cli/cli_helpers.h

@@ -33,6 +33,8 @@ extern "C" {
 #define TOTP_CLI_PRINTF_INFO(format, ...) \
 #define TOTP_CLI_PRINTF_INFO(format, ...) \
     TOTP_CLI_PRINTF_COLORFUL(TOTP_CLI_COLOR_INFO, format, ##__VA_ARGS__)
     TOTP_CLI_PRINTF_COLORFUL(TOTP_CLI_COLOR_INFO, format, ##__VA_ARGS__)
 
 
+#define TOTP_CLI_NL() TOTP_CLI_PRINTF("\r\n")
+
 #define TOTP_CLI_LOCK_UI(plugin_state)                                  \
 #define TOTP_CLI_LOCK_UI(plugin_state)                                  \
     Scene __previous_scene = plugin_state->current_scene;               \
     Scene __previous_scene = plugin_state->current_scene;               \
     totp_scene_director_activate_scene(plugin_state, TotpSceneStandby); \
     totp_scene_director_activate_scene(plugin_state, TotpSceneStandby); \

+ 2 - 2
cli/cli_shared_methods.c

@@ -42,7 +42,7 @@ bool totp_cli_read_line(PipeSide* pipe, FuriString* out_str, bool mask_user_inpu
             pipe_receive(pipe, &c2, 1);
             pipe_receive(pipe, &c2, 1);
             pipe_receive(pipe, &c2, 1);
             pipe_receive(pipe, &c2, 1);
         } else if(c == CliKeyETX) {
         } else if(c == CliKeyETX) {
-            printf("\r\n");
+            TOTP_CLI_NL();
             return false;
             return false;
         } else if(
         } else if(
             (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
             (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
@@ -61,7 +61,7 @@ bool totp_cli_read_line(PipeSide* pipe, FuriString* out_str, bool mask_user_inpu
                 furi_string_left(out_str, out_str_size - 1);
                 furi_string_left(out_str, out_str_size - 1);
             }
             }
         } else if(c == CliKeyCR) {
         } else if(c == CliKeyCR) {
-            printf("\r\n");
+            TOTP_CLI_NL();
             break;
             break;
         }
         }
     }
     }

+ 2 - 2
cli/plugins/automation/automation.c

@@ -131,7 +131,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
                 print_initial_delay(
                 print_initial_delay(
                     plugin_state->automation_initial_delay, TOTP_CLI_COLOR_SUCCESS);
                     plugin_state->automation_initial_delay, TOTP_CLI_COLOR_SUCCESS);
                 TOTP_CLI_PRINTF_SUCCESS(" sec.]");
                 TOTP_CLI_PRINTF_SUCCESS(" sec.]");
-                printf("\r\n");
+                TOTP_CLI_NL();
             } else {
             } else {
                 TOTP_CLI_PRINT_ERROR_UPDATING_CONFIG_FILE();
                 TOTP_CLI_PRINT_ERROR_UPDATING_CONFIG_FILE();
             }
             }
@@ -154,7 +154,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
             TOTP_CLI_PRINTF_INFO(" [");
             TOTP_CLI_PRINTF_INFO(" [");
             print_initial_delay(plugin_state->automation_initial_delay, TOTP_CLI_COLOR_INFO);
             print_initial_delay(plugin_state->automation_initial_delay, TOTP_CLI_COLOR_INFO);
             TOTP_CLI_PRINTF_INFO(" sec.]");
             TOTP_CLI_PRINTF_INFO(" sec.]");
-            printf("\r\n");
+            TOTP_CLI_NL();
         }
         }
     } while(false);
     } while(false);
 
 

+ 2 - 2
cli/plugins/export/export.c

@@ -90,7 +90,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
 
 
     size_t original_index = totp_token_info_iterator_get_current_token_index(iterator_context);
     size_t original_index = totp_token_info_iterator_get_current_token_index(iterator_context);
 
 
-    printf("\r\n");
+    TOTP_CLI_NL();
     TOTP_CLI_PRINTF("# --- EXPORT LIST BEGIN ---\r\n");
     TOTP_CLI_PRINTF("# --- EXPORT LIST BEGIN ---\r\n");
 
 
     for(size_t i = 0; i < total_count; i++) {
     for(size_t i = 0; i < total_count; i++) {
@@ -116,7 +116,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
         } else {
         } else {
             TOTP_CLI_PRINTF("&period=%" PRIu8, token_info->duration);
             TOTP_CLI_PRINTF("&period=%" PRIu8, token_info->duration);
         }
         }
-        printf("\r\n");
+        TOTP_CLI_NL();
     }
     }
 
 
     TOTP_CLI_PRINTF("# --- EXPORT LIST END ---\r\n\r\n");
     TOTP_CLI_PRINTF("# --- EXPORT LIST END ---\r\n\r\n");

+ 2 - 2
cli/plugins/notification/notification.c

@@ -67,7 +67,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
             if(totp_config_file_update_notification_method(plugin_state)) {
             if(totp_config_file_update_notification_method(plugin_state)) {
                 TOTP_CLI_PRINTF_SUCCESS("Notification method is set to ");
                 TOTP_CLI_PRINTF_SUCCESS("Notification method is set to ");
                 totp_cli_command_notification_print_method(new_method, TOTP_CLI_COLOR_SUCCESS);
                 totp_cli_command_notification_print_method(new_method, TOTP_CLI_COLOR_SUCCESS);
-                printf("\r\n");
+                TOTP_CLI_NL();
             } else {
             } else {
                 TOTP_CLI_PRINT_ERROR_UPDATING_CONFIG_FILE();
                 TOTP_CLI_PRINT_ERROR_UPDATING_CONFIG_FILE();
             }
             }
@@ -77,7 +77,7 @@ static void handle(PluginState* plugin_state, FuriString* args, PipeSide* pipe)
             TOTP_CLI_PRINTF_INFO("Current notification method is ");
             TOTP_CLI_PRINTF_INFO("Current notification method is ");
             totp_cli_command_notification_print_method(
             totp_cli_command_notification_print_method(
                 plugin_state->notification_method, TOTP_CLI_COLOR_INFO);
                 plugin_state->notification_method, TOTP_CLI_COLOR_INFO);
-            printf("\r\n");
+            TOTP_CLI_NL();
         }
         }
     } while(false);
     } while(false);
 
 

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

@@ -65,7 +65,7 @@ static bool totp_cli_read_pin(PipeSide* pipe, uint8_t* pin, uint8_t* pin_length)
                 TOTP_CLI_DELETE_LAST_CHAR();
                 TOTP_CLI_DELETE_LAST_CHAR();
             }
             }
         } else if(c == CliKeyCR) {
         } else if(c == CliKeyCR) {
-            printf("\r\n");
+            TOTP_CLI_NL();
             break;
             break;
         }
         }
     }
     }