Keep the line input mode prompt on the local screen after input

It is for visibility.
Note: This line input mode prompt is not recorded by tio's logging
function.
This commit is contained in:
yabu76 2026-02-16 23:34:09 +09:00
parent 4153a4571a
commit d5b4e7d881
3 changed files with 13 additions and 0 deletions

View file

@ -39,6 +39,17 @@ typedef struct readline_s
int escape;
} readline_t;
void print_prompt(readline_t *rl)
{
clear_line();
printf("%s", rl->prompt);
printf("\r"); // Move the cursor back to the beginning
for (int i = 0; i < rl->prompt_length; ++i)
{
printf("\x1b[C"); // Move the cursor right
}
}
void print_line(readline_t *rl)
{
clear_line();

View file

@ -32,3 +32,4 @@ void readline_set_prompt(readline_t *rl, const char *prompt);
void readline_prompt_for_input(readline_t *rl);
void readline_input(readline_t *rl, char input_char);
char *readline_get(readline_t *rl);
void print_prompt(readline_t *rl);

View file

@ -3274,6 +3274,7 @@ int tty_connect(void)
{
// Carriage return
readline_input(readline_ctx, input_char);
print_prompt(readline_ctx);
// Write current line to tty device
char *rl_line = readline_get(readline_ctx);