Hooks sketch
This commit is contained in:
@@ -28,6 +28,12 @@ struct Trigger {
|
||||
};
|
||||
};
|
||||
|
||||
struct CachedTrigger {
|
||||
Trigger *trigger;
|
||||
String key;
|
||||
};
|
||||
Array<CachedTrigger> CachedTriggers;
|
||||
|
||||
void Advance(Lexer *lex) {
|
||||
if (lex->at < lex->end) {
|
||||
if (lex->at[0] == '\n') {
|
||||
@@ -168,12 +174,6 @@ Trigger *ParseKey(Allocator allocator, String key, char *debug_name) {
|
||||
return result;
|
||||
}
|
||||
|
||||
struct CachedTrigger {
|
||||
Trigger *trigger;
|
||||
String key;
|
||||
};
|
||||
Array<CachedTrigger> CachedTriggers;
|
||||
|
||||
Trigger *ParseKeyCached(String key) {
|
||||
key = Trim(key);
|
||||
if (key.len == 0) {
|
||||
|
||||
@@ -7,6 +7,12 @@ struct WindowID { Int id; Window *o; };
|
||||
union Range { struct { Int min; Int max; }; Int e[2]; };
|
||||
struct Caret { union { Range range; Int pos[2]; }; Int ifront;};
|
||||
struct XY { Int col; Int line; };
|
||||
typedef void Function();
|
||||
|
||||
struct FunctionData {
|
||||
String name;
|
||||
Function *function;
|
||||
};
|
||||
|
||||
struct Edit {
|
||||
Range range;
|
||||
@@ -51,10 +57,53 @@ struct Buffer {
|
||||
};
|
||||
};
|
||||
|
||||
typedef void Function();
|
||||
struct FunctionData {
|
||||
enum HookKind {
|
||||
HookKind_Invalid,
|
||||
|
||||
HookKind_AppInit,
|
||||
HookKind_AppUpdate,
|
||||
HookKind_AppExit,
|
||||
|
||||
HookKind_Binding,
|
||||
|
||||
HookKind_BeforeLayoutWindow,
|
||||
HookKind_HandleLayoutWindow,
|
||||
HookKind_AfterLayoutWindow,
|
||||
|
||||
HookKind_BeforeRenderWindow,
|
||||
HookKind_HandleRenderWindow,
|
||||
HookKind_AfterRenderWindow,
|
||||
|
||||
HookKind_BeforeBufferSave,
|
||||
HookKind_HandleBufferSave,
|
||||
HookKind_AfterBufferSave,
|
||||
|
||||
HookKind_BeforeBufferOpen,
|
||||
HookKind_HandleBufferOpen,
|
||||
HookKind_AfterBufferOpen,
|
||||
|
||||
HookKind_ViewUpdate,
|
||||
};
|
||||
|
||||
// Global hooks, per (window, view, buffer) hooks
|
||||
|
||||
struct HookParam {
|
||||
struct Hook *hook;
|
||||
Buffer *buffer;
|
||||
View *view;
|
||||
Window *window;
|
||||
};
|
||||
|
||||
typedef void HookFunction(HookParam *param);
|
||||
struct Hook {
|
||||
HookKind kind;
|
||||
String name;
|
||||
Function *function;
|
||||
String doc;
|
||||
HookFunction *function;
|
||||
|
||||
// HookKind_Binding
|
||||
String binding;
|
||||
struct Trigger *trigger;
|
||||
};
|
||||
|
||||
struct CommandData {
|
||||
|
||||
Reference in New Issue
Block a user