meta: rename to fx
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include <blue/ds/string.h>
|
||||
#include <blue/term/print.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <fx/term/print.h>
|
||||
#include <ctype.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@@ -9,18 +9,18 @@
|
||||
#define DEFAULT_PARAGRAPH_WIDTH 160
|
||||
|
||||
static void indent(
|
||||
struct b_paragraph_format *format, struct b_tty *tty, unsigned int margin)
|
||||
struct fx_paragraph_format *format, struct fx_tty *tty, unsigned int margin)
|
||||
{
|
||||
unsigned int x = 0;
|
||||
while (x < margin) {
|
||||
b_tty_puts(tty, 0, " ");
|
||||
fx_tty_puts(tty, 0, " ");
|
||||
x++;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int extract_line(
|
||||
const char **sp, unsigned int line_length, b_string *out,
|
||||
struct b_paragraph_format *format)
|
||||
const char **sp, unsigned int line_length, fx_string *out,
|
||||
struct fx_paragraph_format *format)
|
||||
{
|
||||
const char *start = *sp;
|
||||
while (isspace(*start) || *start == '\n') {
|
||||
@@ -87,18 +87,18 @@ static unsigned int extract_line(
|
||||
len = strlen(start);
|
||||
}
|
||||
|
||||
b_string_insert_cstrn(out, start, len, B_NPOS);
|
||||
fx_string_insert_cstrn(out, start, len, FX_NPOS);
|
||||
|
||||
*sp = end;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static b_status print_paragraph_tty(
|
||||
const char *str, struct b_tty *tty, struct b_paragraph_format *format)
|
||||
static fx_status print_paragraph_tty(
|
||||
const char *str, struct fx_tty *tty, struct fx_paragraph_format *format)
|
||||
{
|
||||
unsigned int w = 0, h = 0;
|
||||
b_tty_get_dimensions(tty, &w, &h);
|
||||
fx_tty_get_dimensions(tty, &w, &h);
|
||||
|
||||
if (!w) {
|
||||
w = DEFAULT_PARAGRAPH_WIDTH;
|
||||
@@ -108,7 +108,7 @@ static b_status print_paragraph_tty(
|
||||
unsigned int line_length = format->p_line_length;
|
||||
|
||||
if (format->p_left_margin + format->p_right_margin >= w) {
|
||||
return B_SUCCESS;
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
unsigned int page_width
|
||||
@@ -117,32 +117,32 @@ static b_status print_paragraph_tty(
|
||||
line_length = page_width;
|
||||
}
|
||||
|
||||
if (!(format->p_flags & B_PARAGRAPH_DONT_INDENT_FIRST_LINE)) {
|
||||
if (!(format->p_flags & FX_PARAGRAPH_DONT_INDENT_FIRST_LINE)) {
|
||||
indent(format, tty, left_margin);
|
||||
}
|
||||
|
||||
b_string *line = b_string_create();
|
||||
fx_string *line = fx_string_create();
|
||||
bool need_indent = false;
|
||||
|
||||
while (str) {
|
||||
if (*str == '\n') {
|
||||
if (format->p_flags & B_PARAGRAPH_DOUBLE_LINE_BREAK) {
|
||||
b_tty_putc(tty, 0, '\n');
|
||||
if (format->p_flags & FX_PARAGRAPH_DOUBLE_LINE_BREAK) {
|
||||
fx_tty_putc(tty, 0, '\n');
|
||||
}
|
||||
|
||||
str++;
|
||||
need_indent = true;
|
||||
|
||||
while (*str == '\n') {
|
||||
if (format->p_flags & B_PARAGRAPH_MULTI_LINE_BREAK) {
|
||||
b_tty_putc(tty, 0, '\n');
|
||||
if (format->p_flags & FX_PARAGRAPH_MULTI_LINE_BREAK) {
|
||||
fx_tty_putc(tty, 0, '\n');
|
||||
}
|
||||
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
b_string_clear(line);
|
||||
fx_string_clear(line);
|
||||
unsigned int this_line
|
||||
= extract_line(&str, line_length, line, format);
|
||||
if (this_line == 0) {
|
||||
@@ -153,24 +153,24 @@ static b_status print_paragraph_tty(
|
||||
indent(format, tty, left_margin);
|
||||
}
|
||||
|
||||
b_tty_puts(tty, 0, b_string_ptr(line));
|
||||
b_tty_putc(tty, 0, '\n');
|
||||
fx_tty_puts(tty, 0, fx_string_ptr(line));
|
||||
fx_tty_putc(tty, 0, '\n');
|
||||
need_indent = true;
|
||||
}
|
||||
|
||||
b_string_unref(line);
|
||||
fx_string_unref(line);
|
||||
|
||||
return B_SUCCESS;
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
static b_status print_paragraph_file(
|
||||
const char *str, FILE *fp, struct b_paragraph_format *format)
|
||||
static fx_status print_paragraph_file(
|
||||
const char *str, FILE *fp, struct fx_paragraph_format *format)
|
||||
{
|
||||
return B_SUCCESS;
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
b_status b_print_paragraph(
|
||||
const char *str, struct b_tty *fp, struct b_paragraph_format *format)
|
||||
fx_status fx_print_paragraph(
|
||||
const char *str, struct fx_tty *fp, struct fx_paragraph_format *format)
|
||||
{
|
||||
return print_paragraph_tty(str, fp, format);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user