24#if defined(__unix__) || defined(__unix) || \
25 (defined(__APPLE__) && defined(__MACH__))
29#define _PRINTF(...) tcol_fprintf(printer->stream, __VA_ARGS__)
30#define _PUTCHR(...) fputc(__VA_ARGS__, printer->stream)
48#if defined(__unix__) || defined(__unix) || \
49 (defined(__APPLE__) && defined(__MACH__))
50 const int fd = fileno(stream);
54 printer->
color = isatty(fd);
56 printer->
color =
false;
59 if ((printer->
utf8 = utf8)) {
68 const size_t column) {
75 const size_t column) {
98 const char * error_line,
99 const char *color,
const size_t column) {
100 _PRINTF(
"%.*s", (
int)column, error_line);
101 const char *bug = error_line + column;
104 char * nl = strstr(end,
"\n");
105 ptrdiff_t nl_index = nl ? nl - end : (ptrdiff_t)strlen(end) - 1;
106 _PRINTF(
"%.*s\n", (
int)nl_index, end);
112 const char * error_line,
117 char* line = (
char*)error_line;
120 if(*line ==
'\t')
_PRINTF(
"\t");
173 while (idx_cpy > 0 && printer->
source[idx_cpy - 1] !=
'\n') { idx_cpy--; }
174 const char *error_line = (printer->
source + idx_cpy);
175 error_line += (printer->
source[idx_cpy] ==
'\n') ? 1 : 0;
215 while (idx_cpy > 0 && printer->
source[idx_cpy - 1] !=
'\n') { idx_cpy--; }
216 const char *error_line = (printer->
source + idx_cpy);
217 error_line += (printer->
source[idx_cpy] ==
'\n') ? 1 : 0;
234 _PRINTF(
"{-}%s%s%.*s{0} ", color,
242 printer->
runner(printer, err);
static void _perr_print_highlight_error(const perr_printer_t *printer, const perr_t *err, const char *error_line, const char *color, const size_t column, const bool small)
perr_runner_t perr_runner_secondary_style
static void _perr_print_error(const perr_printer_t *printer, const perr_t *err, const char *color)
static char const * _utf8_box_lookup[8]
void perr_printer_init(perr_printer_t *printer, FILE *stream, const char *source, bool utf8, perr_runner_t style)
perr_runner_t perr_runner_basic_style
static void _perr_print_filename(const perr_printer_t *printer, const perr_t *err, const size_t column)
static char const * _ascii_box_lookup[8]
static void _perr_print_fix(const perr_printer_t *printer, const char *fix)
static void _perr_print_offending_line(const perr_printer_t *printer, const perr_t *err, const char *error_line, const char *color, const size_t column)
static void lookup_color(char *color, enum libprettyerr_errtype type)
static char const _tcol_lookup[5]
static const char * _errtype_lookup[5]
void perr_print_line_number(const perr_printer_t *printer, const perr_t *err, const char *color)
static void perr_print_secondary_style(const perr_printer_t *printer, const perr_t *err)
static void perr_print_column(const perr_printer_t *printer, const char *color, const size_t column)
void perr_print_error(const perr_printer_t *printer, const perr_t *err)
static void perr_print_basic_style(const perr_printer_t *printer, const perr_t *err)
libprettyerr_runner_t perr_runner_t
struct libprettyerr_str primary
enum libprettyerr_errtype type
struct libprettyerr_pos error_position
libprettyerr_runner_t runner
int tcol_color_parse(char *dst, size_t dstn, char color[16], size_t k, size_t *len)