frontend: switch to new bluelib tty interface

This commit is contained in:
2024-11-20 22:14:35 +00:00
parent 92f407ac09
commit 17ee2b6b57
14 changed files with 86 additions and 1666 deletions

View File

@@ -113,7 +113,7 @@ void cursor_left(struct line_ed *ed)
{
if (ed->l_cursor_x != 0) {
//fputs("\010", stdout);
s_tty_move_cursor_x(ed->l_tty, TTY_POS_CURSOR, -1);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -1);
fflush(stdout);
ed->l_cursor_x--;
ed->l_buf_ptr--;
@@ -135,8 +135,8 @@ void cursor_left(struct line_ed *ed)
ed->l_cursor_x = len - 1;
//printf("\033[A\033[%dG", len + prompt_len);
s_tty_move_cursor_y(ed->l_tty, TTY_POS_CURSOR, -1);
s_tty_move_cursor_x(ed->l_tty, TTY_POS_START, len + prompt_len);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, -1);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, len + prompt_len);
fflush(stdout);
}
@@ -151,7 +151,7 @@ void cursor_right(struct line_ed *ed)
ed->l_cursor_x++;
ed->l_buf_ptr++;
//fputs("\033[C", stdout);
s_tty_move_cursor_x(ed->l_tty, TTY_POS_CURSOR, 1);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, 1);
fflush(stdout);
return;
}
@@ -165,8 +165,8 @@ void cursor_right(struct line_ed *ed)
ed->l_buf_ptr++;
//printf("\033[B\033[G");
s_tty_move_cursor_y(ed->l_tty, TTY_POS_CURSOR, 1);
s_tty_move_cursor_x(ed->l_tty, TTY_POS_START, 0);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, 1);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, 0);
fflush(stdout);
}
@@ -178,13 +178,13 @@ void arrow_up(struct line_ed *ed)
if (ed->l_cursor_y > 0) {
//printf("\033[%uA", ed->l_cursor_y);
s_tty_move_cursor_y(ed->l_tty, TTY_POS_CURSOR, ed->l_cursor_y);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, ed->l_cursor_y);
}
//printf("\033[%zuG\033[J", prompt_length(ed, PROMPT_MAIN) + 1);
s_tty_move_cursor_x(
ed->l_tty, TTY_POS_START, prompt_length(ed, PROMPT_MAIN));
s_tty_clear(ed->l_tty, TTY_CLEAR_SCREEN | TTY_CLEAR_FROM_CURSOR);
b_tty_move_cursor_x(
ed->l_tty, B_TTY_POS_START, prompt_length(ed, PROMPT_MAIN));
b_tty_clear(ed->l_tty, B_TTY_CLEAR_SCREEN | B_TTY_CLEAR_FROM_CURSOR);
save_buf_to_history(ed);
ed->l_history_pos--;
@@ -202,12 +202,12 @@ void arrow_down(struct line_ed *ed)
if (ed->l_cursor_y > 0) {
//printf("\033[%uA", ed->l_cursor_y);
s_tty_move_cursor_y(ed->l_tty, TTY_POS_CURSOR, ed->l_cursor_y);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, ed->l_cursor_y);
}
//printf("\033[%zuG\033[J", prompt_length(ed, PROMPT_MAIN) + 1);
s_tty_move_cursor_x(
ed->l_tty, TTY_POS_START, prompt_length(ed, PROMPT_MAIN) + 1);
b_tty_move_cursor_x(
ed->l_tty, B_TTY_POS_START, prompt_length(ed, PROMPT_MAIN) + 1);
save_buf_to_history(ed);
ed->l_history_pos++;