From 56d716dde4179c6432cbea21d5d3f2a6752cc647 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Wed, 25 May 2016 18:43:58 -0400 Subject: [PATCH] now generating the functions in 4coder_custom.h --- 4coder_custom.h | 52 ++++----- 4coder_custom_api.h | 142 +++++++++++++++++++++++++ 4coder_default_bindings.cpp | 41 +++---- 4ed.cpp | 4 +- 4ed_metagen.cpp | 206 ++++++++++++++++++++++++++++++++++++ build_all.bat | 2 +- custom_api_spec.txt | 64 +++++++++++ 7 files changed, 458 insertions(+), 53 deletions(-) create mode 100644 4coder_custom_api.h create mode 100644 custom_api_spec.txt diff --git a/4coder_custom.h b/4coder_custom.h index bb5d7455..235013cb 100644 --- a/4coder_custom.h +++ b/4coder_custom.h @@ -368,6 +368,9 @@ extern "C"{ struct Application_Links; +#include "4coder_custom_api.h" + +#if 0 // Command exectuion #define PUSH_PARAMETER_SIG(n) void n(Application_Links *app, Dynamic param, Dynamic value) #define PUSH_MEMORY_SIG(n) char* n(Application_Links *app, int len) @@ -432,30 +435,6 @@ struct Application_Links; #define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int len) #define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int count) - - -// Boundry type flags -#define BoundryWhitespace 0x1 -#define BoundryToken 0x2 -#define BoundryAlphanumeric 0x4 -#define BoundryCamelCase 0x8 - - - -// Input type flags -#define EventOnAnyKey 0x1 -#define EventOnEsc 0x2 -#define EventOnLeftButton 0x4 -#define EventOnRightButton 0x8 -#define EventOnWheel 0x10 -#define EventOnButton (EventOnLeftButton | EventOnRightButton | EventOnWheel) - -// NOTE(allen): These don't work so much, so let's pretend they're not here for now. -#define EventOnMouseMove 0x20 -#define EventOnMouse (EventOnButton | EventOnMouseMove) - - - extern "C"{ // Command exectuion typedef EXECUTE_COMMAND_SIG(Exec_Command_Function); @@ -597,6 +576,31 @@ struct Application_Links{ void *current_coroutine; int type_coroutine; }; +#endif + + + +// Boundry type flags +#define BoundryWhitespace 0x1 +#define BoundryToken 0x2 +#define BoundryAlphanumeric 0x4 +#define BoundryCamelCase 0x8 + + + +// Input type flags +#define EventOnAnyKey 0x1 +#define EventOnEsc 0x2 +#define EventOnLeftButton 0x4 +#define EventOnRightButton 0x8 +#define EventOnWheel 0x10 +#define EventOnButton (EventOnLeftButton | EventOnRightButton | EventOnWheel) + +// NOTE(allen): These don't work so much, so let's pretend they're not here for now. +#define EventOnMouseMove 0x20 +#define EventOnMouse (EventOnButton | EventOnMouseMove) + + #define _GET_VERSION_SIG(n) int n(int maj, int min, int patch) typedef _GET_VERSION_SIG(_Get_Version_Function); diff --git a/4coder_custom_api.h b/4coder_custom_api.h new file mode 100644 index 00000000..5903c3df --- /dev/null +++ b/4coder_custom_api.h @@ -0,0 +1,142 @@ +#define PUSH_PARAMETER_SIG(n) void n(Application_Links *app, Dynamic param, Dynamic value) +#define PUSH_MEMORY_SIG(n) char* n(Application_Links *app, int len) +#define EXEC_COMMAND_KEEP_STACK_SIG(n) void n(Application_Links *app, int command_id) +#define CLEAR_PARAMETERS_SIG(n) void n(Application_Links *app) +#define DIRECTORY_GET_HOT_SIG(n) int n(Application_Links *app, char *out, int capacity) +#define GET_4ED_PATH_SIG(n) int n(Application_Links *app, char *out, int capacity) +#define FILE_EXISTS_SIG(n) int 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 GET_FILE_LIST_SIG(n) File_List n(Application_Links *app, char *dir, int len) +#define FREE_FILE_LIST_SIG(n) void n(Application_Links *app, File_List list) +#define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app) +#define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer) +#define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, int index) +#define GET_ACTIVE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app) +#define GET_PARAMETER_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, int param_index) +#define GET_BUFFER_BY_NAME_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int len) +#define BUFFER_SEEK_DELIMITER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, char delim, int seek_forward, int *out) +#define BUFFER_SEEK_STRING_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, char *str, int len, int seek_forward, int *out) +#define BUFFER_SEEK_STRING_INSENSITIVE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, char *str, int len, int seek_forward, int *out) +#define REFRESH_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer) +#define BUFFER_READ_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int 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_SET_POS_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int pos) +#define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app) +#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view) +#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, int index) +#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app) +#define REFRESH_VIEW_SIG(n) int n(Application_Links *app, View_Summary *view) +#define VIEW_COMPUTE_CURSOR_SIG(n) Full_Cursor n(Application_Links *app, View_Summary *view, Buffer_Seek seek) +#define VIEW_SET_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x) +#define VIEW_SET_MARK_SIG(n) int 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_BUFFER_SIG(n) int n(Application_Links *app, View_Summary *view, int buffer_id) +#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, unsigned int get_type, unsigned int abort_type) +#define GET_COMMAND_INPUT_SIG(n) User_Input n(Application_Links *app) +#define GET_EVENT_MESSAGE_SIG(n) Event_Message n(Application_Links *app) +#define START_QUERY_BAR_SIG(n) int n(Application_Links *app, Query_Bar *bar, unsigned int flags) +#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, unsigned int flags) +#define PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *string, int len) +#define GET_GUI_FUNCTIONS_SIG(n) GUI_Functions* n(Application_Links *app) +#define GET_GUI_SIG(n) GUI* n(Application_Links *app, int view_id) +#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int len) +#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int len) +#define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int count) +extern "C"{ + typedef PUSH_PARAMETER_SIG(Push_Parameter_Function); + typedef PUSH_MEMORY_SIG(Push_Memory_Function); + typedef EXEC_COMMAND_KEEP_STACK_SIG(Exec_Command_Keep_Stack_Function); + typedef CLEAR_PARAMETERS_SIG(Clear_Parameters_Function); + typedef DIRECTORY_GET_HOT_SIG(Directory_Get_Hot_Function); + typedef GET_4ED_PATH_SIG(Get_4ed_Path_Function); + typedef FILE_EXISTS_SIG(File_Exists_Function); + typedef DIRECTORY_CD_SIG(Directory_CD_Function); + typedef GET_FILE_LIST_SIG(Get_File_List_Function); + typedef FREE_FILE_LIST_SIG(Free_File_List_Function); + typedef GET_BUFFER_FIRST_SIG(Get_Buffer_First_Function); + typedef GET_BUFFER_NEXT_SIG(Get_Buffer_Next_Function); + typedef GET_BUFFER_SIG(Get_Buffer_Function); + typedef GET_ACTIVE_BUFFER_SIG(Get_Active_Buffer_Function); + typedef GET_PARAMETER_BUFFER_SIG(Get_Parameter_Buffer_Function); + typedef GET_BUFFER_BY_NAME_SIG(Get_Buffer_By_Name_Function); + typedef BUFFER_SEEK_DELIMITER_SIG(Buffer_Seek_Delimiter_Function); + typedef BUFFER_SEEK_STRING_SIG(Buffer_Seek_String_Function); + typedef BUFFER_SEEK_STRING_INSENSITIVE_SIG(Buffer_Seek_String_Insensitive_Function); + typedef REFRESH_BUFFER_SIG(Refresh_Buffer_Function); + typedef BUFFER_READ_RANGE_SIG(Buffer_Read_Range_Function); + typedef BUFFER_REPLACE_RANGE_SIG(Buffer_Replace_Range_Function); + typedef BUFFER_SET_POS_SIG(Buffer_Set_Pos_Function); + typedef GET_VIEW_FIRST_SIG(Get_View_First_Function); + typedef GET_VIEW_NEXT_SIG(Get_View_Next_Function); + typedef GET_VIEW_SIG(Get_View_Function); + typedef GET_ACTIVE_VIEW_SIG(Get_Active_View_Function); + typedef REFRESH_VIEW_SIG(Refresh_View_Function); + typedef VIEW_COMPUTE_CURSOR_SIG(View_Compute_Cursor_Function); + typedef VIEW_SET_CURSOR_SIG(View_Set_Cursor_Function); + typedef VIEW_SET_MARK_SIG(View_Set_Mark_Function); + typedef VIEW_SET_HIGHLIGHT_SIG(View_Set_Highlight_Function); + typedef VIEW_SET_BUFFER_SIG(View_Set_Buffer_Function); + typedef GET_USER_INPUT_SIG(Get_User_Input_Function); + typedef GET_COMMAND_INPUT_SIG(Get_Command_Input_Function); + typedef GET_EVENT_MESSAGE_SIG(Get_Event_Message_Function); + typedef START_QUERY_BAR_SIG(Start_Query_Bar_Function); + typedef END_QUERY_BAR_SIG(End_Query_Bar_Function); + typedef PRINT_MESSAGE_SIG(Print_Message_Function); + typedef GET_GUI_FUNCTIONS_SIG(Get_GUI_Functions_Function); + typedef GET_GUI_SIG(Get_GUI_Function); + typedef CHANGE_THEME_SIG(Change_Theme_Function); + typedef CHANGE_FONT_SIG(Change_Font_Function); + typedef SET_THEME_COLORS_SIG(Set_Theme_Colors_Function); +} +struct Application_Links{ + void *memory; + int memory_size; + Push_Parameter_Function *push_parameter; + Push_Memory_Function *push_memory; + Exec_Command_Keep_Stack_Function *exec_command_keep_stack; + Clear_Parameters_Function *clear_parameters; + Directory_Get_Hot_Function *directory_get_hot; + Get_4ed_Path_Function *get_4ed_path; + File_Exists_Function *file_exists; + Directory_CD_Function *directory_cd; + Get_File_List_Function *get_file_list; + Free_File_List_Function *free_file_list; + Get_Buffer_First_Function *get_buffer_first; + Get_Buffer_Next_Function *get_buffer_next; + Get_Buffer_Function *get_buffer; + Get_Active_Buffer_Function *get_active_buffer; + Get_Parameter_Buffer_Function *get_parameter_buffer; + Get_Buffer_By_Name_Function *get_buffer_by_name; + Buffer_Seek_Delimiter_Function *buffer_seek_delimiter; + Buffer_Seek_String_Function *buffer_seek_string; + Buffer_Seek_String_Insensitive_Function *buffer_seek_string_insensitive; + Refresh_Buffer_Function *refresh_buffer; + Buffer_Read_Range_Function *buffer_read_range; + Buffer_Replace_Range_Function *buffer_replace_range; + Buffer_Set_Pos_Function *buffer_set_pos; + Get_View_First_Function *get_view_first; + Get_View_Next_Function *get_view_next; + Get_View_Function *get_view; + Get_Active_View_Function *get_active_view; + Refresh_View_Function *refresh_view; + View_Compute_Cursor_Function *view_compute_cursor; + View_Set_Cursor_Function *view_set_cursor; + View_Set_Mark_Function *view_set_mark; + View_Set_Highlight_Function *view_set_highlight; + View_Set_Buffer_Function *view_set_buffer; + Get_User_Input_Function *get_user_input; + Get_Command_Input_Function *get_command_input; + Get_Event_Message_Function *get_event_message; + Start_Query_Bar_Function *start_query_bar; + End_Query_Bar_Function *end_query_bar; + Print_Message_Function *print_message; + Get_GUI_Functions_Function *get_gui_functions; + Get_GUI_Function *get_gui; + Change_Theme_Function *change_theme; + Change_Font_Function *change_font; + Set_Theme_Colors_Function *set_theme_colors; + void *cmd_context; + void *system_links; + void *current_coroutine; + int type_coroutine; +}; diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index 6d9e6d2a..80919503 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -27,19 +27,6 @@ CUSTOM_COMMAND_SIG(write_zero_struct){ write_string(app, make_lit_string(" = {0};")); } -CUSTOM_COMMAND_SIG(write_h){ - write_string(app, make_lit_string("

")); -} - -CUSTOM_COMMAND_SIG(write_div){ - write_string(app, make_lit_string("
")); -} - -CUSTOM_COMMAND_SIG(begin_html_mode){ - push_parameter(app, par_key_mapid, my_empty_map1); - exec_command(app, cmdid_set_settings); -} - CUSTOM_COMMAND_SIG(write_capital){ User_Input command_in = app->get_command_input(app); char c = command_in.key.character_no_caps_lock; @@ -103,25 +90,29 @@ CUSTOM_COMMAND_SIG(move_down_10){ CUSTOM_COMMAND_SIG(rewrite_as_single_caps){ View_Summary view; Buffer_Summary buffer; + Full_Cursor cursor; Range range; String string; int is_first, i; - - exec_command(app, seek_token_left); + view = app->get_active_view(app); + cursor = view.cursor; + + exec_command(app, seek_token_left); + app->refresh_view(app, &view); range.min = view.cursor.pos; - + exec_command(app, seek_token_right); app->refresh_view(app, &view); range.max = view.cursor.pos; - + string.str = (char*)app->memory; string.size = range.max - range.min; assert(string.size < app->memory_size); buffer = app->get_buffer(app, view.buffer_id); app->buffer_read_range(app, &buffer, range.min, range.max, string.str); - + is_first = 1; for (i = 0; i < string.size; ++i){ if (char_is_alpha_true(string.str[i])){ @@ -132,8 +123,12 @@ CUSTOM_COMMAND_SIG(rewrite_as_single_caps){ is_first = 1; } } - + app->buffer_replace_range(app, &buffer, range.min, range.max, string.str, string.size); + + app->view_set_cursor(app, &view, + seek_line_char(cursor.line+1, cursor.character), + 1); } CUSTOM_COMMAND_SIG(open_my_files){ @@ -300,13 +295,6 @@ default_keys(Bind_Helper *context){ end_map(context); - - begin_map(context, my_html_map); - inherit_map(context, mapid_file); - bind(context, 'h', MDFR_ALT, write_h); - bind(context, 'd', MDFR_ALT, write_div); - end_map(context); - begin_map(context, my_empty_map1); inherit_map(context, mapid_nomap); end_map(context); @@ -406,6 +394,7 @@ default_keys(Bind_Helper *context){ bind(context, 's', MDFR_ALT, cmdid_show_scrollbar); bind(context, 's', MDFR_CTRL, cmdid_save); bind(context, 'u', MDFR_CTRL, cmdid_to_uppercase); + bind(context, 'U', MDFR_CTRL, rewrite_as_single_caps); bind(context, 'v', MDFR_CTRL, cmdid_paste); bind(context, 'V', MDFR_CTRL, cmdid_paste_next); bind(context, 'w', MDFR_ALT, cmdid_hide_scrollbar); diff --git a/4ed.cpp b/4ed.cpp index 6fdb4252..2cd65d03 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -1891,7 +1891,7 @@ fill_view_summary(View_Summary *view, View *vptr, Live_Views *live_set, Working_ } extern "C"{ - EXECUTE_COMMAND_SIG(external_exec_command_keep_stack){ + EXEC_COMMAND_KEEP_STACK_SIG(external_exec_command_keep_stack){ Command_Data *cmd = (Command_Data*)app->cmd_context; Command_Function function = command_table[command_id]; Command_Binding binding = {}; @@ -2022,7 +2022,7 @@ extern "C"{ return(buffer); } - GET_BUFFER_BY_NAME(external_get_buffer_by_name){ + GET_BUFFER_BY_NAME_SIG(external_get_buffer_by_name){ Command_Data *cmd = (Command_Data*)app->cmd_context; Buffer_Summary buffer = {}; Editing_File *file; diff --git a/4ed_metagen.cpp b/4ed_metagen.cpp index 6232abaf..8ed6c967 100644 --- a/4ed_metagen.cpp +++ b/4ed_metagen.cpp @@ -60,6 +60,7 @@ void to_camel(char *src, char *dst){ #include #include #include +#include void struct_begin(FILE *file, char *name){ fprintf(file, "struct %s{\n", name); @@ -455,6 +456,208 @@ char* generate_style(){ return(filename); } +struct Function_Signature{ + String name; + String ret; + String args; + int valid; +}; + +String +file_dump(char *filename){ + String result = {0}; + FILE *file = fopen(filename, "rb"); + + if (file){ + fseek(file, 0, SEEK_END); + result.size = ftell(file); + fseek(file, 0, SEEK_SET); + + result.memory_size = result.size + 1; + result.str = (char*)malloc(result.memory_size); + + fread(result.str, 1, result.size, file); + result.str[result.size] = 0; + + fclose(file); + } + + return(result); +} + +String +get_first_line(String source){ + String line = {0}; + int pos = find(source, 0, '\n'); + + line = substr(source, 0, pos); + + return(line); +} + +String +get_next_line(String source, String line){ + String next = {0}; + int pos = (int)(line.str - source.str) + line.size; + int start = 0; + + if (pos < source.size){ + assert(source.str[pos] == '\n'); + start = pos + 1; + + if (start < source.size){ + pos = find(source, start, '\n'); + next = substr(source, start, pos - start); + } + } + + return(next); +} + +String +skip_whitespace(String str){ + String result = {0}; + int i = 0; + for (; i < str.size && char_is_whitespace(str.str[i]); ++i); + result = substr(str, i, str.size - i); + return(result); +} + +int +is_comment(String str){ + int result = 0; + if (str.size >= 2){ + if (str.str[0] == '/' && + str.str[1] == '/'){ + result = 1; + } + } + return(result); +} + +char* +generate_custom_headers(){ + char *filename = "4coder_custom_api.h"; + String data = file_dump("custom_api_spec.txt"); + + int line_count = 0; + String line = {0}; + for (line = get_first_line(data); + line.str; + line = get_next_line(data, line)){ + ++line_count; + } + + Function_Signature *sigs = + (Function_Signature*)malloc(sizeof(Function_Signature)*line_count); + + int max_name_size = 0; + int sig_count = 0; + line_count = 0; + for (line = get_first_line(data); + line.str; + line = get_next_line(data, line)){ + + ++line_count; + + String parse = line; + parse = skip_whitespace(parse); + if (parse.size > 0){ + if (!is_comment(parse)){ + Function_Signature *sig = sigs + sig_count; + memset(sig, 0, sizeof(Function_Signature)); + + ++sig_count; + + int pos = find(parse, 0, ' '); + sig->ret = substr(parse, 0, pos); + parse = substr(parse, pos); + parse = skip_whitespace(parse); + + if (parse.size > 0){ + pos = find(parse, 0, '('); + sig->name = substr(parse, 0, pos); + parse = substr(parse, pos); + + if (parse.size > 0){ + sig->args = parse; + sig->valid = 1; + + if (max_name_size < sig->name.size){ + max_name_size = sig->name.size; + } + } + } + + if (!sig->valid){ + printf("custom_api_spec.txt(%d) : generator warning : invalid function signature\n", + line_count); + } + } + } + } + + FILE *file = fopen("4coder_custom_api.h", "wb"); + int buffer_size = max_name_size + 1; + char *name_buffer = (char*)malloc(buffer_size); + + for (int i = 0; i < sig_count; ++i){ + Function_Signature *sig = sigs + i; + + copy_fast_unsafe(name_buffer, sig->name); + name_buffer[sig->name.size] = 0; + to_upper(name_buffer, name_buffer); + + fprintf(file, "#define %s_SIG(n) %.*s n%.*s\n", + name_buffer, + sig->ret.size, sig->ret.str, + sig->args.size, sig->args.str + ); + } + + fprintf(file, "extern \"C\"{\n"); + for (int i = 0; i < sig_count; ++i){ + Function_Signature *sig = sigs + i; + + copy_fast_unsafe(name_buffer, sig->name); + name_buffer[sig->name.size] = 0; + to_upper(name_buffer, name_buffer); + + fprintf(file, " typedef %s_SIG(%.*s_Function);\n", + name_buffer, + sig->name.size, sig->name.str); + } + fprintf(file, "}\n"); + + fprintf(file, "struct Application_Links{\n"); + fprintf(file, + " void *memory;\n" + " int memory_size;\n" + ); + for (int i = 0; i < sig_count; ++i){ + Function_Signature *sig = sigs + i; + + copy_fast_unsafe(name_buffer, sig->name); + name_buffer[sig->name.size] = 0; + to_lower(name_buffer, name_buffer); + + fprintf(file, " %.*s_Function *%s;\n", + sig->name.size, sig->name.str, + name_buffer); + } + fprintf(file, + " void *cmd_context;\n" + " void *system_links;\n" + " void *current_coroutine;\n" + " int type_coroutine;\n" + ); + fprintf(file, "};\n"); + + fclose(file); + + return(filename); +} + int main(){ char *filename; @@ -466,6 +669,9 @@ int main(){ filename = generate_style(); printf("gen success: %s\n", filename); + + filename = generate_custom_headers(); + printf("gen success: %s\n", filename); } // BOTTOM diff --git a/build_all.bat b/build_all.bat index 9e453dce..bf8abcb0 100644 --- a/build_all.bat +++ b/build_all.bat @@ -11,7 +11,7 @@ set DEFINES= set FirstError=0 pushd ..\meta -cl %OPTS% ..\code\4ed_metagen.cpp /Femetagen +cl %OPTS% ..\code\4ed_metagen.cpp %* /Femetagen if %ERRORLEVEL% neq 0 (set FirstError=1) popd diff --git a/custom_api_spec.txt b/custom_api_spec.txt new file mode 100644 index 00000000..853b2bab --- /dev/null +++ b/custom_api_spec.txt @@ -0,0 +1,64 @@ + +// Command exectuion +void Push_Parameter(Application_Links *app, Dynamic param, Dynamic value) +char* Push_Memory(Application_Links *app, int len) +void Exec_Command_Keep_Stack(Application_Links *app, int command_id) +void Clear_Parameters(Application_Links *app) + +// File system navigation +int Directory_Get_Hot(Application_Links *app, char *out, int capacity) +int Get_4ed_Path(Application_Links *app, char *out, int capacity) +int File_Exists(Application_Links *app, char *filename, int len) +int Directory_CD(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len) +File_List Get_File_List(Application_Links *app, char *dir, int len) +void Free_File_List(Application_Links *app, File_List list) + +// Direct buffer manipulation +Buffer_Summary Get_Buffer_First(Application_Links *app) +void Get_Buffer_Next(Application_Links *app, Buffer_Summary *buffer) + +Buffer_Summary Get_Buffer(Application_Links *app, int index) +Buffer_Summary Get_Active_Buffer(Application_Links *app) +Buffer_Summary Get_Parameter_Buffer(Application_Links *app, int param_index) +Buffer_Summary Get_Buffer_By_Name(Application_Links *app, char *filename, int len) + +// TODO(allen): Need more flexible seek system somehow. Regex? Just expose the text stream to the user? +int Buffer_Seek_Delimiter(Application_Links *app, Buffer_Summary *buffer, int start, char delim, int seek_forward, int *out) +int Buffer_Seek_String(Application_Links *app, Buffer_Summary *buffer, int start, char *str, int len, int seek_forward, int *out) +int Buffer_Seek_String_Insensitive(Application_Links *app, Buffer_Summary *buffer, int start, char *str, int len, int seek_forward, int *out) + +int Refresh_Buffer(Application_Links *app, Buffer_Summary *buffer) +int Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out) +int Buffer_Replace_Range(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len) +int Buffer_Set_Pos(Application_Links *app, Buffer_Summary *buffer, int pos) + +// File view manipulation +View_Summary Get_View_First(Application_Links *app) +void Get_View_Next(Application_Links *app, View_Summary *view) + +View_Summary Get_View(Application_Links *app, int index) +View_Summary Get_Active_View(Application_Links *app) + +int Refresh_View(Application_Links *app, View_Summary *view) +Full_Cursor View_Compute_Cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek) +int View_Set_Cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x) +int View_Set_Mark(Application_Links *app, View_Summary *view, Buffer_Seek seek) +int View_Set_Highlight(Application_Links *app, View_Summary *view, int start, int end, int turn_on) +int View_Set_Buffer(Application_Links *app, View_Summary *view, int buffer_id) + +// Directly get user input +User_Input Get_User_Input(Application_Links *app, unsigned int get_type, unsigned int abort_type) +User_Input Get_Command_Input(Application_Links *app) +Event_Message Get_Event_Message(Application_Links *app) + +// Queries and information display +int Start_Query_Bar(Application_Links *app, Query_Bar *bar, unsigned int flags) +void End_Query_Bar(Application_Links *app, Query_Bar *bar, unsigned int flags) +void Print_Message(Application_Links *app, char *string, int len) +GUI_Functions* Get_GUI_Functions(Application_Links *app) +GUI* Get_GUI(Application_Links *app, int view_id) + +// Color settings +void Change_Theme(Application_Links *app, char *name, int len) +void Change_Font(Application_Links *app, char *name, int len) +void Set_Theme_Colors(Application_Links *app, Theme_Color *colors, int count)