meta: replace bluelib with fx
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include "input.h"
|
||||
#include "prompt.h"
|
||||
|
||||
#include <blue/term/tty.h>
|
||||
#include <fx/term/tty.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -49,14 +49,14 @@ struct line_ed *line_ed_create(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
out->l_history = b_array_create();
|
||||
out->l_history = fx_array_create();
|
||||
if (!out->l_history) {
|
||||
free(out->l_buf);
|
||||
free(out);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
out->l_tty = b_stdtty;
|
||||
out->l_tty = fx_stdtty;
|
||||
out->l_buf_end = out->l_buf + LINE_MAX;
|
||||
out->l_buf_ptr = out->l_buf;
|
||||
out->l_line_end = out->l_buf;
|
||||
@@ -71,7 +71,7 @@ struct line_ed *line_ed_create(void)
|
||||
|
||||
void line_ed_destroy(struct line_ed *ed)
|
||||
{
|
||||
b_array_unref(ed->l_history);
|
||||
fx_array_unref(ed->l_history);
|
||||
line_ed_clear_highlights(ed);
|
||||
free(ed->l_buf);
|
||||
free(ed);
|
||||
@@ -181,8 +181,8 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
|
||||
append_to_index = ed->l_history_pos;
|
||||
}
|
||||
|
||||
b_tty *tty = ed->l_tty;
|
||||
b_tty_set_mode(tty, B_TTY_RAW);
|
||||
fx_tty *tty = ed->l_tty;
|
||||
fx_tty_set_mode(tty, FX_TTY_RAW);
|
||||
show_prompt(ed);
|
||||
|
||||
for (int i = 0; ed->l_buf[i]; i++) {
|
||||
@@ -198,10 +198,10 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
|
||||
bool eof = false;
|
||||
|
||||
while (!end) {
|
||||
b_keycode key = b_tty_read_key(tty);
|
||||
fx_keycode key = fx_tty_read_key(tty);
|
||||
hook_keypress(ed, key);
|
||||
|
||||
if (key == B_TTY_CTRL_KEY('d')) {
|
||||
if (key == FX_TTY_CTRL_KEY('d')) {
|
||||
if (!input_is_empty(ed)) {
|
||||
continue;
|
||||
}
|
||||
@@ -210,13 +210,13 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
|
||||
break;
|
||||
}
|
||||
|
||||
if (key & B_MOD_CTRL) {
|
||||
if (key & FX_MOD_CTRL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
case B_KEY_RETURN:
|
||||
b_tty_reset_vmode(tty);
|
||||
case FX_KEY_RETURN:
|
||||
fx_tty_reset_vmode(tty);
|
||||
if (ed->l_line_end > ed->l_buf
|
||||
&& *(ed->l_line_end - 1) != '\\') {
|
||||
end = true;
|
||||
@@ -243,19 +243,19 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
|
||||
// fputs("\033[G\n", stdout);
|
||||
show_prompt(ed);
|
||||
break;
|
||||
case B_KEY_BACKSPACE:
|
||||
case FX_KEY_BACKSPACE:
|
||||
backspace(ed);
|
||||
break;
|
||||
case B_KEY_ARROW_LEFT:
|
||||
case FX_KEY_ARROW_LEFT:
|
||||
cursor_left(ed);
|
||||
break;
|
||||
case B_KEY_ARROW_RIGHT:
|
||||
case FX_KEY_ARROW_RIGHT:
|
||||
cursor_right(ed);
|
||||
break;
|
||||
case B_KEY_ARROW_UP:
|
||||
case FX_KEY_ARROW_UP:
|
||||
arrow_up(ed);
|
||||
break;
|
||||
case B_KEY_ARROW_DOWN:
|
||||
case FX_KEY_ARROW_DOWN:
|
||||
arrow_down(ed);
|
||||
break;
|
||||
default:
|
||||
@@ -266,7 +266,7 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
|
||||
}
|
||||
}
|
||||
|
||||
b_tty_set_mode(tty, B_TTY_CANONICAL);
|
||||
fx_tty_set_mode(tty, FX_TTY_CANONICAL);
|
||||
fputc('\n', stdout);
|
||||
|
||||
if (*ed->l_buf == '\0') {
|
||||
@@ -277,7 +277,7 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
|
||||
ed->l_history_pos = append_to_index;
|
||||
append_buf_to_history(ed);
|
||||
} else {
|
||||
ed->l_history_pos = b_array_size(ed->l_history) - 1;
|
||||
ed->l_history_pos = fx_array_size(ed->l_history) - 1;
|
||||
|
||||
const char *last = last_history_line(ed);
|
||||
if (!last || strcmp(last, ed->l_buf) != 0) {
|
||||
|
||||
Reference in New Issue
Block a user