shell: shell_ops internal api update

Add prefix z_ to internal functions provided by the shell_ops module.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
Jakub Rzeszutko 2020-12-07 13:22:35 +01:00 committed by Carles Cufí
commit 0eea85bf08
6 changed files with 273 additions and 281 deletions

View file

@ -88,12 +88,12 @@ static inline void state_set(const struct shell *shell, enum shell_state state)
if (state == SHELL_STATE_ACTIVE) {
cmd_buffer_clear(shell);
if (flag_print_noinit_get(shell)) {
if (z_flag_print_noinit_get(shell)) {
z_shell_fprintf(shell, SHELL_WARNING, "%s",
SHELL_MSG_BACKEND_NOT_ACTIVE);
flag_print_noinit_set(shell, false);
z_flag_print_noinit_set(shell, false);
}
shell_print_prompt_and_cmd(shell);
z_shell_print_prompt_and_cmd(shell);
}
}
@ -137,7 +137,7 @@ static void tab_item_print(const struct shell *shell, const char *option,
z_shell_fprintf(shell, SHELL_OPTION, "%s", option);
}
shell_op_cursor_horiz_move(shell, diff);
z_shell_op_cursor_horiz_move(shell, diff);
}
static void history_init(const struct shell *shell)
@ -164,7 +164,7 @@ static void history_mode_exit(const struct shell *shell)
return;
}
flag_history_exit_set(shell, false);
z_flag_history_exit_set(shell, false);
z_shell_history_mode_exit(shell->history);
}
@ -188,8 +188,8 @@ static void history_handle(const struct shell *shell, bool up)
}
/* Checking if history process has been stopped */
if (flag_history_exit_get(shell)) {
flag_history_exit_set(shell, false);
if (z_flag_history_exit_get(shell)) {
z_flag_history_exit_set(shell, false);
z_shell_history_mode_exit(shell->history);
}
@ -220,12 +220,12 @@ static void history_handle(const struct shell *shell, bool up)
len = shell_strlen(shell->ctx->cmd_buff);
}
shell_op_cursor_home_move(shell);
clear_eos(shell);
shell_print_cmd(shell);
z_shell_op_cursor_home_move(shell);
z_clear_eos(shell);
z_shell_print_cmd(shell);
shell->ctx->cmd_buff_pos = len;
shell->ctx->cmd_buff_len = len;
shell_op_cond_next_line(shell);
z_shell_op_cond_next_line(shell);
}
static inline uint16_t completion_space_get(const struct shell *shell)
@ -358,34 +358,34 @@ static void autocomplete(const struct shell *shell,
* complete.
*/
if (cmd_len == arg_len) {
shell_op_char_insert(shell, ' ');
z_shell_op_char_insert(shell, ' ');
}
return;
}
/* no exact match found */
if (cmd_len != arg_len) {
shell_op_completion_insert(shell,
match->syntax + arg_len,
cmd_len - arg_len);
z_shell_op_completion_insert(shell,
match->syntax + arg_len,
cmd_len - arg_len);
}
/* Next character in the buffer is not 'space'. */
if (!isspace((int) shell->ctx->cmd_buff[
shell->ctx->cmd_buff_pos])) {
if (flag_insert_mode_get(shell)) {
flag_insert_mode_set(shell, false);
shell_op_char_insert(shell, ' ');
flag_insert_mode_set(shell, true);
if (z_flag_insert_mode_get(shell)) {
z_flag_insert_mode_set(shell, false);
z_shell_op_char_insert(shell, ' ');
z_flag_insert_mode_set(shell, true);
} else {
shell_op_char_insert(shell, ' ');
z_shell_op_char_insert(shell, ' ');
}
} else {
/* case:
* | | -> cursor
* cons_name $: valid_cmd valid_sub_cmd| |argument <tab>
*/
shell_op_cursor_move(shell, 1);
z_shell_op_cursor_move(shell, 1);
/* result:
* cons_name $: valid_cmd valid_sub_cmd |a|rgument
*/
@ -434,8 +434,8 @@ static void tab_options_print(const struct shell *shell,
cnt--;
}
cursor_next_line_move(shell);
shell_print_prompt_and_cmd(shell);
z_cursor_next_line_move(shell);
z_shell_print_prompt_and_cmd(shell);
}
static uint16_t common_beginning_find(const struct shell *shell,
@ -493,8 +493,8 @@ static void partial_autocomplete(const struct shell *shell,
}
if (common) {
shell_op_completion_insert(shell, &completion[arg_len],
common - arg_len);
z_shell_op_completion_insert(shell, &completion[arg_len],
common - arg_len);
}
}
@ -532,7 +532,7 @@ static int exec_cmd(const struct shell *shell, size_t argc, const char **argv,
}
if (!ret_val) {
flag_cmd_ctx_set(shell, true);
z_flag_cmd_ctx_set(shell, true);
/* Unlock thread mutex in case command would like to borrow
* shell context to other thread to avoid mutex deadlock.
*/
@ -541,7 +541,7 @@ static int exec_cmd(const struct shell *shell, size_t argc, const char **argv,
(char **)argv);
/* Bring back mutex to shell thread. */
k_mutex_lock(&shell->ctx->wr_mtx, K_FOREVER);
flag_cmd_ctx_set(shell, false);
z_flag_cmd_ctx_set(shell, false);
}
return ret_val;
@ -574,8 +574,8 @@ static bool wildcard_check_report(const struct shell *shell, bool found,
* with a handler to avoid multiple function calls.
*/
if (IS_ENABLED(CONFIG_SHELL_WILDCARD) && found && entry->handler) {
shell_op_cursor_end_move(shell);
shell_op_cond_next_line(shell);
z_shell_op_cursor_end_move(shell);
z_shell_op_cond_next_line(shell);
z_shell_fprintf(shell, SHELL_ERROR,
"Error: requested multiple function executions\n");
@ -616,9 +616,9 @@ static int execute(const struct shell *shell)
char *cmd_buf = shell->ctx->cmd_buff;
bool has_last_handler = false;
shell_op_cursor_end_move(shell);
if (!shell_cursor_in_empty_line(shell)) {
cursor_next_line_move(shell);
z_shell_op_cursor_end_move(shell);
if (!z_shell_cursor_in_empty_line(shell)) {
z_cursor_next_line_move(shell);
}
memset(&shell->ctx->active_cmd, 0, sizeof(shell->ctx->active_cmd));
@ -812,17 +812,17 @@ static void alt_metakeys_handle(const struct shell *shell, char data)
return;
}
if (data == SHELL_VT100_ASCII_ALT_B) {
shell_op_cursor_word_move(shell, -1);
z_shell_op_cursor_word_move(shell, -1);
} else if (data == SHELL_VT100_ASCII_ALT_F) {
shell_op_cursor_word_move(shell, 1);
z_shell_op_cursor_word_move(shell, 1);
} else if (data == SHELL_VT100_ASCII_ALT_R &&
IS_ENABLED(CONFIG_SHELL_CMDS_SELECT)) {
if (selected_cmd_get(shell) != NULL) {
shell_cmd_line_erase(shell);
z_shell_cmd_line_erase(shell);
z_shell_fprintf(shell, SHELL_WARNING,
"Restored default root commands\n");
shell->ctx->selected_cmd = NULL;
shell_print_prompt_and_cmd(shell);
z_shell_print_prompt_and_cmd(shell);
}
}
}
@ -836,42 +836,42 @@ static void ctrl_metakeys_handle(const struct shell *shell, char data)
switch (data) {
case SHELL_VT100_ASCII_CTRL_A: /* CTRL + A */
shell_op_cursor_home_move(shell);
z_shell_op_cursor_home_move(shell);
break;
case SHELL_VT100_ASCII_CTRL_B: /* CTRL + B */
shell_op_left_arrow(shell);
z_shell_op_left_arrow(shell);
break;
case SHELL_VT100_ASCII_CTRL_C: /* CTRL + C */
shell_op_cursor_end_move(shell);
if (!shell_cursor_in_empty_line(shell)) {
cursor_next_line_move(shell);
z_shell_op_cursor_end_move(shell);
if (!z_shell_cursor_in_empty_line(shell)) {
z_cursor_next_line_move(shell);
}
flag_history_exit_set(shell, true);
z_flag_history_exit_set(shell, true);
state_set(shell, SHELL_STATE_ACTIVE);
break;
case SHELL_VT100_ASCII_CTRL_D: /* CTRL + D */
shell_op_char_delete(shell);
z_shell_op_char_delete(shell);
break;
case SHELL_VT100_ASCII_CTRL_E: /* CTRL + E */
shell_op_cursor_end_move(shell);
z_shell_op_cursor_end_move(shell);
break;
case SHELL_VT100_ASCII_CTRL_F: /* CTRL + F */
shell_op_right_arrow(shell);
z_shell_op_right_arrow(shell);
break;
case SHELL_VT100_ASCII_CTRL_K: /* CTRL + K */
shell_op_delete_from_cursor(shell);
z_shell_op_delete_from_cursor(shell);
break;
case SHELL_VT100_ASCII_CTRL_L: /* CTRL + L */
SHELL_VT100_CMD(shell, SHELL_VT100_CURSORHOME);
SHELL_VT100_CMD(shell, SHELL_VT100_CLEARSCREEN);
shell_print_prompt_and_cmd(shell);
Z_SHELL_VT100_CMD(shell, SHELL_VT100_CURSORHOME);
Z_SHELL_VT100_CMD(shell, SHELL_VT100_CLEARSCREEN);
z_shell_print_prompt_and_cmd(shell);
break;
case SHELL_VT100_ASCII_CTRL_N: /* CTRL + N */
@ -883,15 +883,15 @@ static void ctrl_metakeys_handle(const struct shell *shell, char data)
break;
case SHELL_VT100_ASCII_CTRL_U: /* CTRL + U */
shell_op_cursor_home_move(shell);
z_shell_op_cursor_home_move(shell);
cmd_buffer_clear(shell);
flag_history_exit_set(shell, true);
clear_eos(shell);
z_flag_history_exit_set(shell, true);
z_clear_eos(shell);
break;
case SHELL_VT100_ASCII_CTRL_W: /* CTRL + W */
shell_op_word_remove(shell);
flag_history_exit_set(shell, true);
z_shell_op_word_remove(shell);
z_flag_history_exit_set(shell, true);
break;
default:
@ -903,13 +903,13 @@ static void ctrl_metakeys_handle(const struct shell *shell, char data)
static bool process_nl(const struct shell *shell, uint8_t data)
{
if ((data != '\r') && (data != '\n')) {
flag_last_nl_set(shell, 0);
z_flag_last_nl_set(shell, 0);
return false;
}
if ((flag_last_nl_get(shell) == 0U) ||
(data == flag_last_nl_get(shell))) {
flag_last_nl_set(shell, data);
if ((z_flag_last_nl_get(shell) == 0U) ||
(data == z_flag_last_nl_get(shell))) {
z_flag_last_nl_set(shell, data);
return true;
}
@ -943,7 +943,7 @@ static void state_collect(const struct shell *shell)
if (process_nl(shell, data)) {
if (!shell->ctx->cmd_buff_len) {
history_mode_exit(shell);
cursor_next_line_move(shell);
z_cursor_next_line_move(shell);
} else {
/* Command execution */
(void)execute(shell);
@ -964,42 +964,42 @@ static void state_collect(const struct shell *shell)
break;
case '\t': /* TAB */
if (flag_echo_get(shell) &&
if (z_flag_echo_get(shell) &&
IS_ENABLED(CONFIG_SHELL_TAB)) {
/* If the Tab key is pressed, "history
* mode" must be terminated because
* tab and history handlers are sharing
* the same array: temp_buff.
*/
flag_history_exit_set(shell, true);
z_flag_history_exit_set(shell, true);
tab_handle(shell);
}
break;
case SHELL_VT100_ASCII_BSPACE: /* BACKSPACE */
if (flag_echo_get(shell)) {
flag_history_exit_set(shell, true);
shell_op_char_backspace(shell);
if (z_flag_echo_get(shell)) {
z_flag_history_exit_set(shell, true);
z_shell_op_char_backspace(shell);
}
break;
case SHELL_VT100_ASCII_DEL: /* DELETE */
if (flag_echo_get(shell)) {
flag_history_exit_set(shell, true);
if (flag_mode_delete_get(shell)) {
shell_op_char_backspace(shell);
if (z_flag_echo_get(shell)) {
z_flag_history_exit_set(shell, true);
if (z_flag_mode_delete_get(shell)) {
z_shell_op_char_backspace(shell);
} else {
shell_op_char_delete(shell);
z_shell_op_char_delete(shell);
}
}
break;
default:
if (isprint((int) data)) {
flag_history_exit_set(shell, true);
shell_op_char_insert(shell, data);
} else if (flag_echo_get(shell)) {
z_flag_history_exit_set(shell, true);
z_shell_op_char_insert(shell, data);
} else if (z_flag_echo_get(shell)) {
ctrl_metakeys_handle(shell, data);
}
break;
@ -1011,7 +1011,7 @@ static void state_collect(const struct shell *shell)
receive_state_change(shell,
SHELL_RECEIVE_ESC_SEQ);
break;
} else if (flag_echo_get(shell)) {
} else if (z_flag_echo_get(shell)) {
alt_metakeys_handle(shell, data);
}
receive_state_change(shell, SHELL_RECEIVE_DEFAULT);
@ -1020,7 +1020,7 @@ static void state_collect(const struct shell *shell)
case SHELL_RECEIVE_ESC_SEQ:
receive_state_change(shell, SHELL_RECEIVE_DEFAULT);
if (!flag_echo_get(shell)) {
if (!z_flag_echo_get(shell)) {
continue;
}
@ -1034,11 +1034,11 @@ static void state_collect(const struct shell *shell)
break;
case 'C': /* RIGHT arrow */
shell_op_right_arrow(shell);
z_shell_op_right_arrow(shell);
break;
case 'D': /* LEFT arrow */
shell_op_left_arrow(shell);
z_shell_op_left_arrow(shell);
break;
case '4': /* END Button in ESC[n~ mode */
@ -1046,7 +1046,7 @@ static void state_collect(const struct shell *shell)
SHELL_RECEIVE_TILDE_EXP);
__fallthrough;
case 'F': /* END Button in VT100 mode */
shell_op_cursor_end_move(shell);
z_shell_op_cursor_end_move(shell);
break;
case '1': /* HOME Button in ESC[n~ mode */
@ -1054,7 +1054,7 @@ static void state_collect(const struct shell *shell)
SHELL_RECEIVE_TILDE_EXP);
__fallthrough;
case 'H': /* HOME Button in VT100 mode */
shell_op_cursor_home_move(shell);
z_shell_op_cursor_home_move(shell);
break;
case '2': /* INSERT Button in ESC[n~ mode */
@ -1062,16 +1062,16 @@ static void state_collect(const struct shell *shell)
SHELL_RECEIVE_TILDE_EXP);
__fallthrough;
case 'L': {/* INSERT Button in VT100 mode */
bool status = flag_insert_mode_get(shell);
flag_insert_mode_set(shell, !status);
bool status = z_flag_insert_mode_get(shell);
z_flag_insert_mode_set(shell, !status);
break;
}
case '3':/* DELETE Button in ESC[n~ mode */
receive_state_change(shell,
SHELL_RECEIVE_TILDE_EXP);
if (flag_echo_get(shell)) {
shell_op_char_delete(shell);
if (z_flag_echo_get(shell)) {
z_shell_op_char_delete(shell);
}
break;
@ -1112,7 +1112,7 @@ static void shell_log_process(const struct shell *shell)
do {
if (!IS_ENABLED(CONFIG_LOG_IMMEDIATE)) {
shell_cmd_line_erase(shell);
z_shell_cmd_line_erase(shell);
processed = z_shell_log_backend_process(
shell->log_backend);
@ -1121,7 +1121,7 @@ static void shell_log_process(const struct shell *shell)
struct k_poll_signal *signal =
&shell->ctx->signals[SHELL_SIGNAL_RXRDY];
shell_print_prompt_and_cmd(shell);
z_shell_print_prompt_and_cmd(shell);
/* Arbitrary delay added to ensure that prompt is
* readable and can be used to enter further commands.
@ -1160,16 +1160,16 @@ static int instance_init(const struct shell *shell, const void *p_config,
shell->stats->log_lost_cnt = 0;
}
flag_tx_rdy_set(shell, true);
flag_echo_set(shell, IS_ENABLED(CONFIG_SHELL_ECHO_STATUS));
flag_mode_delete_set(shell,
z_flag_tx_rdy_set(shell, true);
z_flag_echo_set(shell, IS_ENABLED(CONFIG_SHELL_ECHO_STATUS));
z_flag_mode_delete_set(shell,
IS_ENABLED(CONFIG_SHELL_BACKSPACE_MODE_DELETE));
shell->ctx->vt100_ctx.cons.terminal_wid =
CONFIG_SHELL_DEFAULT_TERMINAL_WIDTH;
shell->ctx->vt100_ctx.cons.terminal_hei =
CONFIG_SHELL_DEFAULT_TERMINAL_HEIGHT;
shell->ctx->vt100_ctx.cons.name_len = shell_strlen(shell->ctx->prompt);
flag_use_colors_set(shell, IS_ENABLED(CONFIG_SHELL_VT100_COLORS));
z_flag_use_colors_set(shell, IS_ENABLED(CONFIG_SHELL_VT100_COLORS));
int ret = shell->iface->api->init(shell->iface, p_config,
transport_evt_handler,
@ -1188,7 +1188,7 @@ static int instance_uninit(const struct shell *shell)
int err;
if (flag_processing_get(shell)) {
if (z_flag_processing_get(shell)) {
return -EBUSY;
}
@ -1339,10 +1339,10 @@ int shell_start(const struct shell *shell)
k_mutex_lock(&shell->ctx->wr_mtx, K_FOREVER);
if (IS_ENABLED(CONFIG_SHELL_VT100_COLORS)) {
shell_vt100_color_set(shell, SHELL_NORMAL);
z_shell_vt100_color_set(shell, SHELL_NORMAL);
}
shell_raw_fprintf(shell->fprintf_ctx, "\n\n");
z_shell_raw_fprintf(shell->fprintf_ctx, "\n\n");
state_set(shell, SHELL_STATE_ACTIVE);
k_mutex_unlock(&shell->ctx->wr_mtx);
@ -1415,17 +1415,17 @@ void shell_vfprintf(const struct shell *shell, enum shell_vt100_color color,
/* Sending a message to a non-active shell leads to a dead lock. */
if (state_get(shell) != SHELL_STATE_ACTIVE) {
flag_print_noinit_set(shell, true);
z_flag_print_noinit_set(shell, true);
return;
}
k_mutex_lock(&shell->ctx->wr_mtx, K_FOREVER);
if (!flag_cmd_ctx_get(shell)) {
shell_cmd_line_erase(shell);
if (!z_flag_cmd_ctx_get(shell)) {
z_shell_cmd_line_erase(shell);
}
z_shell_vfprintf(shell, color, fmt, args);
if (!flag_cmd_ctx_get(shell)) {
shell_print_prompt_and_cmd(shell);
if (!z_flag_cmd_ctx_get(shell)) {
z_shell_print_prompt_and_cmd(shell);
}
transport_buffer_flush(shell);
k_mutex_unlock(&shell->ctx->wr_mtx);

View file

@ -76,7 +76,7 @@ static int cursor_position_get(const struct shell *shell, uint16_t *x, uint16_t
/* escape code asking terminal about its size */
static char const cmd_get_terminal_size[] = "\033[6n";
shell_raw_fprintf(shell->fprintf_ctx, cmd_get_terminal_size);
z_shell_raw_fprintf(shell->fprintf_ctx, cmd_get_terminal_size);
/* fprintf buffer needs to be flushed to start sending prepared
* escape code to the terminal.
@ -173,13 +173,13 @@ static int terminal_size_get(const struct shell *shell)
uint16_t y; /* vertical position */
int ret_val = 0;
cursor_save(shell);
z_cursor_save(shell);
/* Assumption: terminal width and height < 999. */
/* Move to last column. */
shell_op_cursor_vert_move(shell, -SHELL_MAX_TERMINAL_SIZE);
z_shell_op_cursor_vert_move(shell, -SHELL_MAX_TERMINAL_SIZE);
/* Move to last row. */
shell_op_cursor_horiz_move(shell, SHELL_MAX_TERMINAL_SIZE);
z_shell_op_cursor_horiz_move(shell, SHELL_MAX_TERMINAL_SIZE);
if (cursor_position_get(shell, &x, &y) == 0) {
shell->ctx->vt100_ctx.cons.terminal_wid = x;
@ -188,7 +188,7 @@ static int terminal_size_get(const struct shell *shell)
ret_val = -ENOTSUP;
}
cursor_restore(shell);
z_cursor_restore(shell);
return ret_val;
}
@ -196,8 +196,8 @@ static int cmd_clear(const struct shell *shell, size_t argc, char **argv)
{
ARG_UNUSED(argv);
SHELL_VT100_CMD(shell, SHELL_VT100_CURSORHOME);
SHELL_VT100_CMD(shell, SHELL_VT100_CLEARSCREEN);
Z_SHELL_VT100_CMD(shell, SHELL_VT100_CURSORHOME);
Z_SHELL_VT100_CMD(shell, SHELL_VT100_CLEARSCREEN);
return 0;
}
@ -208,7 +208,7 @@ static int cmd_bacskpace_mode_backspace(const struct shell *shell, size_t argc,
ARG_UNUSED(argc);
ARG_UNUSED(argv);
flag_mode_delete_set(shell, false);
z_flag_mode_delete_set(shell, false);
return 0;
}
@ -219,7 +219,7 @@ static int cmd_bacskpace_mode_delete(const struct shell *shell, size_t argc,
ARG_UNUSED(argc);
ARG_UNUSED(argv);
flag_mode_delete_set(shell, true);
z_flag_mode_delete_set(shell, true);
return 0;
}
@ -229,7 +229,7 @@ static int cmd_colors_off(const struct shell *shell, size_t argc, char **argv)
ARG_UNUSED(argc);
ARG_UNUSED(argv);
flag_use_colors_set(shell, false);
z_flag_use_colors_set(shell, false);
return 0;
}
@ -239,7 +239,7 @@ static int cmd_colors_on(const struct shell *shell, size_t argc, char **argv)
ARG_UNUSED(argv);
ARG_UNUSED(argv);
flag_use_colors_set(shell, true);
z_flag_use_colors_set(shell, true);
return 0;
}
@ -249,7 +249,7 @@ static int cmd_echo_off(const struct shell *shell, size_t argc, char **argv)
ARG_UNUSED(argc);
ARG_UNUSED(argv);
flag_echo_set(shell, false);
z_flag_echo_set(shell, false);
return 0;
}
@ -259,7 +259,7 @@ static int cmd_echo_on(const struct shell *shell, size_t argc, char **argv)
ARG_UNUSED(argc);
ARG_UNUSED(argv);
flag_echo_set(shell, true);
z_flag_echo_set(shell, true);
return 0;
}
@ -273,7 +273,7 @@ static int cmd_echo(const struct shell *shell, size_t argc, char **argv)
}
shell_print(shell, "Echo status: %s",
flag_echo_get(shell) ? "on" : "off");
z_flag_echo_get(shell) ? "on" : "off");
return 0;
}
@ -332,7 +332,7 @@ static int cmd_resize_default(const struct shell *shell,
ARG_UNUSED(argc);
ARG_UNUSED(argv);
SHELL_VT100_CMD(shell, SHELL_VT100_SETCOL_80);
Z_SHELL_VT100_CMD(shell, SHELL_VT100_SETCOL_80);
shell->ctx->vt100_ctx.cons.terminal_wid = SHELL_DEFAULT_TERMINAL_WIDTH;
shell->ctx->vt100_ctx.cons.terminal_hei = SHELL_DEFAULT_TERMINAL_HEIGHT;

View file

@ -27,7 +27,7 @@ static void formatted_text_print(const struct shell *shell, const char *str,
}
if (offset_first_line) {
shell_op_cursor_horiz_move(shell, terminal_offset);
z_shell_op_cursor_horiz_move(shell, terminal_offset);
}
@ -46,17 +46,17 @@ static void formatted_text_print(const struct shell *shell, const char *str,
for (idx = 0; idx < length; idx++) {
if (*(str + offset + idx) == '\n') {
transport_buffer_flush(shell);
shell_write(shell, str + offset, idx);
z_shell_write(shell, str + offset, idx);
offset += idx + 1;
cursor_next_line_move(shell);
shell_op_cursor_horiz_move(shell,
z_cursor_next_line_move(shell);
z_shell_op_cursor_horiz_move(shell,
terminal_offset);
break;
}
}
/* String will fit in one line. */
shell_raw_fprintf(shell->fprintf_ctx, str + offset);
z_shell_raw_fprintf(shell->fprintf_ctx, str + offset);
break;
}
@ -89,7 +89,7 @@ static void formatted_text_print(const struct shell *shell, const char *str,
* before calling shell_write.
*/
transport_buffer_flush(shell);
shell_write(shell, str + offset, length);
z_shell_write(shell, str + offset, length);
offset += length;
/* Calculating text offset to ensure that next line will
@ -99,11 +99,11 @@ static void formatted_text_print(const struct shell *shell, const char *str,
++offset;
}
cursor_next_line_move(shell);
shell_op_cursor_horiz_move(shell, terminal_offset);
z_cursor_next_line_move(shell);
z_shell_op_cursor_horiz_move(shell, terminal_offset);
}
cursor_next_line_move(shell);
z_cursor_next_line_move(shell);
}
static void help_item_print(const struct shell *shell, const char *item_name,
@ -129,13 +129,13 @@ static void help_item_print(const struct shell *shell, const char *item_name,
z_shell_fprintf(shell, SHELL_NORMAL, "%s%s", tabulator,
item_name);
for (uint16_t i = 0; i < tmp; i++) {
shell_write(shell, &space, 1);
z_shell_write(shell, &space, 1);
}
z_shell_fprintf(shell, SHELL_NORMAL, "%s:", tabulator);
}
if (item_help == NULL) {
cursor_next_line_move(shell);
z_cursor_next_line_move(shell);
return;
}
/* print option help */

View file

@ -157,14 +157,14 @@ bool z_shell_log_backend_process(const struct shell_log_backend *backend)
struct shell_vt100_colors col;
if (colors) {
shell_vt100_colors_store(shell, &col);
shell_vt100_color_set(shell, SHELL_VT100_COLOR_RED);
z_shell_vt100_colors_store(shell, &col);
z_shell_vt100_color_set(shell, SHELL_VT100_COLOR_RED);
}
log_output_dropped_process(backend->log_output, dropped);
if (colors) {
shell_vt100_colors_restore(shell, &col);
z_shell_vt100_colors_restore(shell, &col);
}
}
@ -193,7 +193,7 @@ static void put(const struct log_backend *const backend, struct log_msg *msg)
break;
case SHELL_LOG_BACKEND_PANIC:
shell_cmd_line_erase(shell);
z_shell_cmd_line_erase(shell);
msg_process(shell->log_backend->log_output, msg, colors);
break;
@ -221,13 +221,13 @@ static void put_sync_string(const struct log_backend *const backend,
}
key = irq_lock();
if (!flag_cmd_ctx_get(shell)) {
shell_cmd_line_erase(shell);
if (!z_flag_cmd_ctx_get(shell)) {
z_shell_cmd_line_erase(shell);
}
log_output_string(shell->log_backend->log_output, src_level, timestamp,
fmt, ap, flags);
if (!flag_cmd_ctx_get(shell)) {
shell_print_prompt_and_cmd(shell);
if (!z_flag_cmd_ctx_get(shell)) {
z_shell_print_prompt_and_cmd(shell);
}
irq_unlock(key);
}
@ -247,13 +247,13 @@ static void put_sync_hexdump(const struct log_backend *const backend,
}
key = irq_lock();
if (!flag_cmd_ctx_get(shell)) {
shell_cmd_line_erase(shell);
if (!z_flag_cmd_ctx_get(shell)) {
z_shell_cmd_line_erase(shell);
}
log_output_hexdump(shell->log_backend->log_output, src_level, timestamp,
metadata, data, length, flags);
if (!flag_cmd_ctx_get(shell)) {
shell_print_prompt_and_cmd(shell);
if (!z_flag_cmd_ctx_get(shell)) {
z_shell_print_prompt_and_cmd(shell);
}
irq_unlock(key);
}
@ -277,8 +277,8 @@ static void panic(const struct log_backend *const backend)
shell_multiline_data_calc(&shell->ctx->vt100_ctx.cons,
shell->ctx->cmd_buff_pos,
shell->ctx->cmd_buff_len);
shell_op_cursor_vert_move(shell, -1);
shell_op_cursor_horiz_move(shell,
z_shell_op_cursor_vert_move(shell, -1);
z_shell_op_cursor_horiz_move(shell,
-shell->ctx->vt100_ctx.cons.cur_x);
while (z_shell_log_backend_process(shell->log_backend)) {

View file

@ -7,21 +7,21 @@
#include <ctype.h>
#include "shell_ops.h"
void shell_op_cursor_vert_move(const struct shell *shell, int32_t delta)
void z_shell_op_cursor_vert_move(const struct shell *shell, int32_t delta)
{
if (delta != 0) {
shell_raw_fprintf(shell->fprintf_ctx, "\033[%d%c",
delta > 0 ? delta : -delta,
delta > 0 ? 'A' : 'B');
z_shell_raw_fprintf(shell->fprintf_ctx, "\033[%d%c",
delta > 0 ? delta : -delta,
delta > 0 ? 'A' : 'B');
}
}
void shell_op_cursor_horiz_move(const struct shell *shell, int32_t delta)
void z_shell_op_cursor_horiz_move(const struct shell *shell, int32_t delta)
{
if (delta != 0) {
shell_raw_fprintf(shell->fprintf_ctx, "\033[%d%c",
delta > 0 ? delta : -delta,
delta > 0 ? 'C' : 'D');
z_shell_raw_fprintf(shell->fprintf_ctx, "\033[%d%c",
delta > 0 ? delta : -delta,
delta > 0 ? 'C' : 'D');
}
}
@ -35,20 +35,20 @@ static inline bool full_line_cmd(const struct shell *shell)
}
/* Function returns true if cursor is at beginning of an empty line. */
bool shell_cursor_in_empty_line(const struct shell *shell)
bool z_shell_cursor_in_empty_line(const struct shell *shell)
{
return ((shell->ctx->cmd_buff_pos + shell_strlen(shell->ctx->prompt))
% shell->ctx->vt100_ctx.cons.terminal_wid == 0U);
}
void shell_op_cond_next_line(const struct shell *shell)
void z_shell_op_cond_next_line(const struct shell *shell)
{
if (shell_cursor_in_empty_line(shell) || full_line_cmd(shell)) {
cursor_next_line_move(shell);
if (z_shell_cursor_in_empty_line(shell) || full_line_cmd(shell)) {
z_cursor_next_line_move(shell);
}
}
void shell_op_cursor_position_synchronize(const struct shell *shell)
void z_shell_op_cursor_position_synchronize(const struct shell *shell)
{
struct shell_multiline_cons *cons = &shell->ctx->vt100_ctx.cons;
bool last_line;
@ -61,20 +61,20 @@ void shell_op_cursor_position_synchronize(const struct shell *shell)
* be moved to the next line.
*/
if (full_line_cmd(shell)) {
cursor_next_line_move(shell);
z_cursor_next_line_move(shell);
}
if (last_line) {
shell_op_cursor_horiz_move(shell, cons->cur_x -
z_shell_op_cursor_horiz_move(shell, cons->cur_x -
cons->cur_x_end);
} else {
shell_op_cursor_vert_move(shell, cons->cur_y_end - cons->cur_y);
shell_op_cursor_horiz_move(shell, cons->cur_x -
z_shell_op_cursor_vert_move(shell, cons->cur_y_end - cons->cur_y);
z_shell_op_cursor_horiz_move(shell, cons->cur_x -
cons->cur_x_end);
}
}
void shell_op_cursor_move(const struct shell *shell, int16_t val)
void z_shell_op_cursor_move(const struct shell *shell, int16_t val)
{
struct shell_multiline_cons *cons = &shell->ctx->vt100_ctx.cons;
uint16_t new_pos = shell->ctx->cmd_buff_pos + val;
@ -93,8 +93,8 @@ void shell_op_cursor_move(const struct shell *shell, int16_t val)
shell->ctx->cmd_buff_pos,
new_pos);
shell_op_cursor_vert_move(shell, -row_span);
shell_op_cursor_horiz_move(shell, col_span);
z_shell_op_cursor_vert_move(shell, -row_span);
z_shell_op_cursor_horiz_move(shell, col_span);
shell->ctx->cmd_buff_pos = new_pos;
}
@ -123,7 +123,7 @@ static uint16_t shift_calc(const char *str, uint16_t pos, uint16_t len, int16_t
return ret;
}
void shell_op_cursor_word_move(const struct shell *shell, int16_t val)
void z_shell_op_cursor_word_move(const struct shell *shell, int16_t val)
{
int16_t shift;
int16_t sign;
@ -139,11 +139,11 @@ void shell_op_cursor_word_move(const struct shell *shell, int16_t val)
shift = shift_calc(shell->ctx->cmd_buff,
shell->ctx->cmd_buff_pos,
shell->ctx->cmd_buff_len, sign);
shell_op_cursor_move(shell, sign * shift);
z_shell_op_cursor_move(shell, sign * shift);
}
}
void shell_op_word_remove(const struct shell *shell)
void z_shell_op_word_remove(const struct shell *shell)
{
char *str = &shell->ctx->cmd_buff[shell->ctx->cmd_buff_pos - 1];
char *str_start = &shell->ctx->cmd_buff[0];
@ -176,36 +176,35 @@ void shell_op_word_remove(const struct shell *shell)
shell->ctx->cmd_buff[shell->ctx->cmd_buff_len] = '\0';
/* Update display. */
shell_op_cursor_move(shell, -chars_to_delete);
cursor_save(shell);
z_shell_op_cursor_move(shell, -chars_to_delete);
z_cursor_save(shell);
z_shell_fprintf(shell, SHELL_NORMAL, "%s", str + 1);
clear_eos(shell);
cursor_restore(shell);
z_clear_eos(shell);
z_cursor_restore(shell);
}
void shell_op_cursor_home_move(const struct shell *shell)
void z_shell_op_cursor_home_move(const struct shell *shell)
{
shell_op_cursor_move(shell, -shell->ctx->cmd_buff_pos);
z_shell_op_cursor_move(shell, -shell->ctx->cmd_buff_pos);
}
void shell_op_cursor_end_move(const struct shell *shell)
void z_shell_op_cursor_end_move(const struct shell *shell)
{
shell_op_cursor_move(shell, shell->ctx->cmd_buff_len -
z_shell_op_cursor_move(shell, shell->ctx->cmd_buff_len -
shell->ctx->cmd_buff_pos);
}
void shell_op_left_arrow(const struct shell *shell)
void z_shell_op_left_arrow(const struct shell *shell)
{
if (shell->ctx->cmd_buff_pos > 0) {
shell_op_cursor_move(shell, -1);
z_shell_op_cursor_move(shell, -1);
}
}
void shell_op_right_arrow(const struct shell *shell)
void z_shell_op_right_arrow(const struct shell *shell)
{
if (shell->ctx->cmd_buff_pos < shell->ctx->cmd_buff_len) {
shell_op_cursor_move(shell, 1);
z_shell_op_cursor_move(shell, 1);
}
}
@ -220,7 +219,7 @@ static void reprint_from_cursor(const struct shell *shell, uint16_t diff,
* bytes transmitted between terminal and device.
*/
if (data_removed) {
clear_eos(shell);
z_clear_eos(shell);
}
z_shell_fprintf(shell, SHELL_NORMAL, "%s",
@ -229,11 +228,11 @@ static void reprint_from_cursor(const struct shell *shell, uint16_t diff,
if (full_line_cmd(shell)) {
if (((data_removed) && (diff > 0)) || (!data_removed)) {
cursor_next_line_move(shell);
z_cursor_next_line_move(shell);
}
}
shell_op_cursor_move(shell, -diff);
z_shell_op_cursor_move(shell, -diff);
}
static void data_insert(const struct shell *shell, const char *data, uint16_t len)
@ -250,7 +249,7 @@ static void data_insert(const struct shell *shell, const char *data, uint16_t le
shell->ctx->cmd_buff_len += len;
shell->ctx->cmd_buff[shell->ctx->cmd_buff_len] = '\0';
if (!flag_echo_get(shell)) {
if (!z_flag_echo_get(shell)) {
shell->ctx->cmd_buff_pos += len;
return;
}
@ -262,17 +261,17 @@ static void char_replace(const struct shell *shell, char data)
{
shell->ctx->cmd_buff[shell->ctx->cmd_buff_pos++] = data;
if (!flag_echo_get(shell)) {
if (!z_flag_echo_get(shell)) {
return;
}
shell_raw_fprintf(shell->fprintf_ctx, "%c", data);
if (shell_cursor_in_empty_line(shell)) {
cursor_next_line_move(shell);
z_shell_raw_fprintf(shell->fprintf_ctx, "%c", data);
if (z_shell_cursor_in_empty_line(shell)) {
z_cursor_next_line_move(shell);
}
}
void shell_op_char_insert(const struct shell *shell, char data)
void z_shell_op_char_insert(const struct shell *shell, char data)
{
if (shell->ctx->internal.flags.insert_mode &&
(shell->ctx->cmd_buff_len != shell->ctx->cmd_buff_pos)) {
@ -282,18 +281,18 @@ void shell_op_char_insert(const struct shell *shell, char data)
}
}
void shell_op_char_backspace(const struct shell *shell)
void z_shell_op_char_backspace(const struct shell *shell)
{
if ((shell->ctx->cmd_buff_len == 0) ||
(shell->ctx->cmd_buff_pos == 0)) {
return;
}
shell_op_cursor_move(shell, -1);
shell_op_char_delete(shell);
z_shell_op_cursor_move(shell, -1);
z_shell_op_char_delete(shell);
}
void shell_op_char_delete(const struct shell *shell)
void z_shell_op_char_delete(const struct shell *shell)
{
uint16_t diff = shell->ctx->cmd_buff_len - shell->ctx->cmd_buff_pos;
char *str = &shell->ctx->cmd_buff[shell->ctx->cmd_buff_pos];
@ -307,31 +306,31 @@ void shell_op_char_delete(const struct shell *shell)
reprint_from_cursor(shell, --diff, true);
}
void shell_op_delete_from_cursor(const struct shell *shell)
void z_shell_op_delete_from_cursor(const struct shell *shell)
{
shell->ctx->cmd_buff_len = shell->ctx->cmd_buff_pos;
shell->ctx->cmd_buff[shell->ctx->cmd_buff_pos] = '\0';
clear_eos(shell);
z_clear_eos(shell);
}
void shell_op_completion_insert(const struct shell *shell,
const char *compl,
uint16_t compl_len)
void z_shell_op_completion_insert(const struct shell *shell,
const char *compl,
uint16_t compl_len)
{
data_insert(shell, compl, compl_len);
}
void shell_cmd_line_erase(const struct shell *shell)
void z_shell_cmd_line_erase(const struct shell *shell)
{
shell_multiline_data_calc(&shell->ctx->vt100_ctx.cons,
shell->ctx->cmd_buff_pos,
shell->ctx->cmd_buff_len);
shell_op_cursor_horiz_move(shell,
z_shell_op_cursor_horiz_move(shell,
-(shell->ctx->vt100_ctx.cons.cur_x - 1));
shell_op_cursor_vert_move(shell, shell->ctx->vt100_ctx.cons.cur_y - 1);
z_shell_op_cursor_vert_move(shell, shell->ctx->vt100_ctx.cons.cur_y - 1);
clear_eos(shell);
z_clear_eos(shell);
}
static void print_prompt(const struct shell *shell)
@ -339,18 +338,18 @@ static void print_prompt(const struct shell *shell)
z_shell_fprintf(shell, SHELL_INFO, "%s", shell->ctx->prompt);
}
void shell_print_cmd(const struct shell *shell)
void z_shell_print_cmd(const struct shell *shell)
{
shell_raw_fprintf(shell->fprintf_ctx, "%s", shell->ctx->cmd_buff);
z_shell_raw_fprintf(shell->fprintf_ctx, "%s", shell->ctx->cmd_buff);
}
void shell_print_prompt_and_cmd(const struct shell *shell)
void z_shell_print_prompt_and_cmd(const struct shell *shell)
{
print_prompt(shell);
if (flag_echo_get(shell)) {
shell_print_cmd(shell);
shell_op_cursor_position_synchronize(shell);
if (z_flag_echo_get(shell)) {
z_shell_print_cmd(shell);
z_shell_op_cursor_position_synchronize(shell);
}
}
@ -362,13 +361,13 @@ static void shell_pend_on_txdone(const struct shell *shell)
k_poll_signal_reset(&shell->ctx->signals[SHELL_SIGNAL_TXDONE]);
} else {
/* Blocking wait in case of bare metal. */
while (!flag_tx_rdy_get(shell)) {
while (!z_flag_tx_rdy_get(shell)) {
}
flag_tx_rdy_set(shell, false);
z_flag_tx_rdy_set(shell, false);
}
}
void shell_write(const struct shell *shell, const void *data,
void z_shell_write(const struct shell *shell, const void *data,
size_t length)
{
__ASSERT_NO_MSG(shell && data);
@ -395,7 +394,7 @@ void shell_write(const struct shell *shell, const void *data,
/* Function shall be only used by the fprintf module. */
void z_shell_print_stream(const void *user_ctx, const char *data, size_t len)
{
shell_write((const struct shell *) user_ctx, data, len);
z_shell_write((const struct shell *) user_ctx, data, len);
}
static void vt100_bgcolor_set(const struct shell *shell,
@ -410,12 +409,12 @@ static void vt100_bgcolor_set(const struct shell *shell,
uint8_t cmd[] = SHELL_VT100_BGCOLOR(bgcolor - 1);
shell->ctx->vt100_ctx.col.bgcol = bgcolor;
shell_raw_fprintf(shell->fprintf_ctx, "%s", cmd);
z_shell_raw_fprintf(shell->fprintf_ctx, "%s", cmd);
}
void shell_vt100_color_set(const struct shell *shell,
enum shell_vt100_color color)
void z_shell_vt100_color_set(const struct shell *shell,
enum shell_vt100_color color)
{
if (shell->ctx->vt100_ctx.col.col == color) {
@ -428,18 +427,18 @@ void shell_vt100_color_set(const struct shell *shell,
uint8_t cmd[] = SHELL_VT100_COLOR(color - 1);
shell_raw_fprintf(shell->fprintf_ctx, "%s", cmd);
z_shell_raw_fprintf(shell->fprintf_ctx, "%s", cmd);
} else {
static const uint8_t cmd[] = SHELL_VT100_MODESOFF;
shell_raw_fprintf(shell->fprintf_ctx, "%s", cmd);
z_shell_raw_fprintf(shell->fprintf_ctx, "%s", cmd);
}
}
void shell_vt100_colors_restore(const struct shell *shell,
void z_shell_vt100_colors_restore(const struct shell *shell,
const struct shell_vt100_colors *color)
{
shell_vt100_color_set(shell, color->col);
z_shell_vt100_color_set(shell, color->col);
vt100_bgcolor_set(shell, color->bgcol);
}
@ -451,12 +450,12 @@ void z_shell_vfprintf(const struct shell *shell, enum shell_vt100_color color,
(color != shell->ctx->vt100_ctx.col.col)) {
struct shell_vt100_colors col;
shell_vt100_colors_store(shell, &col);
shell_vt100_color_set(shell, color);
z_shell_vt100_colors_store(shell, &col);
z_shell_vt100_color_set(shell, color);
z_shell_fprintf_fmt(shell->fprintf_ctx, fmt, args);
shell_vt100_colors_restore(shell, &col);
z_shell_vt100_colors_restore(shell, &col);
} else {
z_shell_fprintf_fmt(shell->fprintf_ctx, fmt, args);
}

View file

@ -15,8 +15,8 @@
extern "C" {
#endif
static inline void shell_raw_fprintf(const struct shell_fprintf *const ctx,
const char *fmt, ...)
static inline void z_shell_raw_fprintf(const struct shell_fprintf *const ctx,
const char *fmt, ...)
{
va_list args;
@ -26,161 +26,155 @@ static inline void shell_raw_fprintf(const struct shell_fprintf *const ctx,
}
/* Macro to send VT100 commands. */
#define SHELL_VT100_CMD(_shell_, _cmd_) \
#define Z_SHELL_VT100_CMD(_shell_, _cmd_) \
do { \
static const char cmd[] = _cmd_; \
shell_raw_fprintf(_shell_->fprintf_ctx, "%s", cmd); \
z_shell_raw_fprintf(_shell_->fprintf_ctx, "%s", cmd); \
} while (0)
/* Function sends VT100 command to clear the screen from cursor position to
* end of the screen.
*/
static inline void clear_eos(const struct shell *shell)
static inline void z_clear_eos(const struct shell *shell)
{
SHELL_VT100_CMD(shell, SHELL_VT100_CLEAREOS);
Z_SHELL_VT100_CMD(shell, SHELL_VT100_CLEAREOS);
}
/* Function sends VT100 command to save cursor position. */
static inline void cursor_save(const struct shell *shell)
static inline void z_cursor_save(const struct shell *shell)
{
SHELL_VT100_CMD(shell, SHELL_VT100_SAVECURSOR);
Z_SHELL_VT100_CMD(shell, SHELL_VT100_SAVECURSOR);
}
/* Function sends VT100 command to restore saved cursor position. */
static inline void cursor_restore(const struct shell *shell)
static inline void z_cursor_restore(const struct shell *shell)
{
SHELL_VT100_CMD(shell, SHELL_VT100_RESTORECURSOR);
Z_SHELL_VT100_CMD(shell, SHELL_VT100_RESTORECURSOR);
}
/* Function forcing new line - cannot be replaced with function
* cursor_down_move.
*/
static inline void cursor_next_line_move(const struct shell *shell)
static inline void z_cursor_next_line_move(const struct shell *shell)
{
shell_raw_fprintf(shell->fprintf_ctx, "\n");
z_shell_raw_fprintf(shell->fprintf_ctx, "\n");
}
/* Function sends 1 character to the shell instance. */
static inline void shell_putc(const struct shell *shell, char ch)
{
shell_raw_fprintf(shell->fprintf_ctx, "%c", ch);
}
static inline bool flag_insert_mode_get(const struct shell *shell)
static inline bool z_flag_insert_mode_get(const struct shell *shell)
{
return shell->ctx->internal.flags.insert_mode == 1;
}
static inline void flag_insert_mode_set(const struct shell *shell, bool val)
static inline void z_flag_insert_mode_set(const struct shell *shell, bool val)
{
shell->ctx->internal.flags.insert_mode = val ? 1 : 0;
}
static inline bool flag_use_colors_get(const struct shell *shell)
static inline bool z_flag_use_colors_get(const struct shell *shell)
{
return shell->ctx->internal.flags.use_colors == 1;
}
static inline void flag_use_colors_set(const struct shell *shell, bool val)
static inline void z_flag_use_colors_set(const struct shell *shell, bool val)
{
shell->ctx->internal.flags.use_colors = val ? 1 : 0;
}
static inline bool flag_echo_get(const struct shell *shell)
static inline bool z_flag_echo_get(const struct shell *shell)
{
return shell->ctx->internal.flags.echo == 1;
}
static inline void flag_echo_set(const struct shell *shell, bool val)
static inline void z_flag_echo_set(const struct shell *shell, bool val)
{
shell->ctx->internal.flags.echo = val ? 1 : 0;
}
static inline bool flag_processing_get(const struct shell *shell)
static inline bool z_flag_processing_get(const struct shell *shell)
{
return shell->ctx->internal.flags.processing == 1;
}
static inline bool flag_tx_rdy_get(const struct shell *shell)
static inline bool z_flag_tx_rdy_get(const struct shell *shell)
{
return shell->ctx->internal.flags.tx_rdy == 1;
}
static inline void flag_tx_rdy_set(const struct shell *shell, bool val)
static inline void z_flag_tx_rdy_set(const struct shell *shell, bool val)
{
shell->ctx->internal.flags.tx_rdy = val ? 1 : 0;
}
static inline bool flag_mode_delete_get(const struct shell *shell)
static inline bool z_flag_mode_delete_get(const struct shell *shell)
{
return shell->ctx->internal.flags.mode_delete == 1;
}
static inline void flag_mode_delete_set(const struct shell *shell, bool val)
static inline void z_flag_mode_delete_set(const struct shell *shell, bool val)
{
shell->ctx->internal.flags.mode_delete = val ? 1 : 0;
}
static inline bool flag_history_exit_get(const struct shell *shell)
static inline bool z_flag_history_exit_get(const struct shell *shell)
{
return shell->ctx->internal.flags.history_exit == 1;
}
static inline void flag_history_exit_set(const struct shell *shell, bool val)
static inline void z_flag_history_exit_set(const struct shell *shell, bool val)
{
shell->ctx->internal.flags.history_exit = val ? 1 : 0;
}
static inline bool flag_cmd_ctx_get(const struct shell *shell)
static inline bool z_flag_cmd_ctx_get(const struct shell *shell)
{
return shell->ctx->internal.flags.cmd_ctx == 1;
}
static inline void flag_cmd_ctx_set(const struct shell *shell, bool val)
static inline void z_flag_cmd_ctx_set(const struct shell *shell, bool val)
{
shell->ctx->internal.flags.cmd_ctx = val ? 1 : 0;
}
static inline uint8_t flag_last_nl_get(const struct shell *shell)
static inline uint8_t z_flag_last_nl_get(const struct shell *shell)
{
return shell->ctx->internal.flags.last_nl;
}
static inline void flag_last_nl_set(const struct shell *shell, uint8_t val)
static inline void z_flag_last_nl_set(const struct shell *shell, uint8_t val)
{
shell->ctx->internal.flags.last_nl = val;
}
static inline bool flag_print_noinit_get(const struct shell *shell)
static inline bool z_flag_print_noinit_get(const struct shell *shell)
{
return shell->ctx->internal.flags.print_noinit == 1;
}
static inline void flag_print_noinit_set(const struct shell *shell, bool val)
static inline void z_flag_print_noinit_set(const struct shell *shell, bool val)
{
shell->ctx->internal.flags.print_noinit = val ? 1 : 0;
}
void shell_op_cursor_vert_move(const struct shell *shell, int32_t delta);
void shell_op_cursor_horiz_move(const struct shell *shell, int32_t delta);
void z_shell_op_cursor_vert_move(const struct shell *shell, int32_t delta);
void z_shell_op_cursor_horiz_move(const struct shell *shell, int32_t delta);
void shell_op_cond_next_line(const struct shell *shell);
void z_shell_op_cond_next_line(const struct shell *shell);
/* Function will move cursor back to position == cmd_buff_pos. Example usage is
* when cursor needs to be moved back after printing some text. This function
* cannot be used to move cursor to new location by manual change of
* cmd_buff_pos.
*/
void shell_op_cursor_position_synchronize(const struct shell *shell);
void z_shell_op_cursor_position_synchronize(const struct shell *shell);
void shell_op_cursor_move(const struct shell *shell, int16_t val);
void z_shell_op_cursor_move(const struct shell *shell, int16_t val);
void shell_op_left_arrow(const struct shell *shell);
void z_shell_op_left_arrow(const struct shell *shell);
void shell_op_right_arrow(const struct shell *shell);
void z_shell_op_right_arrow(const struct shell *shell);
/* Moves cursor by defined number of words left (val negative) or right. */
void shell_op_cursor_word_move(const struct shell *shell, int16_t val);
void z_shell_op_cursor_word_move(const struct shell *shell, int16_t val);
/*
* Removes the "word" to the left of the cursor:
@ -188,45 +182,45 @@ void shell_op_cursor_word_move(const struct shell *shell, int16_t val);
* - remove the non-spaces (word) until a space is found or a beginning of
* buffer
*/
void shell_op_word_remove(const struct shell *shell);
void z_shell_op_word_remove(const struct shell *shell);
/* Function moves cursor to begin of command position, just after console
* name.
*/
void shell_op_cursor_home_move(const struct shell *shell);
void z_shell_op_cursor_home_move(const struct shell *shell);
/* Function moves cursor to end of command. */
void shell_op_cursor_end_move(const struct shell *shell);
void z_shell_op_cursor_end_move(const struct shell *shell);
void shell_op_char_insert(const struct shell *shell, char data);
void z_shell_op_char_insert(const struct shell *shell, char data);
void shell_op_char_backspace(const struct shell *shell);
void z_shell_op_char_backspace(const struct shell *shell);
void shell_op_char_delete(const struct shell *shell);
void z_shell_op_char_delete(const struct shell *shell);
void shell_op_delete_from_cursor(const struct shell *shell);
void z_shell_op_delete_from_cursor(const struct shell *shell);
void shell_op_completion_insert(const struct shell *shell,
const char *compl,
uint16_t compl_len);
void z_shell_op_completion_insert(const struct shell *shell,
const char *compl,
uint16_t compl_len);
bool shell_cursor_in_empty_line(const struct shell *shell);
bool z_shell_cursor_in_empty_line(const struct shell *shell);
void shell_cmd_line_erase(const struct shell *shell);
void z_shell_cmd_line_erase(const struct shell *shell);
/**
* @brief Print command buffer.
*
* @param shell Shell instance.
*/
void shell_print_cmd(const struct shell *shell);
void z_shell_print_cmd(const struct shell *shell);
/**
* @brief Print prompt followed by command buffer.
*
* @param shell Shell instance.
*/
void shell_print_prompt_and_cmd(const struct shell *shell);
void z_shell_print_prompt_and_cmd(const struct shell *shell);
/* Function sends data stream to the shell instance. Each time before the
* shell_write function is called, it must be ensured that IO buffer of fprintf
@ -236,8 +230,7 @@ void shell_print_prompt_and_cmd(const struct shell *shell);
* This function can be only used by shell module, it shall not be called
* directly.
*/
void shell_write(const struct shell *shell, const void *data,
size_t length);
void z_shell_write(const struct shell *shell, const void *data, size_t length);
/**
* @internal @brief This function shall not be used directly, it is required by
@ -250,17 +243,17 @@ void shell_write(const struct shell *shell, const void *data,
void z_shell_print_stream(const void *user_ctx, const char *data, size_t len);
/** @internal @brief Function for setting font color */
void shell_vt100_color_set(const struct shell *shell,
enum shell_vt100_color color);
void z_shell_vt100_color_set(const struct shell *shell,
enum shell_vt100_color color);
static inline void shell_vt100_colors_store(const struct shell *shell,
struct shell_vt100_colors *color)
static inline void z_shell_vt100_colors_store(const struct shell *shell,
struct shell_vt100_colors *color)
{
memcpy(color, &shell->ctx->vt100_ctx.col, sizeof(*color));
}
void shell_vt100_colors_restore(const struct shell *shell,
const struct shell_vt100_colors *color);
void z_shell_vt100_colors_restore(const struct shell *shell,
const struct shell_vt100_colors *color);
/* This function can be called only within shell thread but not from command
* handlers.