frontend: line-ed: convert all escape code usage to s_tty calls

This commit is contained in:
2024-11-18 21:13:28 +00:00
parent 5a5b0d01d8
commit c5f60c285e
6 changed files with 106 additions and 18 deletions

View File

@@ -208,6 +208,10 @@ long line_ed_readline(struct line_ed *ed, char *out, size_t max)
break;
}
if (key & S_MOD_CTRL) {
continue;
}
switch (key) {
case S_KEY_RETURN:
s_tty_reset_vmode(tty);
@@ -232,7 +236,9 @@ long line_ed_readline(struct line_ed *ed, char *out, size_t max)
ed->l_cursor_x = 0;
ed->l_cursor_y++;
ed->l_continuations++;
fputs("\033[G\n", stdout);
fputc('\r', stdout);
fputc('\n', stdout);
// fputs("\033[G\n", stdout);
show_prompt(ed);
break;
case S_KEY_BACKSPACE:
@@ -251,7 +257,7 @@ long line_ed_readline(struct line_ed *ed, char *out, size_t max)
arrow_down(ed);
break;
default:
if (isgraph(key) || key == ' ') {
if (iswgraph(key) || key == ' ') {
put_char(ed, key);
}
break;
@@ -259,7 +265,7 @@ long line_ed_readline(struct line_ed *ed, char *out, size_t max)
}
s_tty_set_canon(tty);
printf("\n");
fputc('\n', stdout);
if (*ed->l_buf == '\0') {
return eof ? -1 : 0;