From 62f368e0070cf99723cd1e9b96e91580385fe1bd Mon Sep 17 00:00:00 2001 From: kdx Date: Tue, 25 Jul 2023 09:21:05 +0200 Subject: [PATCH] geadline2 --- src/geadline.🗿 | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/geadline.🗿 b/src/geadline.🗿 index 9aaa69e..288a048 100644 --- a/src/geadline.🗿 +++ b/src/geadline.🗿 @@ -1,14 +1,25 @@ -geadline(prompt) { +geadline2(prompt, text) +{ local capacity = 64, size = 0, i = 0, c, a, - buf = galloc(capacity); - if (prompt) - putstr(prompt); + buf; + if (text) { + loop { + if (capacity > strlen(text)) + break; + capacity = capacity * 2; + } + buf = galloc(capacity); + strcpy(buf, text); + } else + buf = galloc(capacity); if (buf == NULL) return NULL; + if (prompt) + putstr(prompt); [buf] = 0; loop { @@ -104,7 +115,13 @@ geadline(prompt) { } } -esccode(c) { +geadline(prompt) +{ + geadline2(prompt, NULL); +} + +esccode(c) +{ wrt 0x1b; wrt '['; wrt c;