forked from Bananymous/banan-os
Shell: we now support left/right arrows
This commit is contained in:
parent
480842a203
commit
90e48970e6
|
@ -117,12 +117,6 @@ int main(int argc, char** argv)
|
||||||
char c;
|
char c;
|
||||||
fread(&c, 1, sizeof(char), stdin);
|
fread(&c, 1, sizeof(char), stdin);
|
||||||
|
|
||||||
if (got_csi)
|
|
||||||
{
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '\e':
|
case '\e':
|
||||||
|
@ -134,17 +128,17 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
case 'A': if (index > 0) { index--; col = buffers[index].size(); fprintf(stdout, "\e[%dG%s\e[K", prompt_length(prompt) + 1, buffers[index].data()); fflush(stdout); } break;
|
case 'A': if (index > 0) { index--; col = buffers[index].size(); fprintf(stdout, "\e[%dG%s\e[K", prompt_length(prompt) + 1, buffers[index].data()); fflush(stdout); } break;
|
||||||
case 'B': if (index < buffers.size() - 1) { index++; col = buffers[index].size(); fprintf(stdout, "\e[%dG%s\e[K", prompt_length(prompt) + 1, buffers[index].data()); fflush(stdout); } break;
|
case 'B': if (index < buffers.size() - 1) { index++; col = buffers[index].size(); fprintf(stdout, "\e[%dG%s\e[K", prompt_length(prompt) + 1, buffers[index].data()); fflush(stdout); } break;
|
||||||
case 'C': break;
|
case 'C': if (col < buffers[index].size() - 1) { col++; fprintf(stdout, "\e[C"); fflush(stdout); } break;
|
||||||
case 'D': break;
|
case 'D': if (col > 0) { col--; fprintf(stdout, "\e[D"); fflush(stdout); } break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\b':
|
case '\b':
|
||||||
if (col > 0)
|
if (col > 0)
|
||||||
{
|
{
|
||||||
buffers[index].pop_back();
|
|
||||||
fprintf(stdout, "\b \b");
|
|
||||||
fflush(stdout);
|
|
||||||
col--;
|
col--;
|
||||||
|
buffers[index].remove(col);
|
||||||
|
fprintf(stdout, "\b\e[s%s\e[K\e[u", buffers[index].data() + col);
|
||||||
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
|
|
Loading…
Reference in New Issue