OXYGENHUB
◆ main enhanced-x16-emulator / src / source_view.h
1.6 KiB · Objective-C · last changed chore(): initial commit 25 days ago source blame history raw
1
// Commander X16 Emulator — source file discovery + caching for the debugger's
2
// native "Source" window. Locates the real .s/.c files referenced (by name only)
3
// in cc65 .dbg info and caches their contents split into lines.
4
5
#ifndef _SOURCE_VIEW_H_
6
#define _SOURCE_VIEW_H_
7
8
#include <stdbool.h>
9
10
#ifdef __cplusplus
11
extern "C" {
12
#endif
13
14
// A loaded source file, split into individual lines.
15
typedef struct {
16
	char  *name;      // the file name as referenced by the .dbg (key)
17
	char  *text;      // owned backing buffer (lines point into this)
18
	char **lines;     // array of 'count' pointers into 'text'
19
	int    count;     // number of lines
20
	bool   found;     // false = file could not be located on disk
21
} source_file_t;
22
23
// Register a directory to search for source files. Duplicates are ignored;
24
// most-recently-added roots are searched first. Safe to pass NULL/empty.
25
void source_view_add_path(const char *dir);
26
27
// Look up (and cache) a source file by the name stored in the .dbg. Resolution
28
// order: the name as-is, then each registered search root (most recent first),
29
// then the current working directory. Returns a cached entry (never freed by the
30
// caller). The returned entry is always non-NULL while a lookup slot is available;
31
// check ->found to know whether the file was actually located.
32
const source_file_t *source_view_get(const char *name);
33
34
// Drop all cached file contents (call when loaded modules change, so overlays
35
// re-read fresh). Registered search paths are kept.
36
void source_view_invalidate(void);
37
38
// Free everything (cached files and registered paths). Call on shutdown.
39
void source_view_free(void);
40
41
#ifdef __cplusplus
42
}
43
#endif
44
45
#endif