doc rewrites into full sentences.
parent
6f81e5d3d5
commit
c1986f6f44
1437
4coder_API.html
1437
4coder_API.html
File diff suppressed because it is too large
Load Diff
|
@ -26,8 +26,35 @@ typedef struct Offset_String{
|
||||||
} Offset_String;
|
} Offset_String;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
#include "4coder_types.h"
|
#include "4coder_types.h"
|
||||||
|
|
||||||
|
#define COMMAND_CALLER_HOOK(name) int name(struct Application_Links *app, Generic_Command cmd)
|
||||||
|
typedef COMMAND_CALLER_HOOK(Command_Caller_Hook_Function);
|
||||||
|
|
||||||
inline Key_Event_Data
|
inline Key_Event_Data
|
||||||
key_event_data_zero(){
|
key_event_data_zero(){
|
||||||
Key_Event_Data data={0};
|
Key_Event_Data data={0};
|
||||||
|
@ -51,50 +78,26 @@ make_range(int p1, int p2){
|
||||||
}
|
}
|
||||||
return(range);
|
return(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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,
|
|
||||||
};
|
|
||||||
|
|
||||||
inline Buffer_Summary
|
inline Buffer_Summary
|
||||||
buffer_summary_zero(){
|
buffer_summary_zero(){
|
||||||
Buffer_Summary summary={0};
|
Buffer_Summary summary={0};
|
||||||
return(summary);
|
return(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline View_Summary
|
inline View_Summary
|
||||||
view_summary_zero(){
|
view_summary_zero(){
|
||||||
View_Summary summary={0};
|
View_Summary summary={0};
|
||||||
return(summary);
|
return(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CommandEqual(c1,c2) ((unsigned long long)(c1) == (unsigned long long)(c2))
|
|
||||||
|
|
||||||
#define VIEW_ROUTINE_SIG(name) void name(struct Application_Links *app, int view_id)
|
#define VIEW_ROUTINE_SIG(name) void name(struct Application_Links *app, int view_id)
|
||||||
#define GET_BINDING_DATA(name) int name(void *data, int size)
|
#define GET_BINDING_DATA(name) int name(void *data, int size)
|
||||||
#define CUSTOM_COMMAND_SIG(name) void name(struct Application_Links *app)
|
|
||||||
#define HOOK_SIG(name) int name(struct Application_Links *app)
|
#define HOOK_SIG(name) int name(struct Application_Links *app)
|
||||||
#define OPEN_FILE_HOOK_SIG(name) int name(struct Application_Links *app, int buffer_id)
|
#define OPEN_FILE_HOOK_SIG(name) int name(struct Application_Links *app, int buffer_id)
|
||||||
#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)
|
#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)
|
||||||
#define INPUT_FILTER_SIG(name) void name(Mouse_State *mouse)
|
#define INPUT_FILTER_SIG(name) void name(Mouse_State *mouse)
|
||||||
|
|
||||||
typedef VIEW_ROUTINE_SIG(View_Routine_Function);
|
typedef VIEW_ROUTINE_SIG(View_Routine_Function);
|
||||||
typedef CUSTOM_COMMAND_SIG(Custom_Command_Function);
|
|
||||||
typedef GET_BINDING_DATA(Get_Binding_Data_Function);
|
typedef GET_BINDING_DATA(Get_Binding_Data_Function);
|
||||||
typedef HOOK_SIG(Hook_Function);
|
typedef HOOK_SIG(Hook_Function);
|
||||||
|
|
||||||
|
@ -102,13 +105,6 @@ typedef OPEN_FILE_HOOK_SIG(Open_File_Hook_Function);
|
||||||
typedef SCROLL_RULE_SIG(Scroll_Rule_Function);
|
typedef SCROLL_RULE_SIG(Scroll_Rule_Function);
|
||||||
typedef INPUT_FILTER_SIG(Input_Filter_Function);
|
typedef INPUT_FILTER_SIG(Input_Filter_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);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
#define EXEC_COMMAND_SIG(n) void n(Application_Links *app, uint64_t command_id)
|
#define EXEC_COMMAND_SIG(n) bool32 n(Application_Links *app, Command_ID command_id)
|
||||||
#define EXEC_SYSTEM_COMMAND_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int path_len, char *command, int command_len, unsigned int flags)
|
#define EXEC_SYSTEM_COMMAND_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Input_Flag flags)
|
||||||
#define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, char *str, int len)
|
#define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, int32_t clipboard_id, char *str, int32_t len)
|
||||||
#define CLIPBOARD_COUNT_SIG(n) int n(Application_Links *app)
|
#define CLIPBOARD_COUNT_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id)
|
||||||
#define CLIPBOARD_INDEX_SIG(n) int n(Application_Links *app, int index, char *out, int len)
|
#define CLIPBOARD_INDEX_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len)
|
||||||
#define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app, unsigned int access)
|
#define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app, Access_Flag access)
|
||||||
#define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer, unsigned int access)
|
#define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer, Access_Flag access)
|
||||||
#define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, int buffer_id, unsigned int access)
|
#define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, Buffer_ID buffer_id, Access_Flag access)
|
||||||
#define GET_BUFFER_BY_NAME_SIG(n) Buffer_Summary n(Application_Links *app, char *name, int len, unsigned int access)
|
#define GET_BUFFER_BY_NAME_SIG(n) Buffer_Summary n(Application_Links *app, char *name, int32_t len, Access_Flag access)
|
||||||
#define BUFFER_BOUNDARY_SEEK_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start_pos, int seek_forward, unsigned int flags)
|
#define BUFFER_BOUNDARY_SEEK_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags)
|
||||||
#define BUFFER_READ_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out)
|
#define BUFFER_READ_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out)
|
||||||
#define BUFFER_REPLACE_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len)
|
#define BUFFER_REPLACE_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len)
|
||||||
#define BUFFER_SET_SETTING_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int setting, int value)
|
#define BUFFER_SET_SETTING_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value)
|
||||||
#define BUFFER_AUTO_INDENT_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, int tab_width, unsigned int flags)
|
#define BUFFER_AUTO_INDENT_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, int32_t tab_width, Auto_Indent_Flag flags)
|
||||||
#define CREATE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int filename_len, unsigned int flags)
|
#define CREATE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags)
|
||||||
#define SAVE_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, char *filename, int filename_len, unsigned int flags)
|
#define SAVE_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags)
|
||||||
#define KILL_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Identifier buffer, int view_id, unsigned int flags)
|
#define KILL_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags)
|
||||||
#define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app, unsigned int access)
|
#define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app, Access_Flag access)
|
||||||
#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, unsigned int access)
|
#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, Access_Flag access)
|
||||||
#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, int view_id, unsigned int access)
|
#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, View_ID view_id, Access_Flag access)
|
||||||
#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app, unsigned int access)
|
#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app, Access_Flag access)
|
||||||
#define SET_ACTIVE_VIEW_SIG(n) int n(Application_Links *app, View_Summary *view)
|
#define SET_ACTIVE_VIEW_SIG(n) bool32 n(Application_Links *app, View_Summary *view)
|
||||||
#define VIEW_SET_SETTING_SIG(n) int n(Application_Links *app, View_Summary *view, int setting, int value)
|
#define VIEW_SET_SETTING_SIG(n) bool32 n(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value)
|
||||||
#define VIEW_SET_SPLIT_PROPORTION_SIG(n) int n(Application_Links *app, View_Summary *view, float t)
|
#define VIEW_SET_SPLIT_PROPORTION_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float t)
|
||||||
#define VIEW_COMPUTE_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out)
|
#define VIEW_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out)
|
||||||
#define VIEW_SET_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x)
|
#define VIEW_SET_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x)
|
||||||
#define VIEW_SET_MARK_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
|
#define VIEW_SET_MARK_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
|
||||||
#define VIEW_SET_HIGHLIGHT_SIG(n) int n(Application_Links *app, View_Summary *view, int start, int end, int turn_on)
|
#define VIEW_SET_HIGHLIGHT_SIG(n) bool32 n(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on)
|
||||||
#define VIEW_SET_BUFFER_SIG(n) int n(Application_Links *app, View_Summary *view, int buffer_id, unsigned int flags)
|
#define VIEW_SET_BUFFER_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags)
|
||||||
#define VIEW_POST_FADE_SIG(n) int n(Application_Links *app, View_Summary *view, float seconds, int start, int end, unsigned int color)
|
#define VIEW_POST_FADE_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color)
|
||||||
#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, unsigned int get_type, unsigned int abort_type)
|
#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type)
|
||||||
#define GET_COMMAND_INPUT_SIG(n) User_Input n(Application_Links *app)
|
#define GET_COMMAND_INPUT_SIG(n) User_Input n(Application_Links *app)
|
||||||
#define GET_MOUSE_STATE_SIG(n) Mouse_State n(Application_Links *app)
|
#define GET_MOUSE_STATE_SIG(n) Mouse_State n(Application_Links *app)
|
||||||
#define START_QUERY_BAR_SIG(n) int n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
#define START_QUERY_BAR_SIG(n) bool32 n(Application_Links *app, Query_Bar *bar, uint32_t flags)
|
||||||
#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, uint32_t flags)
|
||||||
#define PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *str, int len)
|
#define PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *str, int32_t len)
|
||||||
#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int len)
|
#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int32_t len)
|
||||||
#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int len)
|
#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int32_t len)
|
||||||
#define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int count)
|
#define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int32_t count)
|
||||||
#define GET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int count)
|
#define GET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int32_t count)
|
||||||
#define DIRECTORY_GET_HOT_SIG(n) int n(Application_Links *app, char *out, int capacity)
|
#define DIRECTORY_GET_HOT_SIG(n) int32_t n(Application_Links *app, char *out, int32_t capacity)
|
||||||
#define GET_FILE_LIST_SIG(n) File_List n(Application_Links *app, char *dir, int len)
|
#define GET_FILE_LIST_SIG(n) File_List n(Application_Links *app, char *dir, int32_t len)
|
||||||
#define FREE_FILE_LIST_SIG(n) void n(Application_Links *app, File_List list)
|
#define FREE_FILE_LIST_SIG(n) void n(Application_Links *app, File_List list)
|
||||||
#define FILE_EXISTS_SIG(n) int n(Application_Links *app, char *filename, int len)
|
#define FILE_EXISTS_SIG(n) bool32 n(Application_Links *app, char *filename, int len)
|
||||||
#define DIRECTORY_CD_SIG(n) int n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)
|
#define DIRECTORY_CD_SIG(n) bool32 n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)
|
||||||
#define GET_4ED_PATH_SIG(n) int n(Application_Links *app, char *out, int capacity)
|
#define GET_4ED_PATH_SIG(n) bool32 n(Application_Links *app, char *out, int32_t capacity)
|
||||||
#define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, int show)
|
#define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show)
|
||||||
extern "C"{
|
extern "C"{
|
||||||
typedef EXEC_COMMAND_SIG(Exec_Command_Function);
|
typedef EXEC_COMMAND_SIG(Exec_Command_Function);
|
||||||
typedef EXEC_SYSTEM_COMMAND_SIG(Exec_System_Command_Function);
|
typedef EXEC_SYSTEM_COMMAND_SIG(Exec_System_Command_Function);
|
||||||
|
|
|
@ -236,7 +236,7 @@ clipboard_copy(Application_Links *app, int start, int end, Buffer_Summary *buffe
|
||||||
|
|
||||||
if (size <= app->memory_size){
|
if (size <= app->memory_size){
|
||||||
app->buffer_read_range(app, &buffer, start, end, str);
|
app->buffer_read_range(app, &buffer, start, end, str);
|
||||||
app->clipboard_post(app, str, size);
|
app->clipboard_post(app, 0, str, size);
|
||||||
if (buffer_out){*buffer_out = buffer;}
|
if (buffer_out){*buffer_out = buffer;}
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ View_Paste_Index *view_paste_index = view_paste_index_ - 1;
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(paste){
|
CUSTOM_COMMAND_SIG(paste){
|
||||||
unsigned int access = AccessOpen;
|
unsigned int access = AccessOpen;
|
||||||
int count = app->clipboard_count(app);
|
int count = app->clipboard_count(app, 0);
|
||||||
if (count > 0){
|
if (count > 0){
|
||||||
View_Summary view = app->get_active_view(app, access);
|
View_Summary view = app->get_active_view(app, access);
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ CUSTOM_COMMAND_SIG(paste){
|
||||||
int paste_index = 0;
|
int paste_index = 0;
|
||||||
view_paste_index[view.view_id].index = paste_index;
|
view_paste_index[view.view_id].index = paste_index;
|
||||||
|
|
||||||
int len = app->clipboard_index(app, paste_index, 0, 0);
|
int len = app->clipboard_index(app, 0, paste_index, 0, 0);
|
||||||
char *str = 0;
|
char *str = 0;
|
||||||
|
|
||||||
if (len <= app->memory_size){
|
if (len <= app->memory_size){
|
||||||
|
@ -302,7 +302,7 @@ CUSTOM_COMMAND_SIG(paste){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str){
|
if (str){
|
||||||
app->clipboard_index(app, paste_index, str, len);
|
app->clipboard_index(app, 0, paste_index, str, len);
|
||||||
|
|
||||||
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
||||||
int pos = view.cursor.pos;
|
int pos = view.cursor.pos;
|
||||||
|
@ -321,7 +321,7 @@ CUSTOM_COMMAND_SIG(paste){
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(paste_next){
|
CUSTOM_COMMAND_SIG(paste_next){
|
||||||
unsigned int access = AccessOpen;
|
unsigned int access = AccessOpen;
|
||||||
int count = app->clipboard_count(app);
|
int count = app->clipboard_count(app, 0);
|
||||||
if (count > 0){
|
if (count > 0){
|
||||||
View_Summary view = app->get_active_view(app, access);
|
View_Summary view = app->get_active_view(app, access);
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ CUSTOM_COMMAND_SIG(paste_next){
|
||||||
int paste_index = view_paste_index[view.view_id].index + 1;
|
int paste_index = view_paste_index[view.view_id].index + 1;
|
||||||
view_paste_index[view.view_id].index = paste_index;
|
view_paste_index[view.view_id].index = paste_index;
|
||||||
|
|
||||||
int len = app->clipboard_index(app, paste_index, 0, 0);
|
int len = app->clipboard_index(app, 0, paste_index, 0, 0);
|
||||||
char *str = 0;
|
char *str = 0;
|
||||||
|
|
||||||
if (len <= app->memory_size){
|
if (len <= app->memory_size){
|
||||||
|
@ -342,7 +342,7 @@ CUSTOM_COMMAND_SIG(paste_next){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str){
|
if (str){
|
||||||
app->clipboard_index(app, paste_index, str, len);
|
app->clipboard_index(app, 0, paste_index, str, len);
|
||||||
|
|
||||||
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
||||||
Range range = get_range(&view);
|
Range range = get_range(&view);
|
||||||
|
@ -970,9 +970,9 @@ isearch(Application_Links *app, int start_reversed){
|
||||||
int step_forward = 0;
|
int step_forward = 0;
|
||||||
int step_backward = 0;
|
int step_backward = 0;
|
||||||
|
|
||||||
if (CommandEqual(in.command, search) ||
|
if ((in.command.command == search) ||
|
||||||
in.key.keycode == key_page_down || in.key.keycode == key_down) step_forward = 1;
|
in.key.keycode == key_page_down || in.key.keycode == key_down) step_forward = 1;
|
||||||
if (CommandEqual(in.command, reverse_search) ||
|
if ((in.command.command == reverse_search) ||
|
||||||
in.key.keycode == key_page_up || in.key.keycode == key_up) step_backward = 1;
|
in.key.keycode == key_page_up || in.key.keycode == key_up) step_backward = 1;
|
||||||
|
|
||||||
int start_pos = pos;
|
int start_pos = pos;
|
||||||
|
@ -1365,6 +1365,39 @@ CUSTOM_COMMAND_SIG(write_and_auto_tab){
|
||||||
// Default Building Stuff
|
// Default Building Stuff
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// NOTE(allen|a4.0.9): This is provided to establish a default method of getting
|
||||||
|
// a "build directory". This function tries to setup the build directory in the
|
||||||
|
// directory of the given buffer, it cannot it get's the 4coder hot directory.
|
||||||
|
// This behavior is a little different than previous versions of 4coder.
|
||||||
|
//
|
||||||
|
// There is requirement that a custom build system in 4coder actually use the
|
||||||
|
// directory given by this function.
|
||||||
|
static int
|
||||||
|
get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_out){
|
||||||
|
int result = false;
|
||||||
|
|
||||||
|
if (buffer->file_name){
|
||||||
|
if (!match(buffer->file_name, buffer->buffer_name)){
|
||||||
|
String dir = make_string(buffer->file_name,
|
||||||
|
buffer->file_name_len,
|
||||||
|
buffer->file_name_len+1);
|
||||||
|
remove_last_folder(&dir);
|
||||||
|
append(dir_out, dir);
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result){
|
||||||
|
int len = app->directory_get_hot(app, dir_out->str,
|
||||||
|
dir_out->memory_size - dir_out->size);
|
||||||
|
if (len + dir_out->size < dir_out->memory_size){
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(build_search_regular){
|
CUSTOM_COMMAND_SIG(build_search_regular){
|
||||||
// NOTE(allen|a3.3): An example of traversing the filesystem through parent
|
// NOTE(allen|a3.3): An example of traversing the filesystem through parent
|
||||||
// directories looking for a file, in this case a batch file to execute.
|
// directories looking for a file, in this case a batch file to execute.
|
||||||
|
@ -1401,14 +1434,15 @@ CUSTOM_COMMAND_SIG(build_search_regular){
|
||||||
// This doesn't actually change the hot directory of 4coder, it's only effect is to
|
// This doesn't actually change the hot directory of 4coder, it's only effect is to
|
||||||
// modify the string you passed in to reflect the change in directory if that change was possible.
|
// modify the string you passed in to reflect the change in directory if that change was possible.
|
||||||
|
|
||||||
int old_size;
|
int old_size = 0;
|
||||||
int size = app->memory_size/2;
|
int size = app->memory_size/2;
|
||||||
|
|
||||||
unsigned int access = AccessAll;
|
unsigned int access = AccessAll;
|
||||||
View_Summary view = app->get_active_view(app, access);
|
View_Summary view = app->get_active_view(app, access);
|
||||||
|
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
||||||
|
|
||||||
String dir = make_string(app->memory, 0, size);
|
String dir = make_string(app->memory, 0, size);
|
||||||
dir.size = app->directory_get_hot(app, dir.str, dir.memory_size);
|
get_build_directory(app, &buffer, &dir);
|
||||||
|
|
||||||
String command = make_string((char*)app->memory + size, 0, size);
|
String command = make_string((char*)app->memory + size, 0, size);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,25 @@
|
||||||
|
|
||||||
|
|
||||||
/* DOC(Key_Code is the type alias for key codes.) */
|
/* DOC(bool32 is an alias name to signal that an integer parameter or field is for
|
||||||
|
true/false vales.) */
|
||||||
|
typedef int32_t bool32;
|
||||||
|
|
||||||
|
/* DOC(int_color is an alias name to signal that an integer parameter or field is for
|
||||||
|
a color value, colors are specified as 24 bit integers in 3 channels: 0xRRGGBB.) */
|
||||||
|
typedef uint32_t int_color;
|
||||||
|
|
||||||
|
/* DOC(Key_Code is the alias for key codes including raw codes and codes translated
|
||||||
|
to textual input that takes modifiers into account.) */
|
||||||
typedef unsigned char Key_Code;
|
typedef unsigned char Key_Code;
|
||||||
|
|
||||||
|
/* DOC(Buffer_ID is used to name a 4coder buffer. Each buffer has a unique id but
|
||||||
|
when a buffer is closed it's id may be recycled by future, different buffers.) */
|
||||||
|
typedef int32_t Buffer_ID;
|
||||||
|
|
||||||
|
/* DOC(View_ID is used to name a 4coder view. Each view has a unique id in
|
||||||
|
the range [1,16].) */
|
||||||
|
typedef int32_t View_ID;
|
||||||
|
|
||||||
#define ENUM(type,name) typedef type name; enum name##_
|
#define ENUM(type,name) typedef type name; enum name##_
|
||||||
#define FLAGENUM(name) typedef uint32_t name; enum name##_
|
#define FLAGENUM(name) typedef uint32_t name; enum name##_
|
||||||
|
|
||||||
|
@ -269,14 +286,26 @@ ENUM(int32_t, Mouse_Cursor_Show_Type){
|
||||||
// MouseCursorShow_WhenActive,// TODO(allen): coming soon
|
// MouseCursorShow_WhenActive,// TODO(allen): coming soon
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* DOC(
|
||||||
|
Generic_Command acts as a name for a command, and can name an
|
||||||
|
internal command or a custom command.
|
||||||
|
)*/
|
||||||
|
union Generic_Command{
|
||||||
|
/*DOC(If this Generic_Command represents an internal command the cmdid field
|
||||||
|
will have a value less than cmdid_count, and this field is the command id for the command.)*/
|
||||||
|
Command_ID cmdid;
|
||||||
|
/*DOC(If this Generic_Command does not represent an internal command the command
|
||||||
|
field is the pointer to the custom command..)*/
|
||||||
|
Custom_Command_Function *command;
|
||||||
|
};
|
||||||
|
|
||||||
/* DOC(
|
/* DOC(
|
||||||
Key_Event_Data describes a key event, including the
|
Key_Event_Data describes a key event, including the
|
||||||
translation to a character, the translation to
|
translation to a character, the translation to
|
||||||
a character ignoring the state of caps lock, and
|
a character ignoring the state of caps lock, and
|
||||||
an array of all the modifiers that were pressed
|
an array of all the modifiers that were pressed
|
||||||
at the time of the event.
|
at the time of the event.
|
||||||
)
|
)*/
|
||||||
*/
|
|
||||||
struct Key_Event_Data{
|
struct Key_Event_Data{
|
||||||
/* DOC(This field is the raw keycode which is always non-zero in valid key events.) */
|
/* DOC(This field is the raw keycode which is always non-zero in valid key events.) */
|
||||||
Key_Code keycode;
|
Key_Code keycode;
|
||||||
|
@ -405,39 +434,39 @@ struct Buffer_Summary{
|
||||||
This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder.
|
This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder.
|
||||||
When this field is false the summary is referred to as a "null summary".
|
When this field is false the summary is referred to as a "null summary".
|
||||||
) */
|
) */
|
||||||
int exists;
|
bool32 exists;
|
||||||
/* DOC(If this is not a null summary, this field indicates whether the buffer has finished loading.) */
|
/* DOC(If this is not a null summary, this field indicates whether the buffer has finished loading.) */
|
||||||
int ready;
|
bool32 ready;
|
||||||
/* DOC(
|
/* DOC(
|
||||||
If this is not a null summary this field is the id of the associated buffer.
|
If this is not a null summary this field is the id of the associated buffer.
|
||||||
If this is a null summary then buffer_id is 0.
|
If this is a null summary then buffer_id is 0.
|
||||||
) */
|
) */
|
||||||
int buffer_id;
|
int32_t buffer_id;
|
||||||
/*
|
/*
|
||||||
DOC(If this is not a null summary, this field contains flags describing the protection status of the buffer.)
|
DOC(If this is not a null summary, this field contains flags describing the protection status of the buffer.)
|
||||||
DOC_SEE(Access_Flag)
|
DOC_SEE(Access_Flag)
|
||||||
*/
|
*/
|
||||||
unsigned int lock_flags;
|
Access_Flag lock_flags;
|
||||||
|
|
||||||
/* DOC(If this is not a null summary, this field specifies the size of the text in the buffer.) */
|
/* DOC(If this is not a null summary, this field specifies the size of the text in the buffer.) */
|
||||||
int size;
|
int32_t size;
|
||||||
|
|
||||||
/* DOC(If this is not a null summary, this field specifies the file name associated to this buffer.) */
|
/* DOC(If this is not a null summary, this field specifies the file name associated to this buffer.) */
|
||||||
char *file_name;
|
char *file_name;
|
||||||
/* DOC(This field specifies the length of the file_name string.) */
|
/* DOC(This field specifies the length of the file_name string.) */
|
||||||
int file_name_len;
|
int32_t file_name_len;
|
||||||
|
|
||||||
/* DOC(If this is not a null summary, this field specifies the name of the buffer.) */
|
/* DOC(If this is not a null summary, this field specifies the name of the buffer.) */
|
||||||
char *buffer_name;
|
char *buffer_name;
|
||||||
/* DOC(This field specifies the length of the buffer_name string.) */
|
/* DOC(This field specifies the length of the buffer_name string.) */
|
||||||
int buffer_name_len;
|
int32_t buffer_name_len;
|
||||||
|
|
||||||
/* DOC(This is a hold over from an old system, consider it deprecated.) */
|
/* DOC(This is a hold over from an old system, consider it deprecated.) */
|
||||||
int buffer_cursor_pos;
|
int32_t buffer_cursor_pos;
|
||||||
/* DOC(If this is not a null summary, this field indicates whether the buffer is set to lex tokens.) */
|
/* DOC(If this is not a null summary, this field indicates whether the buffer is set to lex tokens.) */
|
||||||
int is_lexed;
|
bool32 is_lexed;
|
||||||
/* DOC(If this is not a null summary, this field specifies the id of the command map for this buffer.) */
|
/* DOC(If this is not a null summary, this field specifies the id of the command map for this buffer.) */
|
||||||
int map_id;
|
int32_t map_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DOC(
|
/* DOC(
|
||||||
|
@ -448,19 +477,19 @@ struct View_Summary{
|
||||||
This field indicates whether the View_Summary describes a view that is open in 4coder.
|
This field indicates whether the View_Summary describes a view that is open in 4coder.
|
||||||
When this field is false the summary is referred to as a "null summary".
|
When this field is false the summary is referred to as a "null summary".
|
||||||
) */
|
) */
|
||||||
int exists;
|
bool32 exists;
|
||||||
/* DOC(
|
/* DOC(
|
||||||
If this is not a null summary, this field is the id of the associated view.
|
If this is not a null summary, this field is the id of the associated view.
|
||||||
If this is a null summary then view_id is 0.
|
If this is a null summary then view_id is 0.
|
||||||
) */
|
) */
|
||||||
int view_id;
|
int32_t view_id;
|
||||||
/* DOC(If this is not a null summary, and this view looks at a buffer, this is the id of the buffer.) */
|
/* DOC(If this is not a null summary, and this view looks at a buffer, this is the id of the buffer.) */
|
||||||
int buffer_id;
|
int32_t buffer_id;
|
||||||
/*
|
/*
|
||||||
DOC(If this is not a null summary, this field contains flags describing the protection status of the view.)
|
DOC(If this is not a null summary, this field contains flags describing the protection status of the view.)
|
||||||
DOC_SEE(Access_Flag)
|
DOC_SEE(Access_Flag)
|
||||||
*/
|
*/
|
||||||
unsigned int lock_flags;
|
Access_Flag lock_flags;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DOC(If this is not a null summary, this describes the position of the cursor.)
|
DOC(If this is not a null summary, this describes the position of the cursor.)
|
||||||
|
@ -477,9 +506,9 @@ struct View_Summary{
|
||||||
/* DOC(If this is not a null summary, this specifies the height of a line rendered in the view.) */
|
/* DOC(If this is not a null summary, this specifies the height of a line rendered in the view.) */
|
||||||
float line_height;
|
float line_height;
|
||||||
/* DOC(If this is not a null summary, this indicates that the view is set to render with unwrapped lines.) */
|
/* DOC(If this is not a null summary, this indicates that the view is set to render with unwrapped lines.) */
|
||||||
int unwrapped_lines;
|
bool32 unwrapped_lines;
|
||||||
/* DOC(If this is not a null summary, this indicates that the view is set to highlight white space.) */
|
/* DOC(If this is not a null summary, this indicates that the view is set to highlight white space.) */
|
||||||
int show_whitespace;
|
bool32 show_whitespace;
|
||||||
|
|
||||||
/* DOC(This feature is not fully implemented yet.) */
|
/* DOC(This feature is not fully implemented yet.) */
|
||||||
i32_Rect file_region;
|
i32_Rect file_region;
|
||||||
|
@ -487,15 +516,18 @@ struct View_Summary{
|
||||||
GUI_Scroll_Vars scroll_vars;
|
GUI_Scroll_Vars scroll_vars;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DOC(User_Input describes a user input event which can be either a key press or mouse event.) */
|
/*
|
||||||
|
DOC(User_Input describes a user input event which can be either a key press or mouse event.)
|
||||||
|
DOC_SEE(User_Input_Type_ID)
|
||||||
|
DOC_SEE(Generic_Command)
|
||||||
|
*/
|
||||||
struct User_Input{
|
struct User_Input{
|
||||||
/*
|
/*
|
||||||
DOC(This field specifies whether the event was a key press or mouse event.)
|
DOC(This field specifies whether the event was a key press or mouse event.)
|
||||||
DOC_SEE(User_Input_Type_ID)
|
|
||||||
*/
|
*/
|
||||||
int type;
|
User_Input_Type_ID type;
|
||||||
/* DOC(This field indicates that an abort event has occurred and the command needs to shut down.) */
|
/* DOC(This field indicates that an abort event has occurred and the command needs to shut down.) */
|
||||||
int abort;
|
bool32 abort;
|
||||||
union{
|
union{
|
||||||
/* DOC(This field describes a key press event.) */
|
/* DOC(This field describes a key press event.) */
|
||||||
Key_Event_Data key;
|
Key_Event_Data key;
|
||||||
|
@ -504,9 +536,8 @@ struct User_Input{
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
DOC(If this event would trigger a command, this field specifies what the command would be.)
|
DOC(If this event would trigger a command, this field specifies what the command would be.)
|
||||||
TODO
|
|
||||||
*/
|
*/
|
||||||
unsigned long long command;
|
Generic_Command command;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DOC(Query_Bar is a struct used to store information in the user's control
|
/* DOC(Query_Bar is a struct used to store information in the user's control
|
||||||
|
@ -527,11 +558,11 @@ struct Event_Message{
|
||||||
/*
|
/*
|
||||||
DOC(Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme .)
|
DOC(Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme .)
|
||||||
DOC_SEE(Style_Tag)
|
DOC_SEE(Style_Tag)
|
||||||
|
DOC_SEE(int_color)
|
||||||
*/
|
*/
|
||||||
struct Theme_Color{
|
struct Theme_Color{
|
||||||
Style_Tag tag;
|
Style_Tag tag;
|
||||||
/* DOC(This field specifies a color in a 24, bit 3 channel RGB integer.) */
|
int_color color;
|
||||||
uint32_t color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
6
4ed.cpp
6
4ed.cpp
|
@ -1318,7 +1318,7 @@ app_hardcode_styles(Models *models){
|
||||||
++style;
|
++style;
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
style_set_name(style, make_lit_string("Magic"));
|
style_set_name(style, make_lit_string("Hjortshoej"));
|
||||||
|
|
||||||
style->main.back_color = 0xFFF0F0F0;
|
style->main.back_color = 0xFFF0F0F0;
|
||||||
style->main.margin_color = 0xFF9E9E9E;
|
style->main.margin_color = 0xFF9E9E9E;
|
||||||
|
@ -2402,7 +2402,7 @@ App_Step_Sig(app_step){
|
||||||
User_Input user_in;
|
User_Input user_in;
|
||||||
user_in.type = UserInputKey;
|
user_in.type = UserInputKey;
|
||||||
user_in.key = key;
|
user_in.key = key;
|
||||||
user_in.command = (unsigned long long)cmd_bind.custom;
|
user_in.command.command = cmd_bind.custom;
|
||||||
user_in.abort = 0;
|
user_in.abort = 0;
|
||||||
|
|
||||||
if ((EventOnEsc & abort_flags) && key.keycode == key_esc){
|
if ((EventOnEsc & abort_flags) && key.keycode == key_esc){
|
||||||
|
@ -2453,7 +2453,7 @@ App_Step_Sig(app_step){
|
||||||
User_Input user_in;
|
User_Input user_in;
|
||||||
user_in.type = UserInputMouse;
|
user_in.type = UserInputMouse;
|
||||||
user_in.mouse = input->mouse;
|
user_in.mouse = input->mouse;
|
||||||
user_in.command = 0;
|
user_in.command.cmdid = 0;
|
||||||
user_in.abort = 0;
|
user_in.abort = 0;
|
||||||
|
|
||||||
if (abort_flags & EventOnMouseMove){
|
if (abort_flags & EventOnMouseMove){
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -163,9 +163,7 @@ file_viewing_data_zero(){
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Recent_File_Data{
|
struct Recent_File_Data{
|
||||||
u64 unique_buffer_id;
|
|
||||||
GUI_Scroll_Vars scroll;
|
GUI_Scroll_Vars scroll;
|
||||||
|
|
||||||
Full_Cursor cursor;
|
Full_Cursor cursor;
|
||||||
i32 mark;
|
i32 mark;
|
||||||
f32 preferred_x;
|
f32 preferred_x;
|
||||||
|
@ -1600,7 +1598,7 @@ view_move_cursor_to_view(View *view, GUI_Scroll_Vars scroll){
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll){
|
view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){
|
||||||
f32 max_x = view_file_width(view);
|
f32 max_x = view_file_width(view);
|
||||||
|
|
||||||
f32 cursor_y = view_get_cursor_y(view);
|
f32 cursor_y = view_get_cursor_y(view);
|
||||||
|
@ -1613,11 +1611,21 @@ view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll){
|
||||||
Cursor_Limits limits = view_cursor_limits(view);
|
Cursor_Limits limits = view_cursor_limits(view);
|
||||||
|
|
||||||
if (cursor_y > target_y + limits.max){
|
if (cursor_y > target_y + limits.max){
|
||||||
|
if (center_view){
|
||||||
|
target_y = ROUND32(cursor_y - limits.max*.5f);
|
||||||
|
}
|
||||||
|
else{
|
||||||
target_y = CEIL32(cursor_y - limits.max + limits.delta);
|
target_y = CEIL32(cursor_y - limits.max + limits.delta);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (cursor_y < target_y + limits.min){
|
if (cursor_y < target_y + limits.min){
|
||||||
|
if (center_view){
|
||||||
|
target_y = ROUND32(cursor_y - limits.max*.5f);
|
||||||
|
}
|
||||||
|
else{
|
||||||
target_y = FLOOR32(cursor_y - limits.delta - limits.min);
|
target_y = FLOOR32(cursor_y - limits.delta - limits.min);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
target_y = clamp(0, target_y, scroll_vars.max_y);
|
target_y = clamp(0, target_y, scroll_vars.max_y);
|
||||||
|
|
||||||
|
@ -1645,13 +1653,6 @@ file_view_nullify_file(View *view){
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
view_set_file(View *view, Editing_File *file, Models *models){
|
view_set_file(View *view, Editing_File *file, Models *models){
|
||||||
#if 0
|
|
||||||
// TODO(allen): This belongs somewhere else.
|
|
||||||
Font_Info *fnt_info = get_font_info(models->font_set, models->global_font.font_id);
|
|
||||||
view->font_advance = fnt_info->advance;
|
|
||||||
view->line_height = fnt_info->height;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (view->file_data.file != 0){
|
if (view->file_data.file != 0){
|
||||||
touch_file(&models->working_set, view->file_data.file);
|
touch_file(&models->working_set, view->file_data.file);
|
||||||
}
|
}
|
||||||
|
@ -1662,18 +1663,16 @@ view_set_file(View *view, Editing_File *file, Models *models){
|
||||||
if (file){
|
if (file){
|
||||||
view->file_data.unwrapped_lines = file->settings.unwrapped_lines;
|
view->file_data.unwrapped_lines = file->settings.unwrapped_lines;
|
||||||
|
|
||||||
u64 unique_buffer_id = file->unique_buffer_id;
|
|
||||||
Recent_File_Data *recent = &view->recent;
|
Recent_File_Data *recent = &view->recent;
|
||||||
|
*recent = recent_file_data_zero();
|
||||||
view->recent = recent_file_data_zero();
|
|
||||||
recent->unique_buffer_id = unique_buffer_id;
|
|
||||||
|
|
||||||
if (file_is_ready(file)){
|
if (file_is_ready(file)){
|
||||||
view_measure_wraps(&models->mem.general, view);
|
view_measure_wraps(&models->mem.general, view);
|
||||||
view->recent.cursor = view_compute_cursor_from_pos(view, file->state.cursor_pos);
|
recent->cursor = view_compute_cursor_from_pos(view, file->state.cursor_pos);
|
||||||
view->recent.scroll.max_y = view_compute_max_target_y(view);
|
recent->scroll.max_y = view_compute_max_target_y(view);
|
||||||
|
recent->preferred_x = view_get_cursor_x(view);
|
||||||
|
|
||||||
view_move_view_to_cursor(view, &view->recent.scroll);
|
view_move_view_to_cursor(view, &recent->scroll, true);
|
||||||
view->reinit_scrolling = 1;
|
view->reinit_scrolling = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3581,7 +3580,7 @@ view_end_cursor_scroll_updates(View *view){
|
||||||
if (view->gui_target.did_file){
|
if (view->gui_target.did_file){
|
||||||
view->recent.scroll.max_y = view_compute_max_target_y(view);
|
view->recent.scroll.max_y = view_compute_max_target_y(view);
|
||||||
}
|
}
|
||||||
view_move_view_to_cursor(view, view->current_scroll);
|
view_move_view_to_cursor(view, view->current_scroll, false);
|
||||||
gui_post_scroll_vars(&view->gui_target, view->current_scroll, view->scroll_region);
|
gui_post_scroll_vars(&view->gui_target, view->current_scroll, view->scroll_region);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -4385,7 +4384,6 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
&keys, &view->list_i, &update);
|
&keys, &view->list_i, &update);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
begin_exhaustive_loop(&loop, hdir);
|
begin_exhaustive_loop(&loop, hdir);
|
||||||
for (i = 0; i < loop.count; ++i){
|
for (i = 0; i < loop.count; ++i){
|
||||||
file_info = get_exhaustive_info(system, &models->working_set, &loop, i);
|
file_info = get_exhaustive_info(system, &models->working_set, &loop, i);
|
||||||
|
@ -4410,7 +4408,6 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gui_end_list(target);
|
gui_end_list(target);
|
||||||
|
|
||||||
|
@ -4938,8 +4935,6 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
{
|
{
|
||||||
Recent_File_Data *recent = &view_ptr->recent;
|
Recent_File_Data *recent = &view_ptr->recent;
|
||||||
|
|
||||||
SHOW_GUI_U64 (2, h_align, "absolute buffer id", recent->unique_buffer_id);
|
|
||||||
SHOW_GUI_BLANK (2);
|
|
||||||
SHOW_GUI_SCROLL(2, h_align, "scroll:", recent->scroll);
|
SHOW_GUI_SCROLL(2, h_align, "scroll:", recent->scroll);
|
||||||
SHOW_GUI_BLANK (2);
|
SHOW_GUI_BLANK (2);
|
||||||
SHOW_GUI_CURSOR(2, h_align, "cursor:", recent->cursor);
|
SHOW_GUI_CURSOR(2, h_align, "cursor:", recent->cursor);
|
||||||
|
|
666
4ed_metagen.cpp
666
4ed_metagen.cpp
|
@ -23,6 +23,12 @@
|
||||||
|
|
||||||
#include "4coder_mem.h"
|
#include "4coder_mem.h"
|
||||||
|
|
||||||
|
struct Global_Settings{
|
||||||
|
int generate_docs;
|
||||||
|
};
|
||||||
|
|
||||||
|
static Global_Settings global_settings;
|
||||||
|
|
||||||
struct Struct_Field{
|
struct Struct_Field{
|
||||||
char *type;
|
char *type;
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -605,7 +611,7 @@ doc_parse_last_parameter(String source, int *pos){
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
perform_doc_parse(String doc_string, Documentation *doc){
|
perform_doc_parse(Partition *part, String doc_string, Documentation *doc){
|
||||||
int keep_parsing = true;
|
int keep_parsing = true;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
|
@ -638,7 +644,7 @@ perform_doc_parse(String doc_string, Documentation *doc){
|
||||||
|
|
||||||
if (param_count + see_count > 0){
|
if (param_count + see_count > 0){
|
||||||
int memory_size = sizeof(String)*(2*param_count + see_count);
|
int memory_size = sizeof(String)*(2*param_count + see_count);
|
||||||
doc->param_name = (String*)malloc(memory_size);
|
doc->param_name = push_array(part, String, memory_size);
|
||||||
doc->param_docs = doc->param_name + param_count;
|
doc->param_docs = doc->param_name + param_count;
|
||||||
doc->see_also = doc->param_docs + param_count;
|
doc->see_also = doc->param_docs + param_count;
|
||||||
|
|
||||||
|
@ -976,6 +982,80 @@ print_struct_html(FILE *file, Struct_Member *member){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define BACK_COLOR "#FAFAFA"
|
||||||
|
#define TEXT_COLOR "#0D0D0D"
|
||||||
|
#define CODE_BACK "#DFDFDF"
|
||||||
|
|
||||||
|
#define POP_COLOR_1 "#309030"
|
||||||
|
#define POP_BACK_1 "#E0FFD0"
|
||||||
|
#define VISITED_LINK "#A0C050"
|
||||||
|
|
||||||
|
#define POP_COLOR_2 "#005000"
|
||||||
|
|
||||||
|
#define CODE_STYLE "font-family: \"Courier New\", Courier, monospace; text-align: left;"
|
||||||
|
|
||||||
|
#define DESCRIPT_SECTION_STYLE \
|
||||||
|
"margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; " \
|
||||||
|
"background: "CODE_BACK"; padding: 0.25em;"
|
||||||
|
|
||||||
|
#define DOC_HEAD_OPEN "<div style='margin-top: 3mm; margin-bottom: 3mm; color: "POP_COLOR_1";'><b><i>"
|
||||||
|
#define DOC_HEAD_CLOSE "</i></b></div>"
|
||||||
|
|
||||||
|
#define DOC_ITEM_HEAD_STYLE "font-weight: 600;"
|
||||||
|
|
||||||
|
#define DOC_ITEM_HEAD_INL_OPEN "<span style='"DOC_ITEM_HEAD_STYLE"'>"
|
||||||
|
#define DOC_ITEM_HEAD_INL_CLOSE "</span>"
|
||||||
|
|
||||||
|
#define DOC_ITEM_HEAD_OPEN "<div style='"DOC_ITEM_HEAD_STYLE"'>"
|
||||||
|
#define DOC_ITEM_HEAD_CLOSE "</div>"
|
||||||
|
|
||||||
|
#define DOC_ITEM_OPEN "<div style='margin-left: 5mm; margin-right: 5mm;'>"
|
||||||
|
#define DOC_ITEM_CLOSE "</div>"
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_struct_docs(FILE *file, Partition *part, Struct_Member *member){
|
||||||
|
for (Struct_Member *member_iter = member->first_child;
|
||||||
|
member_iter != 0;
|
||||||
|
member_iter = member_iter->next_sibling){
|
||||||
|
String type = member_iter->type;
|
||||||
|
if (match(type, make_lit_string("struct")) ||
|
||||||
|
match(type, make_lit_string("union"))){
|
||||||
|
print_struct_docs(file, part, member_iter);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Documentation doc = {0};
|
||||||
|
perform_doc_parse(part, member_iter->doc_string, &doc);
|
||||||
|
|
||||||
|
fprintf(file,
|
||||||
|
"<div>\n"
|
||||||
|
"<div style='"CODE_STYLE"'>"DOC_ITEM_HEAD_INL_OPEN
|
||||||
|
"%.*s"DOC_ITEM_HEAD_INL_CLOSE"</div>\n"
|
||||||
|
"<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"</div>\n"
|
||||||
|
"</div>\n",
|
||||||
|
member_iter->name.size, member_iter->name.str,
|
||||||
|
doc.main_doc.size, doc.main_doc.str
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_see_also(FILE *file, Documentation *doc){
|
||||||
|
int doc_see_count = doc->see_also_count;
|
||||||
|
if (doc_see_count > 0){
|
||||||
|
fprintf(file, DOC_HEAD_OPEN"See Also"DOC_HEAD_CLOSE);
|
||||||
|
|
||||||
|
for (int j = 0; j < doc_see_count; ++j){
|
||||||
|
String see_also = doc->see_also[j];
|
||||||
|
fprintf(file,
|
||||||
|
DOC_ITEM_OPEN"<a href='#%.*s_doc'>%.*s</a>"DOC_ITEM_CLOSE,
|
||||||
|
see_also.size, see_also.str,
|
||||||
|
see_also.size, see_also.str
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_enum(Partition *part, Cpp_File file,
|
parse_enum(Partition *part, Cpp_File file,
|
||||||
Cpp_Token *tokens, int count,
|
Cpp_Token *tokens, int count,
|
||||||
|
@ -1101,210 +1181,6 @@ generate_custom_headers(){
|
||||||
|
|
||||||
char *filename = API_H " & " API_DOC;
|
char *filename = API_H " & " API_DOC;
|
||||||
|
|
||||||
Function_Set function_set = {0};
|
|
||||||
Typedef_Set typedef_set = {0};
|
|
||||||
Struct_Set struct_set = {0};
|
|
||||||
Enum_Set flag_set = {0};
|
|
||||||
Enum_Set enum_set = {0};
|
|
||||||
|
|
||||||
|
|
||||||
String type_code = file_dump("4coder_types.h");
|
|
||||||
|
|
||||||
|
|
||||||
// TODO(allen): KILL THIS FUCKIN' Cpp_File FUCKIN' NONSENSE HORSE SHIT!!!!!
|
|
||||||
Cpp_File type_file;
|
|
||||||
type_file.data = type_code.str;
|
|
||||||
type_file.size = type_code.size;
|
|
||||||
|
|
||||||
Cpp_Token_Stack types_tokens = cpp_make_token_stack(512);
|
|
||||||
cpp_lex_file(type_file, &types_tokens);
|
|
||||||
|
|
||||||
int typedef_count = 0;
|
|
||||||
int struct_count = 0;
|
|
||||||
int flag_count = 0;
|
|
||||||
int enum_count = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
int count = types_tokens.count;
|
|
||||||
Cpp_Token *tokens = types_tokens.tokens;
|
|
||||||
Cpp_Token *token = tokens;
|
|
||||||
|
|
||||||
static String type_spec_keys[] = {
|
|
||||||
make_lit_string("typedef"),
|
|
||||||
make_lit_string("struct"),
|
|
||||||
make_lit_string("union"),
|
|
||||||
make_lit_string("ENUM"),
|
|
||||||
make_lit_string("FLAGENUM"),
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i, ++token){
|
|
||||||
if (!(token->flags & CPP_TFLAG_PP_BODY) &&
|
|
||||||
(token->type == CPP_TOKEN_KEY_TYPE_DECLARATION ||
|
|
||||||
token->type == CPP_TOKEN_IDENTIFIER)){
|
|
||||||
|
|
||||||
String lexeme = make_string(type_file.data + token->start, token->size);
|
|
||||||
int match_index = 0;
|
|
||||||
if (string_set_match(type_spec_keys, ArrayCount(type_spec_keys),
|
|
||||||
lexeme, &match_index)){
|
|
||||||
switch (match_index){
|
|
||||||
case 0: //typedef
|
|
||||||
++typedef_count; break;
|
|
||||||
|
|
||||||
case 1: case 2: //struct/union
|
|
||||||
++struct_count; break;
|
|
||||||
|
|
||||||
case 3: //ENUM
|
|
||||||
++enum_count; break;
|
|
||||||
|
|
||||||
case 4: //FLAGENUM
|
|
||||||
++flag_count; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typedef_count > 0){
|
|
||||||
typedef_set.type = push_array(part, String, typedef_count);
|
|
||||||
typedef_set.name = push_array(part, String, typedef_count);
|
|
||||||
typedef_set.doc_string = push_array(part, String, typedef_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (struct_count > 0){
|
|
||||||
struct_set.structs = push_array(part, Struct_Member, struct_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enum_count > 0){
|
|
||||||
enum_set.name = push_array(part, String, enum_count);
|
|
||||||
enum_set.type = push_array(part, String, enum_count);
|
|
||||||
enum_set.first_member = push_array(part, Enum_Member*, enum_count);
|
|
||||||
enum_set.doc_string = push_array(part, String, enum_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag_count > 0){
|
|
||||||
flag_set.name = push_array(part, String, flag_count);
|
|
||||||
flag_set.first_member = push_array(part, Enum_Member*, flag_count);
|
|
||||||
flag_set.doc_string = push_array(part, String, flag_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
int typedef_index = 0;
|
|
||||||
int struct_index = 0;
|
|
||||||
int flag_index = 0;
|
|
||||||
int enum_index = 0;
|
|
||||||
|
|
||||||
token = tokens;
|
|
||||||
for (int i = 0; i < count; ++i, ++token){
|
|
||||||
if (!(token->flags & CPP_TFLAG_PP_BODY) &&
|
|
||||||
(token->type == CPP_TOKEN_KEY_TYPE_DECLARATION ||
|
|
||||||
token->type == CPP_TOKEN_IDENTIFIER)){
|
|
||||||
|
|
||||||
String lexeme = make_string(type_file.data + token->start, token->size);
|
|
||||||
int match_index = 0;
|
|
||||||
if (string_set_match(type_spec_keys, ArrayCount(type_spec_keys),
|
|
||||||
lexeme, &match_index)){
|
|
||||||
switch (match_index){
|
|
||||||
case 0: //typedef
|
|
||||||
{
|
|
||||||
String doc_string = {0};
|
|
||||||
get_type_doc_string(type_file, tokens, i, &doc_string);
|
|
||||||
|
|
||||||
int start_i = i;
|
|
||||||
Cpp_Token *start_token = token;
|
|
||||||
|
|
||||||
for (; i < count; ++i, ++token){
|
|
||||||
if (token->type == CPP_TOKEN_SEMICOLON){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i < count){
|
|
||||||
Cpp_Token *token_j = token;
|
|
||||||
|
|
||||||
for (int j = i; j > start_i; --j, --token_j){
|
|
||||||
if (token_j->type == CPP_TOKEN_IDENTIFIER){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String name = make_string(type_file.data + token_j->start, token_j->size);
|
|
||||||
name = skip_chop_whitespace(name);
|
|
||||||
|
|
||||||
int type_start = start_token->start + start_token->size;
|
|
||||||
int type_end = token_j->start;
|
|
||||||
String type = make_string(type_file.data + type_start, type_end - type_start);
|
|
||||||
type = skip_chop_whitespace(type);
|
|
||||||
|
|
||||||
typedef_set.type[typedef_index] = type;
|
|
||||||
typedef_set.name[typedef_index] = name;
|
|
||||||
typedef_set.doc_string[typedef_index] = doc_string;
|
|
||||||
++typedef_index;
|
|
||||||
}
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case 1: case 2: //struct/union
|
|
||||||
{
|
|
||||||
if (parse_struct(part, (match_index == 1),
|
|
||||||
type_file, tokens, count, &token,
|
|
||||||
struct_set.structs + struct_index)){
|
|
||||||
++struct_index;
|
|
||||||
}
|
|
||||||
i = (int)(token - tokens);
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case 3: //ENUM
|
|
||||||
{
|
|
||||||
String doc_string = {0};
|
|
||||||
get_type_doc_string(type_file, tokens, i, &doc_string);
|
|
||||||
|
|
||||||
int start_i = i;
|
|
||||||
|
|
||||||
for (; i < count; ++i, ++token){
|
|
||||||
if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parse_enum(part, type_file,
|
|
||||||
tokens, count,
|
|
||||||
&token, start_i,
|
|
||||||
enum_set, enum_index)){
|
|
||||||
enum_set.doc_string[enum_index] = doc_string;
|
|
||||||
++enum_index;
|
|
||||||
}
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case 4: //FLAGENUM
|
|
||||||
{
|
|
||||||
String doc_string = {0};
|
|
||||||
get_type_doc_string(type_file, tokens, i, &doc_string);
|
|
||||||
|
|
||||||
int start_i = i;
|
|
||||||
|
|
||||||
for (; i < count; ++i, ++token){
|
|
||||||
if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parse_enum(part, type_file,
|
|
||||||
tokens, count,
|
|
||||||
&token, start_i,
|
|
||||||
flag_set, flag_index)){
|
|
||||||
flag_set.doc_string[flag_index] = doc_string;
|
|
||||||
++flag_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
}break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef_count = typedef_index;
|
|
||||||
struct_count = struct_index;
|
|
||||||
enum_count = enum_index;
|
|
||||||
flag_count = flag_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String code_data[2];
|
String code_data[2];
|
||||||
code_data[0] = file_dump("4ed_api_implementation.cpp");
|
code_data[0] = file_dump("4ed_api_implementation.cpp");
|
||||||
|
@ -1361,6 +1237,7 @@ generate_custom_headers(){
|
||||||
|
|
||||||
int memory_size = (sizeof(String)*6 + sizeof(int) + sizeof(Argument_Breakdown) + sizeof(Documentation))*line_count;
|
int memory_size = (sizeof(String)*6 + sizeof(int) + sizeof(Argument_Breakdown) + sizeof(Documentation))*line_count;
|
||||||
|
|
||||||
|
Function_Set function_set = {0};
|
||||||
function_set.name = (String*)malloc(memory_size);
|
function_set.name = (String*)malloc(memory_size);
|
||||||
function_set.ret = function_set.name + line_count;
|
function_set.ret = function_set.name + line_count;
|
||||||
function_set.args = function_set.ret + line_count;
|
function_set.args = function_set.ret + line_count;
|
||||||
|
@ -1524,7 +1401,7 @@ generate_custom_headers(){
|
||||||
lexeme = make_string(file.data + token->start, token->size);
|
lexeme = make_string(file.data + token->start, token->size);
|
||||||
if (check_and_fix_docs(&lexeme)){
|
if (check_and_fix_docs(&lexeme)){
|
||||||
function_set.doc_string[match] = lexeme;
|
function_set.doc_string[match] = lexeme;
|
||||||
perform_doc_parse(lexeme, &function_set.doc[match]);
|
perform_doc_parse(part, lexeme, &function_set.doc[match]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1626,20 +1503,215 @@ generate_custom_headers(){
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
// NOTE(allen): Documentation
|
// NOTE(allen): Documentation
|
||||||
|
if (global_settings.generate_docs){
|
||||||
|
Typedef_Set typedef_set = {0};
|
||||||
|
Struct_Set struct_set = {0};
|
||||||
|
Enum_Set flag_set = {0};
|
||||||
|
Enum_Set enum_set = {0};
|
||||||
|
|
||||||
|
|
||||||
|
String type_code = file_dump("4coder_types.h");
|
||||||
|
|
||||||
|
|
||||||
|
// TODO(allen): KILL THIS FUCKIN' Cpp_File FUCKIN' NONSENSE HORSE SHIT!!!!!
|
||||||
|
Cpp_File type_file;
|
||||||
|
type_file.data = type_code.str;
|
||||||
|
type_file.size = type_code.size;
|
||||||
|
|
||||||
|
Cpp_Token_Stack types_tokens = cpp_make_token_stack(512);
|
||||||
|
cpp_lex_file(type_file, &types_tokens);
|
||||||
|
|
||||||
|
int typedef_count = 0;
|
||||||
|
int struct_count = 0;
|
||||||
|
int flag_count = 0;
|
||||||
|
int enum_count = 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
int count = types_tokens.count;
|
||||||
|
Cpp_Token *tokens = types_tokens.tokens;
|
||||||
|
Cpp_Token *token = tokens;
|
||||||
|
|
||||||
|
static String type_spec_keys[] = {
|
||||||
|
make_lit_string("typedef"),
|
||||||
|
make_lit_string("struct"),
|
||||||
|
make_lit_string("union"),
|
||||||
|
make_lit_string("ENUM"),
|
||||||
|
make_lit_string("FLAGENUM"),
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < count; ++i, ++token){
|
||||||
|
if (!(token->flags & CPP_TFLAG_PP_BODY) &&
|
||||||
|
(token->type == CPP_TOKEN_KEY_TYPE_DECLARATION ||
|
||||||
|
token->type == CPP_TOKEN_IDENTIFIER)){
|
||||||
|
|
||||||
|
String lexeme = make_string(type_file.data + token->start, token->size);
|
||||||
|
int match_index = 0;
|
||||||
|
if (string_set_match(type_spec_keys, ArrayCount(type_spec_keys),
|
||||||
|
lexeme, &match_index)){
|
||||||
|
switch (match_index){
|
||||||
|
case 0: //typedef
|
||||||
|
++typedef_count; break;
|
||||||
|
|
||||||
|
case 1: case 2: //struct/union
|
||||||
|
++struct_count; break;
|
||||||
|
|
||||||
|
case 3: //ENUM
|
||||||
|
++enum_count; break;
|
||||||
|
|
||||||
|
case 4: //FLAGENUM
|
||||||
|
++flag_count; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typedef_count > 0){
|
||||||
|
typedef_set.type = push_array(part, String, typedef_count);
|
||||||
|
typedef_set.name = push_array(part, String, typedef_count);
|
||||||
|
typedef_set.doc_string = push_array(part, String, typedef_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (struct_count > 0){
|
||||||
|
struct_set.structs = push_array(part, Struct_Member, struct_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enum_count > 0){
|
||||||
|
enum_set.name = push_array(part, String, enum_count);
|
||||||
|
enum_set.type = push_array(part, String, enum_count);
|
||||||
|
enum_set.first_member = push_array(part, Enum_Member*, enum_count);
|
||||||
|
enum_set.doc_string = push_array(part, String, enum_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag_count > 0){
|
||||||
|
flag_set.name = push_array(part, String, flag_count);
|
||||||
|
flag_set.first_member = push_array(part, Enum_Member*, flag_count);
|
||||||
|
flag_set.doc_string = push_array(part, String, flag_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
int typedef_index = 0;
|
||||||
|
int struct_index = 0;
|
||||||
|
int flag_index = 0;
|
||||||
|
int enum_index = 0;
|
||||||
|
|
||||||
|
token = tokens;
|
||||||
|
for (int i = 0; i < count; ++i, ++token){
|
||||||
|
Assert(i == (i32)(token - tokens));
|
||||||
|
if (!(token->flags & CPP_TFLAG_PP_BODY) &&
|
||||||
|
(token->type == CPP_TOKEN_KEY_TYPE_DECLARATION ||
|
||||||
|
token->type == CPP_TOKEN_IDENTIFIER)){
|
||||||
|
|
||||||
|
String lexeme = make_string(type_file.data + token->start, token->size);
|
||||||
|
int match_index = 0;
|
||||||
|
if (string_set_match(type_spec_keys, ArrayCount(type_spec_keys),
|
||||||
|
lexeme, &match_index)){
|
||||||
|
switch (match_index){
|
||||||
|
case 0: //typedef
|
||||||
|
{
|
||||||
|
String doc_string = {0};
|
||||||
|
get_type_doc_string(type_file, tokens, i, &doc_string);
|
||||||
|
|
||||||
|
int start_i = i;
|
||||||
|
Cpp_Token *start_token = token;
|
||||||
|
|
||||||
|
for (; i < count; ++i, ++token){
|
||||||
|
if (token->type == CPP_TOKEN_SEMICOLON){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < count){
|
||||||
|
Cpp_Token *token_j = token;
|
||||||
|
|
||||||
|
for (int j = i; j > start_i; --j, --token_j){
|
||||||
|
if (token_j->type == CPP_TOKEN_IDENTIFIER){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = make_string(type_file.data + token_j->start, token_j->size);
|
||||||
|
name = skip_chop_whitespace(name);
|
||||||
|
|
||||||
|
int type_start = start_token->start + start_token->size;
|
||||||
|
int type_end = token_j->start;
|
||||||
|
String type = make_string(type_file.data + type_start, type_end - type_start);
|
||||||
|
type = skip_chop_whitespace(type);
|
||||||
|
|
||||||
|
typedef_set.type[typedef_index] = type;
|
||||||
|
typedef_set.name[typedef_index] = name;
|
||||||
|
typedef_set.doc_string[typedef_index] = doc_string;
|
||||||
|
++typedef_index;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case 1: case 2: //struct/union
|
||||||
|
{
|
||||||
|
if (parse_struct(part, (match_index == 1),
|
||||||
|
type_file, tokens, count, &token,
|
||||||
|
struct_set.structs + struct_index)){
|
||||||
|
++struct_index;
|
||||||
|
}
|
||||||
|
i = (int)(token - tokens);
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case 3: //ENUM
|
||||||
|
{
|
||||||
|
String doc_string = {0};
|
||||||
|
get_type_doc_string(type_file, tokens, i, &doc_string);
|
||||||
|
|
||||||
|
int start_i = i;
|
||||||
|
|
||||||
|
for (; i < count; ++i, ++token){
|
||||||
|
if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parse_enum(part, type_file,
|
||||||
|
tokens, count,
|
||||||
|
&token, start_i,
|
||||||
|
enum_set, enum_index)){
|
||||||
|
enum_set.doc_string[enum_index] = doc_string;
|
||||||
|
++enum_index;
|
||||||
|
}
|
||||||
|
i = (i32)(token - tokens);
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case 4: //FLAGENUM
|
||||||
|
{
|
||||||
|
String doc_string = {0};
|
||||||
|
get_type_doc_string(type_file, tokens, i, &doc_string);
|
||||||
|
|
||||||
|
int start_i = i;
|
||||||
|
|
||||||
|
for (; i < count; ++i, ++token){
|
||||||
|
if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parse_enum(part, type_file,
|
||||||
|
tokens, count,
|
||||||
|
&token, start_i,
|
||||||
|
flag_set, flag_index)){
|
||||||
|
flag_set.doc_string[flag_index] = doc_string;
|
||||||
|
++flag_index;
|
||||||
|
}
|
||||||
|
i = (i32)(token - tokens);
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef_count = typedef_index;
|
||||||
|
struct_count = struct_index;
|
||||||
|
enum_count = enum_index;
|
||||||
|
flag_count = flag_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
file = fopen(API_DOC, "wb");
|
file = fopen(API_DOC, "wb");
|
||||||
|
|
||||||
#define CODE_STYLE "font-family: \"Courier New\", Courier, monospace; text-align: left;"
|
|
||||||
|
|
||||||
#define BACK_COLOR "#FAFAFA"
|
|
||||||
#define TEXT_COLOR "#0D0D0D"
|
|
||||||
#define CODE_BACK "#DFDFDF"
|
|
||||||
|
|
||||||
#define POP_COLOR_1 "#309030"
|
|
||||||
#define POP_BACK_1 "#E0FFD0"
|
|
||||||
#define VISITED_LINK "#A0C050"
|
|
||||||
|
|
||||||
#define POP_COLOR_2 "#005000"
|
|
||||||
|
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
"<html lang=\"en-US\">\n"
|
"<html lang=\"en-US\">\n"
|
||||||
"<head>\n"
|
"<head>\n"
|
||||||
|
@ -1701,8 +1773,10 @@ generate_custom_headers(){
|
||||||
"<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4coder API</h1>\n"
|
"<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4coder API</h1>\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#define MAJOR_SECTION "1"
|
||||||
|
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
"<h2>§1 Introduction</h2>\n"
|
"<h2>§"MAJOR_SECTION" Introduction</h2>\n"
|
||||||
"<div>\n"
|
"<div>\n"
|
||||||
|
|
||||||
"<p>\n"
|
"<p>\n"
|
||||||
|
@ -1716,10 +1790,21 @@ generate_custom_headers(){
|
||||||
|
|
||||||
"</div>\n");
|
"</div>\n");
|
||||||
|
|
||||||
fprintf(file, "<h2>§2 Types and Functions</h2>\n");
|
#undef MAJOR_SECTION
|
||||||
|
#define MAJOR_SECTION "2"
|
||||||
|
// TODO(allen): Write the 4coder system descriptions.
|
||||||
|
fprintf(file, "<h2>§"MAJOR_SECTION" 4coder Systems</h2>\n");
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef MAJOR_SECTION
|
||||||
|
#define MAJOR_SECTION "3"
|
||||||
|
|
||||||
|
fprintf(file, "<h2>§"MAJOR_SECTION" Types and Functions</h2>\n");
|
||||||
{
|
{
|
||||||
#undef SECTION
|
#undef SECTION
|
||||||
#define SECTION "2.1"
|
#define SECTION MAJOR_SECTION".1"
|
||||||
|
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
"<h3>§"SECTION" Function List</h3>\n"
|
"<h3>§"SECTION" Function List</h3>\n"
|
||||||
|
@ -1738,7 +1823,7 @@ generate_custom_headers(){
|
||||||
fprintf(file, "</ul>\n");
|
fprintf(file, "</ul>\n");
|
||||||
|
|
||||||
#undef SECTION
|
#undef SECTION
|
||||||
#define SECTION "2.2"
|
#define SECTION MAJOR_SECTION".2"
|
||||||
|
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
"<h3>§"SECTION" Type List</h3>\n"
|
"<h3>§"SECTION" Type List</h3>\n"
|
||||||
|
@ -1791,12 +1876,8 @@ generate_custom_headers(){
|
||||||
|
|
||||||
fprintf(file, "</ul>\n");
|
fprintf(file, "</ul>\n");
|
||||||
|
|
||||||
#define DESCRIPT_SECTION_STYLE \
|
|
||||||
"margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; " \
|
|
||||||
"background: "CODE_BACK"; padding: 0.25em;"
|
|
||||||
|
|
||||||
#undef SECTION
|
#undef SECTION
|
||||||
#define SECTION "2.3"
|
#define SECTION MAJOR_SECTION".3"
|
||||||
|
|
||||||
fprintf(file, "<h3>§"SECTION" Function Descriptions</h3>\n");
|
fprintf(file, "<h3>§"SECTION" Function Descriptions</h3>\n");
|
||||||
for (int i = 0; i < sig_count; ++i){
|
for (int i = 0; i < sig_count; ++i){
|
||||||
|
@ -1837,12 +1918,6 @@ generate_custom_headers(){
|
||||||
fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
|
fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DOC_HEAD_OPEN "<div style='margin-top: 3mm; margin-bottom: 3mm; color: "POP_COLOR_1";'><b><i>"
|
|
||||||
#define DOC_HEAD_CLOSE "</i></b></div>"
|
|
||||||
|
|
||||||
#define DOC_ITEM_OPEN "<div style='margin-left: 5mm; margin-right: 5mm;'>"
|
|
||||||
#define DOC_ITEM_CLOSE "</div>"
|
|
||||||
|
|
||||||
Documentation *doc = &function_set.doc[i];
|
Documentation *doc = &function_set.doc[i];
|
||||||
|
|
||||||
int doc_param_count = doc->param_count;
|
int doc_param_count = doc->param_count;
|
||||||
|
@ -1858,7 +1933,7 @@ generate_custom_headers(){
|
||||||
|
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
"<div>\n"
|
"<div>\n"
|
||||||
"<div style='font-weight: 600;'>%.*s</div>\n"
|
DOC_ITEM_HEAD_OPEN"%.*s"DOC_ITEM_HEAD_CLOSE"\n"
|
||||||
"<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"</div>\n"
|
"<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"</div>\n"
|
||||||
"</div>\n",
|
"</div>\n",
|
||||||
param_name.size, param_name.str,
|
param_name.size, param_name.str,
|
||||||
|
@ -1885,25 +1960,13 @@ generate_custom_headers(){
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
int doc_see_count = doc->see_also_count;
|
print_see_also(file, doc);
|
||||||
if (doc_see_count > 0){
|
|
||||||
fprintf(file, DOC_HEAD_OPEN"See Also"DOC_HEAD_CLOSE);
|
|
||||||
|
|
||||||
for (int j = 0; j < doc_see_count; ++j){
|
|
||||||
String see_also = doc->see_also[j];
|
|
||||||
fprintf(file,
|
|
||||||
DOC_ITEM_OPEN"<a href='#%.*s_doc'>%.*s</a>"DOC_ITEM_CLOSE,
|
|
||||||
see_also.size, see_also.str,
|
|
||||||
see_also.size, see_also.str
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(file, "</div><hr>\n");
|
fprintf(file, "</div><hr>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef SECTION
|
#undef SECTION
|
||||||
#define SECTION "2.4"
|
#define SECTION MAJOR_SECTION".4"
|
||||||
|
|
||||||
fprintf(file, "<h3>§"SECTION" Type Descriptions</h3>\n");
|
fprintf(file, "<h3>§"SECTION" Type Descriptions</h3>\n");
|
||||||
int I = 1;
|
int I = 1;
|
||||||
|
@ -1932,7 +1995,20 @@ generate_custom_headers(){
|
||||||
|
|
||||||
// NOTE(allen): Descriptive section
|
// NOTE(allen): Descriptive section
|
||||||
{
|
{
|
||||||
|
String doc_string = typedef_set.doc_string[i];
|
||||||
|
Documentation doc = {0};
|
||||||
|
perform_doc_parse(part, doc_string, &doc);
|
||||||
|
|
||||||
|
String main_doc = doc.main_doc;
|
||||||
|
if (main_doc.size != 0){
|
||||||
|
fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
|
||||||
|
fprintf(file,
|
||||||
|
DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
|
||||||
|
main_doc.size, main_doc.str
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
print_see_also(file, &doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(file, "</div><hr>\n");
|
fprintf(file, "</div><hr>\n");
|
||||||
|
@ -1960,7 +2036,40 @@ generate_custom_headers(){
|
||||||
|
|
||||||
// NOTE(allen): Descriptive section
|
// NOTE(allen): Descriptive section
|
||||||
{
|
{
|
||||||
|
String doc_string = enum_set.doc_string[i];
|
||||||
|
Documentation doc = {0};
|
||||||
|
perform_doc_parse(part, doc_string, &doc);
|
||||||
|
|
||||||
|
String main_doc = doc.main_doc;
|
||||||
|
if (main_doc.size != 0){
|
||||||
|
fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
|
||||||
|
fprintf(file,
|
||||||
|
DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
|
||||||
|
main_doc.size, main_doc.str
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enum_set.first_member[i]){
|
||||||
|
fprintf(file, DOC_HEAD_OPEN"Values"DOC_HEAD_CLOSE);
|
||||||
|
for (Enum_Member *member = enum_set.first_member[i];
|
||||||
|
member;
|
||||||
|
member = member->next){
|
||||||
|
Documentation doc = {0};
|
||||||
|
perform_doc_parse(part, member->doc_string, &doc);
|
||||||
|
|
||||||
|
fprintf(file,
|
||||||
|
"<div>\n"
|
||||||
|
"<div><span style='"CODE_STYLE"'>"DOC_ITEM_HEAD_INL_OPEN
|
||||||
|
"%.*s"DOC_ITEM_HEAD_INL_CLOSE"</span></div>\n"
|
||||||
|
"<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"</div>\n"
|
||||||
|
"</div>\n",
|
||||||
|
member->name.size, member->name.str,
|
||||||
|
doc.main_doc.size, doc.main_doc.str
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_see_also(file, &doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(file, "</div><hr>\n");
|
fprintf(file, "</div><hr>\n");
|
||||||
|
@ -1988,7 +2097,41 @@ generate_custom_headers(){
|
||||||
|
|
||||||
// NOTE(allen): Descriptive section
|
// NOTE(allen): Descriptive section
|
||||||
{
|
{
|
||||||
|
String doc_string = flag_set.doc_string[i];
|
||||||
|
Documentation doc = {0};
|
||||||
|
perform_doc_parse(part, doc_string, &doc);
|
||||||
|
|
||||||
|
String main_doc = doc.main_doc;
|
||||||
|
if (main_doc.size != 0){
|
||||||
|
fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
|
||||||
|
fprintf(file,
|
||||||
|
DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
|
||||||
|
main_doc.size, main_doc.str
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag_set.first_member[i]){
|
||||||
|
fprintf(file, DOC_HEAD_OPEN"Flags"DOC_HEAD_CLOSE);
|
||||||
|
for (Enum_Member *member = flag_set.first_member[i];
|
||||||
|
member;
|
||||||
|
member = member->next){
|
||||||
|
Documentation doc = {0};
|
||||||
|
perform_doc_parse(part, member->doc_string, &doc);
|
||||||
|
|
||||||
|
fprintf(file,
|
||||||
|
"<div>\n"
|
||||||
|
"<div><span style='"CODE_STYLE"'>"DOC_ITEM_HEAD_INL_OPEN
|
||||||
|
"%.*s"DOC_ITEM_HEAD_INL_CLOSE" = %.*s</span></div>\n"
|
||||||
|
"<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"</div>\n"
|
||||||
|
"</div>\n",
|
||||||
|
member->name.size, member->name.str,
|
||||||
|
member->value.size, member->value.str,
|
||||||
|
doc.main_doc.size, doc.main_doc.str
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_see_also(file, &doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(file, "</div><hr>\n");
|
fprintf(file, "</div><hr>\n");
|
||||||
|
@ -2014,7 +2157,25 @@ generate_custom_headers(){
|
||||||
|
|
||||||
// NOTE(allen): Descriptive section
|
// NOTE(allen): Descriptive section
|
||||||
{
|
{
|
||||||
|
String doc_string = member->doc_string;
|
||||||
|
Documentation doc = {0};
|
||||||
|
perform_doc_parse(part, doc_string, &doc);
|
||||||
|
|
||||||
|
String main_doc = doc.main_doc;
|
||||||
|
if (main_doc.size != 0){
|
||||||
|
fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
|
||||||
|
fprintf(file,
|
||||||
|
DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
|
||||||
|
main_doc.size, main_doc.str
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (member->first_child){
|
||||||
|
fprintf(file, DOC_HEAD_OPEN"Fields"DOC_HEAD_CLOSE);
|
||||||
|
print_struct_docs(file, part, member);
|
||||||
|
}
|
||||||
|
|
||||||
|
print_see_also(file, &doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(file, "</div><hr>\n");
|
fprintf(file, "</div><hr>\n");
|
||||||
|
@ -2028,13 +2189,18 @@ generate_custom_headers(){
|
||||||
);
|
);
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
return(filename);
|
return(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(int argc, char **argv){
|
||||||
char *filename = 0;
|
char *filename = 0;
|
||||||
|
|
||||||
|
memset(&global_settings, 0, sizeof(global_settings));
|
||||||
|
|
||||||
|
global_settings.generate_docs = true;
|
||||||
|
|
||||||
filename = generate_keycode_enum();
|
filename = generate_keycode_enum();
|
||||||
filename = generate_style();
|
filename = generate_style();
|
||||||
filename = generate_custom_headers();
|
filename = generate_custom_headers();
|
||||||
|
|
|
@ -61,9 +61,10 @@ CUSTOM_COMMAND_SIG(build_in_build_panel){
|
||||||
# define build_search build_in_build_panel
|
# define build_search build_in_build_panel
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define GET_COMP_BUFFER() app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(close_build_panel){
|
CUSTOM_COMMAND_SIG(close_build_panel){
|
||||||
Buffer_Summary buffer =
|
Buffer_Summary buffer = GET_COMP_BUFFER();
|
||||||
app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
|
|
||||||
|
|
||||||
if (buffer.exists){
|
if (buffer.exists){
|
||||||
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);
|
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);
|
||||||
|
@ -75,8 +76,18 @@ CUSTOM_COMMAND_SIG(close_build_panel){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CUSTOM_COMMAND_SIG(change_to_build_panel){
|
||||||
|
Buffer_Summary buffer = GET_COMP_BUFFER();
|
||||||
|
|
||||||
|
if (buffer.exists){
|
||||||
|
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);
|
||||||
|
|
||||||
|
app->set_active_view(app, &build_view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(change_active_panel_build){
|
CUSTOM_COMMAND_SIG(change_active_panel_build){
|
||||||
Buffer_Summary buffer = app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
|
Buffer_Summary buffer = GET_COMP_BUFFER();
|
||||||
|
|
||||||
if (buffer.exists){
|
if (buffer.exists){
|
||||||
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);
|
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);
|
||||||
|
|
|
@ -286,6 +286,7 @@ get_bindings(void *data, int size){
|
||||||
// begin_map to clear everything that was in the map and
|
// begin_map to clear everything that was in the map and
|
||||||
// bind new things instead.
|
// bind new things instead.
|
||||||
begin_map(context, mapid_global);
|
begin_map(context, mapid_global);
|
||||||
|
bind(context, '.', MDFR_ALT, change_to_build_panel);
|
||||||
bind(context, ',', MDFR_ALT, close_build_panel);
|
bind(context, ',', MDFR_ALT, close_build_panel);
|
||||||
bind(context, 'n', MDFR_ALT, msvc_goto_next_error);
|
bind(context, 'n', MDFR_ALT, msvc_goto_next_error);
|
||||||
bind(context, 'N', MDFR_ALT, msvc_goto_prev_error);
|
bind(context, 'N', MDFR_ALT, msvc_goto_prev_error);
|
||||||
|
|
|
@ -11,18 +11,16 @@ as this is the only one that will be used for generating headers and docs.
|
||||||
|
|
||||||
#define API_EXPORT
|
#define API_EXPORT
|
||||||
|
|
||||||
API_EXPORT int
|
API_EXPORT bool32
|
||||||
File_Exists(Application_Links *app, char *filename, int len)/*
|
File_Exists(Application_Links *app, char *filename, int len)/*
|
||||||
DOC_PARAM(filename, the full path to a file)
|
DOC_PARAM(filename, This parameter specifies the full path to a file; it need not be null terminated.)
|
||||||
DOC_PARAM(len, the number of characters in the filename string)
|
DOC_PARAM(len, This parameter specifies the length of the filename string.)
|
||||||
DOC_RETURN(returns non-zero if the file exists, returns zero if the file does not exist)
|
DOC_RETURN(This call returns non-zero if and only if the file exists.)
|
||||||
*/{
|
*/{
|
||||||
char full_filename_space[1024];
|
char full_filename_space[1024];
|
||||||
String full_filename;
|
String full_filename;
|
||||||
HANDLE file;
|
HANDLE file;
|
||||||
b32 result;
|
b32 result = 0;
|
||||||
|
|
||||||
result = 0;
|
|
||||||
|
|
||||||
if (len < sizeof(full_filename_space)){
|
if (len < sizeof(full_filename_space)){
|
||||||
full_filename = make_fixed_width_string(full_filename_space);
|
full_filename = make_fixed_width_string(full_filename_space);
|
||||||
|
@ -41,23 +39,24 @@ DOC_RETURN(returns non-zero if the file exists, returns zero if the file does no
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT int
|
API_EXPORT bool32
|
||||||
Directory_CD(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)/*
|
Directory_CD(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)/*
|
||||||
DOC_PARAM(dir, a string buffer containing a directory)
|
DOC_PARAM(dir, This parameter provides a character buffer that stores a directory; it need not be null terminated.)
|
||||||
DOC_PARAM(len, the length of the string in the string buffer)
|
DOC_PARAM(len, This parameter specifies the length of the dir string.)
|
||||||
DOC_PARAM(capacity, the maximum size of the string buffer)
|
DOC_PARAM(capacity, This parameter specifies the maximum size of the dir string.)
|
||||||
DOC_PARAM(rel_path, the path to change to, may include '.' or '..')
|
DOC_PARAM(rel_path, This parameter specifies the path to change to, may include '.' or '..'; it need not be null terminated.)
|
||||||
DOC_PARAM(rel_len, the length of the rel_path string)
|
DOC_PARAM(rel_len, This parameter specifies the length of the rel_path string.)
|
||||||
DOC_RETURN(returns non-zero if the call succeeds, returns zero otherwise)
|
DOC_RETURN(This call returns non-zero if the call succeeds.)
|
||||||
DOC
|
DOC
|
||||||
(
|
(
|
||||||
This call succeeds if the directory exists and the new directory fits inside the dir buffer.
|
This call succeeds if the new directory exists and the it fits inside the
|
||||||
If the call succeeds the dir buffer is filled with the new directory and len contains the
|
dir buffer. If the call succeeds the dir buffer is filled with the new
|
||||||
length of the string in the buffer.
|
directory and len is overwritten with the length of the new string in the buffer.
|
||||||
|
|
||||||
For instance if dir contains "C:/Users/MySelf" and rel is "Documents" the buffer will contain
|
For instance if dir contains "C:/Users/MySelf" and rel is "Documents" the buffer
|
||||||
"C:/Users/MySelf/Documents" and len will contain the length of that string. This call can
|
will contain "C:/Users/MySelf/Documents" and len will contain the length of that
|
||||||
also be used with rel set to ".." to traverse to parent folders.
|
string. This call can also be used with rel set to ".." to traverse to parent
|
||||||
|
folders.
|
||||||
)
|
)
|
||||||
*/{
|
*/{
|
||||||
String directory = make_string(dir, *len, capacity);
|
String directory = make_string(dir, *len, capacity);
|
||||||
|
@ -97,11 +96,11 @@ also be used with rel set to ".." to traverse to parent folders.
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT int
|
API_EXPORT bool32
|
||||||
Get_4ed_Path(Application_Links *app, char *out, int capacity)/*
|
Get_4ed_Path(Application_Links *app, char *out, int32_t capacity)/*
|
||||||
DOC_PARAM(out, A char buffer that receives the path to the 4ed executable file.)
|
DOC_PARAM(out, This parameter provides a character buffer that receives the path to the 4ed executable file.)
|
||||||
DOC_PARAM(capacity, The maximum capacity of the output buffer.)
|
DOC_PARAM(capacity, This parameter specifies the maximum capacity of the out buffer.)
|
||||||
DOC_RETURN(Returns non-zero on success, returns zero on failure.)
|
DOC_RETURN(This call returns non-zero on success.)
|
||||||
*/{
|
*/{
|
||||||
String str = make_string(out, 0, capacity);
|
String str = make_string(out, 0, capacity);
|
||||||
return(system_get_binary_path(&str));
|
return(system_get_binary_path(&str));
|
||||||
|
@ -109,8 +108,8 @@ DOC_RETURN(Returns non-zero on success, returns zero on failure.)
|
||||||
|
|
||||||
// TODO(allen): add a "shown but auto-hides on timer" setting here.
|
// TODO(allen): add a "shown but auto-hides on timer" setting here.
|
||||||
API_EXPORT void
|
API_EXPORT void
|
||||||
Show_Mouse_Cursor(Application_Links *app, int show)/*
|
Show_Mouse_Cursor(Application_Links *app, Mouse_Cursor_Show_Type show)/*
|
||||||
DOC_PARAM(show, The show state to put the mouse cursor into, should be one of the Mouse_Cursor_Show_Type enum values.)
|
DOC_PARAM(show, This parameter specifies the new state of the mouse cursor.)
|
||||||
DOC_SEE(Mouse_Cursor_Show_Type)
|
DOC_SEE(Mouse_Cursor_Show_Type)
|
||||||
*/{
|
*/{
|
||||||
switch (show){
|
switch (show){
|
||||||
|
|
Loading…
Reference in New Issue