§3.3.19: create_buffer
Buffer_Summary app->create_buffer(
Application_Links *app,
char *filename,
int32_t filename_len,
Buffer_Create_Flag flags
)
Parameters
filename
The filename parameter specifies the name of the file to be opened or created;
it need not be null terminated.
filename_len
The filename_len parameter spcifies the length of the filename string.
flags
The flags parameter specifies behaviors for buffer creation.
Return
This call returns the summary of the created buffer.
Description
Tries to create a new buffer and associate it to the given filename. If such a buffer
already exists the existing buffer is returned in the Buffer_Summary and no new buffer is
created. If the buffer does not exist a new buffer is created and named after the given
diff --git a/4coder_auto_indent.cpp b/4coder_auto_indent.cpp
index a3248568..20234842 100644
--- a/4coder_auto_indent.cpp
+++ b/4coder_auto_indent.cpp
@@ -146,7 +146,7 @@ set_line_indents(Application_Links *app, Partition *part, Buffer_Summary *buffer
make_batch_from_indent_marks(app, part, buffer, line_start, line_end, indent_marks, opts);
if (batch.edit_count > 0){
- app->buffer_batch_edit(app, buffer, batch.str, batch.str_len,
+ buffer_batch_edit(app, buffer, batch.str, batch.str_len,
batch.edits, batch.edit_count, BatchEdit_PreserveTokens);
}
}
@@ -554,10 +554,10 @@ buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buff
// Stage 1: Read the tokens to be used for indentation.
Cpp_Token_Array tokens;
- tokens.count = app->buffer_token_count(app, buffer);
+ tokens.count = buffer_token_count(app, buffer);
tokens.max_count = tokens.count;
tokens.tokens = push_array(part, Cpp_Token, tokens.count);
- app->buffer_read_tokens(app, buffer, 0, tokens.count, tokens.tokens);
+ buffer_read_tokens(app, buffer, 0, tokens.count, tokens.tokens);
// Stage 2: Decide where the first and last lines are.
// The lines in the range [line_start,line_end) will be indented.
diff --git a/4coder_custom_api.h b/4coder_custom_api.h
index f2b5b583..1b8919d3 100644
--- a/4coder_custom_api.h
+++ b/4coder_custom_api.h
@@ -121,6 +121,7 @@ typedef TOGGLE_FULLSCREEN_SIG(Toggle_Fullscreen_Function);
typedef IS_FULLSCREEN_SIG(Is_Fullscreen_Function);
typedef SEND_EXIT_SIGNAL_SIG(Send_Exit_Signal_Function);
struct Application_Links{
+#if defined(ALLOW_DEP_4CODER)
Exec_Command_Function *exec_command;
Exec_System_Command_Function *exec_system_command;
Clipboard_Post_Function *clipboard_post;
@@ -182,6 +183,69 @@ Show_Mouse_Cursor_Function *show_mouse_cursor;
Toggle_Fullscreen_Function *toggle_fullscreen;
Is_Fullscreen_Function *is_fullscreen;
Send_Exit_Signal_Function *send_exit_signal;
+#else
+Exec_Command_Function *exec_command_;
+Exec_System_Command_Function *exec_system_command_;
+Clipboard_Post_Function *clipboard_post_;
+Clipboard_Count_Function *clipboard_count_;
+Clipboard_Index_Function *clipboard_index_;
+Get_Buffer_Count_Function *get_buffer_count_;
+Get_Buffer_First_Function *get_buffer_first_;
+Get_Buffer_Next_Function *get_buffer_next_;
+Get_Buffer_Function *get_buffer_;
+Get_Buffer_By_Name_Function *get_buffer_by_name_;
+Buffer_Read_Range_Function *buffer_read_range_;
+Buffer_Replace_Range_Function *buffer_replace_range_;
+Buffer_Compute_Cursor_Function *buffer_compute_cursor_;
+Buffer_Batch_Edit_Function *buffer_batch_edit_;
+Buffer_Set_Setting_Function *buffer_set_setting_;
+Buffer_Token_Count_Function *buffer_token_count_;
+Buffer_Read_Tokens_Function *buffer_read_tokens_;
+Buffer_Get_Token_Index_Function *buffer_get_token_index_;
+Create_Buffer_Function *create_buffer_;
+Save_Buffer_Function *save_buffer_;
+Kill_Buffer_Function *kill_buffer_;
+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_;
+Open_View_Function *open_view_;
+Close_View_Function *close_view_;
+Set_Active_View_Function *set_active_view_;
+View_Set_Setting_Function *view_set_setting_;
+View_Set_Split_Proportion_Function *view_set_split_proportion_;
+View_Compute_Cursor_Function *view_compute_cursor_;
+View_Set_Cursor_Function *view_set_cursor_;
+View_Set_Scroll_Function *view_set_scroll_;
+View_Set_Mark_Function *view_set_mark_;
+View_Set_Highlight_Function *view_set_highlight_;
+View_Set_Buffer_Function *view_set_buffer_;
+View_Post_Fade_Function *view_post_fade_;
+Get_User_Input_Function *get_user_input_;
+Get_Command_Input_Function *get_command_input_;
+Get_Mouse_State_Function *get_mouse_state_;
+Start_Query_Bar_Function *start_query_bar_;
+End_Query_Bar_Function *end_query_bar_;
+Print_Message_Function *print_message_;
+Change_Theme_Function *change_theme_;
+Change_Font_Function *change_font_;
+Buffer_Set_Font_Function *buffer_set_font_;
+Set_Theme_Colors_Function *set_theme_colors_;
+Get_Theme_Colors_Function *get_theme_colors_;
+Directory_Get_Hot_Function *directory_get_hot_;
+Get_File_List_Function *get_file_list_;
+Free_File_List_Function *free_file_list_;
+Memory_Allocate_Function *memory_allocate_;
+Memory_Set_Protection_Function *memory_set_protection_;
+Memory_Free_Function *memory_free_;
+File_Exists_Function *file_exists_;
+Directory_CD_Function *directory_cd_;
+Get_4ed_Path_Function *get_4ed_path_;
+Show_Mouse_Cursor_Function *show_mouse_cursor_;
+Toggle_Fullscreen_Function *toggle_fullscreen_;
+Is_Fullscreen_Function *is_fullscreen_;
+Send_Exit_Signal_Function *send_exit_signal_;
+#endif
void *memory;
int32_t memory_size;
void *cmd_context;
@@ -190,64 +254,189 @@ void *current_coroutine;
int32_t type_coroutine;
};
#define FillAppLinksAPI(app_links) do{\
-app_links->exec_command = Exec_Command;\
-app_links->exec_system_command = Exec_System_Command;\
-app_links->clipboard_post = Clipboard_Post;\
-app_links->clipboard_count = Clipboard_Count;\
-app_links->clipboard_index = Clipboard_Index;\
-app_links->get_buffer_count = Get_Buffer_Count;\
-app_links->get_buffer_first = Get_Buffer_First;\
-app_links->get_buffer_next = Get_Buffer_Next;\
-app_links->get_buffer = Get_Buffer;\
-app_links->get_buffer_by_name = Get_Buffer_By_Name;\
-app_links->buffer_read_range = Buffer_Read_Range;\
-app_links->buffer_replace_range = Buffer_Replace_Range;\
-app_links->buffer_compute_cursor = Buffer_Compute_Cursor;\
-app_links->buffer_batch_edit = Buffer_Batch_Edit;\
-app_links->buffer_set_setting = Buffer_Set_Setting;\
-app_links->buffer_token_count = Buffer_Token_Count;\
-app_links->buffer_read_tokens = Buffer_Read_Tokens;\
-app_links->buffer_get_token_index = Buffer_Get_Token_Index;\
-app_links->create_buffer = Create_Buffer;\
-app_links->save_buffer = Save_Buffer;\
-app_links->kill_buffer = Kill_Buffer;\
-app_links->get_view_first = Get_View_First;\
-app_links->get_view_next = Get_View_Next;\
-app_links->get_view = Get_View;\
-app_links->get_active_view = Get_Active_View;\
-app_links->open_view = Open_View;\
-app_links->close_view = Close_View;\
-app_links->set_active_view = Set_Active_View;\
-app_links->view_set_setting = View_Set_Setting;\
-app_links->view_set_split_proportion = View_Set_Split_Proportion;\
-app_links->view_compute_cursor = View_Compute_Cursor;\
-app_links->view_set_cursor = View_Set_Cursor;\
-app_links->view_set_scroll = View_Set_Scroll;\
-app_links->view_set_mark = View_Set_Mark;\
-app_links->view_set_highlight = View_Set_Highlight;\
-app_links->view_set_buffer = View_Set_Buffer;\
-app_links->view_post_fade = View_Post_Fade;\
-app_links->get_user_input = Get_User_Input;\
-app_links->get_command_input = Get_Command_Input;\
-app_links->get_mouse_state = Get_Mouse_State;\
-app_links->start_query_bar = Start_Query_Bar;\
-app_links->end_query_bar = End_Query_Bar;\
-app_links->print_message = Print_Message;\
-app_links->change_theme = Change_Theme;\
-app_links->change_font = Change_Font;\
-app_links->buffer_set_font = Buffer_Set_Font;\
-app_links->set_theme_colors = Set_Theme_Colors;\
-app_links->get_theme_colors = Get_Theme_Colors;\
-app_links->directory_get_hot = Directory_Get_Hot;\
-app_links->get_file_list = Get_File_List;\
-app_links->free_file_list = Free_File_List;\
-app_links->memory_allocate = Memory_Allocate;\
-app_links->memory_set_protection = Memory_Set_Protection;\
-app_links->memory_free = Memory_Free;\
-app_links->file_exists = File_Exists;\
-app_links->directory_cd = Directory_CD;\
-app_links->get_4ed_path = Get_4ed_Path;\
-app_links->show_mouse_cursor = Show_Mouse_Cursor;\
-app_links->toggle_fullscreen = Toggle_Fullscreen;\
-app_links->is_fullscreen = Is_Fullscreen;\
-app_links->send_exit_signal = Send_Exit_Signal;} while(false)
+app_links->exec_command_ = Exec_Command;\
+app_links->exec_system_command_ = Exec_System_Command;\
+app_links->clipboard_post_ = Clipboard_Post;\
+app_links->clipboard_count_ = Clipboard_Count;\
+app_links->clipboard_index_ = Clipboard_Index;\
+app_links->get_buffer_count_ = Get_Buffer_Count;\
+app_links->get_buffer_first_ = Get_Buffer_First;\
+app_links->get_buffer_next_ = Get_Buffer_Next;\
+app_links->get_buffer_ = Get_Buffer;\
+app_links->get_buffer_by_name_ = Get_Buffer_By_Name;\
+app_links->buffer_read_range_ = Buffer_Read_Range;\
+app_links->buffer_replace_range_ = Buffer_Replace_Range;\
+app_links->buffer_compute_cursor_ = Buffer_Compute_Cursor;\
+app_links->buffer_batch_edit_ = Buffer_Batch_Edit;\
+app_links->buffer_set_setting_ = Buffer_Set_Setting;\
+app_links->buffer_token_count_ = Buffer_Token_Count;\
+app_links->buffer_read_tokens_ = Buffer_Read_Tokens;\
+app_links->buffer_get_token_index_ = Buffer_Get_Token_Index;\
+app_links->create_buffer_ = Create_Buffer;\
+app_links->save_buffer_ = Save_Buffer;\
+app_links->kill_buffer_ = Kill_Buffer;\
+app_links->get_view_first_ = Get_View_First;\
+app_links->get_view_next_ = Get_View_Next;\
+app_links->get_view_ = Get_View;\
+app_links->get_active_view_ = Get_Active_View;\
+app_links->open_view_ = Open_View;\
+app_links->close_view_ = Close_View;\
+app_links->set_active_view_ = Set_Active_View;\
+app_links->view_set_setting_ = View_Set_Setting;\
+app_links->view_set_split_proportion_ = View_Set_Split_Proportion;\
+app_links->view_compute_cursor_ = View_Compute_Cursor;\
+app_links->view_set_cursor_ = View_Set_Cursor;\
+app_links->view_set_scroll_ = View_Set_Scroll;\
+app_links->view_set_mark_ = View_Set_Mark;\
+app_links->view_set_highlight_ = View_Set_Highlight;\
+app_links->view_set_buffer_ = View_Set_Buffer;\
+app_links->view_post_fade_ = View_Post_Fade;\
+app_links->get_user_input_ = Get_User_Input;\
+app_links->get_command_input_ = Get_Command_Input;\
+app_links->get_mouse_state_ = Get_Mouse_State;\
+app_links->start_query_bar_ = Start_Query_Bar;\
+app_links->end_query_bar_ = End_Query_Bar;\
+app_links->print_message_ = Print_Message;\
+app_links->change_theme_ = Change_Theme;\
+app_links->change_font_ = Change_Font;\
+app_links->buffer_set_font_ = Buffer_Set_Font;\
+app_links->set_theme_colors_ = Set_Theme_Colors;\
+app_links->get_theme_colors_ = Get_Theme_Colors;\
+app_links->directory_get_hot_ = Directory_Get_Hot;\
+app_links->get_file_list_ = Get_File_List;\
+app_links->free_file_list_ = Free_File_List;\
+app_links->memory_allocate_ = Memory_Allocate;\
+app_links->memory_set_protection_ = Memory_Set_Protection;\
+app_links->memory_free_ = Memory_Free;\
+app_links->file_exists_ = File_Exists;\
+app_links->directory_cd_ = Directory_CD;\
+app_links->get_4ed_path_ = Get_4ed_Path;\
+app_links->show_mouse_cursor_ = Show_Mouse_Cursor;\
+app_links->toggle_fullscreen_ = Toggle_Fullscreen;\
+app_links->is_fullscreen_ = Is_Fullscreen;\
+app_links->send_exit_signal_ = Send_Exit_Signal;} while(false)
+#if defined(ALLOW_DEP_4CODER)
+static inline bool32 exec_command(Application_Links *app, Command_ID command_id){return(app->exec_command(app, command_id));}
+static inline bool32 exec_system_command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags){return(app->exec_system_command(app, view, buffer, path, path_len, command, command_len, flags));}
+static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len){(app->clipboard_post(app, clipboard_id, str, len));}
+static inline int32_t clipboard_count(Application_Links *app, int32_t clipboard_id){return(app->clipboard_count(app, clipboard_id));}
+static inline int32_t clipboard_index(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len){return(app->clipboard_index(app, clipboard_id, item_index, out, len));}
+static inline int32_t get_buffer_count(Application_Links *app){return(app->get_buffer_count(app));}
+static inline Buffer_Summary get_buffer_first(Application_Links *app, Access_Flag access){return(app->get_buffer_first(app, access));}
+static inline void get_buffer_next(Application_Links *app, Buffer_Summary *buffer, Access_Flag access){(app->get_buffer_next(app, buffer, access));}
+static inline Buffer_Summary get_buffer(Application_Links *app, Buffer_ID buffer_id, Access_Flag access){return(app->get_buffer(app, buffer_id, access));}
+static inline Buffer_Summary get_buffer_by_name(Application_Links *app, char *name, int32_t len, Access_Flag access){return(app->get_buffer_by_name(app, name, len, access));}
+static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out){return(app->buffer_read_range(app, buffer, start, end, out));}
+static inline bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len){return(app->buffer_replace_range(app, buffer, start, end, str, len));}
+static inline bool32 buffer_compute_cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor(app, buffer, seek, cursor_out));}
+static inline bool32 buffer_batch_edit(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit(app, buffer, str, str_len, edits, edit_count, type));}
+static inline bool32 buffer_set_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value){return(app->buffer_set_setting(app, buffer, setting, value));}
+static inline int32_t buffer_token_count(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_token_count(app, buffer));}
+static inline bool32 buffer_read_tokens(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out){return(app->buffer_read_tokens(app, buffer, start_token, end_token, tokens_out));}
+static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index(app, buffer, pos, get_result));}
+static inline Buffer_Summary create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags){return(app->create_buffer(app, filename, filename_len, flags));}
+static inline bool32 save_buffer(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags){return(app->save_buffer(app, buffer, filename, filename_len, flags));}
+static inline bool32 kill_buffer(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags){return(app->kill_buffer(app, buffer, view_id, flags));}
+static inline View_Summary get_view_first(Application_Links *app, Access_Flag access){return(app->get_view_first(app, access));}
+static inline void get_view_next(Application_Links *app, View_Summary *view, Access_Flag access){(app->get_view_next(app, view, access));}
+static inline View_Summary get_view(Application_Links *app, View_ID view_id, Access_Flag access){return(app->get_view(app, view_id, access));}
+static inline View_Summary get_active_view(Application_Links *app, Access_Flag access){return(app->get_active_view(app, access));}
+static inline View_Summary open_view(Application_Links *app, View_Summary *view_location, View_Split_Position position){return(app->open_view(app, view_location, position));}
+static inline bool32 close_view(Application_Links *app, View_Summary *view){return(app->close_view(app, view));}
+static inline bool32 set_active_view(Application_Links *app, View_Summary *view){return(app->set_active_view(app, view));}
+static inline bool32 view_set_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value){return(app->view_set_setting(app, view, setting, value));}
+static inline bool32 view_set_split_proportion(Application_Links *app, View_Summary *view, float t){return(app->view_set_split_proportion(app, view, t));}
+static inline bool32 view_compute_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out){return(app->view_compute_cursor(app, view, seek, cursor_out));}
+static inline bool32 view_set_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x){return(app->view_set_cursor(app, view, seek, set_preferred_x));}
+static inline bool32 view_set_scroll(Application_Links *app, View_Summary *view, GUI_Scroll_Vars scroll){return(app->view_set_scroll(app, view, scroll));}
+static inline bool32 view_set_mark(Application_Links *app, View_Summary *view, Buffer_Seek seek){return(app->view_set_mark(app, view, seek));}
+static inline bool32 view_set_highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on){return(app->view_set_highlight(app, view, start, end, turn_on));}
+static inline bool32 view_set_buffer(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags){return(app->view_set_buffer(app, view, buffer_id, flags));}
+static inline bool32 view_post_fade(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color){return(app->view_post_fade(app, view, seconds, start, end, color));}
+static inline User_Input get_user_input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type){return(app->get_user_input(app, get_type, abort_type));}
+static inline User_Input get_command_input(Application_Links *app){return(app->get_command_input(app));}
+static inline Mouse_State get_mouse_state(Application_Links *app){return(app->get_mouse_state(app));}
+static inline bool32 start_query_bar(Application_Links *app, Query_Bar *bar, uint32_t flags){return(app->start_query_bar(app, bar, flags));}
+static inline void end_query_bar(Application_Links *app, Query_Bar *bar, uint32_t flags){(app->end_query_bar(app, bar, flags));}
+static inline void print_message(Application_Links *app, char *str, int32_t len){(app->print_message(app, str, len));}
+static inline void change_theme(Application_Links *app, char *name, int32_t len){(app->change_theme(app, name, len));}
+static inline void change_font(Application_Links *app, char *name, int32_t len, bool32 apply_to_all_files){(app->change_font(app, name, len, apply_to_all_files));}
+static inline void buffer_set_font(Application_Links *app, Buffer_Summary *buffer, char *name, int32_t len){(app->buffer_set_font(app, buffer, name, len));}
+static inline void set_theme_colors(Application_Links *app, Theme_Color *colors, int32_t count){(app->set_theme_colors(app, colors, count));}
+static inline void get_theme_colors(Application_Links *app, Theme_Color *colors, int32_t count){(app->get_theme_colors(app, colors, count));}
+static inline int32_t directory_get_hot(Application_Links *app, char *out, int32_t capacity){return(app->directory_get_hot(app, out, capacity));}
+static inline File_List get_file_list(Application_Links *app, char *dir, int32_t len){return(app->get_file_list(app, dir, len));}
+static inline void free_file_list(Application_Links *app, File_List list){(app->free_file_list(app, list));}
+static inline void* memory_allocate(Application_Links *app, int32_t size){return(app->memory_allocate(app, size));}
+static inline bool32 memory_set_protection(Application_Links *app, void *ptr, int32_t size, Memory_Protect_Flags flags){return(app->memory_set_protection(app, ptr, size, flags));}
+static inline void memory_free(Application_Links *app, void *ptr, int32_t size){(app->memory_free(app, ptr, size));}
+static inline bool32 file_exists(Application_Links *app, char *filename, int32_t len){return(app->file_exists(app, filename, len));}
+static inline bool32 directory_cd(Application_Links *app, char *dir, int32_t *len, int32_t capacity, char *rel_path, int32_t rel_len){return(app->directory_cd(app, dir, len, capacity, rel_path, rel_len));}
+static inline bool32 get_4ed_path(Application_Links *app, char *out, int32_t capacity){return(app->get_4ed_path(app, out, capacity));}
+static inline void show_mouse_cursor(Application_Links *app, Mouse_Cursor_Show_Type show){(app->show_mouse_cursor(app, show));}
+static inline void toggle_fullscreen(Application_Links *app){(app->toggle_fullscreen(app));}
+static inline bool32 is_fullscreen(Application_Links *app){return(app->is_fullscreen(app));}
+static inline void send_exit_signal(Application_Links *app){(app->send_exit_signal(app));}
+#else
+static inline bool32 exec_command(Application_Links *app, Command_ID command_id){return(app->exec_command_(app, command_id));}
+static inline bool32 exec_system_command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags){return(app->exec_system_command_(app, view, buffer, path, path_len, command, command_len, flags));}
+static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len){(app->clipboard_post_(app, clipboard_id, str, len));}
+static inline int32_t clipboard_count(Application_Links *app, int32_t clipboard_id){return(app->clipboard_count_(app, clipboard_id));}
+static inline int32_t clipboard_index(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len){return(app->clipboard_index_(app, clipboard_id, item_index, out, len));}
+static inline int32_t get_buffer_count(Application_Links *app){return(app->get_buffer_count_(app));}
+static inline Buffer_Summary get_buffer_first(Application_Links *app, Access_Flag access){return(app->get_buffer_first_(app, access));}
+static inline void get_buffer_next(Application_Links *app, Buffer_Summary *buffer, Access_Flag access){(app->get_buffer_next_(app, buffer, access));}
+static inline Buffer_Summary get_buffer(Application_Links *app, Buffer_ID buffer_id, Access_Flag access){return(app->get_buffer_(app, buffer_id, access));}
+static inline Buffer_Summary get_buffer_by_name(Application_Links *app, char *name, int32_t len, Access_Flag access){return(app->get_buffer_by_name_(app, name, len, access));}
+static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out){return(app->buffer_read_range_(app, buffer, start, end, out));}
+static inline bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len){return(app->buffer_replace_range_(app, buffer, start, end, str, len));}
+static inline bool32 buffer_compute_cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor_(app, buffer, seek, cursor_out));}
+static inline bool32 buffer_batch_edit(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit_(app, buffer, str, str_len, edits, edit_count, type));}
+static inline bool32 buffer_set_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value){return(app->buffer_set_setting_(app, buffer, setting, value));}
+static inline int32_t buffer_token_count(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_token_count_(app, buffer));}
+static inline bool32 buffer_read_tokens(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out){return(app->buffer_read_tokens_(app, buffer, start_token, end_token, tokens_out));}
+static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index_(app, buffer, pos, get_result));}
+static inline Buffer_Summary create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags){return(app->create_buffer_(app, filename, filename_len, flags));}
+static inline bool32 save_buffer(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags){return(app->save_buffer_(app, buffer, filename, filename_len, flags));}
+static inline bool32 kill_buffer(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags){return(app->kill_buffer_(app, buffer, view_id, flags));}
+static inline View_Summary get_view_first(Application_Links *app, Access_Flag access){return(app->get_view_first_(app, access));}
+static inline void get_view_next(Application_Links *app, View_Summary *view, Access_Flag access){(app->get_view_next_(app, view, access));}
+static inline View_Summary get_view(Application_Links *app, View_ID view_id, Access_Flag access){return(app->get_view_(app, view_id, access));}
+static inline View_Summary get_active_view(Application_Links *app, Access_Flag access){return(app->get_active_view_(app, access));}
+static inline View_Summary open_view(Application_Links *app, View_Summary *view_location, View_Split_Position position){return(app->open_view_(app, view_location, position));}
+static inline bool32 close_view(Application_Links *app, View_Summary *view){return(app->close_view_(app, view));}
+static inline bool32 set_active_view(Application_Links *app, View_Summary *view){return(app->set_active_view_(app, view));}
+static inline bool32 view_set_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value){return(app->view_set_setting_(app, view, setting, value));}
+static inline bool32 view_set_split_proportion(Application_Links *app, View_Summary *view, float t){return(app->view_set_split_proportion_(app, view, t));}
+static inline bool32 view_compute_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out){return(app->view_compute_cursor_(app, view, seek, cursor_out));}
+static inline bool32 view_set_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x){return(app->view_set_cursor_(app, view, seek, set_preferred_x));}
+static inline bool32 view_set_scroll(Application_Links *app, View_Summary *view, GUI_Scroll_Vars scroll){return(app->view_set_scroll_(app, view, scroll));}
+static inline bool32 view_set_mark(Application_Links *app, View_Summary *view, Buffer_Seek seek){return(app->view_set_mark_(app, view, seek));}
+static inline bool32 view_set_highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on){return(app->view_set_highlight_(app, view, start, end, turn_on));}
+static inline bool32 view_set_buffer(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags){return(app->view_set_buffer_(app, view, buffer_id, flags));}
+static inline bool32 view_post_fade(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color){return(app->view_post_fade_(app, view, seconds, start, end, color));}
+static inline User_Input get_user_input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type){return(app->get_user_input_(app, get_type, abort_type));}
+static inline User_Input get_command_input(Application_Links *app){return(app->get_command_input_(app));}
+static inline Mouse_State get_mouse_state(Application_Links *app){return(app->get_mouse_state_(app));}
+static inline bool32 start_query_bar(Application_Links *app, Query_Bar *bar, uint32_t flags){return(app->start_query_bar_(app, bar, flags));}
+static inline void end_query_bar(Application_Links *app, Query_Bar *bar, uint32_t flags){(app->end_query_bar_(app, bar, flags));}
+static inline void print_message(Application_Links *app, char *str, int32_t len){(app->print_message_(app, str, len));}
+static inline void change_theme(Application_Links *app, char *name, int32_t len){(app->change_theme_(app, name, len));}
+static inline void change_font(Application_Links *app, char *name, int32_t len, bool32 apply_to_all_files){(app->change_font_(app, name, len, apply_to_all_files));}
+static inline void buffer_set_font(Application_Links *app, Buffer_Summary *buffer, char *name, int32_t len){(app->buffer_set_font_(app, buffer, name, len));}
+static inline void set_theme_colors(Application_Links *app, Theme_Color *colors, int32_t count){(app->set_theme_colors_(app, colors, count));}
+static inline void get_theme_colors(Application_Links *app, Theme_Color *colors, int32_t count){(app->get_theme_colors_(app, colors, count));}
+static inline int32_t directory_get_hot(Application_Links *app, char *out, int32_t capacity){return(app->directory_get_hot_(app, out, capacity));}
+static inline File_List get_file_list(Application_Links *app, char *dir, int32_t len){return(app->get_file_list_(app, dir, len));}
+static inline void free_file_list(Application_Links *app, File_List list){(app->free_file_list_(app, list));}
+static inline void* memory_allocate(Application_Links *app, int32_t size){return(app->memory_allocate_(app, size));}
+static inline bool32 memory_set_protection(Application_Links *app, void *ptr, int32_t size, Memory_Protect_Flags flags){return(app->memory_set_protection_(app, ptr, size, flags));}
+static inline void memory_free(Application_Links *app, void *ptr, int32_t size){(app->memory_free_(app, ptr, size));}
+static inline bool32 file_exists(Application_Links *app, char *filename, int32_t len){return(app->file_exists_(app, filename, len));}
+static inline bool32 directory_cd(Application_Links *app, char *dir, int32_t *len, int32_t capacity, char *rel_path, int32_t rel_len){return(app->directory_cd_(app, dir, len, capacity, rel_path, rel_len));}
+static inline bool32 get_4ed_path(Application_Links *app, char *out, int32_t capacity){return(app->get_4ed_path_(app, out, capacity));}
+static inline void show_mouse_cursor(Application_Links *app, Mouse_Cursor_Show_Type show){(app->show_mouse_cursor_(app, show));}
+static inline void toggle_fullscreen(Application_Links *app){(app->toggle_fullscreen_(app));}
+static inline bool32 is_fullscreen(Application_Links *app){return(app->is_fullscreen_(app));}
+static inline void send_exit_signal(Application_Links *app){(app->send_exit_signal_(app));}
+#endif
diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp
index 65480ad2..5a61228e 100644
--- a/4coder_default_bindings.cpp
+++ b/4coder_default_bindings.cpp
@@ -32,7 +32,7 @@ CUSTOM_COMMAND_SIG(write_zero_struct){
}
CUSTOM_COMMAND_SIG(write_capital){
- User_Input command_in = app->get_command_input(app);
+ User_Input command_in = get_command_input(app);
char c = command_in.key.character_no_caps_lock;
if (c != 0){
c = char_to_upper(c);
@@ -46,15 +46,15 @@ CUSTOM_COMMAND_SIG(switch_to_compilation){
int32_t name_size = sizeof(name)-1;
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer_by_name(app, name, name_size, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer_by_name(app, name, name_size, access);
- app->view_set_buffer(app, &view, buffer.buffer_id, 0);
+ view_set_buffer(app, &view, buffer.buffer_id, 0);
}
CUSTOM_COMMAND_SIG(rewrite_as_single_caps){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
Full_Cursor cursor = view.cursor;
// TODO(allen): This can be rewritten now without moving the
@@ -73,8 +73,8 @@ CUSTOM_COMMAND_SIG(rewrite_as_single_caps){
string.size = range.max - range.min;
assert(string.size < app->memory_size);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
- app->buffer_read_range(app, &buffer, range.min, range.max, string.str);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
+ buffer_read_range(app, &buffer, range.min, range.max, string.str);
int32_t is_first = true;
for (int32_t i = 0; i < string.size; ++i){
@@ -91,23 +91,23 @@ CUSTOM_COMMAND_SIG(rewrite_as_single_caps){
}
}
- app->buffer_replace_range(app, &buffer, range.min, range.max, string.str, string.size);
+ buffer_replace_range(app, &buffer, range.min, range.max, string.str, string.size);
- app->view_set_cursor(app, &view,
+ view_set_cursor(app, &view,
seek_line_char(cursor.line+1, cursor.character),
true);
}
CUSTOM_COMMAND_SIG(open_my_files){
uint32_t access = AccessAll;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
view_open_file(app, &view, literal("w:/4ed/data/test/basic.cpp"), true);
}
CUSTOM_COMMAND_SIG(build_at_launch_location){
uint32_t access = AccessAll;
- View_Summary view = app->get_active_view(app, access);
- app->exec_system_command(app, &view,
+ View_Summary view = get_active_view(app, access);
+ exec_system_command(app, &view,
buffer_identifier(literal("*compilation*")),
literal("."),
literal("build"),
@@ -127,8 +127,8 @@ CUSTOM_COMMAND_SIG(seek_whitespace_down_end_line){
HOOK_SIG(my_start){
init_memory(app);
- app->change_theme(app, literal("4coder"));
- app->change_font(app, literal("Liberation Sans"), true);
+ change_theme(app, literal("4coder"));
+ change_font(app, literal("Liberation Sans"), true);
exec_command(app, open_panel_vsplit);
exec_command(app, hide_scrollbar);
@@ -159,8 +159,8 @@ HOOK_SIG(my_exit){
}
CUSTOM_COMMAND_SIG(newline_or_goto_position){
- View_Summary view = app->get_active_view(app, AccessProtected);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessProtected);
+ View_Summary view = get_active_view(app, AccessProtected);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
if (buffer.lock_flags & AccessProtected){
exec_command(app, goto_jump_at_cursor);
@@ -173,11 +173,11 @@ CUSTOM_COMMAND_SIG(newline_or_goto_position){
// TODO(allen): Eliminate this hook if you can.
OPEN_FILE_HOOK_SIG(my_file_settings){
- // NOTE(allen|a4.0.8): The app->get_parameter_buffer was eliminated
+ // NOTE(allen|a4.0.8): The get_parameter_buffer was eliminated
// and instead the buffer is passed as an explicit parameter through
// the function call. That is where buffer_id comes from here.
uint32_t access = AccessProtected|AccessHidden;
- Buffer_Summary buffer = app->get_buffer(app, buffer_id, access);
+ Buffer_Summary buffer = get_buffer(app, buffer_id, access);
assert(buffer.exists);
int32_t treat_as_code = 0;
@@ -198,9 +198,9 @@ OPEN_FILE_HOOK_SIG(my_file_settings){
wrap_lines = 0;
}
- app->buffer_set_setting(app, &buffer, BufferSetting_Lex, treat_as_code);
- app->buffer_set_setting(app, &buffer, BufferSetting_WrapLine, wrap_lines);
- app->buffer_set_setting(app, &buffer, BufferSetting_MapID,
+ buffer_set_setting(app, &buffer, BufferSetting_Lex, treat_as_code);
+ buffer_set_setting(app, &buffer, BufferSetting_WrapLine, wrap_lines);
+ buffer_set_setting(app, &buffer, BufferSetting_MapID,
(treat_as_code)?((int32_t)my_code_map):((int32_t)mapid_file));
// no meaning for return
@@ -226,11 +226,11 @@ static void
set_mouse_suppression(Application_Links *app, int32_t suppress){
if (suppress){
suppressing_mouse = true;
- app->show_mouse_cursor(app, MouseCursorShow_Never);
+ show_mouse_cursor(app, MouseCursorShow_Never);
}
else{
suppressing_mouse = false;
- app->show_mouse_cursor(app, MouseCursorShow_Always);
+ show_mouse_cursor(app, MouseCursorShow_Always);
}
}
diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp
index 4c406e2b..b1e54991 100644
--- a/4coder_default_include.cpp
+++ b/4coder_default_include.cpp
@@ -32,8 +32,8 @@ open_file(Application_Links *app,
int32_t never_new){
int32_t result = false;
Buffer_Summary buffer =
- app->get_buffer_by_name(app, filename, filename_len,
- AccessProtected|AccessHidden);
+ get_buffer_by_name(app, filename, filename_len,
+ AccessProtected|AccessHidden);
if (buffer.exists){
if (buffer_out) *buffer_out = buffer;
@@ -47,7 +47,7 @@ open_file(Application_Links *app,
if (never_new){
flags |= BufferCreate_NeverNew;
}
- buffer = app->create_buffer(app, filename, filename_len, flags);
+ buffer = create_buffer(app, filename, filename_len, flags);
if (buffer.exists){
if (buffer_out) *buffer_out = buffer;
result = true;
@@ -68,7 +68,7 @@ view_open_file(Application_Links *app,
if (view){
Buffer_Summary buffer = {0};
if (open_file(app, &buffer, filename, filename_len, false, never_new)){
- app->view_set_buffer(app, view, buffer.buffer_id, 0);
+ view_set_buffer(app, view, buffer.buffer_id, 0);
result = true;
}
}
@@ -88,17 +88,17 @@ read_line(Application_Links *app,
int32_t success = false;
- if (app->buffer_compute_cursor(app, buffer,
- seek_line_char(line, 1), &begin)){
- if (app->buffer_compute_cursor(app, buffer,
- seek_line_char(line, 65536), &end)){
+ if (buffer_compute_cursor(app, buffer,
+ seek_line_char(line, 1), &begin)){
+ if (buffer_compute_cursor(app, buffer,
+ seek_line_char(line, 65536), &end)){
if (begin.line == line){
if (0 <= begin.pos && begin.pos <= end.pos && end.pos <= buffer->size){
int32_t size = (end.pos - begin.pos);
*str = make_string(push_array(part, char, size+1), size+1);
if (str->str){
success = true;
- app->buffer_read_range(app, buffer, begin.pos, end.pos, str->str);
+ buffer_read_range(app, buffer, begin.pos, end.pos, str->str);
str->size = size;
terminate_with_null(str);
}
@@ -124,10 +124,10 @@ init_memory(Application_Links *app){
int32_t general_size = (1 << 20);
- void *part_mem = app->memory_allocate(app, part_size);
+ void *part_mem = memory_allocate(app, part_size);
global_part = make_part(part_mem, part_size);
- void *general_mem = app->memory_allocate(app, general_size);
+ void *general_mem = memory_allocate(app, general_size);
general_memory_open(&global_general, general_mem, general_size);
}
@@ -137,12 +137,12 @@ init_memory(Application_Links *app){
static void
refresh_buffer(Application_Links *app, Buffer_Summary *buffer){
- *buffer = app->get_buffer(app, buffer->buffer_id, AccessAll);
+ *buffer = get_buffer(app, buffer->buffer_id, AccessAll);
}
static void
refresh_view(Application_Links *app, View_Summary *view){
- *view = app->get_view(app, view->view_id, AccessAll);
+ *view = get_view(app, view->view_id, AccessAll);
}
//
@@ -206,7 +206,7 @@ init_stream_chunk(Stream_Chunk *chunk, Application_Links *app, Buffer_Summary *b
}
if (chunk->start < chunk->end){
- app->buffer_read_range(app, buffer, chunk->start, chunk->end, chunk->base_data);
+ buffer_read_range(app, buffer, chunk->start, chunk->end, chunk->base_data);
chunk->data = chunk->base_data - chunk->start;
result = 1;
}
@@ -234,7 +234,7 @@ forward_stream_chunk(Stream_Chunk *chunk){
}
if (chunk->start < chunk->end){
- app->buffer_read_range(app, buffer, chunk->start, chunk->end, chunk->base_data);
+ buffer_read_range(app, buffer, chunk->start, chunk->end, chunk->base_data);
chunk->data = chunk->base_data - chunk->start;
result = 1;
}
@@ -270,7 +270,7 @@ backward_stream_chunk(Stream_Chunk *chunk){
}
if (chunk->start < chunk->end){
- app->buffer_read_range(app, buffer, chunk->start, chunk->end, chunk->base_data);
+ buffer_read_range(app, buffer, chunk->start, chunk->end, chunk->base_data);
chunk->data = chunk->base_data - chunk->start;
result = 1;
}
@@ -304,7 +304,7 @@ init_stream_tokens(Stream_Tokens *stream, Application_Links *app, Buffer_Summary
refresh_buffer(app, buffer);
- int32_t token_count = app->buffer_token_count(app, buffer);
+ int32_t token_count = buffer_token_count(app, buffer);
if (pos >= 0 && pos < token_count && count > 0){
stream->app = app;
stream->buffer = buffer;
@@ -314,7 +314,7 @@ init_stream_tokens(Stream_Tokens *stream, Application_Links *app, Buffer_Summary
stream->end = round_up(pos, count);
stream->token_count = token_count;
- app->buffer_read_tokens(app, buffer, stream->start, stream->end, stream->base_tokens);
+ buffer_read_tokens(app, buffer, stream->start, stream->end, stream->base_tokens);
stream->tokens = stream->base_tokens - stream->start;
result = 1;
}
@@ -331,7 +331,7 @@ static void
end_temp_stream_token(Stream_Tokens *stream, Stream_Tokens temp){
if (stream->start != temp.start || stream->end != temp.end){
Application_Links *app = stream->app;
- app->buffer_read_tokens(app, stream->buffer, stream->start, stream->end, stream->base_tokens);
+ buffer_read_tokens(app, stream->buffer, stream->start, stream->end, stream->base_tokens);
}
}
@@ -351,7 +351,7 @@ forward_stream_tokens(Stream_Tokens *stream){
}
if (stream->start < stream->end){
- app->buffer_read_tokens(app, buffer, stream->start, stream->end, stream->base_tokens);
+ buffer_read_tokens(app, buffer, stream->start, stream->end, stream->base_tokens);
stream->tokens = stream->base_tokens - stream->start;
result = 1;
}
@@ -376,7 +376,7 @@ backward_stream_tokens(Stream_Tokens *stream){
}
if (stream->start < stream->end){
- app->buffer_read_tokens(app, buffer, stream->start, stream->end, stream->base_tokens);
+ buffer_read_tokens(app, buffer, stream->start, stream->end, stream->base_tokens);
stream->tokens = stream->base_tokens - stream->start;
result = 1;
}
@@ -476,7 +476,7 @@ buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer,
for(; pos < stream.end; ++pos){
char at_pos = stream.data[pos];
if (at_pos == first_char){
- app->buffer_read_range(app, buffer, pos, pos+size, read_buffer);
+ buffer_read_range(app, buffer, pos, pos+size, read_buffer);
if (match_ss(needle_str, read_str)){
*result = pos;
goto finished;
@@ -530,7 +530,7 @@ buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer,
for(; pos >= stream.start; --pos){
char at_pos = stream.data[pos];
if (at_pos == first_char){
- app->buffer_read_range(app, buffer, pos, pos+size, read_buffer);
+ buffer_read_range(app, buffer, pos, pos+size, read_buffer);
if (match_ss(needle_str, read_str)){
*result = pos;
goto finished;
@@ -580,7 +580,7 @@ buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *b
for(; pos < stream.end; ++pos){
char at_pos = char_to_upper(stream.data[pos]);
if (at_pos == first_char){
- app->buffer_read_range(app, buffer, pos, pos+size, read_buffer);
+ buffer_read_range(app, buffer, pos, pos+size, read_buffer);
if (match_insensitive_ss(needle_str, read_str)){
*result = pos;
goto finished;
@@ -630,7 +630,7 @@ buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *
for(; pos >= stream.start; --pos){
char at_pos = char_to_upper(stream.data[pos]);
if (at_pos == first_char){
- app->buffer_read_range(app, buffer, pos, pos+size, read_buffer);
+ buffer_read_range(app, buffer, pos, pos+size, read_buffer);
if (match_insensitive_ss(needle_str, read_str)){
*result = pos;
goto finished;
@@ -660,7 +660,7 @@ buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, int32_t li
Partial_Cursor partial_cursor;
int32_t result = buffer->size;
if (line <= buffer->line_count){
- app->buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &partial_cursor);
+ buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &partial_cursor);
result = partial_cursor.pos;
}
return(result);
@@ -669,7 +669,7 @@ buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, int32_t li
static int32_t
buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
Partial_Cursor partial_cursor;
- app->buffer_compute_cursor(app, buffer, seek_pos(pos), &partial_cursor);
+ buffer_compute_cursor(app, buffer, seek_pos(pos), &partial_cursor);
return(partial_cursor.line);
}
@@ -720,9 +720,9 @@ get_view_x(View_Summary view){
CUSTOM_COMMAND_SIG(write_character){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
- User_Input in = app->get_command_input(app);
+ User_Input in = get_command_input(app);
char character = 0;
if (in.type == UserInputKey){
@@ -730,70 +730,70 @@ CUSTOM_COMMAND_SIG(write_character){
}
if (character != 0){
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = view.cursor.pos;
int32_t next_pos = pos + 1;
- app->buffer_replace_range(app, &buffer,
+ buffer_replace_range(app, &buffer,
pos, pos, &character, 1);
- app->view_set_cursor(app, &view, seek_pos(next_pos), true);
+ view_set_cursor(app, &view, seek_pos(next_pos), true);
}
}
CUSTOM_COMMAND_SIG(delete_char){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = view.cursor.pos;
if (0 < buffer.size && pos < buffer.size){
- app->buffer_replace_range(app, &buffer,
+ buffer_replace_range(app, &buffer,
pos, pos+1, 0, 0);
}
}
CUSTOM_COMMAND_SIG(backspace_char){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = view.cursor.pos;
if (0 < pos && pos <= buffer.size){
- app->buffer_replace_range(app, &buffer,
+ buffer_replace_range(app, &buffer,
pos-1, pos, 0, 0);
- app->view_set_cursor(app, &view, seek_pos(pos-1), true);
+ view_set_cursor(app, &view, seek_pos(pos-1), true);
}
}
CUSTOM_COMMAND_SIG(set_mark){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
- app->view_set_mark(app, &view, seek_pos(view.cursor.pos));
+ view_set_mark(app, &view, seek_pos(view.cursor.pos));
// TODO(allen): Just expose the preferred_x seperately
- app->view_set_cursor(app, &view, seek_pos(view.cursor.pos), true);
+ view_set_cursor(app, &view, seek_pos(view.cursor.pos), true);
}
CUSTOM_COMMAND_SIG(cursor_mark_swap){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
int32_t cursor = view.cursor.pos;
int32_t mark = view.mark.pos;
- app->view_set_cursor(app, &view, seek_pos(mark), true);
- app->view_set_mark(app, &view, seek_pos(cursor));
+ view_set_cursor(app, &view, seek_pos(mark), true);
+ view_set_mark(app, &view, seek_pos(cursor));
}
CUSTOM_COMMAND_SIG(delete_range){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
Range range = get_range(&view);
- app->buffer_replace_range(app, &buffer,
+ buffer_replace_range(app, &buffer,
range.min, range.max,
0, 0);
}
@@ -803,7 +803,7 @@ CUSTOM_COMMAND_SIG(delete_range){
//
CUSTOM_COMMAND_SIG(center_view){
- View_Summary view = app->get_active_view(app, AccessProtected);
+ View_Summary view = get_active_view(app, AccessProtected);
i32_Rect region = view.file_region;
GUI_Scroll_Vars scroll = view.scroll_vars;
@@ -812,18 +812,18 @@ CUSTOM_COMMAND_SIG(center_view){
float y = get_view_y(view);
y = y - h*.5f;
scroll.target_y = (int32_t)(y + .5f);
- app->view_set_scroll(app, &view, scroll);
+ view_set_scroll(app, &view, scroll);
}
CUSTOM_COMMAND_SIG(left_adjust_view){
- View_Summary view = app->get_active_view(app, AccessProtected);
+ View_Summary view = get_active_view(app, AccessProtected);
GUI_Scroll_Vars scroll = view.scroll_vars;
float x = get_view_x(view);
x = x - 30.f;
scroll.target_x = (int32_t)(x + .5f);
- app->view_set_scroll(app, &view, scroll);
+ view_set_scroll(app, &view, scroll);
}
int32_t
@@ -853,12 +853,12 @@ get_relative_xy(View_Summary *view, int32_t x, int32_t y, float *x_out, float *y
CUSTOM_COMMAND_SIG(click_set_cursor){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
- Mouse_State mouse = app->get_mouse_state(app);
+ Mouse_State mouse = get_mouse_state(app);
float rx = 0, ry = 0;
if (get_relative_xy(&view, mouse.x, mouse.y, &rx, &ry)){
- app->view_set_cursor(app, &view,
+ view_set_cursor(app, &view,
seek_xy(rx, ry, true,
view.unwrapped_lines),
true);
@@ -867,12 +867,12 @@ CUSTOM_COMMAND_SIG(click_set_cursor){
CUSTOM_COMMAND_SIG(click_set_mark){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
- Mouse_State mouse = app->get_mouse_state(app);
+ Mouse_State mouse = get_mouse_state(app);
float rx = 0, ry = 0;
if (get_relative_xy(&view, mouse.x, mouse.y, &rx, &ry)){
- app->view_set_mark(app, &view,
+ view_set_mark(app, &view,
seek_xy(rx, ry, true,
view.unwrapped_lines)
);
@@ -882,12 +882,12 @@ CUSTOM_COMMAND_SIG(click_set_mark){
inline void
move_vertical(Application_Links *app, float line_multiplier){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
float new_y = get_view_y(view) + line_multiplier*view.line_height;
float x = view.preferred_x;
- app->view_set_cursor(app, &view,
+ view_set_cursor(app, &view,
seek_xy(x, new_y, false, view.unwrapped_lines),
false);
}
@@ -926,14 +926,14 @@ get_page_jump(View_Summary *view){
CUSTOM_COMMAND_SIG(page_up){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
float page_jump = get_page_jump(&view);
move_vertical(app, -page_jump);
}
CUSTOM_COMMAND_SIG(page_down){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
float page_jump = get_page_jump(&view);
move_vertical(app, page_jump);
}
@@ -941,18 +941,18 @@ CUSTOM_COMMAND_SIG(page_down){
CUSTOM_COMMAND_SIG(move_left){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
int32_t new_pos = view.cursor.pos - 1;
- app->view_set_cursor(app, &view,
+ view_set_cursor(app, &view,
seek_pos(new_pos),
true);
}
CUSTOM_COMMAND_SIG(move_right){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
int32_t new_pos = view.cursor.pos + 1;
- app->view_set_cursor(app, &view,
+ view_set_cursor(app, &view,
seek_pos(new_pos),
true);
}
@@ -1048,7 +1048,7 @@ move_past_lead_whitespace(Application_Links *app, View_Summary *view, Buffer_Sum
break2:;
if (i > view->cursor.pos){
- app->view_set_cursor(app, view, seek_pos(i), true);
+ view_set_cursor(app, view, seek_pos(i), true);
}
}
}
@@ -1057,8 +1057,8 @@ move_past_lead_whitespace(Application_Links *app, View_Summary *view, Buffer_Sum
CUSTOM_COMMAND_SIG(auto_tab_line_at_cursor){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
buffer_auto_indent(app, &buffer,
view.cursor.pos, view.cursor.pos,
@@ -1069,8 +1069,8 @@ CUSTOM_COMMAND_SIG(auto_tab_line_at_cursor){
CUSTOM_COMMAND_SIG(auto_tab_whole_file){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
buffer_auto_indent(app, &buffer,
0, buffer.size,
@@ -1080,8 +1080,8 @@ CUSTOM_COMMAND_SIG(auto_tab_whole_file){
CUSTOM_COMMAND_SIG(auto_tab_range){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
Range range = get_range(&view);
buffer_auto_indent(app, &buffer,
@@ -1095,8 +1095,8 @@ CUSTOM_COMMAND_SIG(write_and_auto_tab){
exec_command(app, write_character);
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
buffer_auto_indent(app, &buffer,
view.cursor.pos, view.cursor.pos,
@@ -1108,9 +1108,9 @@ CUSTOM_COMMAND_SIG(write_and_auto_tab){
CUSTOM_COMMAND_SIG(clean_all_lines){
// TODO(allen): This command always iterates accross the entire
// buffer, so streaming it is actually the wrong call. Rewrite this
- // to minimize calls to app->buffer_read_range.
- View_Summary view = app->get_active_view(app, AccessOpen);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen);
+ // to minimize calls to buffer_read_range.
+ View_Summary view = get_active_view(app, AccessOpen);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
int32_t line_count = buffer.line_count;
int32_t edit_max = line_count;
@@ -1162,7 +1162,7 @@ CUSTOM_COMMAND_SIG(clean_all_lines){
}
int32_t edit_count = (int32_t)(edit - edits);
- app->buffer_batch_edit(app, &buffer, 0, 0, edits, edit_count, BatchEdit_PreserveTokens);
+ buffer_batch_edit(app, &buffer, 0, 0, edits, edit_count, BatchEdit_PreserveTokens);
}
}
}
@@ -1171,12 +1171,12 @@ CUSTOM_COMMAND_SIG(clean_all_lines){
// Clipboard
//
-static int32_t
+static bool32
clipboard_copy(Application_Links *app, int32_t start, int32_t end, Buffer_Summary *buffer_out,
uint32_t access){
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
- int32_t result = false;
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
+ bool32 result = 0;
if (buffer.exists){
if (0 <= start && start <= end && end <= buffer.size){
@@ -1184,10 +1184,10 @@ clipboard_copy(Application_Links *app, int32_t start, int32_t end, Buffer_Summar
char *str = (char*)app->memory;
if (size <= app->memory_size){
- app->buffer_read_range(app, &buffer, start, end, str);
- app->clipboard_post(app, 0, str, size);
+ buffer_read_range(app, &buffer, start, end, str);
+ clipboard_post(app, 0, str, size);
if (buffer_out){*buffer_out = buffer;}
- result = true;
+ result = 1;
}
}
}
@@ -1202,7 +1202,7 @@ clipboard_cut(Application_Links *app, int32_t start, int32_t end, Buffer_Summary
int32_t result = false;
if (clipboard_copy(app, start, end, &buffer, access)){
- app->buffer_replace_range(app, &buffer, start, end, 0, 0);
+ buffer_replace_range(app, &buffer, start, end, 0, 0);
if (buffer_out){*buffer_out = buffer;}
}
@@ -1211,14 +1211,14 @@ clipboard_cut(Application_Links *app, int32_t start, int32_t end, Buffer_Summary
CUSTOM_COMMAND_SIG(copy){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
Range range = get_range(&view);
clipboard_copy(app, range.min, range.max, 0, access);
}
CUSTOM_COMMAND_SIG(cut){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
Range range = get_range(&view);
clipboard_cut(app, range.min, range.max, 0, access);
}
@@ -1240,16 +1240,16 @@ View_Paste_Index *view_paste_index = view_paste_index_ - 1;
CUSTOM_COMMAND_SIG(paste){
uint32_t access = AccessOpen;
- int32_t count = app->clipboard_count(app, 0);
+ int32_t count = clipboard_count(app, 0);
if (count > 0){
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
view_paste_index[view.view_id].next_rewrite = RewritePaste;
int32_t paste_index = 0;
view_paste_index[view.view_id].index = paste_index;
- int32_t len = app->clipboard_index(app, 0, paste_index, 0, 0);
+ int32_t len = clipboard_index(app, 0, paste_index, 0, 0);
char *str = 0;
if (len <= app->memory_size){
@@ -1257,28 +1257,28 @@ CUSTOM_COMMAND_SIG(paste){
}
if (str){
- app->clipboard_index(app, 0, paste_index, str, len);
+ clipboard_index(app, 0, paste_index, str, len);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = view.cursor.pos;
- app->buffer_replace_range(app, &buffer, pos, pos, str, len);
- app->view_set_mark(app, &view, seek_pos(pos));
- app->view_set_cursor(app, &view, seek_pos(pos + len), true);
+ buffer_replace_range(app, &buffer, pos, pos, str, len);
+ view_set_mark(app, &view, seek_pos(pos));
+ view_set_cursor(app, &view, seek_pos(pos + len), true);
// TODO(allen): Send this to all views.
Theme_Color paste;
paste.tag = Stag_Paste;
- app->get_theme_colors(app, &paste, 1);
- app->view_post_fade(app, &view, 0.667f, pos, pos + len, paste.color);
+ get_theme_colors(app, &paste, 1);
+ view_post_fade(app, &view, 0.667f, pos, pos + len, paste.color);
}
}
}
CUSTOM_COMMAND_SIG(paste_next){
uint32_t access = AccessOpen;
- int32_t count = app->clipboard_count(app, 0);
+ int32_t count = clipboard_count(app, 0);
if (count > 0){
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
if (view_paste_index[view.view_id].rewrite == RewritePaste){
view_paste_index[view.view_id].next_rewrite = RewritePaste;
@@ -1286,7 +1286,7 @@ CUSTOM_COMMAND_SIG(paste_next){
int32_t paste_index = view_paste_index[view.view_id].index + 1;
view_paste_index[view.view_id].index = paste_index;
- int32_t len = app->clipboard_index(app, 0, paste_index, 0, 0);
+ int32_t len = clipboard_index(app, 0, paste_index, 0, 0);
char *str = 0;
if (len <= app->memory_size){
@@ -1294,20 +1294,20 @@ CUSTOM_COMMAND_SIG(paste_next){
}
if (str){
- app->clipboard_index(app, 0, paste_index, str, len);
+ clipboard_index(app, 0, paste_index, str, len);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
Range range = get_range(&view);
int32_t pos = range.min;
- app->buffer_replace_range(app, &buffer, range.min, range.max, str, len);
- app->view_set_cursor(app, &view, seek_pos(pos + len), true);
+ buffer_replace_range(app, &buffer, range.min, range.max, str, len);
+ view_set_cursor(app, &view, seek_pos(pos + len), true);
// TODO(allen): Send this to all views.
Theme_Color paste;
paste.tag = Stag_Paste;
- app->get_theme_colors(app, &paste, 1);
- app->view_post_fade(app, &view, 0.667f, pos, pos + len, paste.color);
+ get_theme_colors(app, &paste, 1);
+ view_post_fade(app, &view, 0.667f, pos, pos + len, paste.color);
}
}
else{
@@ -1331,38 +1331,38 @@ CUSTOM_COMMAND_SIG(paste_next_and_indent){
//
CUSTOM_COMMAND_SIG(to_uppercase){
- View_Summary view = app->get_active_view(app, AccessOpen);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen);
+ View_Summary view = get_active_view(app, AccessOpen);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
Range range = get_range(&view);
int32_t size = range.max - range.min;
if (size <= app->memory_size){
char *mem = (char*)app->memory;
- app->buffer_read_range(app, &buffer, range.min, range.max, mem);
+ buffer_read_range(app, &buffer, range.min, range.max, mem);
for (int32_t i = 0; i < size; ++i){
mem[i] = char_to_upper(mem[i]);
}
- app->buffer_replace_range(app, &buffer, range.min, range.max, mem, size);
- app->view_set_cursor(app, &view, seek_pos(range.max), true);
+ buffer_replace_range(app, &buffer, range.min, range.max, mem, size);
+ view_set_cursor(app, &view, seek_pos(range.max), true);
}
}
CUSTOM_COMMAND_SIG(to_lowercase){
- View_Summary view = app->get_active_view(app, AccessOpen);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen);
+ View_Summary view = get_active_view(app, AccessOpen);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
Range range = get_range(&view);
int32_t size = range.max - range.min;
if (size <= app->memory_size){
char *mem = (char*)app->memory;
- app->buffer_read_range(app, &buffer, range.min, range.max, mem);
+ buffer_read_range(app, &buffer, range.min, range.max, mem);
for (int32_t i = 0; i < size; ++i){
mem[i] = char_to_lower(mem[i]);
}
- app->buffer_replace_range(app, &buffer, range.min, range.max, mem, size);
- app->view_set_cursor(app, &view, seek_pos(range.max), true);
+ buffer_replace_range(app, &buffer, range.min, range.max, mem, size);
+ view_set_cursor(app, &view, seek_pos(range.max), true);
}
}
@@ -1495,42 +1495,42 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int3
CUSTOM_COMMAND_SIG(seek_whitespace_up){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = buffer_seek_whitespace_up(app, &buffer, view.cursor.pos);
- app->view_set_cursor(app, &view,
+ view_set_cursor(app, &view,
seek_pos(new_pos),
true);
}
CUSTOM_COMMAND_SIG(seek_whitespace_down){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = buffer_seek_whitespace_down(app, &buffer, view.cursor.pos);
- app->view_set_cursor(app, &view,
+ view_set_cursor(app, &view,
seek_pos(new_pos),
true);
}
CUSTOM_COMMAND_SIG(seek_end_of_line){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = seek_line_end(app, &buffer, view.cursor.pos);
- app->view_set_cursor(app, &view, seek_pos(new_pos), true);
+ view_set_cursor(app, &view, seek_pos(new_pos), true);
}
CUSTOM_COMMAND_SIG(seek_beginning_of_line){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = seek_line_beginning(app, &buffer, view.cursor.pos);
- app->view_set_cursor(app, &view, seek_pos(new_pos), true);
+ view_set_cursor(app, &view, seek_pos(new_pos), true);
}
// TODO(allen): REDUCE DUPLICATION!
@@ -1801,10 +1801,10 @@ buffer_get_all_tokens(Application_Links *app, Partition *part, Buffer_Summary *b
Cpp_Token_Array array = {0};
if (buffer->exists && buffer->is_lexed){
- array.count = app->buffer_token_count(app, buffer);
+ array.count = buffer_token_count(app, buffer);
array.max_count = array.count;
array.tokens = push_array(part, Cpp_Token, array.count);
- app->buffer_read_tokens(app, buffer, 0, array.count, array.tokens);
+ buffer_read_tokens(app, buffer, 0, array.count, array.tokens);
}
return(array);
@@ -1934,10 +1934,10 @@ buffer_boundary_seek(Application_Links *app, Buffer_Summary *buffer,
static void
basic_seek(Application_Links *app, int32_t seek_type, uint32_t flags){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_type, flags);
- app->view_set_cursor(app, &view, seek_pos(pos), true);
+ view_set_cursor(app, &view, seek_pos(pos), true);
}
#define seek_command(n, dir, flags)\
@@ -1968,12 +1968,12 @@ seek_command(alphanumeric_or_camel, left, BoundaryAlphanumeric | BoundaryCamelC
static void
write_string(Application_Links *app, String string){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
- app->buffer_replace_range(app, &buffer,
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
+ buffer_replace_range(app, &buffer,
view.cursor.pos, view.cursor.pos,
string.str, string.size);
- app->view_set_cursor(app, &view, seek_pos(view.cursor.pos + string.size), true);
+ view_set_cursor(app, &view, seek_pos(view.cursor.pos + string.size), true);
}
CUSTOM_COMMAND_SIG(write_increment){
@@ -1983,12 +1983,12 @@ CUSTOM_COMMAND_SIG(write_increment){
static void
long_braces(Application_Links *app, char *text, int32_t size){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = view.cursor.pos;
- app->buffer_replace_range(app, &buffer, pos, pos, text, size);
- app->view_set_cursor(app, &view, seek_pos(pos + 2), true);
+ buffer_replace_range(app, &buffer, pos, pos, text, size);
+ view_set_cursor(app, &view, seek_pos(pos + 2), true);
buffer_auto_indent(app, &buffer,
pos, pos + size,
@@ -2024,8 +2024,8 @@ CUSTOM_COMMAND_SIG(if0_off){
char text2[] = "#endif\n";
int32_t size2 = sizeof(text2) - 1;
- View_Summary view = app->get_active_view(app, AccessOpen);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen);
+ View_Summary view = get_active_view(app, AccessOpen);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
Range range = get_range(&view);
@@ -2048,18 +2048,18 @@ CUSTOM_COMMAND_SIG(if0_off){
edits[1].start = range.max;
edits[1].end = range.max;
- app->buffer_batch_edit(app,&buffer,
+ buffer_batch_edit(app,&buffer,
base, global_part.pos,
edits, ArrayCount(edits), BatchEdit_Normal);
- view = app->get_view(app, view.view_id, AccessAll);
+ view = get_view(app, view.view_id, AccessAll);
if (view.cursor.pos > view.mark.pos){
- app->view_set_cursor(app, &view,
+ view_set_cursor(app, &view,
seek_line_char(view.cursor.line+1, view.cursor.character),
true);
}
else{
- app->view_set_mark(app, &view,
+ view_set_mark(app, &view,
seek_line_char(view.mark.line+1, view.mark.character));
}
@@ -2080,8 +2080,8 @@ CUSTOM_COMMAND_SIG(if0_off){
CUSTOM_COMMAND_SIG(backspace_word){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
if (buffer.exists){
int32_t pos2 = 0, pos1 = 0;
@@ -2091,15 +2091,15 @@ CUSTOM_COMMAND_SIG(backspace_word){
refresh_view(app, &view);
pos1 = view.cursor.pos;
- app->buffer_replace_range(app, &buffer, pos1, pos2, 0, 0);
+ buffer_replace_range(app, &buffer, pos1, pos2, 0, 0);
}
}
CUSTOM_COMMAND_SIG(delete_word){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
if (buffer.exists){
int32_t pos2 = 0, pos1 = 0;
@@ -2109,7 +2109,7 @@ CUSTOM_COMMAND_SIG(delete_word){
refresh_view(app, &view);
pos2 = view.cursor.pos;
- app->buffer_replace_range(app, &buffer, pos1, pos2, 0, 0);
+ buffer_replace_range(app, &buffer, pos1, pos2, 0, 0);
}
}
@@ -2120,14 +2120,14 @@ CUSTOM_COMMAND_SIG(snipe_token_or_word){
Buffer_Summary buffer;
int32_t pos1, pos2;
- view = app->get_active_view(app, access);
- buffer = app->get_buffer(app, view.buffer_id, access);
+ view = get_active_view(app, access);
+ buffer = get_buffer(app, view.buffer_id, access);
pos1 = buffer_boundary_seek(app, &buffer, view.cursor.pos, false, BoundaryToken | BoundaryWhitespace);
pos2 = buffer_boundary_seek(app, &buffer, pos1, true, BoundaryToken | BoundaryWhitespace);
Range range = make_range(pos1, pos2);
- app->buffer_replace_range(app, &buffer, range.start, range.end, 0, 0);
+ buffer_replace_range(app, &buffer, range.start, range.end, 0, 0);
}
//
@@ -2135,13 +2135,13 @@ CUSTOM_COMMAND_SIG(snipe_token_or_word){
//
CUSTOM_COMMAND_SIG(show_scrollbar){
- View_Summary view = app->get_active_view(app, AccessProtected);
- app->view_set_setting(app, &view, ViewSetting_ShowScrollbar, true);
+ View_Summary view = get_active_view(app, AccessProtected);
+ view_set_setting(app, &view, ViewSetting_ShowScrollbar, true);
}
CUSTOM_COMMAND_SIG(hide_scrollbar){
- View_Summary view = app->get_active_view(app, AccessProtected);
- app->view_set_setting(app, &view, ViewSetting_ShowScrollbar, false);
+ View_Summary view = get_active_view(app, AccessProtected);
+ view_set_setting(app, &view, ViewSetting_ShowScrollbar, false);
}
//
@@ -2150,9 +2150,9 @@ CUSTOM_COMMAND_SIG(hide_scrollbar){
static void
get_view_next_looped(Application_Links *app, View_Summary *view, uint32_t access){
- app->get_view_next(app, view, access);
+ get_view_next(app, view, access);
if (!view->exists){
- *view = app->get_view_first(app, access);
+ *view = get_view_first(app, access);
}
}
@@ -2160,23 +2160,23 @@ static View_ID special_note_view_id = 0;
static void
close_special_note_view(Application_Links *app){
- View_Summary special_view = app->get_view(app, special_note_view_id, AccessAll);
+ View_Summary special_view = get_view(app, special_note_view_id, AccessAll);
if (special_view.exists){
- app->close_view(app, &special_view);
+ close_view(app, &special_view);
}
special_note_view_id = 0;
}
static View_Summary
open_special_note_view(Application_Links *app, bool32 create_if_not_exist = true){
- View_Summary special_view = app->get_view(app, special_note_view_id, AccessAll);
+ View_Summary special_view = get_view(app, special_note_view_id, AccessAll);
if (create_if_not_exist && !special_view.exists){
- View_Summary view = app->get_active_view(app, AccessAll);
- special_view = app->open_view(app, &view, ViewSplit_Bottom);
- app->view_set_setting(app, &special_view, ViewSetting_ShowScrollbar, false);
- app->view_set_split_proportion(app, &special_view, .2f);
- app->set_active_view(app, &view);
+ View_Summary view = get_active_view(app, AccessAll);
+ special_view = open_view(app, &view, ViewSplit_Bottom);
+ view_set_setting(app, &special_view, ViewSetting_ShowScrollbar, false);
+ view_set_split_proportion(app, &special_view, .2f);
+ set_active_view(app, &view);
special_note_view_id = special_view.view_id;
}
@@ -2184,7 +2184,7 @@ open_special_note_view(Application_Links *app, bool32 create_if_not_exist = true
}
CUSTOM_COMMAND_SIG(change_active_panel){
- View_Summary view = app->get_active_view(app, AccessAll);
+ View_Summary view = get_active_view(app, AccessAll);
View_ID original_view_id = view.view_id;
do{
@@ -2195,25 +2195,25 @@ CUSTOM_COMMAND_SIG(change_active_panel){
}while(view.view_id != original_view_id);
if (view.exists){
- app->set_active_view(app, &view);
+ set_active_view(app, &view);
}
}
CUSTOM_COMMAND_SIG(close_panel){
- View_Summary view = app->get_active_view(app, AccessAll);
- app->close_view(app, &view);
+ View_Summary view = get_active_view(app, AccessAll);
+ close_view(app, &view);
}
CUSTOM_COMMAND_SIG(open_panel_vsplit){
- View_Summary view = app->get_active_view(app, AccessAll);
- View_Summary new_view = app->open_view(app, &view, ViewSplit_Right);
- app->view_set_setting(app, &new_view, ViewSetting_ShowScrollbar, false);
+ View_Summary view = get_active_view(app, AccessAll);
+ View_Summary new_view = open_view(app, &view, ViewSplit_Right);
+ view_set_setting(app, &new_view, ViewSetting_ShowScrollbar, false);
}
CUSTOM_COMMAND_SIG(open_panel_hsplit){
- View_Summary view = app->get_active_view(app, AccessAll);
- View_Summary new_view = app->open_view(app, &view, ViewSplit_Bottom);
- app->view_set_setting(app, &new_view, ViewSetting_ShowScrollbar, false);
+ View_Summary view = get_active_view(app, AccessAll);
+ View_Summary new_view = open_view(app, &view, ViewSplit_Bottom);
+ view_set_setting(app, &new_view, ViewSetting_ShowScrollbar, false);
}
//
@@ -2230,8 +2230,8 @@ file_name_in_quotes(Application_Links *app, String *file_name){
char short_file_name[128];
int32_t pos, start, end, size;
- view = app->get_active_view(app, access);
- buffer = app->get_buffer(app, view.buffer_id, access);
+ view = get_active_view(app, access);
+ buffer = get_buffer(app, view.buffer_id, access);
pos = view.cursor.pos;
buffer_seek_delimiter_forward(app, &buffer, pos, '"', &end);
buffer_seek_delimiter_backward(app, &buffer, pos, '"', &start);
@@ -2239,10 +2239,10 @@ file_name_in_quotes(Application_Links *app, String *file_name){
++start;
size = end - start;
- // NOTE(allen): This check is necessary because app->buffer_read_range
+ // NOTE(allen): This check is necessary because buffer_read_range
// requiers that the output buffer you provide is at least (end - start) bytes long.
if (size < sizeof(short_file_name)){
- if (app->buffer_read_range(app, &buffer, start, end, short_file_name)){
+ if (buffer_read_range(app, &buffer, start, end, short_file_name)){
result = true;
copy_ss(file_name, make_string(buffer.file_name, buffer.file_name_len));
remove_last_folder(file_name);
@@ -2259,7 +2259,7 @@ CUSTOM_COMMAND_SIG(open_file_in_quotes){
if (file_name_in_quotes(app, &file_name)){
exec_command(app, change_active_panel);
- View_Summary view = app->get_active_view(app, AccessAll);
+ View_Summary view = get_active_view(app, AccessAll);
view_open_file(app, &view, expand_str(file_name), true);
}
}
@@ -2296,13 +2296,13 @@ static void
isearch(Application_Links *app, int32_t start_reversed){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
if (!buffer.exists) return;
Query_Bar bar = {0};
- if (app->start_query_bar(app, &bar, 0) == 0) return;
+ if (start_query_bar(app, &bar, 0) == 0) return;
int32_t reverse = start_reversed;
int32_t pos = view.cursor.pos;
@@ -2318,13 +2318,13 @@ isearch(Application_Links *app, int32_t start_reversed){
User_Input in = {0};
for (;;){
- app->view_set_highlight(app, &view, match.start, match.end, true);
+ view_set_highlight(app, &view, match.start, match.end, true);
// NOTE(allen): Change the bar's prompt to match the current direction.
if (reverse) bar.prompt = rsearch_str;
else bar.prompt = isearch_str;
- in = app->get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
+ in = get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
if (in.abort) break;
// NOTE(allen): If we're getting mouse events here it's a 4coder bug, because we
@@ -2408,13 +2408,13 @@ isearch(Application_Links *app, int32_t start_reversed){
}
}
}
- app->view_set_highlight(app, &view, 0, 0, false);
+ view_set_highlight(app, &view, 0, 0, false);
if (in.abort){
- app->view_set_cursor(app, &view, seek_pos(first_pos), true);
+ view_set_cursor(app, &view, seek_pos(first_pos), true);
return;
}
- app->view_set_cursor(app, &view, seek_pos(match.min), true);
+ view_set_cursor(app, &view, seek_pos(match.min), true);
}
CUSTOM_COMMAND_SIG(search){
@@ -2444,8 +2444,8 @@ CUSTOM_COMMAND_SIG(replace_in_range){
String r = replace.string, w = with.string;
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
Range range = get_range(&view);
@@ -2455,7 +2455,7 @@ CUSTOM_COMMAND_SIG(replace_in_range){
buffer_seek_string_forward(app, &buffer, pos, 0, r.str, r.size, &new_pos);
while (new_pos + r.size <= range.end){
- app->buffer_replace_range(app, &buffer, new_pos, new_pos + r.size, w.str, w.size);
+ buffer_replace_range(app, &buffer, new_pos, new_pos + r.size, w.str, w.size);
refresh_view(app, &view);
range = get_range(&view);
pos = new_pos + w.size;
@@ -2491,11 +2491,11 @@ CUSTOM_COMMAND_SIG(query_replace){
bar.prompt = make_lit_string("Replace? (y)es, (n)ext, (esc)\n");
bar.string = null_string;
- app->start_query_bar(app, &bar, 0);
+ start_query_bar(app, &bar, 0);
uint32_t access = AccessOpen;
- view = app->get_active_view(app, access);
- buffer = app->get_buffer(app, view.buffer_id, access);
+ view = get_active_view(app, access);
+ buffer = get_buffer(app, view.buffer_id, access);
pos = view.cursor.pos;
buffer_seek_string_forward(app, &buffer, pos, 0, r.str, r.size, &new_pos);
@@ -2503,16 +2503,16 @@ CUSTOM_COMMAND_SIG(query_replace){
User_Input in = {0};
while (new_pos < buffer.size){
Range match = make_range(new_pos, new_pos + r.size);
- app->view_set_highlight(app, &view, match.min, match.max, 1);
+ view_set_highlight(app, &view, match.min, match.max, 1);
- in = app->get_user_input(app, EventOnAnyKey, EventOnButton);
+ in = get_user_input(app, EventOnAnyKey, EventOnButton);
if (in.abort || in.key.keycode == key_esc || !key_is_unmodified(&in.key)) break;
if (in.key.character == 'y' ||
in.key.character == 'Y' ||
in.key.character == '\n' ||
in.key.character == '\t'){
- app->buffer_replace_range(app, &buffer, match.min, match.max, w.str, w.size);
+ buffer_replace_range(app, &buffer, match.min, match.max, w.str, w.size);
pos = match.start + w.size;
}
else{
@@ -2522,10 +2522,10 @@ CUSTOM_COMMAND_SIG(query_replace){
buffer_seek_string_forward(app, &buffer, pos, 0, r.str, r.size, &new_pos);
}
- app->view_set_highlight(app, &view, 0, 0, 0);
+ view_set_highlight(app, &view, 0, 0, 0);
if (in.abort) return;
- app->view_set_cursor(app, &view, seek_pos(pos), 1);
+ view_set_cursor(app, &view, seek_pos(pos), 1);
}
//
@@ -2542,9 +2542,9 @@ CUSTOM_COMMAND_SIG(close_all_code){
int32_t buffers_to_close_count = 0;
uint32_t access = AccessAll;
- for (buffer = app->get_buffer_first(app, access);
+ for (buffer = get_buffer_first(app, access);
buffer.exists;
- app->get_buffer_next(app, &buffer, access)){
+ get_buffer_next(app, &buffer, access)){
extension = file_extension(make_string(buffer.file_name, buffer.file_name_len));
if (match_ss(extension, make_lit_string("cpp")) ||
@@ -2558,7 +2558,7 @@ CUSTOM_COMMAND_SIG(close_all_code){
}
for (int32_t i = 0; i < buffers_to_close_count; ++i){
- app->kill_buffer(app, buffer_identifier(buffers_to_close[i]), true, 0);
+ kill_buffer(app, buffer_identifier(buffers_to_close[i]), true, 0);
}
}
@@ -2569,12 +2569,12 @@ CUSTOM_COMMAND_SIG(open_all_code){
// push_directory isn't a very good option since it's tied to the parameter
// stack, so I am phasing that idea out now.
String dir = make_string_cap(app->memory, 0, app->memory_size);
- dir.size = app->directory_get_hot(app, dir.str, dir.memory_size);
+ dir.size = directory_get_hot(app, dir.str, dir.memory_size);
int32_t dir_size = dir.size;
// NOTE(allen|a3.4.4): Here we get the list of files in this directory.
// Notice that we free_file_list at the end.
- File_List list = app->get_file_list(app, dir.str, dir.size);
+ File_List list = get_file_list(app, dir.str, dir.size);
for (int32_t i = 0; i < list.count; ++i){
File_Info *info = list.infos + i;
@@ -2592,12 +2592,12 @@ CUSTOM_COMMAND_SIG(open_all_code){
// was originally, so that new appends overwrite old ones.
dir.size = dir_size;
append_sc(&dir, info->filename);
- app->create_buffer(app, dir.str, dir.size, 0);
+ create_buffer(app, dir.str, dir.size, 0);
}
}
}
- app->free_file_list(app, list);
+ free_file_list(app, list);
}
char out_buffer_space[1024];
@@ -2617,12 +2617,12 @@ CUSTOM_COMMAND_SIG(execute_any_cli){
if (!query_user_string(app, &bar_cmd)) return;
String hot_directory = make_fixed_width_string(hot_directory_space);
- hot_directory.size = app->directory_get_hot(app, hot_directory.str, hot_directory.memory_size);
+ hot_directory.size = directory_get_hot(app, hot_directory.str, hot_directory.memory_size);
uint32_t access = AccessAll;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
- app->exec_system_command(app, &view,
+ exec_system_command(app, &view,
buffer_identifier(bar_out.string.str, bar_out.string.size),
hot_directory.str, hot_directory.size,
bar_cmd.string.str, bar_cmd.string.size,
@@ -2636,9 +2636,9 @@ CUSTOM_COMMAND_SIG(execute_previous_cli){
if (out_buffer.size > 0 && cmd.size > 0 && hot_directory.size > 0){
uint32_t access = AccessAll;
- View_Summary view = app->get_active_view(app, access);
+ View_Summary view = get_active_view(app, access);
- app->exec_system_command(app, &view,
+ exec_system_command(app, &view,
buffer_identifier(out_buffer.str, out_buffer.size),
hot_directory.str, hot_directory.size,
cmd.str, cmd.size,
@@ -2650,39 +2650,37 @@ CUSTOM_COMMAND_SIG(execute_previous_cli){
// Common Settings Commands
//
-CUSTOM_COMMAND_SIG(toggle_fullscreen){
- app->toggle_fullscreen(app);
-}
+//toggle_fullscreen can be used as a command
CUSTOM_COMMAND_SIG(toggle_line_wrap){
- View_Summary view = app->get_active_view(app, AccessProtected);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessProtected);
+ View_Summary view = get_active_view(app, AccessProtected);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
bool32 unwrapped = view.unwrapped_lines;
- app->view_set_setting(app, &view, ViewSetting_WrapLine, unwrapped);
- app->buffer_set_setting(app, &buffer, BufferSetting_WrapLine, unwrapped);
+ view_set_setting(app, &view, ViewSetting_WrapLine, unwrapped);
+ buffer_set_setting(app, &buffer, BufferSetting_WrapLine, unwrapped);
}
CUSTOM_COMMAND_SIG(toggle_show_whitespace){
- View_Summary view = app->get_active_view(app, AccessProtected);
- app->view_set_setting(app, &view, ViewSetting_ShowWhitespace, !view.show_whitespace);
+ View_Summary view = get_active_view(app, AccessProtected);
+ view_set_setting(app, &view, ViewSetting_ShowWhitespace, !view.show_whitespace);
}
CUSTOM_COMMAND_SIG(eol_dosify){
- View_Summary view = app->get_active_view(app, AccessOpen);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen);
- app->buffer_set_setting(app, &buffer, BufferSetting_Eol, true);
+ View_Summary view = get_active_view(app, AccessOpen);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
+ buffer_set_setting(app, &buffer, BufferSetting_Eol, true);
}
CUSTOM_COMMAND_SIG(eol_nixify){
- View_Summary view = app->get_active_view(app, AccessOpen);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen);
- app->buffer_set_setting(app, &buffer, BufferSetting_Eol, false);
+ View_Summary view = get_active_view(app, AccessOpen);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
+ buffer_set_setting(app, &buffer, BufferSetting_Eol, false);
}
CUSTOM_COMMAND_SIG(exit_4coder){
- app->send_exit_signal(app);
+ send_exit_signal(app);
}
@@ -2712,28 +2710,28 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
search_iter_init(general, &iter, string.string.size);
copy_ss(&iter.word, string.string);
- int32_t buffer_count = app->get_buffer_count(app);
+ int32_t buffer_count = get_buffer_count(app);
search_set_init(general, &set, buffer_count);
Search_Range *ranges = set.ranges;
String search_name = make_lit_string("*search*");
- Buffer_Summary search_buffer = app->get_buffer_by_name(app, search_name.str, search_name.size,
+ Buffer_Summary search_buffer = get_buffer_by_name(app, search_name.str, search_name.size,
AccessAll);
if (!search_buffer.exists){
- search_buffer = app->create_buffer(app, search_name.str, search_name.size, BufferCreate_AlwaysNew);
- app->buffer_set_setting(app, &search_buffer, BufferSetting_Unimportant, true);
- app->buffer_set_setting(app, &search_buffer, BufferSetting_ReadOnly, true);
- app->buffer_set_setting(app, &search_buffer, BufferSetting_WrapLine, false);
+ search_buffer = create_buffer(app, search_name.str, search_name.size, BufferCreate_AlwaysNew);
+ buffer_set_setting(app, &search_buffer, BufferSetting_Unimportant, true);
+ buffer_set_setting(app, &search_buffer, BufferSetting_ReadOnly, true);
+ buffer_set_setting(app, &search_buffer, BufferSetting_WrapLine, false);
}
else{
- app->buffer_replace_range(app, &search_buffer, 0, search_buffer.size, 0, 0);
+ buffer_replace_range(app, &search_buffer, 0, search_buffer.size, 0, 0);
}
{
- View_Summary view = app->get_active_view(app, AccessProtected);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessProtected);
+ View_Summary view = get_active_view(app, AccessProtected);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
int32_t j = 0;
if (buffer.exists){
@@ -2747,9 +2745,9 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
}
}
- for (Buffer_Summary buffer_it = app->get_buffer_first(app, AccessAll);
+ for (Buffer_Summary buffer_it = get_buffer_first(app, AccessAll);
buffer_it.exists;
- app->get_buffer_next(app, &buffer_it, AccessAll)){
+ get_buffer_next(app, &buffer_it, AccessAll)){
if (buffer.buffer_id != buffer_it.buffer_id){
if (search_buffer.buffer_id != buffer_it.buffer_id){
ranges[j].type = SearchRange_FrontToBack;
@@ -2773,7 +2771,7 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
Search_Match match = search_next_match(app, &set, &iter);
if (match.found_match){
Partial_Cursor word_pos = {0};
- if (app->buffer_compute_cursor(app, &match.buffer, seek_pos(match.start), &word_pos)){
+ if (buffer_compute_cursor(app, &match.buffer, seek_pos(match.start), &word_pos)){
int32_t file_len = match.buffer.file_name_len;
int32_t line_num_len = int_to_str_size(word_pos.line);
int32_t column_num_len = int_to_str_size(word_pos.character);
@@ -2788,7 +2786,7 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
char *spare = push_array(part, char, str_len);
if (spare == 0){
- app->buffer_replace_range(app, &search_buffer,
+ buffer_replace_range(app, &search_buffer,
size, size, str, part_size);
size += part_size;
@@ -2820,10 +2818,10 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
}
}
- app->buffer_replace_range(app, &search_buffer, size, size, str, part_size);
+ buffer_replace_range(app, &search_buffer, size, size, str, part_size);
- View_Summary view = app->get_active_view(app, AccessAll);
- app->view_set_buffer(app, &view, search_buffer.buffer_id, 0);
+ View_Summary view = get_active_view(app, AccessAll);
+ view_set_buffer(app, &view, search_buffer.buffer_id, 0);
lock_jump_buffer(search_name.str, search_name.size);
@@ -2859,8 +2857,8 @@ struct Word_Complete_State{
static Word_Complete_State complete_state = {0};
CUSTOM_COMMAND_SIG(word_complete){
- View_Summary view = app->get_active_view(app, AccessOpen);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen);
+ View_Summary view = get_active_view(app, AccessOpen);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
// NOTE(allen): I just do this because this command is a lot of work
// and there is no point in doing any of it if nothing will happen anyway.
@@ -2918,12 +2916,12 @@ CUSTOM_COMMAND_SIG(word_complete){
// with the partial word.
complete_state.initialized = true;
search_iter_init(&global_general, &complete_state.iter, size);
- app->buffer_read_range(app, &buffer, word_start, word_end,
+ buffer_read_range(app, &buffer, word_start, word_end,
complete_state.iter.word.str);
complete_state.iter.word.size = size;
// NOTE(allen): Initialize the set of ranges to be searched.
- int32_t buffer_count = app->get_buffer_count(app);
+ int32_t buffer_count = get_buffer_count(app);
search_set_init(&global_general, &complete_state.set, buffer_count);
Search_Range *ranges = complete_state.set.ranges;
@@ -2936,9 +2934,9 @@ CUSTOM_COMMAND_SIG(word_complete){
ranges[0].mid_size = size;
int32_t j = 1;
- for (Buffer_Summary buffer_it = app->get_buffer_first(app, AccessAll);
+ for (Buffer_Summary buffer_it = get_buffer_first(app, AccessAll);
buffer_it.exists;
- app->get_buffer_next(app, &buffer_it, AccessAll)){
+ get_buffer_next(app, &buffer_it, AccessAll)){
if (buffer.buffer_id != buffer_it.buffer_id){
ranges[j].type = SearchRange_FrontToBack;
ranges[j].flags = SearchFlag_MatchWordPrefix;
@@ -2979,14 +2977,14 @@ CUSTOM_COMMAND_SIG(word_complete){
Temp_Memory temp = begin_temp_memory(&global_part);
char *spare = push_array(&global_part, char, match_size);
- app->buffer_read_range(app, &match.buffer,
+ buffer_read_range(app, &match.buffer,
match.start, match.end, spare);
if (search_hit_add(&global_general, &complete_state.hits, &complete_state.str,
spare, match_size)){
- app->buffer_replace_range(app, &buffer, word_start, word_end,
+ buffer_replace_range(app, &buffer, word_start, word_end,
spare, match_size);
- app->view_set_cursor(app, &view,
+ view_set_cursor(app, &view,
seek_pos(word_start + match_size),
true);
@@ -3009,9 +3007,9 @@ CUSTOM_COMMAND_SIG(word_complete){
match_size = complete_state.iter.word.size;
char *str = complete_state.iter.word.str;
- app->buffer_replace_range(app, &buffer, word_start, word_end,
+ buffer_replace_range(app, &buffer, word_start, word_end,
str, match_size);
- app->view_set_cursor(app, &view,
+ view_set_cursor(app, &view,
seek_pos(word_start + match_size),
true);
@@ -3058,7 +3056,7 @@ get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_
}
if (!result){
- int32_t len = app->directory_get_hot(app, dir_out->str,
+ int32_t len = directory_get_hot(app, dir_out->str,
dir_out->memory_size - dir_out->size);
if (len + dir_out->size < dir_out->memory_size){
dir_out->size += len;
@@ -3085,7 +3083,7 @@ standard_build_search(Application_Links *app,
int32_t old_size = dir->size;
append_ss(dir, filename);
- if (app->file_exists(app, dir->str, dir->size)){
+ if (file_exists(app, dir->str, dir->size)){
dir->size = old_size;
if (use_path_in_command){
@@ -3103,10 +3101,10 @@ standard_build_search(Application_Links *app,
append_ss(&message, make_lit_string("Building with: "));
append_ss(&message, *command);
append_s_char(&message, '\n');
- app->print_message(app, message.str, message.size);
+ print_message(app, message.str, message.size);
- app->exec_system_command(app, view,
+ exec_system_command(app, view,
buffer_identifier(literal("*compilation*")),
dir->str, dir->size,
command->str, command->size,
@@ -3116,14 +3114,14 @@ standard_build_search(Application_Links *app,
}
dir->size = old_size;
- if (app->directory_cd(app, dir->str, &dir->size, dir->memory_size, literal("..")) == 0){
+ if (directory_cd(app, dir->str, &dir->size, dir->memory_size, literal("..")) == 0){
if (perform_backup){
- dir->size = app->directory_get_hot(app, dir->str, dir->memory_size);
+ dir->size = directory_get_hot(app, dir->str, dir->memory_size);
char backup_space[256];
String backup_command = make_fixed_width_string(backup_space);
append_ss(&backup_command, make_lit_string("echo could not find "));
append_ss(&backup_command, filename);
- app->exec_system_command(app, view,
+ exec_system_command(app, view,
buffer_identifier(literal("*compilation*")),
dir->str, dir->size,
backup_command.str, backup_command.size,
@@ -3215,14 +3213,14 @@ execute_standard_build(Application_Links *app, View_Summary *view,
CUSTOM_COMMAND_SIG(build_search){
uint32_t access = AccessAll;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
execute_standard_build(app, &view, &buffer);
prev_location = null_location;
lock_jump_buffer(literal("*compilation*"));
}
-#define GET_COMP_BUFFER(app) app->get_buffer_by_name(app, literal("*compilation*"), AccessAll)
+#define GET_COMP_BUFFER(app) get_buffer_by_name(app, literal("*compilation*"), AccessAll)
static View_Summary
get_or_open_build_panel(Application_Links *app){
@@ -3241,14 +3239,14 @@ get_or_open_build_panel(Application_Links *app){
static void
set_fancy_compilation_buffer_font(Application_Links *app){
- Buffer_Summary comp_buffer = app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
- app->buffer_set_font(app, &comp_buffer, literal("Inconsolata"));
+ Buffer_Summary comp_buffer = get_buffer_by_name(app, literal("*compilation*"), AccessAll);
+ buffer_set_font(app, &comp_buffer, literal("Inconsolata"));
}
CUSTOM_COMMAND_SIG(build_in_build_panel){
uint32_t access = AccessAll;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
View_Summary build_view = get_or_open_build_panel(app);
@@ -3270,12 +3268,12 @@ CUSTOM_COMMAND_SIG(change_to_build_panel){
Buffer_Summary buffer = GET_COMP_BUFFER(app);
if (buffer.exists){
view = open_special_note_view(app);
- app->view_set_buffer(app, &view, buffer.buffer_id, 0);
+ view_set_buffer(app, &view, buffer.buffer_id, 0);
}
}
if (view.exists){
- app->set_active_view(app, &view);
+ set_active_view(app, &view);
}
}
@@ -3299,7 +3297,7 @@ CUSTOM_COMMAND_SIG(execute_arbitrary_command){
// command it might ALSO have query bars and I don't want this one hanging
// around at that point. Since the bar exists on my stack the result of the query
// is still available in bar.string though.
- app->end_query_bar(app, &bar, 0);
+ end_query_bar(app, &bar, 0);
if (match_ss(bar.string, make_lit_string("open all code"))){
exec_command(app, open_all_code);
@@ -3317,7 +3315,7 @@ CUSTOM_COMMAND_SIG(execute_arbitrary_command){
exec_command(app, eol_nixify);
}
else{
- app->print_message(app, literal("unrecognized command\n"));
+ print_message(app, literal("unrecognized command\n"));
}
}
@@ -3415,7 +3413,7 @@ SCROLL_RULE_SIG(smooth_scroll_rule){
// NOTE(allen|a4.0.10): As of this version the word_complete command
// also relies on this particular command caller hook.
COMMAND_CALLER_HOOK(default_command_caller){
- View_Summary view = app->get_active_view(app, AccessAll);
+ View_Summary view = get_active_view(app, AccessAll);
view_paste_index[view.view_id].next_rewrite = false;
diff --git a/4coder_helper.h b/4coder_helper.h
index e5c66b7e..7e97036f 100644
--- a/4coder_helper.h
+++ b/4coder_helper.h
@@ -246,11 +246,6 @@ get_rect(View_Summary *view){
return(rect);
}
-inline void
-exec_command(Application_Links *app, Command_ID id){
- app->exec_command(app, id);
-}
-
inline void
exec_command(Application_Links *app, Custom_Command_Function *func){
func(app);
@@ -269,12 +264,12 @@ exec_command(Application_Links *app, Generic_Command cmd){
inline void
active_view_to_line(Application_Links *app, uint32_t access, int32_t line_number){
View_Summary view;
- view = app->get_active_view(app, access);
+ view = get_active_view(app, access);
// NOTE(allen|a3.4.4): We don't have to worry about whether this is a valid line number.
// When it's not possible to place a cursor at the position for whatever reason it will set the
// cursor to a nearby valid position.
- app->view_set_cursor(app, &view, seek_line_char(line_number, 0), 1);
+ view_set_cursor(app, &view, seek_line_char(line_number, 0), 1);
}
inline View_Summary
@@ -284,11 +279,11 @@ get_first_view_with_buffer(Application_Links *app, int32_t buffer_id){
if (buffer_id != 0){
uint32_t access = AccessAll;
- for(test = app->get_view_first(app, access);
+ for(test = get_view_first(app, access);
test.exists;
- app->get_view_next(app, &test, access)){
+ get_view_next(app, &test, access)){
- Buffer_Summary buffer = app->get_buffer(app, test.buffer_id, access);
+ Buffer_Summary buffer = get_buffer(app, test.buffer_id, access);
if(buffer.buffer_id == buffer_id){
result = test;
@@ -318,14 +313,14 @@ query_user_general(Application_Links *app, Query_Bar *bar, int32_t force_number)
// user, if this command starts intercepting input even though no prompt is shown.
// This will only happen if you have a lot of bars open already or if the current view
// doesn't support query bars.
- if (app->start_query_bar(app, bar, 0) == 0) return 0;
+ if (start_query_bar(app, bar, 0) == 0) return 0;
while (1){
// NOTE(allen|a3.4.4): This call will block until the user does one of the input
// types specified in the flags. The first set of flags are inputs you'd like to intercept
// that you don't want to abort on. The second set are inputs that you'd like to cause
// the command to abort. If an event satisfies both flags, it is treated as an abort.
- in = app->get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
+ in = get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
// NOTE(allen|a3.4.4): The responsible thing to do on abort is to end the command
// without waiting on get_user_input again.
@@ -385,17 +380,17 @@ query_user_number(Application_Links *app, Query_Bar *bar){
inline Buffer_Summary
get_active_buffer(Application_Links *app, uint32_t access){
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
return(buffer);
}
inline char
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char result = ' ';
- *buffer = app->get_buffer(app, buffer->buffer_id, AccessAll);
+ *buffer = get_buffer(app, buffer->buffer_id, AccessAll);
if (pos >= 0 && pos < buffer->size){
- app->buffer_read_range(app, buffer, pos, pos+1, &result);
+ buffer_read_range(app, buffer, pos, pos+1, &result);
}
return(result);
}
diff --git a/4coder_jump_parsing.cpp b/4coder_jump_parsing.cpp
index 9de0631d..fa5dfb1c 100644
--- a/4coder_jump_parsing.cpp
+++ b/4coder_jump_parsing.cpp
@@ -18,7 +18,7 @@ static ID_Based_Jump_Location null_location = {0};
static void
jump_to_location(Application_Links *app, View_Summary *view, Name_Based_Jump_Location *l){
if (view_open_file(app, view, l->file.str, l->file.size, true)){
- app->view_set_cursor(app, view, seek_line_char(l->line, l->column), true);
+ view_set_cursor(app, view, seek_line_char(l->line, l->column), true);
}
}
@@ -168,7 +168,7 @@ parse_jump_from_buffer_line(Application_Links *app,
int32_t result = false;
String line_str = {0};
- Buffer_Summary buffer = app->get_buffer(app, buffer_id, AccessAll);
+ Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
if (read_line(app, part, &buffer, line, &line_str)){
int32_t colon_char = 0;
if (parse_jump_location(line_str, location, skip_sub_errors, &colon_char)){
@@ -181,7 +181,7 @@ parse_jump_from_buffer_line(Application_Links *app,
CUSTOM_COMMAND_SIG(goto_jump_at_cursor){
Temp_Memory temp = begin_temp_memory(&global_part);
- View_Summary view = app->get_active_view(app, AccessProtected);
+ View_Summary view = get_active_view(app, AccessProtected);
Name_Based_Jump_Location location = {0};
if (parse_jump_from_buffer_line(app, &global_part,
@@ -189,7 +189,7 @@ CUSTOM_COMMAND_SIG(goto_jump_at_cursor){
&location)){
exec_command(app, change_active_panel);
- view = app->get_active_view(app, AccessAll);
+ view = get_active_view(app, AccessAll);
jump_to_location(app, &view, &location);
}
@@ -217,7 +217,7 @@ seek_next_jump_in_buffer(Application_Links *app,
int32_t result = false;
int32_t line = first_line;
String line_str = {0};
- Buffer_Summary buffer = app->get_buffer(app, buffer_id, AccessAll);
+ Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
for (;;){
if (read_line(app, part, &buffer, line, &line_str)){
if (parse_jump_location(line_str, location_out, skip_sub_errors, colon_index_out)){
@@ -244,7 +244,7 @@ static ID_Based_Jump_Location
convert_name_based_to_id_based(Application_Links *app, Name_Based_Jump_Location loc){
ID_Based_Jump_Location result = {0};
Buffer_Summary buffer =
- app->get_buffer_by_name(app, loc.file.str, loc.file.size, AccessAll);
+ get_buffer_by_name(app, loc.file.str, loc.file.size, AccessAll);
if (buffer.exists){
result.buffer_id = buffer.buffer_id;
@@ -326,7 +326,7 @@ advance_cursor_in_jump_view(Application_Links *app,
if (result){
*location_out = location;
- app->view_set_cursor(app, view, seek_line_char(line, colon_index+1), true);
+ view_set_cursor(app, view, seek_line_char(line, colon_index+1), true);
}
prev_location = jump;
@@ -357,7 +357,7 @@ get_view_for_locked_jump_buffer(Application_Links *app){
View_Summary view = {0};
if (locked_buffer.size > 0){
- Buffer_Summary buffer = app->get_buffer_by_name(app, locked_buffer.str, locked_buffer.size, AccessAll);
+ Buffer_Summary buffer = get_buffer_by_name(app, locked_buffer.str, locked_buffer.size, AccessAll);
if (buffer.exists){
view = get_first_view_with_buffer(app, buffer.buffer_id);
}
@@ -384,10 +384,10 @@ seek_error(Application_Links *app,
if (advance_cursor_in_jump_view(app, &global_part, &view,
skip_repeats, skip_sub_errors, direction,
&location)){
- View_Summary active_view = app->get_active_view(app, AccessAll);
+ View_Summary active_view = get_active_view(app, AccessAll);
if (active_view.view_id == view.view_id){
exec_command(app, change_active_panel);
- active_view = app->get_active_view(app, AccessAll);
+ active_view = get_active_view(app, AccessAll);
}
jump_to_location(app, &active_view, &location);
@@ -432,7 +432,7 @@ CUSTOM_COMMAND_SIG(goto_first_jump){
View_Summary view = get_view_for_locked_jump_buffer(app);
if (view.exists){
- app->view_set_cursor(app, &view, seek_pos(0), true);
+ view_set_cursor(app, &view, seek_pos(0), true);
prev_location = null_location;
seek_error(app, &global_part, false, true, 1);
diff --git a/4coder_search.cpp b/4coder_search.cpp
index 24496893..861af0e8 100644
--- a/4coder_search.cpp
+++ b/4coder_search.cpp
@@ -282,7 +282,7 @@ search_front_to_back_step(Application_Links *app,
int32_t case_insensitive = (range->flags & SearchFlag_CaseInsensitive);
- result.buffer = app->get_buffer(app, range->buffer, AccessAll);
+ result.buffer = get_buffer(app, range->buffer, AccessAll);
if (case_insensitive){
buffer_seek_string_insensitive_forward(app, &result.buffer,
start_pos, end_pos,
@@ -344,7 +344,7 @@ search_back_to_front_step(Application_Links *app,
if (*pos > range->start){
int32_t start_pos = *pos;
- result.buffer = app->get_buffer(app, range->buffer, AccessAll);
+ result.buffer = get_buffer(app, range->buffer, AccessAll);
buffer_seek_string_backward(app, &result.buffer,
start_pos, range->start,
word.str, word.size,
diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp
index c0876482..19e8575b 100644
--- a/4ed_api_implementation.cpp
+++ b/4ed_api_implementation.cpp
@@ -176,7 +176,7 @@ DOC_SEE(Command_ID)
result = true;
}
else{
- app->print_message(app, literal("WARNING: An invalid Command_ID was passed to exec_command."));
+ print_message(app, literal("WARNING: An invalid Command_ID was passed to exec_command."));
}
return(result);
@@ -703,7 +703,8 @@ DOC_SEE(Buffer_Batch_Edit_Type)
}
API_EXPORT bool32
-Buffer_Set_Setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value)/*
+Buffer_Set_Setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value)
+/*
DOC_PARAM(buffer, The buffer parameter specifies the buffer on which to set a setting.)
DOC_PARAM(setting, The setting parameter identifies the setting that shall be changed.)
DOC_PARAM(value, The value parameter specifies the value to which the setting shall be changed.)
@@ -799,7 +800,8 @@ DOC_SEE(Buffer_Setting_ID)
}
API_EXPORT int32_t
-Buffer_Token_Count(Application_Links *app, Buffer_Summary *buffer)/*
+Buffer_Token_Count(Application_Links *app, Buffer_Summary *buffer)
+/*
DOC_PARAM(buffer, Specifies the buffer from which to read the token count.)
DOC_RETURN(If tokens are available for the buffer, the number of tokens on the buffer is returned.
If the buffer does not exist or if it is not a lexed buffer, the return is zero.)
@@ -817,7 +819,8 @@ If the buffer does not exist or if it is not a lexed buffer, the return is zero.
}
API_EXPORT bool32
-Buffer_Read_Tokens(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out)/*
+Buffer_Read_Tokens(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out)
+/*
DOC_PARAM(buffer, Specifies the buffer from which to read tokens.)
DOC_PARAM(first_token, Specifies the index of the first token to read.)
DOC_PARAM(end_token, Specifies the token to stop reading at.)
@@ -843,7 +846,18 @@ The number of output tokens will be end_token - start_token.)
}
API_EXPORT bool32
-Buffer_Get_Token_Index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result){
+Buffer_Get_Token_Index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result)
+/*
+DOC_PARAM(buffer, The buffer from which to get a token.)
+DOC_PARAM(pos, The position in the buffer in absolute coordinates.)
+DOC_PARAM(get_result, The output struct specifying which token contains pos.)
+DOC_RETURN(Returns non-zero on success. This call can fail if the buffer doesn't exist,
+or if the buffer doesn't have tokens ready.)
+DOC(This call finds the token that contains a particular position, or if the position is in between
+tokens it finds the index of the token to the left of the position.)
+DOC_SEE(Cpp_Get_Token_Result)
+DOC_SEE(cpp_get_token)
+*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
Editing_File *file = imp_get_file(cmd, buffer);
Cpp_Token_Array token_array = file->state.token_array;
@@ -1027,7 +1041,7 @@ DOC_SEE(Buffer_Identifier)
}
else{
#define MESSAGE "CUSTOM WARNING: the buffer is dirty and no view was specified for a dialogue.\n"
- app->print_message(app, literal(MESSAGE));
+ print_message(app, literal(MESSAGE));
#undef MESSAGE
}
}
diff --git a/4ed_metagen.cpp b/4ed_metagen.cpp
index cabe3c5d..f64c2137 100644
--- a/4ed_metagen.cpp
+++ b/4ed_metagen.cpp
@@ -2601,9 +2601,10 @@ generate_custom_headers(){
append_sc(&out, "_Function);\n");
}
- append_sc(&out,
- "struct Application_Links{\n");
+ append_sc(&out, "struct Application_Links{\n");
+
+ append_sc(&out, "#if defined(ALLOW_DEP_4CODER)\n");
for (int32_t i = 0; i < unit_custom.set.count; ++i){
append_ss(&out, unit_custom.set.items[i].name);
append_sc(&out, "_Function *");
@@ -2611,6 +2612,16 @@ generate_custom_headers(){
append_sc(&out, ";\n");
}
+ append_sc(&out, "#else\n");
+
+ for (int32_t i = 0; i < unit_custom.set.count; ++i){
+ append_ss(&out, unit_custom.set.items[i].name);
+ append_sc(&out, "_Function *");
+ append_ss(&out, func_4ed_names.names[i].public_name);
+ append_sc(&out, "_;\n");
+ }
+ append_sc(&out, "#endif\n");
+
append_sc(&out,
"void *memory;\n"
"int32_t memory_size;\n"
@@ -2621,16 +2632,66 @@ generate_custom_headers(){
"};\n");
append_sc(&out, "#define FillAppLinksAPI(app_links) do{");
-
for (int32_t i = 0; i < unit_custom.set.count; ++i){
append_sc(&out, "\\\napp_links->");
append_ss(&out, func_4ed_names.names[i].public_name);
- append_sc(&out, " = ");
+ append_sc(&out, "_ = ");
append_ss(&out, unit_custom.set.items[i].name);
append_s_char(&out, ';');
}
append_sc(&out, "} while(false)\n");
+ append_sc(&out, "#if defined(ALLOW_DEP_4CODER)\n");
+ for (int32_t use_dep = 1; use_dep >= 0; --use_dep){
+ for (int32_t i = 0; i < unit_custom.set.count; ++i){
+ Argument_Breakdown breakdown = unit_custom.set.items[i].breakdown;
+ String ret = unit_custom.set.items[i].ret;
+ String public_name = func_4ed_names.names[i].public_name;
+
+ append_sc(&out, "static inline ");
+ append_ss(&out, ret);
+ append_sc(&out, " ");
+ append_ss(&out, public_name);
+
+ append_sc(&out, "(");
+ for (int32_t j = 0; j < breakdown.count; ++j){
+ append_ss(&out, breakdown.args[j].param_string);
+ if (j+1 != breakdown.count){
+ append_sc(&out, ", ");
+ }
+ }
+ append_sc(&out, "){");
+
+ if (match_ss(ret, make_lit_string("void"))){
+ append_sc(&out, "(");
+ }
+ else{
+ append_sc(&out, "return(");
+ }
+
+ append_sc(&out, "app->");
+ append_ss(&out, public_name);
+ if (!use_dep){
+ append_sc(&out, "_");
+ }
+
+ append_sc(&out, "(");
+ for (int32_t j = 0; j < breakdown.count; ++j){
+ append_ss(&out, breakdown.args[j].param_name);
+ if (j+1 != breakdown.count){
+ append_sc(&out, ", ");
+ }
+ }
+ append_sc(&out, ")");
+
+ append_sc(&out, ");}\n");
+ }
+ if (use_dep == 1){
+ append_sc(&out, "#else\n");
+ }
+ }
+ append_sc(&out, "#endif\n");
+
end_file_out(context);
}
else{
diff --git a/buildsuper.bat b/buildsuper.bat
index e79d29f3..45c02c1f 100644
--- a/buildsuper.bat
+++ b/buildsuper.bat
@@ -10,19 +10,16 @@ if "%SRC%" == "" SET SRC=4coder_default_bindings.cpp
SET OPTS=/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /WX
SET OPTS=%OPTS% /GR- /nologo /FC
SET DEBUG=/Zi
-set BUILD_DLL=/LD /link /INCREMENTAL:NO /OPT:REF
+SET BUILD_DLL=/LD /link /INCREMENTAL:NO /OPT:REF
SET EXPORTS=/EXPORT:get_bindings /EXPORT:get_alpha_4coder_version
-REM SET LINKS=user32.lib gdi32.lib
-SET LINKS=
-
REM This stores the path of the buildsuper.bat script
REM in CODE_HOME. This way you can always include the
REM default files no matter where you store your code.
REM And no matter how you call buildsuper.bat.
SET CODE_HOME=%~dp0
-cl /I%CODE_HOME% %OPTS% %DEBUG% %SRC% %LINKS% /Fe4coder_custom %BUILD_DLL% %EXPORTS%
+cl /I%CODE_HOME% %OPTS% %DEBUG% %SRC% /Fe4coder_custom %BUILD_DLL% %EXPORTS%
REM file spammation preventation
del *.exp
diff --git a/internal_4coder_tests.cpp b/internal_4coder_tests.cpp
index 764c3839..fea67f01 100644
--- a/internal_4coder_tests.cpp
+++ b/internal_4coder_tests.cpp
@@ -37,7 +37,7 @@ CUSTOM_COMMAND_SIG(load_lots_of_files){
// I set the goal of 10M for all tests.
TEST_TIME_B(10000000);
- File_List list = app->get_file_list(app, literal(LOTS_OF_FILES));
+ File_List list = get_file_list(app, literal(LOTS_OF_FILES));
File_Info *info = list.infos;
char space[1024];
@@ -49,14 +49,14 @@ CUSTOM_COMMAND_SIG(load_lots_of_files){
for (int32_t i = 0; i < list.count; ++i, ++info){
if (!info->folder){
append_ss(&str, make_string(info->filename, info->filename_len));
- Buffer_Summary buffer = app->create_buffer(app, str.str, str.size,
+ Buffer_Summary buffer = create_buffer(app, str.str, str.size,
BufferCreate_Background);
assert(buffer.size != 0);
str.size = size;
}
}
- app->free_file_list(app, list);
+ free_file_list(app, list);
// TODO(allen): Pass this time test!
//TEST_TIME_E();
@@ -67,9 +67,9 @@ CUSTOM_COMMAND_SIG(reopen_test){
// based on 4GHz and 60fps
TEST_TIME_B(700000);
- Buffer_Summary buffer = app->create_buffer(app, literal(TEST_FILES "/basic.cpp"), 0);
- View_Summary view = app->get_active_view(app, AccessAll);
- app->view_set_buffer(app, &view, buffer.buffer_id, 0);
+ Buffer_Summary buffer = create_buffer(app, literal(TEST_FILES "/basic.cpp"), 0);
+ View_Summary view = get_active_view(app, AccessAll);
+ view_set_buffer(app, &view, buffer.buffer_id, 0);
exec_command(app, cmdid_reopen);
@@ -78,9 +78,9 @@ CUSTOM_COMMAND_SIG(reopen_test){
}
CUSTOM_COMMAND_SIG(generate_stop_spots_test_data){
- Buffer_Summary buffer = app->create_buffer(app, literal(LOTS_OF_FILES "/4ed.cpp"), 0);
- View_Summary view = app->get_active_view(app, AccessAll);
- app->view_set_buffer(app, &view, buffer.buffer_id, 0);
+ Buffer_Summary buffer = create_buffer(app, literal(LOTS_OF_FILES "/4ed.cpp"), 0);
+ View_Summary view = get_active_view(app, AccessAll);
+ view_set_buffer(app, &view, buffer.buffer_id, 0);
FILE *file = fopen(TEST_FILES "/stop_spots_data", "wb");
@@ -88,14 +88,14 @@ CUSTOM_COMMAND_SIG(generate_stop_spots_test_data){
Partial_Cursor curs;
int32_t pos;
- app->buffer_compute_cursor(app, &buffer, seek_line_char(316, 29), &curs);
+ buffer_compute_cursor(app, &buffer, seek_line_char(316, 29), &curs);
fwrite(&curs.pos, 4, 1, file);
for (int32_t i = 0; i < 10; ++i){
Query_Bar bar = {0};
bar.prompt = make_lit_string("Do something to continue the test");
- if (app->start_query_bar(app, &bar, 0)){
- app->get_user_input(app, EventAll, EventAll);
+ if (start_query_bar(app, &bar, 0)){
+ get_user_input(app, EventAll, EventAll);
}
refresh_buffer(app, &buffer);
if (buffer.tokens_are_ready){
@@ -135,9 +135,9 @@ fcheck(int32_t x, FILE *file){
}
CUSTOM_COMMAND_SIG(stop_spots_test){
- Buffer_Summary buffer = app->create_buffer(app, literal(LOTS_OF_FILES "/4ed.cpp"), 0);
- View_Summary view = app->get_active_view(app, AccessAll);
- app->view_set_buffer(app, &view, buffer.buffer_id, 0);
+ Buffer_Summary buffer = create_buffer(app, literal(LOTS_OF_FILES "/4ed.cpp"), 0);
+ View_Summary view = get_active_view(app, AccessAll);
+ view_set_buffer(app, &view, buffer.buffer_id, 0);
FILE *file = fopen(TEST_FILES "/stop_spots_data", "rb");
@@ -145,14 +145,14 @@ CUSTOM_COMMAND_SIG(stop_spots_test){
Partial_Cursor curs;
int32_t pos;
- app->buffer_compute_cursor(app, &buffer, seek_line_char(316, 29), &curs);
+ buffer_compute_cursor(app, &buffer, seek_line_char(316, 29), &curs);
fcheck(curs.pos, file);
for (int32_t i = 0; i < 10; ++i){
Query_Bar bar = {0};
bar.prompt = make_lit_string("Do something to continue the test");
- if (app->start_query_bar(app, &bar, 0)){
- app->get_user_input(app, EventAll, EventAll);
+ if (start_query_bar(app, &bar, 0)){
+ get_user_input(app, EventAll, EventAll);
}
refresh_buffer(app, &buffer);
if (buffer.tokens_are_ready){
@@ -185,11 +185,11 @@ CUSTOM_COMMAND_SIG(stop_spots_test){
}
CUSTOM_COMMAND_SIG(load_unicode_file){
- Buffer_Summary buffer = app->create_buffer(app, literal(TEST_FILES "/mod_markov.c"), 0);
- View_Summary view = app->get_active_view(app, AccessAll);
- app->view_set_buffer(app, &view, buffer.buffer_id, 0);
+ Buffer_Summary buffer = create_buffer(app, literal(TEST_FILES "/mod_markov.c"), 0);
+ View_Summary view = get_active_view(app, AccessAll);
+ view_set_buffer(app, &view, buffer.buffer_id, 0);
- app->view_set_cursor(app, &view, seek_line_char(230, 25), 1);
+ view_set_cursor(app, &view, seek_line_char(230, 25), 1);
}
CUSTOM_COMMAND_SIG(run_all_tests){
diff --git a/power/4coder_experiments.cpp b/power/4coder_experiments.cpp
index 6164b822..a9a42e98 100644
--- a/power/4coder_experiments.cpp
+++ b/power/4coder_experiments.cpp
@@ -13,8 +13,8 @@
#include
CUSTOM_COMMAND_SIG(kill_rect){
- View_Summary view = app->get_active_view(app, AccessOpen);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen);
+ View_Summary view = get_active_view(app, AccessOpen);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
Buffer_Rect rect = get_rect(&view);
@@ -26,15 +26,15 @@ CUSTOM_COMMAND_SIG(kill_rect){
Full_Cursor cursor = {0};
success = success &&
- app->view_compute_cursor(app, &view, seek_line_char(line, rect.char0), &cursor);
+ view_compute_cursor(app, &view, seek_line_char(line, rect.char0), &cursor);
start = cursor.pos;
success = success &&
- app->view_compute_cursor(app, &view, seek_line_char(line, rect.char1), &cursor);
+ view_compute_cursor(app, &view, seek_line_char(line, rect.char1), &cursor);
end = cursor.pos;
if (success){
- app->buffer_replace_range(app, &buffer, start, end, 0, 0);
+ buffer_replace_range(app, &buffer, start, end, 0, 0);
}
}
}
@@ -46,15 +46,15 @@ pad_buffer_line(Application_Links *app, Partition *part,
Partial_Cursor start = {0};
Partial_Cursor end = {0};
- if (app->buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &start)){
- if (app->buffer_compute_cursor(app, buffer, seek_line_char(line, 65536), &end)){
+ if (buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &start)){
+ if (buffer_compute_cursor(app, buffer, seek_line_char(line, 65536), &end)){
if (start.line == line){
if (end.character-1 < target){
Temp_Memory temp = begin_temp_memory(part);
int size = target - (end.character-1);
char *str = push_array(part, char, size);
memset(str, ' ', size);
- app->buffer_replace_range(app, buffer, end.pos, end.pos, str, size);
+ buffer_replace_range(app, buffer, end.pos, end.pos, str, size);
end_temp_memory(temp);
}
}
@@ -100,8 +100,8 @@ doing multi-cursor for now.
CUSTOM_COMMAND_SIG(multi_line_edit){
Partition *part = &global_part;
- View_Summary view = app->get_active_view(app, AccessOpen);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen);
+ View_Summary view = get_active_view(app, AccessOpen);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
Buffer_Rect rect = get_rect(&view);
@@ -115,7 +115,7 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
int line_count = rect.line1 - rect.line0 + 1;
for (;;){
- User_Input in = app->get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
+ User_Input in = get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
if (in.abort) break;
if (in.key.character && key_is_unmodified(&in.key)){
@@ -128,7 +128,7 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
for (int i = rect.line0; i <= rect.line1; ++i){
Partial_Cursor cursor = {0};
- if (app->buffer_compute_cursor(app, &buffer, seek_line_char(i, pos+1), &cursor)){
+ if (buffer_compute_cursor(app, &buffer, seek_line_char(i, pos+1), &cursor)){
edit->str_start = 0;
edit->len = 1;
edit->start = cursor.pos;
@@ -138,13 +138,13 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
}
int edit_count = (int)(edit - edits);
- app->buffer_batch_edit(app, &buffer, &str, 1, edits, edit_count, BatchEdit_Normal);
+ buffer_batch_edit(app, &buffer, &str, 1, edits, edit_count, BatchEdit_Normal);
end_temp_memory(temp);
++pos;
- app->view_set_cursor(app, &view, seek_line_char(start_line, pos+1), true);
+ view_set_cursor(app, &view, seek_line_char(start_line, pos+1), true);
}
else if (in.key.keycode == key_back){
if (pos > 0){
@@ -156,7 +156,7 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
for (int i = rect.line0; i <= rect.line1; ++i){
Partial_Cursor cursor = {0};
- if (app->buffer_compute_cursor(app, &buffer, seek_line_char(i, pos+1), &cursor)){
+ if (buffer_compute_cursor(app, &buffer, seek_line_char(i, pos+1), &cursor)){
edit->str_start = 0;
edit->len = 0;
edit->start = cursor.pos-1;
@@ -166,7 +166,7 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
}
int edit_count = (int)(edit - edits);
- app->buffer_batch_edit(app, &buffer, 0, 0, edits, edit_count, BatchEdit_Normal);
+ buffer_batch_edit(app, &buffer, 0, 0, edits, edit_count, BatchEdit_Normal);
end_temp_memory(temp);
@@ -184,8 +184,8 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
// if the API exposed access to the tokens in a code file.
CUSTOM_COMMAND_SIG(mark_matching_brace){
uint32_t access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
@@ -259,14 +259,14 @@ CUSTOM_COMMAND_SIG(mark_matching_brace){
finished:
if (found_result){
- app->view_set_mark(app, &view, seek_pos(result+1));
+ view_set_mark(app, &view, seek_pos(result+1));
}
}
CUSTOM_COMMAND_SIG(cursor_to_surrounding_scope){
unsigned int access = AccessProtected;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int start_pos = view.cursor.pos - 1;
@@ -305,7 +305,7 @@ CUSTOM_COMMAND_SIG(cursor_to_surrounding_scope){
finished:
if (found_result){
- app->view_set_cursor(app, &view, seek_pos(result), 0);
+ view_set_cursor(app, &view, seek_pos(result), 0);
}
}
@@ -313,15 +313,15 @@ CUSTOM_COMMAND_SIG(cursor_to_surrounding_scope){
CUSTOM_COMMAND_SIG(rename_parameter){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
Partition *part = &global_part;
Temp_Memory temp = begin_temp_memory(part);
Cpp_Get_Token_Result result;
- if (app->buffer_get_token_index(app, &buffer, view.cursor.pos, &result)){
+ if (buffer_get_token_index(app, &buffer, view.cursor.pos, &result)){
if (!result.in_whitespace){
Cpp_Token stream_space[32];
Stream_Tokens stream = {0};
@@ -338,7 +338,7 @@ CUSTOM_COMMAND_SIG(rename_parameter){
if (token.size < sizeof(old_lexeme_base)){
Cpp_Token original_token = token;
old_lexeme.size = token.size;
- app->buffer_read_range(app, &buffer, token.start,
+ buffer_read_range(app, &buffer, token.start,
token.start+token.size,
old_lexeme.str);
@@ -406,7 +406,7 @@ CUSTOM_COMMAND_SIG(rename_parameter){
char other_lexeme_base[128];
String other_lexeme = make_fixed_width_string(other_lexeme_base);
other_lexeme.size = old_lexeme.size;
- app->buffer_read_range(app, &buffer, token_ptr->start,
+ buffer_read_range(app, &buffer, token_ptr->start,
token_ptr->start+token_ptr->size,
other_lexeme.str);
@@ -450,7 +450,7 @@ CUSTOM_COMMAND_SIG(rename_parameter){
doublebreak2:;
if (closed_correctly){
- app->buffer_batch_edit(app, &buffer, replace_string.str, replace_string.size,
+ buffer_batch_edit(app, &buffer, replace_string.str, replace_string.size,
edits, edit_count, BatchEdit_Normal);
}
}
@@ -465,15 +465,15 @@ CUSTOM_COMMAND_SIG(rename_parameter){
CUSTOM_COMMAND_SIG(write_explicit_enum_values){
uint32_t access = AccessOpen;
- View_Summary view = app->get_active_view(app, access);
- Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
+ View_Summary view = get_active_view(app, access);
+ Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
Partition *part = &global_part;
Temp_Memory temp = begin_temp_memory(part);
Cpp_Get_Token_Result result;
- if (app->buffer_get_token_index(app, &buffer, view.cursor.pos, &result)){
+ if (buffer_get_token_index(app, &buffer, view.cursor.pos, &result)){
if (!result.in_whitespace){
Cpp_Token stream_space[32];
Stream_Tokens stream = {0};
@@ -595,7 +595,7 @@ CUSTOM_COMMAND_SIG(write_explicit_enum_values){
finished:;
if (closed_correctly){
- app->buffer_batch_edit(app, &buffer, string_base, string.size,
+ buffer_batch_edit(app, &buffer, string_base, string.size,
edits, edit_count, BatchEdit_Normal);
}
}
@@ -622,8 +622,8 @@ CUSTOM_COMMAND_SIG(save_theme_settings){
fclose(file);
- app->change_theme(app, theme_name, strlen(theme_name));
- app->change_font(app, font_name, strlen(font_name));
+ change_theme(app, theme_name, strlen(theme_name));
+ change_font(app, font_name, strlen(font_name));
}
}
#endif
@@ -641,7 +641,7 @@ HOOK_SIG(experimental_start){
if (!file){
char module_path[512];
- int len = app->get_4ed_path(app, module_path, 448);
+ int len = get_4ed_path(app, module_path, 448);
memcpy(module_path+len, SETTINGS_FILE, sizeof(SETTINGS_FILE));
file = fopen(module_path, "rb");
}
@@ -660,8 +660,8 @@ HOOK_SIG(experimental_start){
int theme_len = (int)strlen(theme_name);
int font_len = (int)strlen(font_name);
- app->change_theme(app, theme_name, theme_len);
- app->change_font(app, font_name, font_len, true);
+ change_theme(app, theme_name, theme_len);
+ change_font(app, font_name, font_len, true);
exec_command(app, open_panel_vsplit);
exec_command(app, hide_scrollbar);
diff --git a/win32_api_impl.cpp b/win32_api_impl.cpp
index 0d61c08e..da123470 100644
--- a/win32_api_impl.cpp
+++ b/win32_api_impl.cpp
@@ -162,7 +162,8 @@ folders.
}
API_EXPORT bool32
-Get_4ed_Path(Application_Links *app, char *out, int32_t capacity)/*
+Get_4ed_Path(Application_Links *app, char *out, int32_t capacity)
+/*
DOC_PARAM(out, This parameter provides a character buffer that receives the path to the 4ed executable file.)
DOC_PARAM(capacity, This parameter specifies the maximum capacity of the out buffer.)
DOC_RETURN(This call returns non-zero on success.)
@@ -173,7 +174,8 @@ DOC_RETURN(This call returns non-zero on success.)
// TODO(allen): add a "shown but auto-hides on timer" setting here.
API_EXPORT void
-Show_Mouse_Cursor(Application_Links *app, Mouse_Cursor_Show_Type show)/*
+Show_Mouse_Cursor(Application_Links *app, Mouse_Cursor_Show_Type show)
+/*
DOC_PARAM(show, This parameter specifies the new state of the mouse cursor.)
DOC_SEE(Mouse_Cursor_Show_Type)
*/{
@@ -191,7 +193,8 @@ DOC_SEE(Mouse_Cursor_Show_Type)
}
API_EXPORT void
-Toggle_Fullscreen(Application_Links *app)/*
+Toggle_Fullscreen(Application_Links *app)
+/*
DOC(This call tells 4coder to switch into or out of full screen mode.
The changes of full screen mode do not take effect until the end of the current frame.
On Windows this call will not work unless 4coder was started in "stream mode".
@@ -207,12 +210,13 @@ Stream mode can be enabled with -S or -F flags on the command line to 4ed.)
win32vars.do_toggle = !win32vars.do_toggle;
}
else{
- app->print_message(app, literal("WARNING: Cannot go full screen unless 4coder is in stream mode\n Use the flag -S to put 4coder in stream mode.\n"));
+ print_message(app, literal("WARNING: Cannot go full screen unless 4coder is in stream mode\n Use the flag -S to put 4coder in stream mode.\n"));
}
}
API_EXPORT bool32
-Is_Fullscreen(Application_Links *app)/*
+Is_Fullscreen(Application_Links *app)
+/*
DOC(This call returns true if the 4coder is in full screen mode. This call
takes toggles that have already occured this frame into account. So it may return
true even though the frame has not ended and actually put 4coder into full screen. If
@@ -228,7 +232,8 @@ frame if the state is not changed.)
}
API_EXPORT void
-Send_Exit_Signal(Application_Links *app)/*
+Send_Exit_Signal(Application_Links *app)
+/*
DOC(This call sends a signal to 4coder to attempt to exit. If there are unsaved
files this triggers a dialogue ensuring you're okay with closing.)
*/{