meta: replace bluelib with fx

This commit is contained in:
2026-03-16 14:07:33 +00:00
parent d2abb6faa3
commit e5546f97c2
105 changed files with 1668 additions and 1668 deletions

View File

@@ -1,42 +1,42 @@
#include "line-ed.h"
#include <blue/ds/array.h>
#include <blue/ds/string.h>
#include <fx/ds/array.h>
#include <fx/ds/string.h>
void alloc_empty_history_entry(struct line_ed *ed)
{
b_string *str = (b_string *)b_array_at(
ed->l_history, b_array_size(ed->l_history) - 1);
if (!str || b_string_get_size(str, B_STRLEN_NORMAL) > 0) {
str = b_string_create();
b_array_append(ed->l_history, (b_object *)str);
fx_string *str = (fx_string *)fx_array_at(
ed->l_history, fx_array_size(ed->l_history) - 1);
if (!str || fx_string_get_size(str, FX_STRLEN_NORMAL) > 0) {
str = fx_string_create();
fx_array_append(ed->l_history, (fx_object *)str);
}
ed->l_history_pos = b_array_size(ed->l_history) - 1;
ed->l_history_pos = fx_array_size(ed->l_history) - 1;
}
void save_buf_to_history(struct line_ed *ed)
{
b_string *cur = (b_string *)b_array_get(ed->l_history, ed->l_history_pos);
b_string_replace_all(cur, ed->l_buf);
fx_string *cur = (fx_string *)fx_array_get(ed->l_history, ed->l_history_pos);
fx_string_replace_all(cur, ed->l_buf);
}
void append_buf_to_history(struct line_ed *ed)
{
b_string *cur = (b_string *)b_array_get(ed->l_history, ed->l_history_pos);
fx_string *cur = (fx_string *)fx_array_get(ed->l_history, ed->l_history_pos);
char s[] = {'\n', 0};
b_string_append_cstr(cur, s);
b_string_append_cstr(cur, ed->l_buf);
fx_string_append_cstr(cur, s);
fx_string_append_cstr(cur, ed->l_buf);
}
void load_buf_from_history(struct line_ed *ed)
{
b_string *cur = (b_string *)b_array_at(ed->l_history, ed->l_history_pos);
fx_string *cur = (fx_string *)fx_array_at(ed->l_history, ed->l_history_pos);
size_t len
= MIN((size_t)(ed->l_buf_end - ed->l_buf - 1),
b_string_get_size(cur, B_STRLEN_NORMAL));
fx_string_get_size(cur, FX_STRLEN_NORMAL));
memcpy(ed->l_buf, b_string_ptr(cur), len);
memcpy(ed->l_buf, fx_string_ptr(cur), len);
ed->l_buf[len] = '\0';
unsigned int x = 0, y = 0;
@@ -57,11 +57,11 @@ void load_buf_from_history(struct line_ed *ed)
const char *last_history_line(struct line_ed *ed)
{
size_t nlines = b_array_size(ed->l_history);
size_t nlines = fx_array_size(ed->l_history);
if (nlines < 2) {
return NULL;
}
b_string *last = (b_string *)b_array_at(ed->l_history, nlines - 2);
return b_string_ptr(last);
fx_string *last = (fx_string *)fx_array_at(ed->l_history, nlines - 2);
return fx_string_ptr(last);
}

View File

@@ -30,22 +30,22 @@ int compare_coords(size_t ax, size_t ay, size_t bx, size_t by)
struct hl_range *get_hl_range(struct line_ed *ed, size_t x, size_t y)
{
if (b_queue_empty(&ed->l_hl_ranges)) {
if (fx_queue_empty(&ed->l_hl_ranges)) {
return NULL;
}
struct hl_range *best_match = NULL;
b_queue_entry *entry = b_queue_first(&ed->l_hl_ranges);
fx_queue_entry *entry = fx_queue_first(&ed->l_hl_ranges);
while (entry) {
struct hl_range *cur = b_unbox(struct hl_range, entry, h_entry);
struct hl_range *cur = fx_unbox(struct hl_range, entry, h_entry);
int cmp_end = compare_coords(x, y, cur->h_end_x, cur->h_end_y);
if (cmp_end != 1) {
return cur;
}
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
return NULL;
@@ -53,20 +53,20 @@ struct hl_range *get_hl_range(struct line_ed *ed, size_t x, size_t y)
struct hl_range *get_next_hl_range(struct hl_range *range)
{
b_queue_entry *entry = &range->h_entry;
entry = b_queue_next(entry);
fx_queue_entry *entry = &range->h_entry;
entry = fx_queue_next(entry);
if (!entry) {
return NULL;
}
range = b_unbox(struct hl_range, entry, h_entry);
range = fx_unbox(struct hl_range, entry, h_entry);
return range;
}
int apply_hl_range(struct hl_range *range, b_tty *tty, size_t x, size_t y)
int apply_hl_range(struct hl_range *range, fx_tty *tty, size_t x, size_t y)
{
if (!range) {
b_tty_reset_vmode(tty);
fx_tty_reset_vmode(tty);
return 0;
}
@@ -74,11 +74,11 @@ int apply_hl_range(struct hl_range *range, b_tty *tty, size_t x, size_t y)
int cmp_end = compare_coords(x, y, range->h_end_x, range->h_end_y);
if (cmp_start < 0) {
b_tty_reset_vmode(tty);
fx_tty_reset_vmode(tty);
}
if (cmp_start >= 0 && cmp_end <= 0) {
b_tty_set_vmode(tty, &range->h_vmode);
fx_tty_set_vmode(tty, &range->h_vmode);
}
if (cmp_end == 1) {
@@ -90,7 +90,7 @@ int apply_hl_range(struct hl_range *range, b_tty *tty, size_t x, size_t y)
struct hl_range *create_highlight(
size_t start_x, size_t start_y, size_t end_x, size_t end_y,
const b_tty_vmode *vmode)
const fx_tty_vmode *vmode)
{
struct hl_range *out = malloc(sizeof *out);
if (!out) {
@@ -179,7 +179,7 @@ static void move_start_to_meet_end(
void line_ed_put_highlight(
struct line_ed *ed, unsigned long start_x, unsigned long start_y,
unsigned long end_x, unsigned long end_y, const struct b_tty_vmode *vmode)
unsigned long end_x, unsigned long end_y, const struct fx_tty_vmode *vmode)
{
struct hl_range *highlight
= create_highlight(start_x, start_y, end_x, end_y, vmode);
@@ -189,30 +189,30 @@ void line_ed_put_highlight(
struct hl_range *h2 = NULL;
b_queue_entry *entry = NULL;
entry = b_queue_first(&ed->l_hl_ranges);
fx_queue_entry *entry = NULL;
entry = fx_queue_first(&ed->l_hl_ranges);
if (!entry) {
b_queue_push_back(&ed->l_hl_ranges, &highlight->h_entry);
fx_queue_push_back(&ed->l_hl_ranges, &highlight->h_entry);
return;
}
struct hl_range *cur = NULL;
enum hl_range_comparison prev_cmp = -1;
b_queue_entry *insert_before = NULL;
b_queue_entry *insert_after = NULL;
fx_queue_entry *insert_before = NULL;
fx_queue_entry *insert_after = NULL;
bool end = false;
while (entry) {
b_queue_entry *next = b_queue_next(entry);
cur = b_unbox(struct hl_range, entry, h_entry);
fx_queue_entry *next = fx_queue_next(entry);
cur = fx_unbox(struct hl_range, entry, h_entry);
enum hl_range_comparison cmp = compare_hl_ranges(cur, highlight);
switch (cmp) {
case HL_RANGE_A_IN_B:
b_queue_delete(&ed->l_hl_ranges, entry);
fx_queue_delete(&ed->l_hl_ranges, entry);
free(cur);
break;
case HL_RANGE_B_IN_A:
@@ -220,10 +220,10 @@ void line_ed_put_highlight(
h2 = create_highlight(
0, 0, cur->h_end_x, cur->h_end_y, &cur->h_vmode);
move_start_to_meet_end(h2, highlight);
b_queue_insert_after(
fx_queue_insert_after(
&ed->l_hl_ranges, &highlight->h_entry,
&cur->h_entry);
b_queue_insert_after(
fx_queue_insert_after(
&ed->l_hl_ranges, &h2->h_entry,
&highlight->h_entry);
insert_before = insert_after = NULL;
@@ -239,7 +239,7 @@ void line_ed_put_highlight(
insert_before = entry;
break;
case HL_RANGE_GREATER:
b_queue_insert_before(
fx_queue_insert_before(
&ed->l_hl_ranges, &highlight->h_entry, entry);
insert_before = insert_after = NULL;
end = true;
@@ -255,32 +255,32 @@ void line_ed_put_highlight(
}
if (insert_before) {
b_queue_insert_before(
fx_queue_insert_before(
&ed->l_hl_ranges, &highlight->h_entry, insert_before);
} else if (insert_after) {
b_queue_insert_after(
fx_queue_insert_after(
&ed->l_hl_ranges, &highlight->h_entry, insert_after);
}
}
void line_ed_clear_highlights(struct line_ed *ed)
{
b_queue_entry *entry = b_queue_pop_front(&ed->l_hl_ranges);
fx_queue_entry *entry = fx_queue_pop_front(&ed->l_hl_ranges);
while (entry) {
struct hl_range *range = b_unbox(struct hl_range, entry, h_entry);
struct hl_range *range = fx_unbox(struct hl_range, entry, h_entry);
free(range);
entry = b_queue_pop_front(&ed->l_hl_ranges);
entry = fx_queue_pop_front(&ed->l_hl_ranges);
}
}
void line_ed_print_highlights(struct line_ed *ed)
{
b_queue_entry *entry = b_queue_first(&ed->l_hl_ranges);
fx_queue_entry *entry = fx_queue_first(&ed->l_hl_ranges);
while (entry) {
struct hl_range *h = b_unbox(struct hl_range, entry, h_entry);
struct hl_range *h = fx_unbox(struct hl_range, entry, h_entry);
printf("(%zu, %zu) -> (%zu, %zu)\n", h->h_start_x, h->h_start_y,
h->h_end_x, h->h_end_y);
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
}

View File

@@ -1,9 +1,9 @@
#ifndef LINE_ED_HL_RANGE_H_
#define LINE_ED_HL_RANGE_H_
#include <blue/term/tty.h>
#include <fx/term/tty.h>
#include <blue/core/queue.h>
#include <fx/core/queue.h>
struct line_ed;
@@ -20,18 +20,18 @@ enum hl_range_comparison {
struct hl_range {
size_t h_start_x, h_start_y;
size_t h_end_x, h_end_y;
b_tty_vmode h_vmode;
b_queue_entry h_entry;
fx_tty_vmode h_vmode;
fx_queue_entry h_entry;
};
extern int compare_coords(size_t ax, size_t ay, size_t bx, size_t by);
extern struct hl_range *get_hl_range(struct line_ed *ed, size_t x, size_t y);
extern struct hl_range *get_next_hl_range(struct hl_range *range);
extern int apply_hl_range(struct hl_range *range, b_tty *tty, size_t x, size_t y);
extern int apply_hl_range(struct hl_range *range, fx_tty *tty, size_t x, size_t y);
extern struct hl_range *create_highlight(
size_t start_x, size_t start_y, size_t end_x, size_t end_y,
const struct b_tty_vmode *vmode);
const struct fx_tty_vmode *vmode);
extern enum hl_range_comparison compare_hl_ranges(
const struct hl_range *a, const struct hl_range *b);

View File

@@ -4,38 +4,38 @@
void line_ed_add_hook(struct line_ed *ed, struct line_ed_hook *hook)
{
b_queue_push_back(&ed->l_hooks, &hook->hook_entry);
fx_queue_push_back(&ed->l_hooks, &hook->hook_entry);
}
void line_ed_remove_hook(struct line_ed *ed, struct line_ed_hook *hook)
{
b_queue_delete(&ed->l_hooks, &hook->hook_entry);
fx_queue_delete(&ed->l_hooks, &hook->hook_entry);
}
void hook_keypress(struct line_ed *ed, b_keycode key)
void hook_keypress(struct line_ed *ed, fx_keycode key)
{
b_queue_entry *entry = b_queue_first(&ed->l_hooks);
fx_queue_entry *entry = fx_queue_first(&ed->l_hooks);
while (entry) {
struct line_ed_hook *hook
= b_unbox(struct line_ed_hook, entry, hook_entry);
= fx_unbox(struct line_ed_hook, entry, hook_entry);
if (hook->hook_keypress) {
hook->hook_keypress(ed, hook, key);
}
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
}
void hook_buffer_modified(struct line_ed *ed)
{
b_queue_entry *entry = b_queue_first(&ed->l_hooks);
fx_queue_entry *entry = fx_queue_first(&ed->l_hooks);
while (entry) {
struct line_ed_hook *hook
= b_unbox(struct line_ed_hook, entry, hook_entry);
= fx_unbox(struct line_ed_hook, entry, hook_entry);
if (hook->hook_buffer_modified) {
hook->hook_buffer_modified(ed, hook);
}
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
}

View File

@@ -1,7 +1,7 @@
#ifndef LINE_ED_HOOK_H_
#define LINE_ED_HOOK_H_
#include <blue/term/tty.h>
#include <fx/term/tty.h>
enum hook_id {
HOOK_KEYPRESS,
@@ -10,7 +10,7 @@ enum hook_id {
struct line_ed;
extern void hook_keypress(struct line_ed *ed, b_keycode key);
extern void hook_keypress(struct line_ed *ed, fx_keycode key);
extern void hook_buffer_modified(struct line_ed *ed);
#endif

View File

@@ -113,7 +113,7 @@ void cursor_left(struct line_ed *ed)
{
if (ed->l_cursor_x != 0) {
//fputs("\010", stdout);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -1);
fx_tty_move_cursor_x(ed->l_tty, FX_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);
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, (int)(len + prompt_len));
fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, -1);
fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_START, (int)(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);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, 1);
fx_tty_move_cursor_x(ed->l_tty, FX_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");
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);
fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, 1);
fx_tty_move_cursor_x(ed->l_tty, FX_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);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, (long long)ed->l_cursor_y);
fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, (long long)ed->l_cursor_y);
}
//printf("\033[%zuG\033[J", prompt_length(ed, PROMPT_MAIN) + 1);
b_tty_move_cursor_x(
ed->l_tty, B_TTY_POS_START, (long long)prompt_length(ed, PROMPT_MAIN));
b_tty_clear(ed->l_tty, B_TTY_CLEAR_SCREEN | B_TTY_CLEAR_FROM_CURSOR);
fx_tty_move_cursor_x(
ed->l_tty, FX_TTY_POS_START, (long long)prompt_length(ed, PROMPT_MAIN));
fx_tty_clear(ed->l_tty, FX_TTY_CLEAR_SCREEN | FX_TTY_CLEAR_FROM_CURSOR);
save_buf_to_history(ed);
ed->l_history_pos--;
@@ -196,18 +196,18 @@ void arrow_up(struct line_ed *ed)
void arrow_down(struct line_ed *ed)
{
if (ed->l_history_pos == b_array_size(ed->l_history) - 1) {
if (ed->l_history_pos == fx_array_size(ed->l_history) - 1) {
return;
}
if (ed->l_cursor_y > 0) {
//printf("\033[%uA", ed->l_cursor_y);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, (int)ed->l_cursor_y);
fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, (int)ed->l_cursor_y);
}
//printf("\033[%zuG\033[J", prompt_length(ed, PROMPT_MAIN) + 1);
b_tty_move_cursor_x(
ed->l_tty, B_TTY_POS_START, prompt_length(ed, PROMPT_MAIN) + 1);
fx_tty_move_cursor_x(
ed->l_tty, FX_TTY_POS_START, prompt_length(ed, PROMPT_MAIN) + 1);
save_buf_to_history(ed);
ed->l_history_pos++;

View File

@@ -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) {

View File

@@ -3,21 +3,21 @@
#define LINE_MAX 4096
#include <blue/term/tty.h>
#include <blue/core/queue.h>
#include <blue/ds/array.h>
#include <fx/term/tty.h>
#include <fx/core/queue.h>
#include <fx/ds/array.h>
#include <ivy/line-source.h>
#include <stddef.h>
struct s_tty;
struct b_tty_vmode;
struct fx_tty_vmode;
struct line_ed;
struct line_ed_hook {
void (*hook_keypress)(struct line_ed *, struct line_ed_hook *, b_keycode);
void (*hook_keypress)(struct line_ed *, struct line_ed_hook *, fx_keycode);
void (*hook_buffer_modified)(struct line_ed *, struct line_ed_hook *);
b_queue_entry hook_entry;
fx_queue_entry hook_entry;
};
enum line_ed_flags {
@@ -57,7 +57,7 @@ struct line_ed {
struct ivy_line_source l_line_source;
/* pointer to tty interface */
b_tty *l_tty;
fx_tty *l_tty;
/* the lexical scope that we are currently in.
* this is provided by components further up the input pipeline,
@@ -65,14 +65,14 @@ struct line_ed {
const char *l_scope_type;
/* array of previously entered commands */
b_array *l_history;
fx_array *l_history;
/* index of the currently selected history entry */
size_t l_history_pos;
/* list of defined highlight ranges */
b_queue l_hl_ranges;
fx_queue l_hl_ranges;
/* list of installed hooks */
b_queue l_hooks;
fx_queue l_hooks;
};
extern struct line_ed *line_ed_create(void);
@@ -82,7 +82,7 @@ extern void line_ed_set_scope_type(struct line_ed *ed, const char *scope_type);
extern void line_ed_put_highlight(
struct line_ed *ed, unsigned long start_x, unsigned long start_y,
unsigned long end_x, unsigned long end_y, const struct b_tty_vmode *vmode);
unsigned long end_x, unsigned long end_y, const struct fx_tty_vmode *vmode);
extern void line_ed_clear_highlights(struct line_ed *ed);
extern void line_ed_print_highlights(struct line_ed *ed);

View File

@@ -5,7 +5,7 @@
#include "buffer.h"
#include "cursor.h"
#include "hl-range.h"
#include <blue/term/tty.h>
#include <fx/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, size_t x, size_t y, const char *s)
{
b_tty *tty = ed->l_tty;
fx_tty *tty = ed->l_tty;
struct hl_range *cur_range = get_hl_range(ed, x, y);
for (size_t i = 0; s[i] != '\n' && s[i] != '\0'; i++) {
if (!cur_range) {
b_tty_reset_vmode(tty);
fx_tty_reset_vmode(tty);
fputc(s[i], stdout);
continue;
}
@@ -107,7 +107,7 @@ void put_refresh(struct line_ed *ed, struct refresh_state *state)
if (ed->l_flags & LINE_ED_FULL_REPRINT) {
if (start_x) {
//fprintf(stdout, "\033[%uD", start_x);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -(long long)start_x);
fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_CURSOR, -(long long)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--;
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -cursor_rdelta);
fx_tty_move_cursor_x(ed->l_tty, FX_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);
b_tty_clear(ed->l_tty, B_TTY_CLEAR_SCREEN | B_TTY_CLEAR_FROM_CURSOR);
fx_tty_clear(ed->l_tty, FX_TTY_CLEAR_SCREEN | FX_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 */
size_t tmp_x;
line_ed_coords_to_physical_coords(ed, 0, ed->l_cursor_y, &tmp_x, NULL);
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);
fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, -1);
fx_tty_move_cursor_x(ed->l_tty, FX_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);
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);
fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, -1);
fx_tty_move_cursor_x(ed->l_tty, FX_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);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, ydiff);
fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, ydiff);
}
//fprintf(stdout, "\033[%uG", new_x);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, new_x);
fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_START, new_x);
fflush(stdout);
}
@@ -232,14 +232,14 @@ void backspace_simple_refresh(struct line_ed *ed, struct refresh_state *state)
if (ed->l_flags & LINE_ED_FULL_REPRINT) {
if (start_x) {
//fprintf(stdout, "\033[%uD", start_x);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -(long long)start_x);
fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_CURSOR, -(long long)start_x);
}
start_x = 0;
}
//fputc('\010', stdout);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -1);
fx_tty_move_cursor_x(ed->l_tty, FX_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++;
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -cursor_rdelta);
fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_CURSOR, -cursor_rdelta);
#if 0
for (unsigned int i = 0; i < cursor_rdelta; i++) {