shell: fix margin handling after newlines in formatted help text
Lines following newlines in shell help text were not properly indented. For example, in "abc def\ndef ghi\njkl mno", the lines "def ghi" and "jkl mno" would appear without the expected left margin. The issue was that after processing a newline and setting proper cursor position, the function would fall through to z_shell_raw_fprintf() which Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
parent
75bfd799c4
commit
7bdeffb5a6
1 changed files with 7 additions and 0 deletions
|
@ -38,6 +38,7 @@ static void formatted_text_print(const struct shell *sh, const char *str,
|
|||
|
||||
while (true) {
|
||||
size_t idx = 0;
|
||||
bool newline_found = false;
|
||||
|
||||
length = z_shell_strlen(str) - offset;
|
||||
|
||||
|
@ -51,10 +52,16 @@ static void formatted_text_print(const struct shell *sh, const char *str,
|
|||
z_cursor_next_line_move(sh);
|
||||
z_shell_op_cursor_horiz_move(sh,
|
||||
terminal_offset);
|
||||
newline_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we found a newline, continue processing the remaining text */
|
||||
if (newline_found) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* String will fit in one line. */
|
||||
z_shell_raw_fprintf(sh->fprintf_ctx, str + offset);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue