-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfaces.h
More file actions
164 lines (150 loc) · 5.65 KB
/
Copy pathfaces.h
File metadata and controls
164 lines (150 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#pragma once
#include <obsidian/obsidian.h>
#include <stdbool.h>
typedef struct Buffer Buffer;
typedef enum {
FACE_DEFAULT = 0,
FACE_MODE_LINE,
FACE_MODE_LINE_ACTIVE,
FACE_MODE_LINE_INACTIVE,
FACE_FRINGE,
FACE_CURSOR,
FACE_BORDER,
FACE_WINDOW_DIVIDER,
FACE_BOLD,
FACE_ITALIC,
FACE_BOLD_ITALIC,
FACE_VISIBLE_MARK,
FACE_ERROR,
FACE_SUCCESS,
FACE_WARNING,
FACE_FONT_LOCK_BRACKET,
FACE_FONT_LOCK_BUILTIN,
FACE_FONT_LOCK_COMMENT_DELIMITER,
FACE_FONT_LOCK_COMMENT,
FACE_FONT_LOCK_CONSTANT,
FACE_FONT_LOCK_DELIMITER,
FACE_FONT_LOCK_DOC,
FACE_FONT_LOCK_DOC_MARKUP,
FACE_FONT_LOCK_ESCAPE,
FACE_FONT_LOCK_FUNCTION_CALL,
FACE_FONT_LOCK_FUNCTION_NAME,
FACE_FONT_LOCK_KEYWORD,
FACE_FONT_LOCK_MISC_PUNCTUATION,
FACE_FONT_LOCK_NEGATION_CHAR,
FACE_FONT_LOCK_NUMBER,
FACE_FONT_LOCK_OPERATOR,
FACE_FONT_LOCK_PREPROCESSOR,
FACE_FONT_LOCK_PROPERTY_NAME,
FACE_FONT_LOCK_PROPERTY_USE,
FACE_FONT_LOCK_PUNCTUATION,
FACE_FONT_LOCK_REGEXP,
FACE_FONT_LOCK_REGEXP_GROUPING_BACKSLASH,
FACE_FONT_LOCK_REGEXP_GROUPING_CONSTRUCT,
FACE_FONT_LOCK_STRING,
FACE_FONT_LOCK_TYPE,
FACE_FONT_LOCK_VARIABLE_NAME,
FACE_FONT_LOCK_VARIABLE_USE,
FACE_FONT_LOCK_WARNING,
FACE_MINIBUFFER_PROMPT,
FACE_UNDERLINE,
FACE_STRIKE_THROUGH,
FACE_BOX,
FACE_REGION,
FACE_SHADOW,
FACE_HIGHLIGHT,
FACE_HELP_KEY_BINDING,
FACE_COMPLETIONS_HIGHLIGHT,
FACE_COMPLETIONS_ANNOTATIONS,
FACE_COMPLETIONS_COMMON_PART,
FACE_COMPLETIONS_FIRST_DIFFERENCE,
FACE_RAINBOW_DELIMITERS_DEPTH_1,
FACE_RAINBOW_DELIMITERS_DEPTH_2,
FACE_RAINBOW_DELIMITERS_DEPTH_3,
FACE_RAINBOW_DELIMITERS_DEPTH_4,
FACE_RAINBOW_DELIMITERS_DEPTH_5,
FACE_RAINBOW_DELIMITERS_DEPTH_6,
FACE_RAINBOW_DELIMITERS_DEPTH_7,
FACE_RAINBOW_DELIMITERS_DEPTH_8,
FACE_RAINBOW_DELIMITERS_DEPTH_9,
FACE_RAINBOW_DELIMITERS_UNMATCHED,
FACE_RAINBOW_DELIMITERS_MISMATCHED,
FACE_ESCAPE_GLYPH,
FACE_ISEARCH,
FACE_ISEARCH_FAIL,
FACE_LAZY_HIGHLIGHT,
FACE_BUILTIN_COUNT,
} FaceId;
typedef struct Face {
int id;
Color fg;
Color bg;
Font *font; // Resolved font pointer (may be NULL = use default_font)
bool bold;
bool italic;
bool underline;
Color underline_color;
bool strike_through;
Color strike_through_color;
bool box;
Color box_color;
bool fg_set;
bool bg_set;
bool extend;
int inherit_from; // face ID to inherit from, -1 for none
// Explicit font spec (set via set-face-attribute).
// When family is non-NULL the face owns its own Font* rather than
// sharing the global default variants.
char *family; // heap-allocated, or NULL → use default family
int height; // in 1/10 pt (Emacs convention), 0 → use default
struct Face *next;
} Face;
typedef struct {
Face **faces;
int size;
int count;
} FaceCache;
// ── Font registry ─────────────────────────────────────────────────────────────
// Lazily-loaded fonts keyed by (family, pixel_size, bold, italic).
// Shared across all faces; never freed until free_faces().
// ─────────────────────────────────────────────────────────────────────────────
typedef struct FontRegistryEntry {
char *family;
int pixel_size;
bool bold;
bool italic;
Font *font;
struct FontRegistryEntry *next;
} FontRegistryEntry;
// Global
extern FaceCache *face_cache;
// ── Font registry API ─────────────────────────────────────────────────────────
// Look up or load a font. All returned Font* are owned by the registry.
Font *font_registry_get(const char *family, int pixel_size, bool bold, bool italic);
void font_registry_free_all(void);
// Return the pixel size that corresponds to an Emacs :height value (1/10 pt)
// given the current frame DPI. Falls back to the default pixel size when
// height == 0.
int height_to_pixel_size(int height_10pt);
// ── Default font spec ─────────────────────────────────────────────────────────
// These are the family/size used for the DEFAULT face and as fallback for all
// faces that have no explicit :family / :height. Updated by set-face-attribute
// on the 'default face.
extern char *g_default_family; // heap-allocated
extern int g_default_pixel_size;
// ── Core face API ─────────────────────────────────────────────────────────────
void init_faces(void);
void free_faces(void);
Face *get_face(int id);
// Return the font that should be used to render a character in `face`.
// Respects face->family / face->height and bold/italic attributes.
// Never returns NULL as long as at least one font could be loaded.
Font *get_face_font(Face *face);
void resolve_face_inheritance(void);
Face *get_named_face(const char *name);
int face_id_from_name(const char *name);
int face_at_pos(Buffer *buf, size_t pos);
Font *fontconfig_load_font(const char *family, int size, bool bold, bool italic);
Color parse_color(const char *str);
int register_dynamic_face(const char *name, int inherit_from);
void init_face_bindings(void);