Compare commits

..

No commits in common. "a84415a953b17ff349bdd38a93cac19f0a3a4b01" and "09e0d32c15bd33c56d212e249edc0f6f23e626f2" have entirely different histories.

View File

@ -1,35 +1,18 @@
geadline2(prompt, text)
{
geadline(prompt) {
local capacity = 64,
size = 0,
i = 0,
c,
a,
buf;
if (text) {
size = strlen(text);
i = size;
loop {
if (capacity > size)
break;
capacity = capacity * 2;
}
buf = galloc(capacity);
if (buf == NULL)
return NULL;
strcpy(buf, text);
} else {
buf = galloc(capacity);
if (buf == NULL)
return NULL;
[buf] = 0;
}
buf = galloc(capacity);
if (prompt)
putstr(prompt);
putstr(buf);
if (buf == NULL)
return NULL;
[buf] = 0;
loop {
c = getchar();
red &c;
if ((c == 0xffff) | (c == 0x04)) {
if ((size == 0) | (c == 0xffff)) {
free(buf);
@ -37,8 +20,8 @@ geadline2(prompt, text)
}
} else if (c == 0x1b) {
// ESC code
getchar(); // skip [
c = getchar(); // value
red &c; // skip [
red &c; // value
if ((c == 'A') & (size > 0)) {
loop {
@ -121,13 +104,7 @@ geadline2(prompt, text)
}
}
geadline(prompt)
{
geadline2(prompt, NULL);
}
esccode(c)
{
esccode(c) {
wrt 0x1b;
wrt '[';
wrt c;