2016-02-01 05:03:42 +00:00
|
|
|
|
2016-03-24 01:05:28 +00:00
|
|
|
#ifndef FCODER_CUSTOM_H
|
|
|
|
#define FCODER_CUSTOM_H
|
|
|
|
|
2016-06-29 18:23:14 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2016-03-04 06:06:11 +00:00
|
|
|
#include "4coder_version.h"
|
2016-02-25 23:52:11 +00:00
|
|
|
#include "4coder_keycodes.h"
|
2016-03-04 23:10:00 +00:00
|
|
|
#include "4coder_style.h"
|
2016-05-25 02:12:49 +00:00
|
|
|
#include "4coder_rect.h"
|
|
|
|
#include "4coder_mem.h"
|
2016-02-24 05:16:08 +00:00
|
|
|
|
2016-07-06 19:18:10 +00:00
|
|
|
#ifndef FSTRING_STRUCT
|
|
|
|
#define FSTRING_STRUCT
|
2016-03-03 19:27:09 +00:00
|
|
|
typedef struct String{
|
|
|
|
char *str;
|
2016-08-29 01:03:26 +00:00
|
|
|
int32_t size;
|
|
|
|
int32_t memory_size;
|
2016-03-03 19:27:09 +00:00
|
|
|
} String;
|
|
|
|
|
|
|
|
typedef struct Offset_String{
|
2016-08-29 01:03:26 +00:00
|
|
|
int32_t offset;
|
|
|
|
int32_t size;
|
2016-03-03 19:27:09 +00:00
|
|
|
} Offset_String;
|
|
|
|
#endif
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
// These are regular hooks, any of them can be set to any function
|
|
|
|
// that matches the HOOK_SIG pattern.
|
|
|
|
enum Hook_ID{
|
|
|
|
hook_start,
|
|
|
|
hook_file_out_of_sync,
|
|
|
|
// never below this
|
|
|
|
hook_type_count
|
|
|
|
};
|
|
|
|
|
|
|
|
// These are for special hooks, each must bind to specialized signatures
|
|
|
|
// that do not necessarily have access to the app pointer.
|
|
|
|
enum Special_Hook_ID{
|
|
|
|
_hook_scroll_rule = hook_type_count,
|
|
|
|
_hook_new_file,
|
|
|
|
_hook_open_file,
|
|
|
|
_hook_command_caller,
|
|
|
|
_hook_input_filter,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define CommandEqual(c1,c2) ((unsigned long long)(c1) == (unsigned long long)(c2))
|
|
|
|
|
|
|
|
#define CUSTOM_COMMAND_SIG(name) void name(struct Application_Links *app)
|
|
|
|
typedef CUSTOM_COMMAND_SIG(Custom_Command_Function);
|
|
|
|
|
2016-07-01 05:42:19 +00:00
|
|
|
#include "4coder_types.h"
|
2016-07-02 22:59:16 +00:00
|
|
|
#include "4coder_buffer_types.h"
|
|
|
|
#include "4coder_gui.h"
|
2016-03-03 19:27:09 +00:00
|
|
|
|
2016-08-29 01:03:26 +00:00
|
|
|
#define COMMAND_CALLER_HOOK(name) int32_t name(struct Application_Links *app, Generic_Command cmd)
|
2016-07-02 14:15:15 +00:00
|
|
|
typedef COMMAND_CALLER_HOOK(Command_Caller_Hook_Function);
|
|
|
|
|
2016-06-29 19:11:37 +00:00
|
|
|
inline Key_Event_Data
|
|
|
|
key_event_data_zero(){
|
|
|
|
Key_Event_Data data={0};
|
|
|
|
return(data);
|
|
|
|
}
|
|
|
|
inline Mouse_State
|
|
|
|
mouse_state_zero(){
|
|
|
|
Mouse_State data={0};
|
|
|
|
return(data);
|
|
|
|
}
|
2016-03-03 19:27:09 +00:00
|
|
|
inline Range
|
2016-08-29 01:03:26 +00:00
|
|
|
make_range(int32_t p1, int32_t p2){
|
2016-03-03 19:27:09 +00:00
|
|
|
Range range;
|
|
|
|
if (p1 < p2){
|
|
|
|
range.min = p1;
|
|
|
|
range.max = p2;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
range.min = p2;
|
|
|
|
range.max = p1;
|
|
|
|
}
|
|
|
|
return(range);
|
|
|
|
}
|
2016-05-12 17:41:52 +00:00
|
|
|
inline Buffer_Summary
|
|
|
|
buffer_summary_zero(){
|
|
|
|
Buffer_Summary summary={0};
|
|
|
|
return(summary);
|
|
|
|
}
|
|
|
|
inline View_Summary
|
|
|
|
view_summary_zero(){
|
|
|
|
View_Summary summary={0};
|
|
|
|
return(summary);
|
|
|
|
}
|
2016-02-24 05:16:08 +00:00
|
|
|
|
2016-08-29 02:14:02 +00:00
|
|
|
|
2016-08-29 01:03:26 +00:00
|
|
|
#define HOOK_SIG(name) int32_t name(struct Application_Links *app)
|
|
|
|
#define OPEN_FILE_HOOK_SIG(name) int32_t name(struct Application_Links *app, int32_t buffer_id)
|
|
|
|
#define SCROLL_RULE_SIG(name) int32_t name(float target_x, float target_y, float *scroll_x, float *scroll_y, int32_t view_id, int32_t is_new_target, float dt)
|
2016-06-29 19:11:37 +00:00
|
|
|
#define INPUT_FILTER_SIG(name) void name(Mouse_State *mouse)
|
2016-02-01 05:03:42 +00:00
|
|
|
|
2016-06-29 18:23:14 +00:00
|
|
|
typedef HOOK_SIG(Hook_Function);
|
|
|
|
typedef OPEN_FILE_HOOK_SIG(Open_File_Hook_Function);
|
|
|
|
typedef SCROLL_RULE_SIG(Scroll_Rule_Function);
|
2016-06-29 19:11:37 +00:00
|
|
|
typedef INPUT_FILTER_SIG(Input_Filter_Function);
|
2016-06-29 18:23:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-01 05:03:42 +00:00
|
|
|
|
2016-02-26 06:26:26 +00:00
|
|
|
struct Application_Links;
|
2016-05-25 22:43:58 +00:00
|
|
|
#include "4coder_custom_api.h"
|
|
|
|
|
|
|
|
|
2016-02-01 05:03:42 +00:00
|
|
|
|
2016-08-29 02:14:02 +00:00
|
|
|
#define VIEW_ROUTINE_SIG(name) void name(struct Application_Links *app, int32_t view_id)
|
|
|
|
#define GET_BINDING_DATA(name) int32_t name(void *data, int32_t size)
|
2016-08-29 01:03:26 +00:00
|
|
|
#define _GET_VERSION_SIG(n) int32_t n(int32_t maj, int32_t min, int32_t patch)
|
2016-03-07 05:13:20 +00:00
|
|
|
|
2016-08-29 02:14:02 +00:00
|
|
|
typedef VIEW_ROUTINE_SIG(View_Routine_Function);
|
|
|
|
typedef GET_BINDING_DATA(Get_Binding_Data_Function);
|
|
|
|
typedef _GET_VERSION_SIG(_Get_Version_Function);
|
2016-03-07 05:13:20 +00:00
|
|
|
|
2016-02-01 05:03:42 +00:00
|
|
|
struct Custom_API{
|
2016-05-24 18:22:22 +00:00
|
|
|
View_Routine_Function *view_routine;
|
2016-02-01 05:03:42 +00:00
|
|
|
Get_Binding_Data_Function *get_bindings;
|
2016-03-07 05:13:20 +00:00
|
|
|
_Get_Version_Function *get_alpha_4coder_version;
|
2016-02-01 05:03:42 +00:00
|
|
|
};
|
|
|
|
|
2016-08-29 02:14:02 +00:00
|
|
|
extern "C" _GET_VERSION_SIG(get_alpha_4coder_version){
|
|
|
|
int32_t result = (maj == MAJOR && min == MINOR && patch == PATCH);
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-02-01 05:03:42 +00:00
|
|
|
// NOTE(allen): definitions for the buffer that communicates to 4ed.exe
|
|
|
|
|
|
|
|
enum Binding_Unit_Type{
|
|
|
|
unit_header,
|
|
|
|
unit_map_begin,
|
|
|
|
unit_binding,
|
|
|
|
unit_callback,
|
|
|
|
unit_inherit,
|
|
|
|
unit_hook
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Map_ID{
|
|
|
|
mapid_global = (1 << 24),
|
|
|
|
mapid_file,
|
2016-02-22 02:45:41 +00:00
|
|
|
|
2016-02-01 05:03:42 +00:00
|
|
|
// NOTE(allen): mapid_nomap will remain empty even if you attempt to fill it
|
|
|
|
// it is for setting a map's parent to nothing, in cases where you don't want
|
|
|
|
// to inherit from global (which is the default).
|
|
|
|
mapid_nomap
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Binding_Unit{
|
|
|
|
Binding_Unit_Type type;
|
|
|
|
union{
|
2016-08-29 01:03:26 +00:00
|
|
|
struct{ int32_t total_size; int32_t user_map_count; int32_t error; } header;
|
2016-02-01 05:03:42 +00:00
|
|
|
|
2016-08-29 01:03:26 +00:00
|
|
|
struct{ int32_t mapid; int32_t replace; int32_t bind_count; } map_begin;
|
|
|
|
struct{ int32_t mapid; } map_inherit;
|
2016-02-01 05:03:42 +00:00
|
|
|
struct{
|
2016-08-29 01:03:26 +00:00
|
|
|
int16_t code;
|
|
|
|
uint8_t modifiers;
|
|
|
|
int32_t command_id;
|
2016-02-01 05:03:42 +00:00
|
|
|
} binding;
|
|
|
|
struct{
|
2016-08-29 01:03:26 +00:00
|
|
|
int16_t code;
|
|
|
|
uint8_t modifiers;
|
2016-02-01 05:03:42 +00:00
|
|
|
Custom_Command_Function *func;
|
|
|
|
} callback;
|
|
|
|
struct{
|
2016-08-29 01:03:26 +00:00
|
|
|
int32_t hook_id;
|
2016-03-04 06:06:11 +00:00
|
|
|
void *func;
|
2016-02-01 05:03:42 +00:00
|
|
|
} hook;
|
|
|
|
};
|
|
|
|
};
|
2016-03-24 01:05:28 +00:00
|
|
|
|
|
|
|
#endif
|