blob: 776ef9ba7968906711a261a150c1bc1c12f4c5b6 (
plain)
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
|
#ifndef _COMPLETION_H
#define _COMPLETION_H
#include "dged/location.h"
struct buffer;
struct buffers;
struct commands;
struct completion {
const char *display;
const char *insert;
bool complete;
};
struct completion_context {
struct buffer *buffer;
const struct location location;
const uint32_t max_ncompletions;
struct completion *completions;
};
typedef uint32_t (*completion_fn)(struct completion_context ctx,
void *userdata);
struct completion_provider {
char name[16];
completion_fn complete;
void *userdata;
};
enum completion_trigger_kind {
CompletionTrigger_Input = 0,
CompletionTrigger_Char = 1,
};
struct completion_trigger_input {
uint32_t nchars;
bool trigger_initially;
};
struct completion_trigger {
enum completion_trigger_kind kind;
union {
uint32_t c;
struct completion_trigger_input input;
};
};
void init_completion(struct buffers *buffers, struct commands *commands);
void destroy_completion();
typedef void (*insert_cb)();
/**
* Enable completions in the buffer @ref source.
*
* @param source [in] The buffer to provide completions for.
* @param trigger [in] The completion trigger to use for this completion.
* @param providers [in] The completion providers to use.
* @param nproviders [in] The number of providers in @ref providers.
*/
void enable_completion(struct buffer *source, struct completion_trigger trigger,
struct completion_provider *providers,
uint32_t nproviders, insert_cb on_completion_inserted);
struct completion_provider path_provider();
struct completion_provider buffer_provider();
struct completion_provider commands_provider();
/**
* Abort any active completion.
*/
void abort_completion();
/**
* Is a completion currently showing?
*
* @returns True if the completion window is showing completions.
*/
bool completion_active();
/**
* Disable completion for @ref buffer.
*
* @param buffer [in] Buffer to disable completions for.
*/
void disable_completion(struct buffer *buffer);
#endif
|