frontend: switch to new bluelib tty interface
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include "buffer.h"
|
||||
#include "cursor.h"
|
||||
#include "hl-range.h"
|
||||
#include "tty.h"
|
||||
#include <blue/term/tty.h>
|
||||
|
||||
/* prints the provided string to the terminal, applying any relevant highlight ranges.
|
||||
* this function prints all characters in `s` until it encounters a null char (\0) or
|
||||
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
void print_text(struct line_ed *ed, unsigned int x, unsigned int y, const char *s)
|
||||
{
|
||||
struct s_tty *tty = s_get_tty();
|
||||
b_tty *tty = ed->l_tty;
|
||||
struct hl_range *cur_range = get_hl_range(ed, x, y);
|
||||
|
||||
for (unsigned int i = 0; s[i] != '\n' && s[i] != '\0'; i++) {
|
||||
if (!cur_range) {
|
||||
s_tty_reset_vmode(tty);
|
||||
b_tty_reset_vmode(tty);
|
||||
fputc(s[i], stdout);
|
||||
continue;
|
||||
}
|
||||
@@ -96,18 +96,18 @@ void put_refresh(struct line_ed *ed, struct refresh_state *state)
|
||||
size_t line_len = strcspn(line_buf, "\n");
|
||||
|
||||
/* the index of the first char in line_buf that needs to be reprinted */
|
||||
unsigned int start_x = state->r_prev_cursor_x;
|
||||
int start_x = state->r_prev_cursor_x;
|
||||
|
||||
/* the distance between the first char to be reprinted and the end
|
||||
* of the line.
|
||||
* the physical cursor will be moved back by this amount after the
|
||||
* line is reprinted. */
|
||||
unsigned int cursor_rdelta = line_len - start_x;
|
||||
int cursor_rdelta = (int)(line_len - start_x);
|
||||
|
||||
if (ed->l_flags & LINE_ED_FULL_REPRINT) {
|
||||
if (start_x) {
|
||||
//fprintf(stdout, "\033[%uD", start_x);
|
||||
s_tty_move_cursor_x(ed->l_tty, TTY_POS_CURSOR, -start_x);
|
||||
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -start_x);
|
||||
}
|
||||
|
||||
start_x = 0;
|
||||
@@ -119,7 +119,7 @@ void put_refresh(struct line_ed *ed, struct refresh_state *state)
|
||||
* so that the physical cursor will be placed AFTER the character that
|
||||
* was just inserted. */
|
||||
cursor_rdelta--;
|
||||
s_tty_move_cursor_x(ed->l_tty, TTY_POS_CURSOR, -cursor_rdelta);
|
||||
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -cursor_rdelta);
|
||||
|
||||
#if 0
|
||||
for (unsigned int i = 0; i < cursor_rdelta; i++) {
|
||||
@@ -162,21 +162,21 @@ void backspace_nl_refresh(struct line_ed *ed, struct refresh_state *state)
|
||||
* has just been moved up. from here, clear this line and the rest
|
||||
* from the screen. */
|
||||
//fputs("\033[J", stdout);
|
||||
s_tty_clear(ed->l_tty, TTY_CLEAR_SCREEN | TTY_CLEAR_FROM_CURSOR);
|
||||
b_tty_clear(ed->l_tty, B_TTY_CLEAR_SCREEN | B_TTY_CLEAR_FROM_CURSOR);
|
||||
|
||||
if (ed->l_flags & LINE_ED_FULL_REPRINT) {
|
||||
/* next, move the physical cursor up and to the beginning of the previous line */
|
||||
unsigned int tmp_x;
|
||||
line_ed_coords_to_physical_coords(ed, 0, ed->l_cursor_y, &tmp_x, NULL);
|
||||
s_tty_move_cursor_y(ed->l_tty, TTY_POS_CURSOR, -1);
|
||||
s_tty_move_cursor_x(ed->l_tty, TTY_POS_START, tmp_x);
|
||||
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, tmp_x);
|
||||
//fprintf(stdout, "\033[A\033[%uG", tmp_x + 1);
|
||||
start_x = 0;
|
||||
} else {
|
||||
/* next, move the physical cursor up and to the end of the previous line */
|
||||
//fprintf(stdout, "\033[A\033[%uG", new_x);
|
||||
s_tty_move_cursor_y(ed->l_tty, TTY_POS_CURSOR, -1);
|
||||
s_tty_move_cursor_x(ed->l_tty, TTY_POS_START, new_x);
|
||||
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, new_x);
|
||||
}
|
||||
|
||||
/* now reprint all of the buffer lines, starting with the first of the
|
||||
@@ -202,11 +202,11 @@ void backspace_nl_refresh(struct line_ed *ed, struct refresh_state *state)
|
||||
* were concatenated. */
|
||||
if (ydiff) {
|
||||
//fprintf(stdout, "\033[%uA", ydiff);
|
||||
s_tty_move_cursor_y(ed->l_tty, TTY_POS_CURSOR, ydiff);
|
||||
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, ydiff);
|
||||
}
|
||||
|
||||
//fprintf(stdout, "\033[%uG", new_x);
|
||||
s_tty_move_cursor_x(ed->l_tty, TTY_POS_START, new_x);
|
||||
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, new_x);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
@@ -220,26 +220,26 @@ void backspace_simple_refresh(struct line_ed *ed, struct refresh_state *state)
|
||||
size_t line_len = strcspn(line_buf, "\n");
|
||||
|
||||
/* the index of the first char in line_buf that needs to be reprinted */
|
||||
unsigned int start_x = ed->l_cursor_x;
|
||||
int start_x = ed->l_cursor_x;
|
||||
//get_data_cursor_position(ed, &start_x, NULL);
|
||||
|
||||
/* the distance between the first char to be reprinted and the end
|
||||
* of the line.
|
||||
* the physical cursor will be moved back by this amount after the
|
||||
* line is reprinted. */
|
||||
unsigned int cursor_rdelta = line_len - start_x;
|
||||
int cursor_rdelta = (int)(line_len - start_x);
|
||||
|
||||
if (ed->l_flags & LINE_ED_FULL_REPRINT) {
|
||||
if (start_x) {
|
||||
//fprintf(stdout, "\033[%uD", start_x);
|
||||
s_tty_move_cursor_x(ed->l_tty, TTY_POS_CURSOR, -start_x);
|
||||
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -start_x);
|
||||
}
|
||||
|
||||
start_x = 0;
|
||||
}
|
||||
|
||||
//fputc('\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);
|
||||
print_text(ed, start_x, ed->l_cursor_y, line_buf + start_x);
|
||||
fputc(' ', stdout);
|
||||
|
||||
@@ -248,7 +248,7 @@ void backspace_simple_refresh(struct line_ed *ed, struct refresh_state *state)
|
||||
* the fact that backspace was just pressed) */
|
||||
cursor_rdelta++;
|
||||
|
||||
s_tty_move_cursor_x(ed->l_tty, TTY_POS_CURSOR, -cursor_rdelta);
|
||||
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -cursor_rdelta);
|
||||
|
||||
#if 0
|
||||
for (unsigned int i = 0; i < cursor_rdelta; i++) {
|
||||
|
||||
Reference in New Issue
Block a user