ucode-mod-uline: fix prompt after set_hint with string bigger than the window size
authorFelix Fietkau <nbd@nbd.name>
Mon, 24 Feb 2025 12:30:36 +0000 (13:30 +0100)
committerFelix Fietkau <nbd@nbd.name>
Mon, 24 Feb 2025 12:31:53 +0000 (13:31 +0100)
Redraw the prompt after the hint instead of trying to move backwards

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/utils/ucode-mod-uline/src/uline.c

index 4bee2597c3fab389a12231bdada3a8a1b00f11ed..26cea6fa246fd418164b23690032d62369e5628c 100644 (file)
@@ -880,7 +880,14 @@ void uline_set_hint(struct uline_state *s, const char *str, size_t len)
                pos_add_string(s, &s->cursor_pos, str, len);
        }
 
-       set_cursor(s, prev_pos);
+       if (s->cursor_pos.y >= s->rows) {
+               if (s->cursor_pos.x > 0)
+                       vt100_next_line(s->output);
+               s->cursor_pos = (struct pos){};
+               s->full_update = true;
+       } else {
+               set_cursor(s, prev_pos);
+       }
        fflush(s->output);
 }