code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(26 lines)
1 // Definitions of an API for loading files.
3 #pragma once
5 #include <stdbool.h>
6 #include <stdint.h>
7 #include <unistd.h>
9 typedef struct {
10 const char *filename, *relative_filename;
11 const char *text;
12 int64_t len;
13 int64_t num_lines, line_capacity;
14 int64_t *line_offsets;
15 } file_t;
17 char *resolve_path(const char *path, const char *relative_to, const char *system_path);
18 __attribute__((pure, nonnull)) char *file_base_name(const char *path);
19 __attribute__((nonnull)) file_t *load_file(const char *filename);
20 __attribute__((nonnull, returns_nonnull)) file_t *spoof_file(const char *filename, const char *text);
21 __attribute__((pure, nonnull)) int64_t get_line_number(file_t *f, const char *p);
22 __attribute__((pure, nonnull)) int64_t get_line_column(file_t *f, const char *p);
23 __attribute__((pure, nonnull)) const char *get_line(file_t *f, int64_t line_number);
24 __attribute__((pure, nonnull)) const char *get_file_pos(file_t *f, const char *p);
25 int highlight_error(file_t *file, const char *start, const char *end, const char *hl_color, int64_t context_lines,
26 bool use_color);