Lines Matching full:sh
73 static int cursor_position_get(const struct shell *sh, uint16_t *x, uint16_t *y) in cursor_position_get() argument
82 memset(sh->ctx->temp_buff, 0, sizeof(sh->ctx->temp_buff)); in cursor_position_get()
87 z_shell_raw_fprintf(sh->fprintf_ctx, cmd_get_terminal_size); in cursor_position_get()
92 z_transport_buffer_flush(sh); in cursor_position_get()
97 (void)sh->iface->api->read(sh->iface, &c, in cursor_position_get()
104 (sh->ctx->temp_buff[0] != in cursor_position_get()
110 sh->ctx->temp_buff[buff_idx] = '\0'; in cursor_position_get()
111 if (sh->ctx->temp_buff[1] != '[') { in cursor_position_get()
112 sh->ctx->temp_buff[0] = 0; in cursor_position_get()
121 while (sh->ctx->temp_buff[buff_idx] != ';') { in cursor_position_get()
123 (sh->ctx->temp_buff[buff_idx++] - in cursor_position_get()
135 while (sh->ctx->temp_buff[buff_idx] in cursor_position_get()
138 (sh->ctx->temp_buff[buff_idx++] - in cursor_position_get()
156 sh->ctx->temp_buff[0] = 0; in cursor_position_get()
161 sh->ctx->temp_buff[buff_idx] = c; in cursor_position_get()
164 sh->ctx->temp_buff[0] = 0; in cursor_position_get()
178 static int terminal_size_get(const struct shell *sh) in terminal_size_get() argument
184 z_cursor_save(sh); in terminal_size_get()
188 z_shell_op_cursor_vert_move(sh, -SHELL_MAX_TERMINAL_SIZE); in terminal_size_get()
190 z_shell_op_cursor_horiz_move(sh, SHELL_MAX_TERMINAL_SIZE); in terminal_size_get()
192 if (cursor_position_get(sh, &x, &y) == 0) { in terminal_size_get()
193 sh->ctx->vt100_ctx.cons.terminal_wid = x; in terminal_size_get()
194 sh->ctx->vt100_ctx.cons.terminal_hei = y; in terminal_size_get()
199 z_cursor_restore(sh); in terminal_size_get()
203 static int cmd_comment(const struct shell *sh, size_t argc, char **argv) in cmd_comment() argument
205 ARG_UNUSED(sh); in cmd_comment()
212 static int cmd_clear(const struct shell *sh, size_t argc, char **argv) in cmd_clear() argument
216 Z_SHELL_VT100_CMD(sh, SHELL_VT100_CURSORHOME); in cmd_clear()
217 Z_SHELL_VT100_CMD(sh, SHELL_VT100_CLEARSCREEN); in cmd_clear()
222 static int cmd_backends(const struct shell *sh, size_t argc, char **argv) in cmd_backends() argument
229 shell_print(sh, "Active shell backends:"); in cmd_backends()
231 shell_print(sh, " %2d. :%s (%s)", cnt++, obj->ctx->prompt, obj->name); in cmd_backends()
237 static int cmd_bacskpace_mode_backspace(const struct shell *sh, size_t argc, in cmd_bacskpace_mode_backspace() argument
243 z_flag_mode_delete_set(sh, false); in cmd_bacskpace_mode_backspace()
248 static int cmd_bacskpace_mode_delete(const struct shell *sh, size_t argc, in cmd_bacskpace_mode_delete() argument
254 z_flag_mode_delete_set(sh, true); in cmd_bacskpace_mode_delete()
259 static int cmd_colors_off(const struct shell *sh, size_t argc, char **argv) in cmd_colors_off() argument
264 z_flag_use_colors_set(sh, false); in cmd_colors_off()
269 static int cmd_colors_on(const struct shell *sh, size_t argc, char **argv) in cmd_colors_on() argument
274 z_flag_use_colors_set(sh, true); in cmd_colors_on()
279 static int cmd_vt100_off(const struct shell *sh, size_t argc, char **argv) in cmd_vt100_off() argument
284 z_flag_use_vt100_set(sh, false); in cmd_vt100_off()
289 static int cmd_vt100_on(const struct shell *sh, size_t argc, char **argv) in cmd_vt100_on() argument
294 z_flag_use_vt100_set(sh, true); in cmd_vt100_on()
299 static int cmd_prompt_off(const struct shell *sh, size_t argc, char **argv) in cmd_prompt_off() argument
304 shell_prompt_change(sh, ""); in cmd_prompt_off()
309 static int cmd_prompt_on(const struct shell *sh, size_t argc, char **argv) in cmd_prompt_on() argument
314 shell_prompt_change(sh, sh->default_prompt); in cmd_prompt_on()
319 static int cmd_echo_off(const struct shell *sh, size_t argc, char **argv) in cmd_echo_off() argument
324 z_flag_echo_set(sh, false); in cmd_echo_off()
329 static int cmd_echo_on(const struct shell *sh, size_t argc, char **argv) in cmd_echo_on() argument
334 z_flag_echo_set(sh, true); in cmd_echo_on()
339 static int cmd_echo(const struct shell *sh, size_t argc, char **argv) in cmd_echo() argument
342 shell_error(sh, "%s:%s%s", argv[0], in cmd_echo()
347 shell_print(sh, "Echo status: %s", in cmd_echo()
348 z_flag_echo_get(sh) ? "on" : "off"); in cmd_echo()
353 static int cmd_history(const struct shell *sh, size_t argc, char **argv) in cmd_history() argument
362 z_shell_history_get(sh->history, true, in cmd_history()
363 sh->ctx->temp_buff, &len); in cmd_history()
366 shell_print(sh, "[%3d] %s", in cmd_history()
367 (int)i++, sh->ctx->temp_buff); in cmd_history()
374 sh->ctx->temp_buff[0] = '\0'; in cmd_history()
379 static int cmd_shell_stats_show(const struct shell *sh, size_t argc, in cmd_shell_stats_show() argument
385 shell_print(sh, "Lost logs: %lu", sh->stats->log_lost_cnt); in cmd_shell_stats_show()
390 static int cmd_shell_stats_reset(const struct shell *sh, in cmd_shell_stats_reset() argument
396 sh->stats->log_lost_cnt = 0; in cmd_shell_stats_reset()
401 static int cmd_resize_default(const struct shell *sh, in cmd_resize_default() argument
407 Z_SHELL_VT100_CMD(sh, SHELL_VT100_SETCOL_80); in cmd_resize_default()
408 sh->ctx->vt100_ctx.cons.terminal_wid = CONFIG_SHELL_DEFAULT_TERMINAL_WIDTH; in cmd_resize_default()
409 sh->ctx->vt100_ctx.cons.terminal_hei = CONFIG_SHELL_DEFAULT_TERMINAL_HEIGHT; in cmd_resize_default()
414 static int cmd_resize(const struct shell *sh, size_t argc, char **argv) in cmd_resize() argument
419 shell_error(sh, "%s:%s%s", argv[0], in cmd_resize()
424 err = terminal_size_get(sh); in cmd_resize()
426 sh->ctx->vt100_ctx.cons.terminal_wid = in cmd_resize()
428 sh->ctx->vt100_ctx.cons.terminal_hei = in cmd_resize()
430 shell_warn(sh, "No response from the terminal, assumed 80x24" in cmd_resize()
438 static int cmd_get_retval(const struct shell *sh, size_t argc, char **argv) in cmd_get_retval() argument
443 shell_print(sh, "%d", shell_get_return_value(sh)); in cmd_get_retval()
452 static int cmd_select(const struct shell *sh, size_t argc, char **argv) in cmd_select() argument
460 candidate = z_shell_get_last_command(sh->ctx->selected_cmd, in cmd_select()
466 sh->ctx->selected_cmd = candidate; in cmd_select()
470 shell_error(sh, "Cannot select command"); in cmd_select()