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
|
|
|
#include "4coder_buffer_types.h"
|
2016-05-25 02:12:49 +00:00
|
|
|
#include "4coder_gui.h"
|
2016-02-24 05:16:08 +00:00
|
|
|
|
2016-06-13 16:56:33 +00:00
|
|
|
#define MDFR_NONE 0x0
|
|
|
|
#define MDFR_CTRL 0x1
|
|
|
|
#define MDFR_ALT 0x2
|
|
|
|
#define MDFR_SHIFT 0x4
|
|
|
|
|
2016-03-03 19:27:09 +00:00
|
|
|
#ifndef FRED_STRING_STRUCT
|
|
|
|
#define FRED_STRING_STRUCT
|
|
|
|
typedef struct String{
|
|
|
|
char *str;
|
|
|
|
int size;
|
|
|
|
int memory_size;
|
|
|
|
} String;
|
|
|
|
|
|
|
|
typedef struct Offset_String{
|
|
|
|
int offset;
|
|
|
|
int size;
|
|
|
|
} Offset_String;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef unsigned char Code;
|
|
|
|
|
|
|
|
typedef enum{
|
|
|
|
MDFR_SHIFT_INDEX,
|
|
|
|
MDFR_CONTROL_INDEX,
|
|
|
|
MDFR_ALT_INDEX,
|
|
|
|
MDFR_CAPS_INDEX,
|
2016-06-07 17:22:42 +00:00
|
|
|
MDFR_HOLD_INDEX,
|
2016-03-03 19:27:09 +00:00
|
|
|
// always last
|
|
|
|
MDFR_INDEX_COUNT
|
|
|
|
} Key_Control;
|
|
|
|
|
|
|
|
typedef struct Key_Event_Data{
|
|
|
|
Code keycode;
|
|
|
|
Code character;
|
|
|
|
Code character_no_caps_lock;
|
|
|
|
char modifiers[MDFR_INDEX_COUNT];
|
|
|
|
} Key_Event_Data;
|
2016-05-12 17:41:52 +00:00
|
|
|
inline Key_Event_Data
|
|
|
|
key_event_data_zero(){
|
|
|
|
Key_Event_Data data={0};
|
|
|
|
return(data);
|
|
|
|
}
|
2016-03-03 19:27:09 +00:00
|
|
|
|
|
|
|
typedef struct Mouse_State{
|
|
|
|
char l, r;
|
|
|
|
char press_l, press_r;
|
|
|
|
char release_l, release_r;
|
|
|
|
char wheel;
|
|
|
|
char out_of_window;
|
|
|
|
int x, y;
|
|
|
|
} Mouse_State;
|
|
|
|
|
|
|
|
typedef union Range{
|
|
|
|
struct{
|
|
|
|
int min, max;
|
|
|
|
};
|
|
|
|
struct{
|
|
|
|
int start, end;
|
|
|
|
};
|
|
|
|
} Range;
|
|
|
|
|
|
|
|
inline Range
|
|
|
|
make_range(int p1, int p2){
|
|
|
|
Range range;
|
|
|
|
if (p1 < p2){
|
|
|
|
range.min = p1;
|
|
|
|
range.max = p2;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
range.min = p2;
|
|
|
|
range.max = p1;
|
|
|
|
}
|
|
|
|
return(range);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct File_Info{
|
|
|
|
String filename;
|
|
|
|
int folder;
|
|
|
|
} File_Info;
|
|
|
|
|
|
|
|
typedef struct File_List{
|
|
|
|
// Ignore this, it's for internal stuff.
|
|
|
|
void *block;
|
|
|
|
|
|
|
|
// The list of files and folders.
|
|
|
|
File_Info *infos;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
// Ignore this, it's for internal stuff.
|
|
|
|
int block_size;
|
|
|
|
} File_List;
|
|
|
|
|
2016-06-17 03:31:15 +00:00
|
|
|
// NOTE(allen|a4.0.8): This is used to identify which buffer
|
2016-06-13 16:56:33 +00:00
|
|
|
// an operation should work on when you might want to
|
|
|
|
// identify it by id or by name.
|
|
|
|
typedef struct Buffer_Identifier{
|
|
|
|
char *name;
|
|
|
|
int name_len;
|
|
|
|
int id;
|
|
|
|
} Buffer_Identifier;
|
2016-02-01 05:03:42 +00:00
|
|
|
|
2016-06-29 18:23:14 +00:00
|
|
|
typedef uint64_t Command_ID;
|
|
|
|
|
|
|
|
enum{
|
2016-02-01 05:03:42 +00:00
|
|
|
cmdid_null,
|
2016-06-03 16:20:45 +00:00
|
|
|
|
2016-03-21 22:27:27 +00:00
|
|
|
cmdid_center_view,
|
2016-06-10 23:46:30 +00:00
|
|
|
cmdid_left_adjust_view,
|
2016-06-17 03:31:15 +00:00
|
|
|
cmdid_page_up,
|
|
|
|
cmdid_page_down,
|
2016-06-03 16:20:45 +00:00
|
|
|
|
2016-02-20 21:36:16 +00:00
|
|
|
cmdid_word_complete,
|
2016-06-03 16:20:45 +00:00
|
|
|
|
2016-02-01 05:03:42 +00:00
|
|
|
cmdid_undo,
|
|
|
|
cmdid_redo,
|
|
|
|
cmdid_history_backward,
|
|
|
|
cmdid_history_forward,
|
2016-06-03 16:20:45 +00:00
|
|
|
|
2016-02-01 05:03:42 +00:00
|
|
|
cmdid_to_uppercase,
|
|
|
|
cmdid_to_lowercase,
|
2016-06-03 16:20:45 +00:00
|
|
|
|
|
|
|
cmdid_toggle_line_wrap,
|
2016-02-01 05:03:42 +00:00
|
|
|
cmdid_toggle_show_whitespace,
|
2016-06-03 16:20:45 +00:00
|
|
|
cmdid_clean_all_lines,
|
2016-06-07 16:26:11 +00:00
|
|
|
cmdid_eol_dosify,
|
|
|
|
cmdid_eol_nixify,
|
2016-06-03 16:20:45 +00:00
|
|
|
|
2016-06-17 03:31:15 +00:00
|
|
|
cmdid_hide_scrollbar,
|
|
|
|
cmdid_show_scrollbar,
|
2016-06-03 16:20:45 +00:00
|
|
|
|
2016-06-17 03:31:15 +00:00
|
|
|
cmdid_interactive_new,
|
|
|
|
cmdid_interactive_open,
|
|
|
|
cmdid_reopen,
|
|
|
|
cmdid_save,
|
|
|
|
cmdid_save_as,
|
|
|
|
cmdid_interactive_switch_buffer,
|
|
|
|
cmdid_interactive_kill_buffer,
|
|
|
|
cmdid_kill_buffer,
|
2016-06-03 16:20:45 +00:00
|
|
|
|
|
|
|
cmdid_open_color_tweaker,
|
2016-06-06 18:41:17 +00:00
|
|
|
cmdid_open_config,
|
2016-02-01 05:03:42 +00:00
|
|
|
cmdid_open_menu,
|
2016-06-06 18:41:17 +00:00
|
|
|
cmdid_open_debug,
|
|
|
|
|
2016-06-17 03:31:15 +00:00
|
|
|
cmdid_open_panel_vsplit,
|
|
|
|
cmdid_open_panel_hsplit,
|
|
|
|
cmdid_close_panel,
|
|
|
|
cmdid_change_active_panel,
|
2016-06-07 16:26:11 +00:00
|
|
|
|
2016-02-01 05:03:42 +00:00
|
|
|
//
|
|
|
|
cmdid_count
|
|
|
|
};
|
|
|
|
|
2016-03-04 06:06:11 +00:00
|
|
|
// These are regular hooks, any of them can be set to any function
|
|
|
|
// that matches the HOOK_SIG pattern.
|
2016-02-01 05:03:42 +00:00
|
|
|
enum Hook_ID{
|
|
|
|
hook_start,
|
2016-03-20 03:09:00 +00:00
|
|
|
hook_file_out_of_sync,
|
2016-02-01 05:03:42 +00:00
|
|
|
// never below this
|
|
|
|
hook_type_count
|
|
|
|
};
|
|
|
|
|
2016-03-04 06:06:11 +00:00
|
|
|
// 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,
|
2016-06-23 23:11:09 +00:00
|
|
|
_hook_new_file,
|
|
|
|
_hook_open_file,
|
2016-06-29 18:23:14 +00:00
|
|
|
_hook_command_caller,
|
2016-03-04 06:06:11 +00:00
|
|
|
};
|
|
|
|
|
2016-06-03 16:20:45 +00:00
|
|
|
// None of the members of *_Summary structs nor any of the data pointed
|
|
|
|
// to by the members should be modified, I would have made them all
|
|
|
|
// const... but that causes a lot problems for C++ reasons.
|
2016-02-01 05:03:42 +00:00
|
|
|
struct Buffer_Summary{
|
2016-02-23 16:04:55 +00:00
|
|
|
int exists;
|
|
|
|
int ready;
|
2016-02-26 17:40:51 +00:00
|
|
|
int buffer_id;
|
2016-06-20 20:34:48 +00:00
|
|
|
unsigned int lock_flags;
|
2016-02-01 05:03:42 +00:00
|
|
|
|
|
|
|
int size;
|
|
|
|
|
|
|
|
int file_name_len;
|
|
|
|
int buffer_name_len;
|
2016-02-25 00:04:08 +00:00
|
|
|
char *file_name;
|
|
|
|
char *buffer_name;
|
2016-02-01 05:03:42 +00:00
|
|
|
|
2016-02-26 17:40:51 +00:00
|
|
|
int buffer_cursor_pos;
|
2016-02-01 05:03:42 +00:00
|
|
|
int is_lexed;
|
|
|
|
int map_id;
|
|
|
|
};
|
2016-05-12 17:41:52 +00:00
|
|
|
inline Buffer_Summary
|
|
|
|
buffer_summary_zero(){
|
|
|
|
Buffer_Summary summary={0};
|
|
|
|
return(summary);
|
|
|
|
}
|
2016-02-01 05:03:42 +00:00
|
|
|
|
2016-03-03 04:10:45 +00:00
|
|
|
struct View_Summary{
|
2016-02-24 05:16:08 +00:00
|
|
|
int exists;
|
|
|
|
int view_id;
|
2016-02-26 17:40:51 +00:00
|
|
|
int buffer_id;
|
2016-06-20 20:34:48 +00:00
|
|
|
unsigned int lock_flags;
|
2016-02-24 05:16:08 +00:00
|
|
|
|
|
|
|
Full_Cursor cursor;
|
|
|
|
Full_Cursor mark;
|
2016-02-25 00:04:08 +00:00
|
|
|
float preferred_x;
|
2016-06-03 16:20:45 +00:00
|
|
|
float line_height;
|
2016-02-25 00:04:08 +00:00
|
|
|
int unwrapped_lines;
|
2016-06-03 16:20:45 +00:00
|
|
|
int show_whitespace;
|
2016-06-10 23:46:30 +00:00
|
|
|
|
|
|
|
i32_Rect file_region;
|
|
|
|
GUI_Scroll_Vars scroll_vars;
|
2016-02-24 05:16:08 +00:00
|
|
|
};
|
2016-05-12 17:41:52 +00:00
|
|
|
inline View_Summary
|
|
|
|
view_summary_zero(){
|
|
|
|
View_Summary summary={0};
|
|
|
|
return(summary);
|
|
|
|
}
|
2016-02-24 05:16:08 +00:00
|
|
|
|
2016-02-26 17:40:51 +00:00
|
|
|
struct User_Input{
|
2016-02-27 07:44:17 +00:00
|
|
|
int type;
|
2016-02-27 17:34:13 +00:00
|
|
|
int abort;
|
2016-02-27 07:44:17 +00:00
|
|
|
union{
|
|
|
|
Key_Event_Data key;
|
|
|
|
Mouse_State mouse;
|
|
|
|
};
|
2016-02-27 17:34:13 +00:00
|
|
|
unsigned long long command;
|
2016-02-26 17:40:51 +00:00
|
|
|
};
|
|
|
|
|
2016-02-27 17:34:13 +00:00
|
|
|
#define CommandEqual(c1,c2) ((unsigned long long)(c1) == (unsigned long long)(c2))
|
|
|
|
|
2016-02-27 07:44:17 +00:00
|
|
|
struct Query_Bar{
|
2016-02-26 17:40:51 +00:00
|
|
|
String prompt;
|
|
|
|
String string;
|
|
|
|
};
|
|
|
|
|
2016-05-25 02:12:49 +00:00
|
|
|
struct Event_Message{
|
|
|
|
int type;
|
|
|
|
};
|
|
|
|
|
2016-03-05 04:10:55 +00:00
|
|
|
struct Theme_Color{
|
|
|
|
Style_Tag tag;
|
|
|
|
unsigned int color;
|
|
|
|
};
|
|
|
|
|
2016-06-23 23:11:09 +00:00
|
|
|
// Flags and enum values
|
|
|
|
// TODO(allen): auto generate this and the docs for it
|
|
|
|
enum User_Input_Type_ID{
|
|
|
|
UserInputNone,
|
|
|
|
UserInputKey,
|
|
|
|
UserInputMouse
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Event_Message_Type_ID{
|
|
|
|
EventMessage_NoMessage,
|
|
|
|
EventMessage_OpenView,
|
|
|
|
EventMessage_Frame,
|
|
|
|
EventMessage_CloseView
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Buffer_Setting_ID{
|
|
|
|
BufferSetting_Null,
|
|
|
|
BufferSetting_Lex,
|
|
|
|
BufferSetting_WrapLine,
|
|
|
|
BufferSetting_MapID,
|
|
|
|
};
|
|
|
|
|
2016-06-24 02:21:11 +00:00
|
|
|
enum Buffer_Kill_Flag{
|
|
|
|
BufferKill_Background = 0x1,
|
|
|
|
BufferKill_AlwaysKill = 0x2,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Buffer_Create_Flag{
|
|
|
|
BufferCreate_Background = 0x1,
|
|
|
|
BufferCreate_AlwaysNew = 0x2,
|
|
|
|
};
|
|
|
|
|
2016-06-23 23:11:09 +00:00
|
|
|
enum Access_Flag{
|
2016-06-20 20:34:48 +00:00
|
|
|
AccessOpen = 0x0,
|
|
|
|
AccessProtected = 0x1,
|
|
|
|
AccessHidden = 0x2,
|
|
|
|
AccessAll = 0xFF
|
|
|
|
};
|
|
|
|
|
2016-06-23 23:11:09 +00:00
|
|
|
enum Seek_Boundry_Flag{
|
|
|
|
BoundryWhitespace = 0x1,
|
|
|
|
BoundryToken = 0x2,
|
|
|
|
BoundryAlphanumeric = 0x4,
|
|
|
|
BoundryCamelCase = 0x8
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Command_Line_Input_Flag{
|
|
|
|
CLI_OverlapWithConflict = 0x1,
|
|
|
|
CLI_AlwaysBindToView = 0x2,
|
|
|
|
CLI_CursorAtEnd = 0x4,
|
|
|
|
};
|
|
|
|
|
2016-06-24 02:53:33 +00:00
|
|
|
enum Auto_Indent_Flag{
|
|
|
|
AutoIndent_ClearLine = 0x1,
|
|
|
|
AutoIndent_UseTab = 0x2
|
2016-06-23 23:11:09 +00:00
|
|
|
};
|
|
|
|
|
2016-06-24 04:02:09 +00:00
|
|
|
enum Set_Buffer_Flag{
|
|
|
|
SetBuffer_KeepOriginalGUI = 0x1
|
|
|
|
};
|
|
|
|
|
2016-06-23 23:11:09 +00:00
|
|
|
enum Input_Type_Flag{
|
|
|
|
EventOnAnyKey = 0x1,
|
|
|
|
EventOnEsc = 0x2,
|
|
|
|
EventOnLeftButton = 0x4,
|
|
|
|
EventOnRightButton = 0x8,
|
|
|
|
EventOnWheel = 0x10,
|
|
|
|
EventOnButton = (EventOnLeftButton | EventOnRightButton | EventOnWheel),
|
|
|
|
|
|
|
|
// NOTE(allen): These don't work so much, so let's pretend they're not here for now.
|
|
|
|
EventOnMouseMove = 0x20,
|
|
|
|
EventOnMouse = (EventOnButton | EventOnMouseMove),
|
|
|
|
|
|
|
|
EventAll = 0xFF
|
|
|
|
};
|
2016-03-05 04:10:55 +00:00
|
|
|
|
2016-05-25 02:12:49 +00:00
|
|
|
#define VIEW_ROUTINE_SIG(name) void name(struct Application_Links *app, int view_id)
|
2016-02-25 23:52:11 +00:00
|
|
|
#define GET_BINDING_DATA(name) int name(void *data, int size)
|
2016-02-26 06:26:26 +00:00
|
|
|
#define CUSTOM_COMMAND_SIG(name) void name(struct Application_Links *app)
|
2016-03-07 05:13:20 +00:00
|
|
|
#define HOOK_SIG(name) int name(struct Application_Links *app)
|
2016-06-23 23:11:09 +00:00
|
|
|
#define OPEN_FILE_HOOK_SIG(name) int name(struct Application_Links *app, int buffer_id)
|
2016-06-07 16:26:11 +00:00
|
|
|
#define SCROLL_RULE_SIG(name) int name(float target_x, float target_y, float *scroll_x, float *scroll_y, int view_id, int is_new_target, float dt)
|
2016-02-01 05:03:42 +00:00
|
|
|
|
2016-06-29 18:23:14 +00:00
|
|
|
typedef VIEW_ROUTINE_SIG(View_Routine_Function);
|
|
|
|
typedef CUSTOM_COMMAND_SIG(Custom_Command_Function);
|
|
|
|
typedef GET_BINDING_DATA(Get_Binding_Data_Function);
|
|
|
|
typedef HOOK_SIG(Hook_Function);
|
|
|
|
|
|
|
|
typedef OPEN_FILE_HOOK_SIG(Open_File_Hook_Function);
|
|
|
|
typedef SCROLL_RULE_SIG(Scroll_Rule_Function);
|
|
|
|
|
|
|
|
union Generic_Command{
|
|
|
|
Command_ID cmdid;
|
|
|
|
Custom_Command_Function *command;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define COMMAND_CALLER_HOOK(name) int name(struct Application_Links *app, Generic_Command cmd)
|
|
|
|
typedef COMMAND_CALLER_HOOK(Command_Caller_Hook_Function);
|
|
|
|
|
|
|
|
|
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-03-07 05:13:20 +00:00
|
|
|
#define _GET_VERSION_SIG(n) int n(int maj, int min, int patch)
|
|
|
|
typedef _GET_VERSION_SIG(_Get_Version_Function);
|
|
|
|
|
|
|
|
extern "C" _GET_VERSION_SIG(get_alpha_4coder_version){
|
|
|
|
int result = (maj == MAJOR && min == MINOR && patch == PATCH);
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
// 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{
|
|
|
|
struct{ int total_size; int user_map_count; int error; } header;
|
|
|
|
|
2016-05-19 13:29:38 +00:00
|
|
|
struct{ int mapid; int replace; int bind_count; } map_begin;
|
2016-02-01 05:03:42 +00:00
|
|
|
struct{ int mapid; } map_inherit;
|
|
|
|
struct{
|
|
|
|
short code;
|
|
|
|
unsigned char modifiers;
|
|
|
|
int command_id;
|
|
|
|
} binding;
|
|
|
|
struct{
|
|
|
|
short code;
|
|
|
|
unsigned char modifiers;
|
|
|
|
Custom_Command_Function *func;
|
|
|
|
} callback;
|
|
|
|
struct{
|
|
|
|
int 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
|