frontend: update bluelib api usage
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "line-ed.h"
|
||||
|
||||
#include <blue/object/array.h>
|
||||
#include <blue/object/string.h>
|
||||
#include <blue/ds/array.h>
|
||||
#include <blue/ds/string.h>
|
||||
|
||||
void alloc_empty_history_entry(struct line_ed *ed)
|
||||
{
|
||||
|
||||
@@ -36,16 +36,16 @@ struct hl_range *get_hl_range(struct line_ed *ed, size_t x, size_t y)
|
||||
|
||||
struct hl_range *best_match = NULL;
|
||||
|
||||
b_queue_iterator it;
|
||||
b_queue_foreach (&it, &ed->l_hl_ranges) {
|
||||
struct hl_range *cur = b_unbox(struct hl_range, it.entry, h_entry);
|
||||
b_queue_entry *entry = b_queue_first(&ed->l_hl_ranges);
|
||||
while (entry) {
|
||||
struct hl_range *cur = b_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) {
|
||||
continue;
|
||||
if (cmp_end != 1) {
|
||||
return cur;
|
||||
}
|
||||
|
||||
return cur;
|
||||
entry = b_queue_next(entry);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -276,10 +276,11 @@ void line_ed_clear_highlights(struct line_ed *ed)
|
||||
|
||||
void line_ed_print_highlights(struct line_ed *ed)
|
||||
{
|
||||
b_queue_iterator it;
|
||||
b_queue_foreach (&it, &ed->l_hl_ranges) {
|
||||
struct hl_range *h = b_unbox(struct hl_range, it.entry, h_entry);
|
||||
b_queue_entry *entry = b_queue_first(&ed->l_hl_ranges);
|
||||
while (entry) {
|
||||
struct hl_range *h = b_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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,24 +14,28 @@ void line_ed_remove_hook(struct line_ed *ed, struct line_ed_hook *hook)
|
||||
|
||||
void hook_keypress(struct line_ed *ed, b_keycode key)
|
||||
{
|
||||
b_queue_iterator it;
|
||||
b_queue_foreach (&it, &ed->l_hooks) {
|
||||
b_queue_entry *entry = b_queue_first(&ed->l_hooks);
|
||||
while (entry) {
|
||||
struct line_ed_hook *hook
|
||||
= b_unbox(struct line_ed_hook, it.entry, hook_entry);
|
||||
= b_unbox(struct line_ed_hook, entry, hook_entry);
|
||||
if (hook->hook_keypress) {
|
||||
hook->hook_keypress(ed, hook, key);
|
||||
}
|
||||
|
||||
entry = b_queue_next(entry);
|
||||
}
|
||||
}
|
||||
|
||||
void hook_buffer_modified(struct line_ed *ed)
|
||||
{
|
||||
b_queue_iterator it;
|
||||
b_queue_foreach (&it, &ed->l_hooks) {
|
||||
b_queue_entry *entry = b_queue_first(&ed->l_hooks);
|
||||
while (entry) {
|
||||
struct line_ed_hook *hook
|
||||
= b_unbox(struct line_ed_hook, it.entry, hook_entry);
|
||||
= b_unbox(struct line_ed_hook, entry, hook_entry);
|
||||
if (hook->hook_buffer_modified) {
|
||||
hook->hook_buffer_modified(ed, hook);
|
||||
}
|
||||
|
||||
entry = b_queue_next(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ struct line_ed *line_ed_create(void)
|
||||
|
||||
void line_ed_destroy(struct line_ed *ed)
|
||||
{
|
||||
b_array_release(ed->l_history);
|
||||
b_array_unref(ed->l_history);
|
||||
line_ed_clear_highlights(ed);
|
||||
free(ed->l_buf);
|
||||
free(ed);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <blue/term/tty.h>
|
||||
#include <blue/core/queue.h>
|
||||
#include <blue/object/array.h>
|
||||
#include <blue/ds/array.h>
|
||||
#include <ivy/line-source.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user