Cthulhu
0.2.10
Cthulhu compiler collection
common.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: LGPL-3.0-only
2
3
#pragma once
4
5
#include "
format/format.h
"
6
#include "
format/colour.h
"
7
8
#include "
core/where.h
"
9
10
#include <stddef.h>
11
#include <stdbool.h>
12
14
15
size_t
get_offset_line
(
bool
zero_indexed_lines,
size_t
line);
16
18
int
get_num_width
(
size_t
num);
19
20
#define FMT_BASE10_MAX_WIDTH 20
21
22
char
*
fmt_left_align
(
arena_t
*arena,
size_t
width,
const
char
*
fmt
, ...);
23
char
*
fmt_right_align
(
arena_t
*arena,
size_t
width,
const
char
*
fmt
, ...);
24
28
29
typedef
struct
source_config_t
30
{
31
format_context_t
context
;
32
colour_t
colour
;
33
heading_style_t
heading_style
;
34
bool
zero_indexed_lines
;
35
}
source_config_t
;
36
37
format_context_t
format_context_make
(
print_options_t
options);
38
char
*
fmt_source_location
(
source_config_t
config,
const
char
*path,
where_t
where);
colour.h
format.h
colour_t
colour_t
a colour code
Definition:
colour.h:23
fmt_heading_t
fmt_heading_t
line heading style
Definition:
format.h:18
fmt
CT_NODISCARD STA_FORMAT_STRING const char * fmt
Definition:
str.h:68
arena_t
an allocator object
Definition:
arena.h:86
fmt_options_t
generic print options
Definition:
format.h:35
format_context_t
a formatting context when using colours
Definition:
colour.h:46
source_config_t
Definition:
common.h:30
source_config_t::zero_indexed_lines
bool zero_indexed_lines
Definition:
common.h:34
source_config_t::heading_style
heading_style_t heading_style
Definition:
common.h:33
source_config_t::colour
colour_t colour
Definition:
common.h:32
source_config_t::context
format_context_t context
Definition:
common.h:31
where_t
a location inside a scanner locations are inclusive and 0-based
Definition:
where.h:23
fmt_source_location
char * fmt_source_location(source_config_t config, const char *path, where_t where)
Definition:
common.c:124
get_offset_line
size_t get_offset_line(bool zero_indexed_lines, size_t line)
colour defines
Definition:
common.c:12
fmt_left_align
char * fmt_left_align(arena_t *arena, size_t width, const char *fmt,...)
Definition:
common.c:36
fmt_right_align
char * fmt_right_align(arena_t *arena, size_t width, const char *fmt,...)
Definition:
common.c:59
get_num_width
int get_num_width(size_t num)
get the width of a number if it were printed as base10
Definition:
common.c:21
format_context_make
format_context_t format_context_make(print_options_t options)
Definition:
common.c:114
where.h
support
format
src
common.h
Generated by
1.9.1