diff --git a/src/geadline.🗿 b/src/geadline.🗿 index 9aaa69e..4301176 100644 --- a/src/geadline.🗿 +++ b/src/geadline.🗿 @@ -1,14 +1,28 @@ -geadline(prompt) { +geadline2(prompt, text) +{ local capacity = 64, size = 0, i = 0, c, a, - buf = galloc(capacity); - if (prompt) - putstr(prompt); + buf; + if (text) { + size = strlen(text); + i = size; + loop { + if (capacity > size) + break; + capacity = capacity * 2; + } + buf = galloc(capacity); + strcpy(buf, text); + } else + buf = galloc(capacity); if (buf == NULL) return NULL; + if (prompt) + putstr(prompt); + putstr(buf); [buf] = 0; loop { @@ -104,7 +118,13 @@ geadline(prompt) { } } -esccode(c) { +geadline(prompt) +{ + geadline2(prompt, NULL); +} + +esccode(c) +{ wrt 0x1b; wrt '['; wrt c;