merge
commit
ab68afae76
434
4coder_API.html
434
4coder_API.html
File diff suppressed because one or more lines are too long
|
@ -12,15 +12,14 @@
|
|||
#define BUFFER_REPLACE_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len)
|
||||
#define BUFFER_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out)
|
||||
#define BUFFER_BATCH_EDIT_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type)
|
||||
#define BUFFER_GET_SETTING_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting)
|
||||
#define BUFFER_GET_SETTING_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out)
|
||||
#define BUFFER_SET_SETTING_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value)
|
||||
#define BUFFER_TOKEN_COUNT_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer)
|
||||
#define BUFFER_READ_TOKENS_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out)
|
||||
#define BUFFER_GET_TOKEN_INDEX_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result)
|
||||
#define BEGIN_BUFFER_CREATION_SIG(n) void n(Application_Links *app, Buffer_Creation_Data *data, Buffer_Create_Flag flags)
|
||||
#define BUFFER_CREATION_NAME_SIG(n) void n(Application_Links *app, Buffer_Creation_Data *data, char *filename, int32_t filename_len, uint32_t flags)
|
||||
#define BEGIN_BUFFER_CREATION_SIG(n) bool32 n(Application_Links *app, Buffer_Creation_Data *data, Buffer_Create_Flag flags)
|
||||
#define BUFFER_CREATION_NAME_SIG(n) bool32 n(Application_Links *app, Buffer_Creation_Data *data, char *filename, int32_t filename_len, uint32_t flags)
|
||||
#define END_BUFFER_CREATION_SIG(n) Buffer_Summary n(Application_Links *app, Buffer_Creation_Data *data)
|
||||
#define CREATE_BUFFER__SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags)
|
||||
#define SAVE_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags)
|
||||
#define KILL_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags)
|
||||
#define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app, Access_Flag access)
|
||||
|
@ -30,7 +29,7 @@
|
|||
#define OPEN_VIEW_SIG(n) View_Summary n(Application_Links *app, View_Summary *view_location, View_Split_Position position)
|
||||
#define CLOSE_VIEW_SIG(n) bool32 n(Application_Links *app, View_Summary *view)
|
||||
#define SET_ACTIVE_VIEW_SIG(n) bool32 n(Application_Links *app, View_Summary *view)
|
||||
#define VIEW_GET_SETTING_SIG(n) int32_t n(Application_Links *app, View_Summary *view, View_Setting_ID setting)
|
||||
#define VIEW_GET_SETTING_SIG(n) bool32 n(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t *value_out)
|
||||
#define VIEW_SET_SETTING_SIG(n) bool32 n(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value)
|
||||
#define VIEW_SET_SPLIT_PROPORTION_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float t)
|
||||
#define VIEW_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out)
|
||||
|
@ -49,7 +48,7 @@
|
|||
#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int32_t len)
|
||||
#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int32_t len, bool32 apply_to_all_files)
|
||||
#define BUFFER_SET_FONT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer, char *name, int32_t len)
|
||||
#define BUFFER_GET_FONT_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer, char *name_out, int32_t name_max)
|
||||
#define BUFFER_GET_FONT_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *name_out, int32_t name_max)
|
||||
#define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int32_t count)
|
||||
#define GET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int32_t count)
|
||||
#define DIRECTORY_GET_HOT_SIG(n) int32_t n(Application_Links *app, char *out, int32_t capacity)
|
||||
|
@ -88,7 +87,6 @@ typedef BUFFER_GET_TOKEN_INDEX_SIG(Buffer_Get_Token_Index_Function);
|
|||
typedef BEGIN_BUFFER_CREATION_SIG(Begin_Buffer_Creation_Function);
|
||||
typedef BUFFER_CREATION_NAME_SIG(Buffer_Creation_Name_Function);
|
||||
typedef END_BUFFER_CREATION_SIG(End_Buffer_Creation_Function);
|
||||
typedef CREATE_BUFFER__SIG(Create_Buffer__Function);
|
||||
typedef SAVE_BUFFER_SIG(Save_Buffer_Function);
|
||||
typedef KILL_BUFFER_SIG(Kill_Buffer_Function);
|
||||
typedef GET_VIEW_FIRST_SIG(Get_View_First_Function);
|
||||
|
@ -158,7 +156,6 @@ Buffer_Get_Token_Index_Function *buffer_get_token_index;
|
|||
Begin_Buffer_Creation_Function *begin_buffer_creation;
|
||||
Buffer_Creation_Name_Function *buffer_creation_name;
|
||||
End_Buffer_Creation_Function *end_buffer_creation;
|
||||
Create_Buffer__Function *create_buffer_;
|
||||
Save_Buffer_Function *save_buffer;
|
||||
Kill_Buffer_Function *kill_buffer;
|
||||
Get_View_First_Function *get_view_first;
|
||||
|
@ -227,7 +224,6 @@ Buffer_Get_Token_Index_Function *buffer_get_token_index_;
|
|||
Begin_Buffer_Creation_Function *begin_buffer_creation_;
|
||||
Buffer_Creation_Name_Function *buffer_creation_name_;
|
||||
End_Buffer_Creation_Function *end_buffer_creation_;
|
||||
Create_Buffer__Function *create_buffer__;
|
||||
Save_Buffer_Function *save_buffer_;
|
||||
Kill_Buffer_Function *kill_buffer_;
|
||||
Get_View_First_Function *get_view_first_;
|
||||
|
@ -304,7 +300,6 @@ app_links->buffer_get_token_index_ = Buffer_Get_Token_Index;\
|
|||
app_links->begin_buffer_creation_ = Begin_Buffer_Creation;\
|
||||
app_links->buffer_creation_name_ = Buffer_Creation_Name;\
|
||||
app_links->end_buffer_creation_ = End_Buffer_Creation;\
|
||||
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;\
|
||||
|
@ -365,15 +360,14 @@ static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *b
|
|||
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 int32_t buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting){return(app->buffer_get_setting(app, buffer, setting));}
|
||||
static inline int32_t buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out){return(app->buffer_get_setting(app, buffer, setting, value_out));}
|
||||
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 void begin_buffer_creation(Application_Links *app, Buffer_Creation_Data *data, Buffer_Create_Flag flags){(app->begin_buffer_creation(app, data, flags));}
|
||||
static inline void buffer_creation_name(Application_Links *app, Buffer_Creation_Data *data, char *filename, int32_t filename_len, uint32_t flags){(app->buffer_creation_name(app, data, filename, filename_len, flags));}
|
||||
static inline bool32 begin_buffer_creation(Application_Links *app, Buffer_Creation_Data *data, Buffer_Create_Flag flags){return(app->begin_buffer_creation(app, data, flags));}
|
||||
static inline bool32 buffer_creation_name(Application_Links *app, Buffer_Creation_Data *data, char *filename, int32_t filename_len, uint32_t flags){return(app->buffer_creation_name(app, data, filename, filename_len, flags));}
|
||||
static inline Buffer_Summary end_buffer_creation(Application_Links *app, Buffer_Creation_Data *data){return(app->end_buffer_creation(app, data));}
|
||||
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));}
|
||||
|
@ -383,7 +377,7 @@ static inline View_Summary get_active_view(Application_Links *app, Access_Flag a
|
|||
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 int32_t view_get_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting){return(app->view_get_setting(app, view, setting));}
|
||||
static inline bool32 view_get_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t *value_out){return(app->view_get_setting(app, view, setting, value_out));}
|
||||
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));}
|
||||
|
@ -402,7 +396,7 @@ static inline void print_message(Application_Links *app, char *str, int32_t 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 int32_t buffer_get_font(Application_Links *app, Buffer_Summary *buffer, char *name_out, int32_t name_max){return(app->buffer_get_font(app, buffer, name_out, name_max));}
|
||||
static inline bool32 buffer_get_font(Application_Links *app, Buffer_Summary *buffer, char *name_out, int32_t name_max){return(app->buffer_get_font(app, buffer, name_out, name_max));}
|
||||
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));}
|
||||
|
@ -434,15 +428,14 @@ static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *b
|
|||
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 int32_t buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting){return(app->buffer_get_setting_(app, buffer, setting));}
|
||||
static inline int32_t buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out){return(app->buffer_get_setting_(app, buffer, setting, value_out));}
|
||||
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 void begin_buffer_creation(Application_Links *app, Buffer_Creation_Data *data, Buffer_Create_Flag flags){(app->begin_buffer_creation_(app, data, flags));}
|
||||
static inline void buffer_creation_name(Application_Links *app, Buffer_Creation_Data *data, char *filename, int32_t filename_len, uint32_t flags){(app->buffer_creation_name_(app, data, filename, filename_len, flags));}
|
||||
static inline bool32 begin_buffer_creation(Application_Links *app, Buffer_Creation_Data *data, Buffer_Create_Flag flags){return(app->begin_buffer_creation_(app, data, flags));}
|
||||
static inline bool32 buffer_creation_name(Application_Links *app, Buffer_Creation_Data *data, char *filename, int32_t filename_len, uint32_t flags){return(app->buffer_creation_name_(app, data, filename, filename_len, flags));}
|
||||
static inline Buffer_Summary end_buffer_creation(Application_Links *app, Buffer_Creation_Data *data){return(app->end_buffer_creation_(app, data));}
|
||||
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));}
|
||||
|
@ -452,7 +445,7 @@ static inline View_Summary get_active_view(Application_Links *app, Access_Flag a
|
|||
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 int32_t view_get_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting){return(app->view_get_setting_(app, view, setting));}
|
||||
static inline bool32 view_get_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t *value_out){return(app->view_get_setting_(app, view, setting, value_out));}
|
||||
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));}
|
||||
|
@ -471,7 +464,7 @@ static inline void print_message(Application_Links *app, char *str, int32_t 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 int32_t buffer_get_font(Application_Links *app, Buffer_Summary *buffer, char *name_out, int32_t name_max){return(app->buffer_get_font_(app, buffer, name_out, name_max));}
|
||||
static inline bool32 buffer_get_font(Application_Links *app, Buffer_Summary *buffer, char *name_out, int32_t name_max){return(app->buffer_get_font_(app, buffer, name_out, name_max));}
|
||||
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));}
|
||||
|
|
|
@ -158,8 +158,30 @@ HOOK_SIG(my_start){
|
|||
HOOK_SIG(my_exit){
|
||||
// if this returns zero it cancels the exit.
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(allen): delete this
|
||||
CUSTOM_COMMAND_SIG(weird_buffer_test){
|
||||
for (Buffer_Summary buffer = get_buffer_first(app, AccessAll);
|
||||
buffer.exists;
|
||||
get_buffer_next(app, &buffer, AccessAll)){
|
||||
print_message(app, literal("filename:"));
|
||||
if (buffer.file_name){
|
||||
print_message(app, buffer.file_name, buffer.file_name_len);
|
||||
}
|
||||
else{
|
||||
print_message(app, literal("*NULL*"));
|
||||
}
|
||||
print_message(app, literal("buffername:"));
|
||||
if (buffer.buffer_name){
|
||||
print_message(app, buffer.buffer_name, buffer.buffer_name_len);
|
||||
}
|
||||
else{
|
||||
print_message(app, literal("*NULL*"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(allen|a4.0.12): This is for testing it may be removed and replaced with a better test for the buffer_get_font when you eventally read this and wonder what it's about.
|
||||
CUSTOM_COMMAND_SIG(write_name_of_font){
|
||||
View_Summary view = get_active_view(app, AccessOpen);
|
||||
|
@ -217,7 +239,7 @@ OPEN_FILE_HOOK_SIG(my_file_settings){
|
|||
buffer_set_setting(app, &buffer, BufferSetting_WrapPosition, default_wrap_width);
|
||||
buffer_set_setting(app, &buffer, BufferSetting_MapID, (treat_as_code)?((int32_t)my_code_map):((int32_t)mapid_file));
|
||||
|
||||
if (treat_as_code && enable_code_wrapping && buffer.size < (1 << 20)){
|
||||
if (treat_as_code && enable_code_wrapping && buffer.size < (1 << 18)){
|
||||
// NOTE(allen|a4.0.12): There is a little bit of grossness going on here.
|
||||
// If we set BufferSetting_Lex to true, it will launch a lexing job.
|
||||
// If a lexing job is active when we set BufferSetting_VirtualWhitespace on
|
||||
|
@ -314,6 +336,7 @@ default_keys(Bind_Helper *context){
|
|||
bind(context, key_f2, MDFR_NONE, toggle_mouse);
|
||||
bind(context, key_page_up, MDFR_CTRL, toggle_fullscreen);
|
||||
bind(context, 'E', MDFR_ALT, exit_4coder);
|
||||
bind(context, 'K', MDFR_ALT, weird_buffer_test);
|
||||
|
||||
end_map(context);
|
||||
|
||||
|
|
|
@ -2661,7 +2661,8 @@ CUSTOM_COMMAND_SIG(increase_line_wrap){
|
|||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
|
||||
|
||||
int32_t wrap = buffer_get_setting(app, &buffer, BufferSetting_WrapPosition);
|
||||
int32_t wrap = 0;
|
||||
buffer_get_setting(app, &buffer, BufferSetting_WrapPosition, &wrap);
|
||||
buffer_set_setting(app, &buffer, BufferSetting_WrapPosition, wrap + 10);
|
||||
}
|
||||
|
||||
|
@ -2669,7 +2670,8 @@ CUSTOM_COMMAND_SIG(decrease_line_wrap){
|
|||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
|
||||
|
||||
int32_t wrap = buffer_get_setting(app, &buffer, BufferSetting_WrapPosition);
|
||||
int32_t wrap = 0;
|
||||
buffer_get_setting(app, &buffer, BufferSetting_WrapPosition, &wrap);
|
||||
buffer_set_setting(app, &buffer, BufferSetting_WrapPosition, wrap - 10);
|
||||
}
|
||||
|
||||
|
@ -2677,7 +2679,8 @@ CUSTOM_COMMAND_SIG(toggle_virtual_whitespace){
|
|||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
|
||||
|
||||
int32_t vwhite = buffer_get_setting(app, &buffer, BufferSetting_VirtualWhitespace);
|
||||
int32_t vwhite = 0;
|
||||
buffer_get_setting(app, &buffer, BufferSetting_VirtualWhitespace, &vwhite);
|
||||
buffer_set_setting(app, &buffer, BufferSetting_VirtualWhitespace, !vwhite);
|
||||
}
|
||||
|
||||
|
|
672
4coder_string.h
672
4coder_string.h
File diff suppressed because it is too large
Load Diff
201
4coder_types.h
201
4coder_types.h
|
@ -1,28 +1,41 @@
|
|||
|
||||
|
||||
#ifndef ENUM
|
||||
#define ENUM(type,name) typedef type name; enum name##_
|
||||
# define ENUM(type,name) typedef type name; enum name##_
|
||||
#endif
|
||||
|
||||
#ifndef TYPEDEF
|
||||
# define TYPEDEF typedef
|
||||
#endif
|
||||
|
||||
#ifndef STRUCT
|
||||
# define STRUCT struct
|
||||
#endif
|
||||
|
||||
#ifndef UNION
|
||||
# define UNION union
|
||||
#endif
|
||||
|
||||
|
||||
/* DOC(bool32 is an alias name to signal that an integer parameter or field is for
|
||||
true/false vales.) */
|
||||
typedef int32_t bool32;
|
||||
true/false values.) */
|
||||
TYPEDEF int32_t bool32;
|
||||
|
||||
/* DOC(int_color is an alias name to signal that an integer parameter or field is for
|
||||
a color value, colors are specified as 24 bit integers in 3 channels: 0xRRGGBB.) */
|
||||
typedef uint32_t int_color;
|
||||
TYPEDEF uint32_t int_color;
|
||||
|
||||
/* DOC(Key_Code is the alias for key codes including raw codes and codes translated
|
||||
to textual input that takes modifiers into account.) */
|
||||
typedef unsigned char Key_Code;
|
||||
TYPEDEF unsigned char Key_Code;
|
||||
|
||||
/* DOC(Buffer_ID is used to name a 4coder buffer. Each buffer has a unique id but
|
||||
when a buffer is closed it's id may be recycled by future, different buffers.) */
|
||||
typedef int32_t Buffer_ID;
|
||||
TYPEDEF int32_t Buffer_ID;
|
||||
|
||||
/* DOC(View_ID is used to name a 4coder view. Each view has a unique id in
|
||||
the interval [1,16].) */
|
||||
typedef int32_t View_ID;
|
||||
TYPEDEF int32_t View_ID;
|
||||
|
||||
/* DOC(A Key_Modifier acts as an index for specifying modifiers in arrays.) */
|
||||
ENUM(int32_t, Key_Modifier){
|
||||
|
@ -216,9 +229,9 @@ ENUM(uint32_t, Buffer_Create_Flag){
|
|||
};
|
||||
|
||||
|
||||
/* DOC(TODO)
|
||||
/* DOC(Buffer_Creation_Data is a struct used as a local handle for the creation of a buffer. )
|
||||
HIDE_MEMBERS() */
|
||||
struct Buffer_Creation_Data{
|
||||
STRUCT Buffer_Creation_Data{
|
||||
Buffer_Create_Flag flags;
|
||||
char fname_space [256];
|
||||
int32_t fname_len;
|
||||
|
@ -233,12 +246,7 @@ ENUM(uint32_t, Buffer_Kill_Flag){
|
|||
BufferKill_AlwaysKill = 0x2,
|
||||
};
|
||||
|
||||
/* DOC(An Access_Flag field specifies what sort of permission you grant to an
|
||||
access call. An access call is usually one the returns a summary struct. If a
|
||||
4coder object has a particular protection flag set and the corresponding bit is
|
||||
not set in the access field, that 4coder object is hidden. On the other hand if
|
||||
a protection flag is set in the access parameter and the object does not have
|
||||
that protection flag, the object is still returned from the access call.) */
|
||||
/* DOC(An Access_Flag field specifies what sort of permission you grant to an access call. An access call is usually one the returns a summary struct. If a 4coder object has a particular protection flag set and the corresponding bit is not set in the access field, that 4coder object is hidden. On the other hand if a protection flag is set in the access parameter and the object does not have that protection flag, the object is still returned from the access call.) */
|
||||
ENUM(uint32_t, Access_Flag){
|
||||
/* DOC(AccessOpen does not include any bits, it indicates that the access should
|
||||
only return objects that have no protection flags set.) */
|
||||
|
@ -255,25 +263,19 @@ ENUM(uint32_t, Access_Flag){
|
|||
AccessAll = 0xFF
|
||||
};
|
||||
|
||||
/* DOC(A Dirty_State value describes whether changes have been made to a buffer
|
||||
or to an underlying file since the last sync time between the two. Saving a buffer
|
||||
to it's file or loading the buffer from the file both act as sync points.) */
|
||||
/* DOC(A Dirty_State value describes whether changes have been made to a buffer or to an underlying file since the last sync time between the two. Saving a buffer to it's file or loading the buffer from the file both act as sync points.) */
|
||||
ENUM(uint32_t, Dirty_State){
|
||||
/* DOC(DirtyState_UpToDate indicates that there are no unsaved changes and
|
||||
the underlying system file still agrees with the buffer's state.) */
|
||||
/* DOC(DirtyState_UpToDate indicates that there are no unsaved changes and the underlying system file still agrees with the buffer's state.) */
|
||||
DirtyState_UpToDate = 0,
|
||||
|
||||
/* DOC(DirtyState_UnsavedChanges indicates that there have been changes in the
|
||||
buffer since the last sync point.) */
|
||||
/* DOC(DirtyState_UnsavedChanges indicates that there have been changes in the buffer since the last sync point.) */
|
||||
DirtyState_UnsavedChanges = 1,
|
||||
|
||||
/* DOC(DirtyState_UnsavedChanges indicates that the underlying file has been
|
||||
edited since the last sync point with the buffer.) */
|
||||
/* DOC(DirtyState_UnsavedChanges indicates that the underlying file has been edited since the last sync point with the buffer.) */
|
||||
DirtyState_UnloadedChanges = 2
|
||||
};
|
||||
|
||||
/* DOC(A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the
|
||||
beginning or end of different types of words.) */
|
||||
/* DOC(A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the beginning or end of different types of words.) */
|
||||
ENUM(uint32_t, Seek_Boundary_Flag){
|
||||
BoundaryWhitespace = 0x1,
|
||||
BoundaryToken = 0x2,
|
||||
|
@ -283,34 +285,23 @@ ENUM(uint32_t, Seek_Boundary_Flag){
|
|||
|
||||
/* DOC(A Command_Line_Interface_Flag field specifies the behavior of a call to a command line interface.) */
|
||||
ENUM(uint32_t, Command_Line_Interface_Flag){
|
||||
/* DOC(If CLI_OverlapWithConflict is set if output buffer of the new command is already
|
||||
in use by another command which is still executing, the older command relinquishes control
|
||||
of the buffer and both operate simultaneously with only the newer command outputting to
|
||||
the buffer.) */
|
||||
/* DOC(If CLI_OverlapWithConflict is set if output buffer of the new command is already in use by another command which is still executing, the older command relinquishes control of the buffer and both operate simultaneously with only the newer command outputting to the buffer.) */
|
||||
CLI_OverlapWithConflict = 0x1,
|
||||
/* DOC(If CLI_AlwaysBindToView is set the output buffer will always be set in the active
|
||||
view even if it is already set in another open view.) */
|
||||
/* DOC(If CLI_AlwaysBindToView is set the output buffer will always be set in the active view even if it is already set in another open view.) */
|
||||
CLI_AlwaysBindToView = 0x2,
|
||||
/* DOC(If CLI_CursorAtEnd is set the cursor will be kept at the end of the output buffer,
|
||||
otherwise the cursor is kept at the beginning.) */
|
||||
/* DOC(If CLI_CursorAtEnd is set the cursor will be kept at the end of the output buffer, otherwise the cursor is kept at the beginning.) */
|
||||
CLI_CursorAtEnd = 0x4,
|
||||
};
|
||||
|
||||
/* DOC(An Auto_Indent_Flag field specifies the behavior of an auto indentation operation.) */
|
||||
ENUM(uint32_t, Auto_Indent_Flag){
|
||||
/* DOC(If AutoIndent_ClearLine is set, then any line that is only whitespace will
|
||||
be cleared to contain nothing at all. otherwise the line is filled with whitespace
|
||||
to match the nearby indentation.) */
|
||||
/* DOC(If AutoIndent_ClearLine is set, then any line that is only whitespace will be cleared to contain nothing at all. otherwise the line is filled with whitespace to match the nearby indentation.) */
|
||||
AutoIndent_ClearLine = 0x1,
|
||||
/* DOC(If AutoIndent_UseTab is set, then when putting in leading whitespace to align
|
||||
code, as many tabs will be used as possible until the fine grained control of spaces
|
||||
is needed to finish the alignment.) */
|
||||
/* DOC(If AutoIndent_UseTab is set, then when putting in leading whitespace to align code, as many tabs will be used as possible until the fine grained control of spaces is needed to finish the alignment.) */
|
||||
AutoIndent_UseTab = 0x2,
|
||||
/* DOC(If AutoIndent_ExactAlignBlock is set, then block comments are indented by putting
|
||||
the first non-whitespace character of the line in line with the beginning of the comment.) */
|
||||
/* DOC(If AutoIndent_ExactAlignBlock is set, then block comments are indented by putting the first non-whitespace character of the line in line with the beginning of the comment.) */
|
||||
AutoIndent_ExactAlignBlock = 0x4,
|
||||
/* DOC(If AutoIndent_FullTokens is set, then the set of lines that are indented is
|
||||
automatically expanded so that any token spanning multiple lines gets entirely indented.) */
|
||||
/* DOC(If AutoIndent_FullTokens is set, then the set of lines that are indented is automatically expanded so that any token spanning multiple lines gets entirely indented.) */
|
||||
AutoIndent_FullTokens = 0x8,
|
||||
};
|
||||
|
||||
|
@ -355,8 +346,7 @@ ENUM(int32_t, Mouse_Cursor_Show_Type){
|
|||
// MouseCursorShow_WhenActive,// TODO(allen): coming soon
|
||||
};
|
||||
|
||||
/* DOC(A View_Split_Position specifies where a new view should be placed as a result of
|
||||
a view split operation.) */
|
||||
/* DOC(A View_Split_Position specifies where a new view should be placed as a result of a view split operation.) */
|
||||
ENUM(int32_t, View_Split_Position){
|
||||
/* DOC(This value indicates that the new view should be above the existing view.) */
|
||||
ViewSplit_Top,
|
||||
|
@ -368,52 +358,35 @@ ENUM(int32_t, View_Split_Position){
|
|||
ViewSplit_Right
|
||||
};
|
||||
|
||||
/* DOC(
|
||||
Generic_Command acts as a name for a command, and can name an
|
||||
internal command or a custom command.
|
||||
)*/
|
||||
union Generic_Command{
|
||||
/*DOC(If this Generic_Command represents an internal command the cmdid field
|
||||
will have a value less than cmdid_count, and this field is the command id for the command.)*/
|
||||
/* DOC(Generic_Command acts as a name for a command, and can name an internal command or a custom command.) */
|
||||
UNION Generic_Command{
|
||||
/*DOC(If this Generic_Command represents an internal command the cmdid field will have a value less than cmdid_count, and this field is the command id for the command.)*/
|
||||
Command_ID cmdid;
|
||||
/*DOC(If this Generic_Command does not represent an internal command the command
|
||||
field is the pointer to the custom command..)*/
|
||||
Custom_Command_Function *command;
|
||||
};
|
||||
|
||||
/* DOC(
|
||||
Key_Event_Data describes a key event, including the
|
||||
translation to a character, the translation to
|
||||
a character ignoring the state of caps lock, and
|
||||
an array of all the modifiers that were pressed
|
||||
at the time of the event.
|
||||
)*/
|
||||
struct Key_Event_Data{
|
||||
/* DOC(Key_Event_Data describes a key event, including the translation to a character, the translation to a character ignoring the state of caps lock, and an array of all the modifiers that were pressed at the time of the event.) */
|
||||
STRUCT Key_Event_Data{
|
||||
/* DOC(This field is the raw keycode which is always non-zero in valid key events.) */
|
||||
Key_Code keycode;
|
||||
|
||||
/* DOC(This field is the keycode after translation to a character, this is 0 if there is no translation.) */
|
||||
Key_Code character;
|
||||
|
||||
/* DOC(
|
||||
This field is like the field character, except that the state of caps lock is ignored in the translation.
|
||||
) */
|
||||
/* DOC(This field is like the field character, except that the state of caps lock is ignored in the translation.) */
|
||||
Key_Code character_no_caps_lock;
|
||||
|
||||
/* DOC(
|
||||
This field is an array indicating the state of modifiers at the time of the key press.
|
||||
The array is indexed using the values of Key_Modifier. A 1 indicates that the corresponding
|
||||
modifier was held, and a 0 indicates that it was not held.
|
||||
)
|
||||
/* DOC(This field is an array indicating the state of modifiers at the time of the key press. The array is indexed using the values of Key_Modifier. A 1 indicates that the corresponding modifier was held, and a 0 indicates that it was not held.)
|
||||
|
||||
DOC_SEE(Key_Modifier)
|
||||
*/
|
||||
char modifiers[MDFR_INDEX_COUNT];
|
||||
};
|
||||
|
||||
/* DOC(Mouse_State describes an entire mouse state complete with the
|
||||
position, left and right button states, the wheel state, and whether
|
||||
or not the mouse if in the window.) */
|
||||
struct Mouse_State{
|
||||
/* DOC(Mouse_State describes an entire mouse state complete with the position, left and right button states, the wheel state, and whether or not the mouse if in the window.) */
|
||||
STRUCT Mouse_State{
|
||||
/* DOC(This field indicates that the left button is held.) */
|
||||
char l;
|
||||
/* DOC(This field indicates that the right button is held.) */
|
||||
|
@ -439,21 +412,17 @@ struct Mouse_State{
|
|||
};
|
||||
|
||||
/* DOC(
|
||||
Range describes an integer range typically used for ranges within a buffer.
|
||||
Ranges tend are usually not passed as a Range struct into the API, but this
|
||||
struct is used to return ranges.
|
||||
Range describes an integer range typically used for ranges within a buffer. Ranges tend are usually not passed as a Range struct into the API, but this struct is used to return ranges.
|
||||
|
||||
Throughout the API ranges are thought of in the form [min,max) where max is
|
||||
"one past the end" of the range that is actually read/edited/modified.
|
||||
) */
|
||||
union Range{
|
||||
struct{
|
||||
Throughout the API ranges are thought of in the form [min,max) where max is "one past the end" of the range that is actually read/edited/modified.) */
|
||||
UNION Range{
|
||||
STRUCT{
|
||||
/* DOC(This is the smaller value in the range, it is also the 'start'.) */
|
||||
int32_t min;
|
||||
/* DOC(This is the larger value in the range, it is also the 'end'.) */
|
||||
int32_t max;
|
||||
};
|
||||
struct{
|
||||
STRUCT{
|
||||
/* DOC(This is the start of the range, it is also the 'min'.) */
|
||||
int32_t start;
|
||||
/* DOC(This is the end of the range, it is also the 'max'.) */
|
||||
|
@ -465,7 +434,7 @@ union Range{
|
|||
DOC(File_Info describes the name and type of a file.)
|
||||
DOC_SEE(File_List)
|
||||
*/
|
||||
struct File_Info{
|
||||
STRUCT File_Info{
|
||||
/* DOC(This field is a null terminated string specifying the name of the file.) */
|
||||
char *filename;
|
||||
/* DOC(This field specifies the length of the filename string not counting the null terminator.) */
|
||||
|
@ -475,7 +444,7 @@ struct File_Info{
|
|||
};
|
||||
|
||||
/* DOC(File_List is a list of File_Info structs.) */
|
||||
struct File_List{
|
||||
STRUCT File_List{
|
||||
/* DOC(This field is for inernal use.) */
|
||||
void *block;
|
||||
/* DOC(This field is an array of File_Info structs.) */
|
||||
|
@ -486,26 +455,20 @@ struct File_List{
|
|||
int32_t block_size;
|
||||
};
|
||||
|
||||
/* DOC(
|
||||
Buffer_Identifier acts as a loosely typed description of a buffer that
|
||||
can either be a name or an id. If the
|
||||
) */
|
||||
struct Buffer_Identifier{
|
||||
/* DOC(
|
||||
This field is the name of the buffer; it need not be null terminated.
|
||||
If id is specified this pointer should be NULL.
|
||||
) */
|
||||
/* DOC(Buffer_Identifier acts as a loosely typed description of a buffer that can either be a name or an id.) */
|
||||
STRUCT Buffer_Identifier{
|
||||
/* DOC(This field is the name of the buffer; it need not be null terminated. If id is specified this pointer should be NULL.) */
|
||||
char *name;
|
||||
|
||||
/* DOC(This field specifies the length of the name string.) */
|
||||
int32_t name_len;
|
||||
|
||||
/* DOC(This field is the id of the buffer. If name is specified this should be 0.) */
|
||||
int32_t id;
|
||||
Buffer_ID id;
|
||||
};
|
||||
|
||||
/* DOC(This struct is a part of an incomplete feature.) */
|
||||
struct GUI_Scroll_Vars{
|
||||
STRUCT GUI_Scroll_Vars{
|
||||
/* DOC(TODO) */
|
||||
float scroll_y;
|
||||
/* DOC(TODO) */
|
||||
|
@ -542,32 +505,26 @@ ENUM(int32_t, Buffer_Seek_Type){
|
|||
buffer_seek_line_char
|
||||
};
|
||||
|
||||
/* DOC(Buffer_Seek describes the destination of a seek operation. There are helpers
|
||||
for concisely creating Buffer_Seek structs. They can be found in 4coder_buffer_types.h.)
|
||||
/* DOC(Buffer_Seek describes the destination of a seek operation. There are helpers for concisely creating Buffer_Seek structs. They can be found in 4coder_buffer_types.h.)
|
||||
DOC_SEE(Buffer_Seek_Type)
|
||||
DOC_SEE(4coder_Buffer_Positioning_System)*/
|
||||
struct Buffer_Seek{
|
||||
DOC_SEE(4coder_Buffer_Positioning_System) */
|
||||
STRUCT Buffer_Seek{
|
||||
/* DOC(The type field determines the coordinate system of the seek operation.) */
|
||||
Buffer_Seek_Type type;
|
||||
union{
|
||||
struct {
|
||||
UNION{
|
||||
STRUCT {
|
||||
/* DOC(The pos field specified the pos when the seek is in absolute position.) */
|
||||
int32_t pos;
|
||||
};
|
||||
struct {
|
||||
/* DOC(For xy coordinate seeks, rounding down means that any x in the box of the
|
||||
character lands on that character. For instance when clicking rounding down is the
|
||||
user's expected behavior. Not rounding down means that the right hand portion of
|
||||
the character's box, which is closer to the next character, will land on that next
|
||||
character. The unrounded behavior is the expected behavior when moving vertically
|
||||
and keeping the preferred x.) */
|
||||
STRUCT {
|
||||
/* DOC(For xy coordinate seeks, rounding down means that any x in the box of the character lands on that character. For instance when clicking rounding down is the user's expected behavior. Not rounding down means that the right hand portion of the character's box, which is closer to the next character, will land on that next character. The unrounded behavior is the expected behavior when moving vertically and keeping the preferred x.) */
|
||||
bool32 round_down;
|
||||
/* DOC(The x coordinate for xy type seeks.) */
|
||||
float x;
|
||||
/* DOC(The y coordinate for xy type seeks.) */
|
||||
float y;
|
||||
};
|
||||
struct {
|
||||
STRUCT {
|
||||
/* DOC(The line number of a line-character type seek.) */
|
||||
int32_t line;
|
||||
/* DOC(The character number of a line-character type seek.) */
|
||||
|
@ -576,11 +533,9 @@ struct Buffer_Seek{
|
|||
};
|
||||
};
|
||||
|
||||
/* DOC(Full_Cursor describes the position of a cursor in every buffer
|
||||
coordinate system supported by 4coder. This cursor type requires that
|
||||
the buffer is associated with a view to give the x/y values meaning.)
|
||||
/* DOC(Full_Cursor describes the position of a cursor in every buffer coordinate system supported by 4coder. This cursor type requires that the buffer is associated with a view to give the x/y values meaning.)
|
||||
DOC_SEE(4coder_Buffer_Positioning_System) */
|
||||
struct Full_Cursor{
|
||||
STRUCT Full_Cursor{
|
||||
/* DOC(This field contains the cursor's position in absolute byte index positioning.) */
|
||||
int32_t pos;
|
||||
/* DOC(This field contains the cursor's position in apparent character index positioning.) */
|
||||
|
@ -608,7 +563,7 @@ the coordinate systems that a invariant to the View. In other words
|
|||
the coordinate systems available here can be used on a buffer that is
|
||||
not currently associated with a View.)
|
||||
DOC_SEE(4coder_Buffer_Positioning_System) */
|
||||
struct Partial_Cursor{
|
||||
STRUCT Partial_Cursor{
|
||||
/* DOC(This field contains the cursor's position in absolute byte index positioning.) */
|
||||
int32_t pos;
|
||||
/* DOC(This field contains the number of the character from the beginninf of the line
|
||||
|
@ -621,7 +576,7 @@ struct Partial_Cursor{
|
|||
/* DOC(Buffer_Edit describes a range of a buffer and string to replace that range.
|
||||
A Buffer_Edit has to be paired with a string that contains the actual text that
|
||||
will be replaced into the buffer.) */
|
||||
struct Buffer_Edit{
|
||||
STRUCT Buffer_Edit{
|
||||
/* DOC(The str_start field specifies the first character in the accompanying string that corresponds with this edit.) */
|
||||
int32_t str_start;
|
||||
/* DOC(The len field specifies the length of the string being written into the buffer.) */
|
||||
|
@ -635,7 +590,7 @@ struct Buffer_Edit{
|
|||
/* DOC(Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.)
|
||||
DOC_SEE(Access_Flag)
|
||||
DOC_SEE(Dirty_State) */
|
||||
struct Buffer_Summary{
|
||||
STRUCT Buffer_Summary{
|
||||
/* DOC(This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder.
|
||||
When this field is false the summary is referred to as a "null summary".) */
|
||||
bool32 exists;
|
||||
|
@ -681,7 +636,7 @@ struct Buffer_Summary{
|
|||
/* DOC(View_Summary acts as a handle to a view and describes the state of the view.)
|
||||
DOC_SEE(Access_Flag)
|
||||
DOC_SEE(Full_Cursor) */
|
||||
struct View_Summary{
|
||||
STRUCT View_Summary{
|
||||
/* DOC(
|
||||
This field indicates whether the View_Summary describes a view that is open in 4coder.
|
||||
When this field is false the summary is referred to as a "null summary".
|
||||
|
@ -727,14 +682,14 @@ DOC(User_Input describes a user input event which can be either a key press or m
|
|||
DOC_SEE(User_Input_Type_ID)
|
||||
DOC_SEE(Generic_Command)
|
||||
*/
|
||||
struct User_Input{
|
||||
STRUCT User_Input{
|
||||
/*
|
||||
DOC(This field specifies whether the event was a key press or mouse event.)
|
||||
*/
|
||||
User_Input_Type_ID type;
|
||||
/* DOC(This field indicates that an abort event has occurred and the command needs to shut down.) */
|
||||
bool32 abort;
|
||||
union{
|
||||
UNION{
|
||||
/* DOC(This field describes a key press event.) */
|
||||
Key_Event_Data key;
|
||||
/* DOC(This field describes a mouse input event.) */
|
||||
|
@ -748,7 +703,7 @@ struct User_Input{
|
|||
|
||||
/* DOC(Query_Bar is a struct used to store information in the user's control
|
||||
that will be displayed as a drop down bar durring an interactive command.) */
|
||||
struct Query_Bar{
|
||||
STRUCT Query_Bar{
|
||||
/* DOC(This specifies the prompt portion of the drop down bar.) */
|
||||
String prompt;
|
||||
/* DOC(This specifies the main string portion of the drop down bar.) */
|
||||
|
@ -756,7 +711,7 @@ struct Query_Bar{
|
|||
};
|
||||
|
||||
/* DOC(This feature is not implemented.) */
|
||||
struct Event_Message{
|
||||
STRUCT Event_Message{
|
||||
/* DOC(This feature is not implemented.) */
|
||||
int32_t type;
|
||||
};
|
||||
|
@ -766,7 +721,7 @@ DOC(Theme_Color stores a style tag/color pair, for the purpose of setting and ge
|
|||
DOC_SEE(Style_Tag)
|
||||
DOC_SEE(int_color)
|
||||
*/
|
||||
struct Theme_Color{
|
||||
STRUCT Theme_Color{
|
||||
/* DOC(The style slot in the style palette.) */
|
||||
Style_Tag tag;
|
||||
/* DOC(The color in the slot.) */
|
||||
|
@ -787,7 +742,7 @@ DOC(This struct is used to bundle the parameters of the buffer_batch_edit functi
|
|||
for a few functions that return a batch edit to the user.)
|
||||
DOC_SEE(buffer_batch_edit)
|
||||
*/
|
||||
struct Buffer_Batch_Edit{
|
||||
STRUCT Buffer_Batch_Edit{
|
||||
/* DOC(The pointer to the edit string buffer.) */
|
||||
char *str;
|
||||
/* DOC(The length of the edit string buffer.) */
|
||||
|
|
60
4cpp_lexer.h
60
4cpp_lexer.h
|
@ -12,7 +12,9 @@
|
|||
# define FCPP_LINK static
|
||||
#endif
|
||||
|
||||
#define FCPP_INTERNAL FCPP_LINK
|
||||
#ifndef API_EXPORT
|
||||
#define API_EXPORT
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#if !defined(FSTRING_GUARD)
|
||||
|
@ -150,7 +152,7 @@ static String_And_Flag keywords[] = {
|
|||
};
|
||||
|
||||
|
||||
FCPP_LINK Cpp_Get_Token_Result
|
||||
API_EXPORT FCPP_LINK Cpp_Get_Token_Result
|
||||
cpp_get_token(Cpp_Token_Array array, int32_t pos)/*
|
||||
DOC_PARAM(array, The array of tokens from which to get a token.)
|
||||
DOC_PARAM(pos, The position, measured in bytes, to get the token for.)
|
||||
|
@ -226,7 +228,7 @@ DOC_SEE(Cpp_Get_Token_Result)
|
|||
return(result);
|
||||
}
|
||||
|
||||
FCPP_INTERNAL Cpp_Lex_PP_State
|
||||
FCPP_LINK Cpp_Lex_PP_State
|
||||
cpp_pp_directive_to_state(Cpp_Token_Type type){
|
||||
Cpp_Lex_PP_State result = LSPP_default;
|
||||
switch (type){
|
||||
|
@ -280,7 +282,7 @@ cpp_pp_directive_to_state(Cpp_Token_Type type){
|
|||
|
||||
#define DrReturn(n) { token_array_out->count = token_i; *S_ptr = S; S_ptr->__pc__ = -1; return(n); }
|
||||
|
||||
FCPP_INTERNAL Cpp_Lex_Result
|
||||
FCPP_LINK Cpp_Lex_Result
|
||||
cpp_lex_nonalloc_null_end_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size,
|
||||
Cpp_Token_Array *token_array_out){
|
||||
Cpp_Lex_Data S = *S_ptr;
|
||||
|
@ -888,7 +890,7 @@ cpp_lex_nonalloc_null_end_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t siz
|
|||
#undef DrReturn
|
||||
#undef DrCase
|
||||
|
||||
FCPP_INTERNAL Cpp_Lex_Result
|
||||
FCPP_LINK Cpp_Lex_Result
|
||||
cpp_lex_nonalloc_null_end_out_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size,
|
||||
Cpp_Token_Array *token_array_out, int32_t max_tokens_out){
|
||||
Cpp_Token_Array temp_array = *token_array_out;
|
||||
|
@ -908,7 +910,7 @@ cpp_lex_nonalloc_null_end_out_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t si
|
|||
return(result);
|
||||
}
|
||||
|
||||
FCPP_INTERNAL Cpp_Lex_Result
|
||||
FCPP_LINK Cpp_Lex_Result
|
||||
cpp_lex_nonalloc_no_null_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size, int32_t full_size,
|
||||
Cpp_Token_Array *token_array_out){
|
||||
Cpp_Lex_Result result = 0;
|
||||
|
@ -928,7 +930,7 @@ cpp_lex_nonalloc_no_null_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size
|
|||
return(result);
|
||||
}
|
||||
|
||||
FCPP_INTERNAL Cpp_Lex_Result
|
||||
FCPP_LINK Cpp_Lex_Result
|
||||
cpp_lex_nonalloc_no_null_out_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size, int32_t full_size,
|
||||
Cpp_Token_Array *token_array_out, int32_t max_tokens_out){
|
||||
Cpp_Token_Array temp_stack = *token_array_out;
|
||||
|
@ -953,7 +955,7 @@ cpp_lex_nonalloc_no_null_out_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t siz
|
|||
#define HAS_NULL_TERM ((int32_t)(-1))
|
||||
#define NO_OUT_LIMIT ((int32_t)(-1))
|
||||
|
||||
FCPP_LINK Cpp_Lex_Result
|
||||
API_EXPORT FCPP_LINK Cpp_Lex_Result
|
||||
cpp_lex_step(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size, int32_t full_size, Cpp_Token_Array *token_array_out, int32_t max_tokens_out)/*
|
||||
DOC_PARAM(S_ptr, The lexer state. Go to the Cpp_Lex_Data section to see how to initialize the state.)
|
||||
DOC_PARAM(chunk, The first or next chunk of the file being lexed.)
|
||||
|
@ -1038,7 +1040,7 @@ DOC_SEE(Cpp_Lex_Result)
|
|||
return(result);
|
||||
}
|
||||
|
||||
FCPP_LINK Cpp_Lex_Data
|
||||
API_EXPORT FCPP_LINK Cpp_Lex_Data
|
||||
cpp_lex_data_init()/*
|
||||
DOC_RETURN(A brand new lex state ready to begin lexing a file from the beginning.)
|
||||
|
||||
|
@ -1051,7 +1053,7 @@ as the file being lexed.)
|
|||
return(data);
|
||||
}
|
||||
|
||||
FCPP_LINK int32_t
|
||||
API_EXPORT FCPP_LINK int32_t
|
||||
cpp_lex_data_temp_size(Cpp_Lex_Data *lex_data)/*
|
||||
DOC_PARAM(lex_data, The lex state from which to get the temporary buffer size.)
|
||||
DOC(This call gets the current size of the temporary buffer in the lexer state so
|
||||
|
@ -1064,7 +1066,7 @@ DOC_SEE(cpp_lex_data_new_temp)
|
|||
return(result);
|
||||
}
|
||||
|
||||
FCPP_LINK void
|
||||
API_EXPORT FCPP_LINK void
|
||||
cpp_lex_data_temp_read(Cpp_Lex_Data *lex_data, char *out_buffer)/*
|
||||
DOC_PARAM(lex_data, The lex state from which to read the temporary buffer.)
|
||||
DOC_PARAM(out_buffer, The buffer into which the contents of the temporary buffer will be written.
|
||||
|
@ -1081,16 +1083,16 @@ DOC_SEE(cpp_lex_data_new_temp)
|
|||
}
|
||||
}
|
||||
|
||||
FCPP_LINK void
|
||||
API_EXPORT FCPP_LINK void
|
||||
cpp_lex_data_new_temp_DEP(Cpp_Lex_Data *lex_data, char *new_buffer)
|
||||
/*DOC(Deprecated in 4cpp Lexer 1.0.1*/{}
|
||||
|
||||
FCPP_INTERNAL char
|
||||
FCPP_LINK char
|
||||
cpp_token_get_pp_state(uint16_t bitfield){
|
||||
return (char)(bitfield);
|
||||
}
|
||||
|
||||
FCPP_INTERNAL void
|
||||
FCPP_LINK void
|
||||
cpp_shift_token_starts(Cpp_Token_Array *array, int32_t from_token_i, int32_t shift_amount){
|
||||
Cpp_Token *token = array->tokens + from_token_i;
|
||||
int32_t count = array->count, i = 0;
|
||||
|
@ -1099,7 +1101,7 @@ cpp_shift_token_starts(Cpp_Token_Array *array, int32_t from_token_i, int32_t shi
|
|||
}
|
||||
}
|
||||
|
||||
FCPP_INTERNAL Cpp_Token
|
||||
FCPP_LINK Cpp_Token
|
||||
cpp_index_array(Cpp_Token_Array *array, int32_t file_size, int32_t index){
|
||||
Cpp_Token result;
|
||||
if (index < array->count){
|
||||
|
@ -1115,7 +1117,7 @@ cpp_index_array(Cpp_Token_Array *array, int32_t file_size, int32_t index){
|
|||
return(result);
|
||||
}
|
||||
|
||||
FCPP_LINK Cpp_Relex_Range
|
||||
API_EXPORT FCPP_LINK Cpp_Relex_Range
|
||||
cpp_get_relex_range(Cpp_Token_Array *array, int32_t start_pos, int32_t end_pos)
|
||||
/*
|
||||
DOC_PARAM(array, A pointer to the token array that will be modified by the relex,
|
||||
|
@ -1148,7 +1150,7 @@ The start and end points are based on the edited region of the file before the e
|
|||
return(range);
|
||||
}
|
||||
|
||||
FCPP_LINK Cpp_Relex_Data
|
||||
API_EXPORT FCPP_LINK Cpp_Relex_Data
|
||||
cpp_relex_init(Cpp_Token_Array *array, int32_t start_pos, int32_t end_pos, int32_t character_shift_amount)
|
||||
/*
|
||||
DOC_PARAM(array, A pointer to the token array that will be modified by the relex,
|
||||
|
@ -1192,7 +1194,7 @@ DOC_SEE(cpp_relex_is_start_chunk)
|
|||
return(state);
|
||||
}
|
||||
|
||||
FCPP_LINK int32_t
|
||||
API_EXPORT FCPP_LINK int32_t
|
||||
cpp_relex_start_position(Cpp_Relex_Data *S_ptr)
|
||||
/*
|
||||
DOC_PARAM(S_ptr, A pointer to a state that is done with the first stage of initialization (cpp_relex_init))
|
||||
|
@ -1211,7 +1213,7 @@ DOC_SEE(cpp_relex_declare_first_chunk_position)
|
|||
return(result);
|
||||
}
|
||||
|
||||
FCPP_LINK void
|
||||
API_EXPORT FCPP_LINK void
|
||||
cpp_relex_declare_first_chunk_position(Cpp_Relex_Data *S_ptr, int32_t position)
|
||||
/*
|
||||
DOC_PARAM(S_ptr, A pointer to a state that is done with the first stage of initialization (cpp_relex_init))
|
||||
|
@ -1230,7 +1232,7 @@ DOC_SEE(cpp_relex_start_position)
|
|||
S_ptr->lex.chunk_pos = position;
|
||||
}
|
||||
|
||||
FCPP_LINK int32_t
|
||||
API_EXPORT FCPP_LINK int32_t
|
||||
cpp_relex_is_start_chunk(Cpp_Relex_Data *S_ptr, char *chunk, int32_t chunk_size)
|
||||
/*
|
||||
DOC_PARAM(S_ptr, A pointer to a state that is done with the first stage of initialization (cpp_relex_init))
|
||||
|
@ -1280,7 +1282,7 @@ DOC_SEE(cpp_relex_init)
|
|||
S_ptr->result_state = n; \
|
||||
*S_ptr = S; S_ptr->__pc__ = -1; return(n); }
|
||||
|
||||
FCPP_LINK Cpp_Lex_Result
|
||||
API_EXPORT FCPP_LINK Cpp_Lex_Result
|
||||
cpp_relex_step(Cpp_Relex_Data *S_ptr, char *chunk, int32_t chunk_size, int32_t full_size,
|
||||
Cpp_Token_Array *array, Cpp_Token_Array *relex_array)
|
||||
/*
|
||||
|
@ -1385,7 +1387,7 @@ DOC_SEE(cpp_relex_abort)
|
|||
#undef DrReturn
|
||||
#undef DrCase
|
||||
|
||||
FCPP_LINK int32_t
|
||||
API_EXPORT FCPP_LINK int32_t
|
||||
cpp_relex_get_new_count(Cpp_Relex_Data *S_ptr, int32_t current_count, Cpp_Token_Array *relex_array)
|
||||
/*
|
||||
DOC_PARAM(S_ptr, A pointer to a state that has gone through cpp_relex_step with a LexResult_Finished return.)
|
||||
|
@ -1411,7 +1413,7 @@ the new array, it's capacity should be increased before passing to cpp_relex_com
|
|||
#include <string.h>
|
||||
#endif
|
||||
|
||||
FCPP_INTERNAL void
|
||||
FCPP_LINK void
|
||||
cpp__block_move(void *dst, void *src, int32_t size){
|
||||
#if !defined(FCPP_FORBID_MEMCPY)
|
||||
memmove(dst, src, size);
|
||||
|
@ -1433,7 +1435,7 @@ cpp__block_move(void *dst, void *src, int32_t size){
|
|||
#endif
|
||||
}
|
||||
|
||||
FCPP_LINK void
|
||||
API_EXPORT FCPP_LINK void
|
||||
cpp_relex_complete(Cpp_Relex_Data *S_ptr, Cpp_Token_Array *array, Cpp_Token_Array *relex_array)
|
||||
/*
|
||||
DOC_PARAM(S_ptr, A pointer to a state that has gone through cpp_relex_step with a LexResult_Finished return.)
|
||||
|
@ -1460,7 +1462,7 @@ does the necessary replacement of tokens in the array to make it match the new f
|
|||
sizeof(Cpp_Token)*relex_array->count);
|
||||
}
|
||||
|
||||
FCPP_LINK void
|
||||
API_EXPORT FCPP_LINK void
|
||||
cpp_relex_abort(Cpp_Relex_Data *S_ptr, Cpp_Token_Array *array)
|
||||
/*
|
||||
DOC_PARAM(S_ptr, A pointer to a state that has gone through at least one cpp_relex_step.)
|
||||
|
@ -1480,7 +1482,7 @@ is dead.)
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
FCPP_LINK Cpp_Token_Array
|
||||
API_EXPORT FCPP_LINK Cpp_Token_Array
|
||||
cpp_make_token_array(int32_t starting_max)/*
|
||||
DOC_PARAM(starting_max, The number of tokens to initialize the array with.)
|
||||
DOC_RETURN(An empty Cpp_Token_Array with memory malloc'd for storing tokens.)
|
||||
|
@ -1495,7 +1497,7 @@ used in the convenience functions.)
|
|||
return(token_array);
|
||||
}
|
||||
|
||||
FCPP_LINK void
|
||||
API_EXPORT FCPP_LINK void
|
||||
cpp_free_token_array(Cpp_Token_Array token_array)/*
|
||||
DOC_PARAM(token_array, An array previously allocated by cpp_make_token_array)
|
||||
DOC(This call frees a Cpp_Token_Array.)
|
||||
|
@ -1504,7 +1506,7 @@ DOC_SEE(cpp_make_token_array)
|
|||
free(token_array.tokens);
|
||||
}
|
||||
|
||||
FCPP_LINK void
|
||||
API_EXPORT FCPP_LINK void
|
||||
cpp_resize_token_array(Cpp_Token_Array *token_array, int32_t new_max)/*
|
||||
DOC_PARAM(token_array, An array previously allocated by cpp_make_token_array.)
|
||||
DOC_PARAM(new_max, The new maximum size the array should support. If this is not greater
|
||||
|
@ -1525,7 +1527,7 @@ DOC_SEE(cpp_make_token_array)
|
|||
}
|
||||
}
|
||||
|
||||
FCPP_LINK void
|
||||
API_EXPORT FCPP_LINK void
|
||||
cpp_lex_file(char *data, int32_t size, Cpp_Token_Array *token_array_out)/*
|
||||
DOC_PARAM(data, The file data to be lexed in a single contiguous block.)
|
||||
DOC_PARAM(size, The number of bytes in data.)
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#define ENUM_INTERNAL(type,name) typedef type name; enum name##_
|
||||
#endif
|
||||
|
||||
#ifndef struct_internal
|
||||
#define struct_internal struct
|
||||
#ifndef STRUCT
|
||||
#define STRUCT struct
|
||||
#endif
|
||||
|
||||
/* DOC(A Cpp_Token_Type classifies a token to make parsing easier. Some types are not actually output by the lexer, but exist because parsers will also make use of token types in their own output.) */
|
||||
|
@ -233,7 +233,7 @@ ENUM(uint32_t, Cpp_Token_Type){
|
|||
/* DOC(Cpp_Token represents a single lexed token.
|
||||
It is the primary output of the lexing system.)
|
||||
DOC_SEE(Cpp_Token_Flag) */
|
||||
struct Cpp_Token{
|
||||
STRUCT Cpp_Token{
|
||||
/* DOC(The type field indicates the type of the token.
|
||||
All tokens have a type no matter the circumstances.) */
|
||||
Cpp_Token_Type type;
|
||||
|
@ -275,7 +275,7 @@ ENUM(uint16_t, Cpp_Token_Flag){
|
|||
of a growing array of Cpp_Tokens. To initialize it the tokens field should
|
||||
point to a block of memory with a size equal to max_count*sizeof(Cpp_Token)
|
||||
and the count should be initialized to zero.) */
|
||||
struct Cpp_Token_Array{
|
||||
STRUCT Cpp_Token_Array{
|
||||
/* DOC(The tokens field points to the memory used to store the array of tokens.) */
|
||||
Cpp_Token *tokens;
|
||||
|
||||
|
@ -291,7 +291,7 @@ static Cpp_Token_Array null_cpp_token_array = {0};
|
|||
|
||||
/* DOC(Cpp_Get_Token_Result is the return result of the cpp_get_token call.)
|
||||
DOC_SEE(cpp_get_token) */
|
||||
struct Cpp_Get_Token_Result{
|
||||
STRUCT Cpp_Get_Token_Result{
|
||||
/* DOC(The token_index field indicates which token answers the query. To get the token from
|
||||
the source array CODE_EXAMPLE(array.tokens[result.token_index])) */
|
||||
int32_t token_index;
|
||||
|
@ -311,7 +311,7 @@ struct Cpp_Get_Token_Result{
|
|||
|
||||
/* DOC(Cpp_Relex_Range is the return result of the cpp_get_relex_range call.)
|
||||
DOC_SEE(cpp_get_relex_range) */
|
||||
struct Cpp_Relex_Range{
|
||||
STRUCT Cpp_Relex_Range{
|
||||
/* DOC(The index of the first token in the unedited array that needs to be relexed.) */
|
||||
int32_t start_token_index;
|
||||
/* DOC(The index of the first token in the unedited array after the edited range
|
||||
|
@ -320,7 +320,7 @@ struct Cpp_Relex_Range{
|
|||
int32_t end_token_index;
|
||||
};
|
||||
|
||||
struct_internal Cpp_Lex_FSM{
|
||||
struct Cpp_Lex_FSM{
|
||||
uint8_t state;
|
||||
uint8_t int_state;
|
||||
uint8_t emit_token;
|
||||
|
@ -335,7 +335,7 @@ a new lexer state call cpp_lex_data_init.
|
|||
The internals of the lex state should not be treated as a part of the public API.)
|
||||
DOC_SEE(cpp_lex_data_init)
|
||||
HIDE_MEMBERS() */
|
||||
struct Cpp_Lex_Data{
|
||||
STRUCT Cpp_Lex_Data{
|
||||
char tb[32];
|
||||
int32_t tb_pos;
|
||||
int32_t token_start;
|
||||
|
@ -375,7 +375,7 @@ ENUM(int32_t, Cpp_Lex_Result){
|
|||
To create a new relex state call cpp_relex_init.)
|
||||
DOC_SEE(cpp_relex_init)
|
||||
HIDE_MEMBERS()*/
|
||||
struct Cpp_Relex_Data{
|
||||
STRUCT Cpp_Relex_Data{
|
||||
Cpp_Lex_Data lex;
|
||||
|
||||
Cpp_Token end_token;
|
||||
|
|
10
4ed.cpp
10
4ed.cpp
|
@ -361,6 +361,8 @@ COMMAND_DECL(reopen){
|
|||
|
||||
if (buffer){
|
||||
if (system->load_file(handle, buffer, size)){
|
||||
system->load_close(handle);
|
||||
|
||||
General_Memory *general = &models->mem.general;
|
||||
|
||||
File_Edit_Positions edit_poss[16];
|
||||
|
@ -395,11 +397,15 @@ COMMAND_DECL(reopen){
|
|||
file->settings.unwrapped_lines);
|
||||
}
|
||||
}
|
||||
else{
|
||||
system->load_close(handle);
|
||||
}
|
||||
}
|
||||
else{
|
||||
system->load_close(handle);
|
||||
}
|
||||
|
||||
end_temp_memory(temp);
|
||||
|
||||
system->load_close(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -398,12 +398,9 @@ DOC_PARAM(item_index, This parameter specifies which item to read, 0 is the most
|
|||
DOC_PARAM(out, This parameter provides a buffer where the clipboard contents are written. This parameter may be NULL.)
|
||||
DOC_PARAM(len, This parameter specifies the length of the out buffer.)
|
||||
DOC_RETURN(This call returns the size of the item associated with item_index.)
|
||||
DOC
|
||||
(
|
||||
This function always returns the size of the item even if the output buffer is NULL.
|
||||
If the output buffer is too small to contain the whole string, it is filled with the
|
||||
first len character of the clipboard contents. The output string is not null terminated.
|
||||
)
|
||||
|
||||
DOC(This function always returns the size of the item even if the output buffer is NULL. If the output buffer is too small to contain the whole string, it is filled with the first len character of the clipboard contents. The output string is not null terminated. )
|
||||
|
||||
DOC_SEE(The_4coder_Clipboard)
|
||||
*/{
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
|
@ -423,7 +420,10 @@ DOC_SEE(The_4coder_Clipboard)
|
|||
}
|
||||
|
||||
API_EXPORT int32_t
|
||||
Get_Buffer_Count(Application_Links *app){
|
||||
Get_Buffer_Count(Application_Links *app)
|
||||
/*
|
||||
DOC(Gives the total number of buffers in the application.)
|
||||
*/{
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
Working_Set *working_set = &cmd->models->working_set;
|
||||
int32_t result = working_set->file_count;
|
||||
|
@ -709,21 +709,27 @@ DOC_SEE(Buffer_Batch_Edit_Type)
|
|||
}
|
||||
|
||||
API_EXPORT int32_t
|
||||
Buffer_Get_Setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting){
|
||||
Buffer_Get_Setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out)
|
||||
/*
|
||||
DOC_PARAM(buffer, the buffer from which to read a setting)
|
||||
DOC_PARAM(setting, the setting to read from the buffer)
|
||||
DOC_PARAM(value_out, address to write the setting value on success)
|
||||
DOC_RETURN(returns non-zero on success)
|
||||
*/{
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
Editing_File *file = imp_get_file(cmd, buffer);
|
||||
int32_t result = -1;
|
||||
int32_t result = 0;
|
||||
|
||||
if (file){
|
||||
switch (setting){
|
||||
case BufferSetting_Lex: result = file->settings.tokens_exist; break;
|
||||
case BufferSetting_WrapLine: result = !file->settings.unwrapped_lines; break;
|
||||
case BufferSetting_WrapPosition: result = file->settings.display_width; break;
|
||||
case BufferSetting_MapID: result = file->settings.base_map_id; break;
|
||||
case BufferSetting_Eol: result = file->settings.dos_write_mode; break;
|
||||
case BufferSetting_Unimportant: result = file->settings.unimportant; break;
|
||||
case BufferSetting_ReadOnly: result = file->settings.read_only; break;
|
||||
case BufferSetting_VirtualWhitespace: result = file->settings.virtual_white; break;
|
||||
case BufferSetting_Lex: result = file->settings.tokens_exist; break;
|
||||
case BufferSetting_WrapLine: result = !file->settings.unwrapped_lines; break;
|
||||
case BufferSetting_WrapPosition: result = file->settings.display_width; break;
|
||||
case BufferSetting_MapID: result = file->settings.base_map_id; break;
|
||||
case BufferSetting_Eol: result = file->settings.dos_write_mode; break;
|
||||
case BufferSetting_Unimportant: result = file->settings.unimportant; break;
|
||||
case BufferSetting_ReadOnly: result = file->settings.read_only; break;
|
||||
case BufferSetting_VirtualWhitespace: result = file->settings.virtual_white; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -972,20 +978,61 @@ DOC_SEE(cpp_get_token)
|
|||
return(result);
|
||||
}
|
||||
|
||||
API_EXPORT void
|
||||
Begin_Buffer_Creation(Application_Links *app, Buffer_Creation_Data *data, Buffer_Create_Flag flags){
|
||||
// TODO(allen): Buffer_Creation_Flag
|
||||
API_EXPORT bool32
|
||||
Begin_Buffer_Creation(Application_Links *app, Buffer_Creation_Data *data, Buffer_Create_Flag flags)
|
||||
/*
|
||||
DOC_PARAM(data, a local user handle for the buffer creation process)
|
||||
DOC_PARAM(flags, flags defining the buffer creation behavior)
|
||||
|
||||
DOC(Begins a buffer creation by initializing a Buffer_Creation_Data struct. The buffer is not actually created until end_buffer_creation is called.)
|
||||
|
||||
DOC_SEE(buffer_creation_name)
|
||||
DOC_SEE(end_buffer_creation)
|
||||
|
||||
DOC_SEE(Buffer_Creation_Data)
|
||||
DOC_SEE(Buffer_Create_Flag)
|
||||
*/{
|
||||
bool32 result = 0;
|
||||
if (data){
|
||||
data->flags = flags;
|
||||
result = 1;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
API_EXPORT void
|
||||
Buffer_Creation_Name(Application_Links *app, Buffer_Creation_Data *data, char *filename, int32_t filename_len, uint32_t flags){
|
||||
API_EXPORT bool32
|
||||
Buffer_Creation_Name(Application_Links *app, Buffer_Creation_Data *data, char *filename, int32_t filename_len, uint32_t flags)
|
||||
/*
|
||||
DOC_PARAM(data, a local user handle for buffer creation that has already been initialized by begin_buffer_creation)
|
||||
DOC_PARAM(filename, the name to associate to the buffer; This string need not be null terminated.)
|
||||
DOC_PARAM(filename_len, the length of the filename string)
|
||||
DOC_PARAM(flags, not currently used this should be 0)
|
||||
|
||||
DOC(This call sets the name associated to the buffer. If the name is a filename, that filename will be used for loading and saving with the disk, and the buffer name will be extracted from the filename. If the name is not a filename it will be an unassociated buffer and the buffer name will be exactly set to filename.)
|
||||
|
||||
DOC_SEE(begin_buffer_creation)
|
||||
DOC_SEE(end_buffer_creation)
|
||||
*/{
|
||||
bool32 result = 0;
|
||||
if (data){
|
||||
String fname = make_fixed_width_string(data->fname_space);
|
||||
copy_ss(&fname, make_string(filename, filename_len));
|
||||
data->fname_len = filename_len;
|
||||
result = 1;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
API_EXPORT Buffer_Summary
|
||||
End_Buffer_Creation(Application_Links *app, Buffer_Creation_Data *data){
|
||||
End_Buffer_Creation(Application_Links *app, Buffer_Creation_Data *data)
|
||||
/*
|
||||
DOC_PARAM(data, a local user handle for buffer creation that has already been initialized by begin_buffer_creation and used in subsequent buffer creation flags)
|
||||
|
||||
DOC_RETURN(returns a summary of the newly created buffer or of the existing buffer that already has the specified name. If there is not enough creation data to make the buffer the returned summary will be null.)
|
||||
|
||||
DOC_SEE(begin_buffer_creation)
|
||||
*/{
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
System_Functions *system = cmd->system;
|
||||
Models *models = cmd->models;
|
||||
|
@ -995,7 +1042,7 @@ End_Buffer_Creation(Application_Links *app, Buffer_Creation_Data *data){
|
|||
|
||||
Buffer_Summary result = {0};
|
||||
|
||||
if (data->fname_len > 0){
|
||||
if (data && data->fname_len > 0){
|
||||
String fname = make_string(data->fname_space, data->fname_len);
|
||||
|
||||
Editing_File *file = 0;
|
||||
|
@ -1044,6 +1091,7 @@ End_Buffer_Creation(Application_Links *app, Buffer_Creation_Data *data){
|
|||
}
|
||||
|
||||
if (system->load_file(handle, buffer, size)){
|
||||
system->load_close(handle);
|
||||
file = working_set_alloc_always(system, working_set, general);
|
||||
if (file){
|
||||
buffer_bind_file(system, general, working_set, file, canon.name);
|
||||
|
@ -1052,12 +1100,13 @@ End_Buffer_Creation(Application_Links *app, Buffer_Creation_Data *data){
|
|||
fill_buffer_summary(&result, file, cmd);
|
||||
}
|
||||
}
|
||||
else{
|
||||
system->load_close(handle);
|
||||
}
|
||||
|
||||
if (in_general_mem){
|
||||
general_memory_free(system, general, buffer);
|
||||
}
|
||||
|
||||
system->load_close(handle);
|
||||
}
|
||||
else if (!(flags & BufferCreate_NeverNew)){
|
||||
file = working_set_alloc_always(system, working_set, general);
|
||||
|
@ -1073,114 +1122,7 @@ End_Buffer_Creation(Application_Links *app, Buffer_Creation_Data *data){
|
|||
}
|
||||
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
API_EXPORT Buffer_Summary
|
||||
Create_Buffer_(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags)
|
||||
/*
|
||||
DOC_PARAM(filename, The filename parameter specifies the name of the file to be opened or created;
|
||||
it need not be null terminated.)
|
||||
DOC_PARAM(filename_len, The filename_len parameter spcifies the length of the filename string.)
|
||||
DOC_PARAM(flags, The flags parameter specifies behaviors for buffer creation.)
|
||||
DOC_RETURN(This call returns the summary of the created buffer.)
|
||||
|
||||
DOC(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
|
||||
filename. If the filename corresponds to a file on the disk that file is loaded and put into
|
||||
buffer, if the filename does not correspond to a file on disk the buffer is created empty.)
|
||||
|
||||
DOC_SEE(Buffer_Summary)
|
||||
DOC_SEE(Buffer_Create_Flag)
|
||||
*/{
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
System_Functions *system = cmd->system;
|
||||
Models *models = cmd->models;
|
||||
Working_Set *working_set = &models->working_set;
|
||||
General_Memory *general = &models->mem.general;
|
||||
Partition *part = &models->mem.part;
|
||||
|
||||
Buffer_Summary result = {0};
|
||||
|
||||
String fname = make_string(filename, filename_len);
|
||||
|
||||
Temp_Memory temp = begin_temp_memory(part);
|
||||
|
||||
if (filename != 0){
|
||||
Editing_File *file = 0;
|
||||
b32 do_new_file = 0;
|
||||
Plat_Handle handle = {0};
|
||||
|
||||
Editing_File_Canon_Name canon = {0};
|
||||
if (get_canon_name(system, &canon, fname)){
|
||||
file = working_set_canon_contains(working_set, canon.name);
|
||||
}
|
||||
else{
|
||||
do_new_file = 1;
|
||||
}
|
||||
|
||||
if (!file){
|
||||
file = working_set_name_contains(working_set, fname);
|
||||
}
|
||||
|
||||
if (!file){
|
||||
if (!do_new_file){
|
||||
if (flags & BufferCreate_AlwaysNew){
|
||||
do_new_file = 1;
|
||||
}
|
||||
else{
|
||||
if (!system->load_handle(canon.name.str, &handle)){
|
||||
do_new_file = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!do_new_file){
|
||||
Assert(!handle_equal(handle, handle_zero()));
|
||||
|
||||
i32 size = system->load_size(handle);
|
||||
b32 in_general_mem = 0;
|
||||
char *buffer = push_array(part, char, size);
|
||||
|
||||
if (buffer == 0){
|
||||
buffer = (char*)general_memory_allocate(system, general, size);
|
||||
Assert(buffer != 0);
|
||||
in_general_mem = 1;
|
||||
}
|
||||
|
||||
if (system->load_file(handle, buffer, size)){
|
||||
file = working_set_alloc_always(system, working_set, general);
|
||||
if (file){
|
||||
buffer_bind_file(system, general, working_set, file, canon.name);
|
||||
buffer_bind_name(system, general, working_set, file, fname);
|
||||
init_normal_file(system, models, file, buffer, size);
|
||||
fill_buffer_summary(&result, file, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
if (in_general_mem){
|
||||
general_memory_free(system, general, buffer);
|
||||
}
|
||||
|
||||
system->load_close(handle);
|
||||
}
|
||||
else if (!(flags & BufferCreate_NeverNew)){
|
||||
file = working_set_alloc_always(system, working_set, general);
|
||||
if (file){
|
||||
buffer_bind_name(system, general, working_set, file, fname);
|
||||
init_normal_file(system, models, file, 0, 0);
|
||||
fill_buffer_summary(&result, file, cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
fill_buffer_summary(&result, file, cmd);
|
||||
}
|
||||
}
|
||||
end_temp_memory(temp);
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
@ -1201,14 +1143,16 @@ DOC_RETURN(This call returns non-zero on success.)
|
|||
|
||||
Editing_File *file = imp_get_file(cmd, buffer);
|
||||
if (file){
|
||||
if (file_get_sync(file) != DirtyState_UpToDate){
|
||||
result = true;
|
||||
|
||||
Partition *part = &models->mem.part;
|
||||
Temp_Memory temp = begin_temp_memory(part);
|
||||
String name = make_string_terminated(part, filename, filename_len);
|
||||
save_file_to_name(system, &models->mem, file, name.str);
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
save_file_to_name(system, &models->mem, file, name.str);
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
@ -1588,8 +1532,14 @@ DOC_SEE(get_active_view)
|
|||
return(result);
|
||||
}
|
||||
|
||||
API_EXPORT int32_t
|
||||
View_Get_Setting(Application_Links *app, View_Summary *view, View_Setting_ID setting){
|
||||
API_EXPORT bool32
|
||||
View_Get_Setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t *value_out)
|
||||
/*
|
||||
DOC_PARAM(view, the view from which to read a setting)
|
||||
DOC_PARAM(setting, the view setting to read)
|
||||
DOC_PARAM(value_out, address to write the setting value on success)
|
||||
DOC_RETURN(returns non-zero on success)
|
||||
*/{
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
View *vptr = imp_get_view(cmd, view);
|
||||
int32_t result = -1;
|
||||
|
@ -2104,14 +2054,20 @@ DOC(This call sets the display font of a particular buffer.)
|
|||
}
|
||||
}
|
||||
|
||||
API_EXPORT int32_t
|
||||
API_EXPORT bool32
|
||||
Buffer_Get_Font(Application_Links *app, Buffer_Summary *buffer, char *name_out, int32_t name_max)
|
||||
/*
|
||||
DOC_PARAM(buffer, the buffer from which to get the font name)
|
||||
DOC_PARAM(name_out, a character array in which to write the name of the font)
|
||||
DOC_PARAM(name_max, the capacity of name_out)
|
||||
DOC_RETURN(returns non-zero on success)
|
||||
*/
|
||||
{
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
Models *models = cmd->models;
|
||||
Editing_File *file = imp_get_file(cmd, buffer);
|
||||
|
||||
int32_t result = 0;
|
||||
bool32 result = 0;
|
||||
if (file){
|
||||
Font_Set *set = models->font_set;
|
||||
String name = make_string_cap(name_out, 0, name_max);
|
||||
|
@ -2249,6 +2205,11 @@ DOC(After this call the file list passed in should not be read or written to.)
|
|||
|
||||
API_EXPORT void
|
||||
Set_GUI_Up_Down_Keys(Application_Links *app, int16_t up_key, int16_t down_key)
|
||||
/*
|
||||
DOC_PARAM(up_key, the code of the key that should be interpreted as an up key)
|
||||
DOC_PARAM(down_key, the code of the key that should be interpreted as a down key)
|
||||
|
||||
DOC(This is a temporary ad-hoc solution to allow some customization of the behavior of the built in GUI. There is a high chance that it will be removed and not replaced at some point, so it is not recommended that it be heavily used.) */
|
||||
{
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
Models *models = cmd->models;
|
||||
|
|
|
@ -3792,10 +3792,12 @@ view_open_file(System_Functions *system, Models *models, View *view, String file
|
|||
}
|
||||
|
||||
if (system->load_file(handle, buffer, size)){
|
||||
system->load_close(handle);
|
||||
init_normal_file(system, models, file, buffer, size);
|
||||
}
|
||||
|
||||
else{
|
||||
system->load_close(handle);
|
||||
}
|
||||
|
||||
if (gen_buffer){
|
||||
general_memory_free(system, general, buffer);
|
||||
|
|
2499
4ed_metagen.cpp
2499
4ed_metagen.cpp
File diff suppressed because it is too large
Load Diff
4
Makefile
4
Makefile
|
@ -3,7 +3,7 @@ C_FILES := $(wildcard *.c) $(wildcard **/*.c)
|
|||
H_FILES := $(wildcard *.h) $(wildcard **/*.h)
|
||||
|
||||
WARNINGS := -Wno-write-strings
|
||||
FLAGS := -D_GNU_SOURCE -fPIC
|
||||
FLAGS := -D_GNU_SOURCE -fPIC -fpermissive
|
||||
|
||||
debug: FLAGS += -DDEV_BUILD
|
||||
debug: ../build/build
|
||||
|
@ -12,7 +12,7 @@ package: FLAGS += -DPACKAGE
|
|||
package: ../build/build
|
||||
|
||||
../build/build: $(CPP_FILES) $(C_FILES) $(H_FILES)
|
||||
gcc $(WARNINGS) $(FLAGS) build.cpp -g -o $@
|
||||
g++ $(WARNINGS) $(FLAGS) build.cpp -g -o $@
|
||||
../build/build
|
||||
|
||||
clean:
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
FLAGS := -Wno-write-strings -D_GNU_SOURCE -fno-threadsafe-statics \
|
||||
-pthread -I../foreign -I. -Wno-literal-suffix
|
||||
LIBS := -lX11 -lXfixes -lGL -lrt -ldl -lm -lfreetype -lfontconfig
|
||||
|
||||
# main targets
|
||||
|
||||
debug: FLAGS += -DFRED_SUPER=1 -DFRED_INTERNAL=1 -O0 -g
|
||||
debug: ../4ed ../4ed_app.so ../4coder_custom.so
|
||||
|
||||
super: FLAGS += -DFRED_SUPER=1
|
||||
super: alpha ../4coder_custom.so
|
||||
|
||||
alpha: FLAGS += -O3 -Wl,-s -fno-stack-protector -U_FORTIFY_SOURCE -DFRED_KEEP_ASSERT=1
|
||||
alpha: ../4ed ../4ed_app.so
|
||||
|
||||
# auto-generated dependencies
|
||||
|
||||
-include ../build/*.d
|
||||
|
||||
# file targets
|
||||
|
||||
../build:
|
||||
mkdir $@
|
||||
|
||||
../build/fsmgen: fsm_table_generator.cpp | ../build
|
||||
$(CXX) -MMD $(FLAGS) $< -o $@
|
||||
$@
|
||||
|
||||
../build/metagen: 4ed_metagen.cpp | ../build
|
||||
$(CXX) -MMD $(FLAGS) $< -o $@
|
||||
$@
|
||||
|
||||
../4ed: linux_4ed.cpp ../build/fsmgen ../build/metagen
|
||||
$(CXX) -MMD -MF ../build/4ed.d $(FLAGS) $(shell pkg-config --cflags freetype2) $< -o $@ $(LIBS)
|
||||
|
||||
../4ed_app.so: 4ed_app_target.cpp ../build/fsmgen ../build/metagen
|
||||
$(CXX) -MMD -MF ../build/app.d $(FLAGS) -fPIC -shared $< -o $@
|
||||
|
||||
../4coder_custom.so: power/4coder_experiments.cpp ../build/fsmgen ../build/metagen
|
||||
$(CXX) -MMD -MF ../build/custom.d $(FLAGS) -I. -fPIC -shared $< -o $@
|
||||
|
||||
# cleaning
|
||||
|
||||
clean:
|
||||
$(RM) ../4ed_app.so ../4ed ../4coder_custom.so
|
||||
|
||||
veryclean: clean
|
||||
$(RM) ../build/fsmgen ../build/metagen ../build/*.d
|
||||
|
||||
# packaging
|
||||
|
||||
PACKAGE_FILES := ../4ed ../4ed_app.so README.txt TODO.txt
|
||||
V_MAJ := $(shell grep "define MAJOR" 4coder_version.h | cut -d\ -f 3)
|
||||
V_MIN := $(shell grep "define MINOR" 4coder_version.h | cut -d\ -f 3)
|
||||
V_PCH := $(shell grep "define PATCH" 4coder_version.h | cut -d\ -f 3)
|
||||
|
||||
super_zip: PACKAGE_FILES += ../4coder_custom.so 4coder_*.h 4coder_*.cpp buildsuper.sh
|
||||
super_zip: ../4coder-linux-64-$(V_MAJ)-$(V_MIN)-$(V_PCH)-super.zip
|
||||
alpha_zip: ../4coder-linux-64-$(V_MAJ)-$(V_MIN)-$(V_PCH)-alpha.zip
|
||||
|
||||
../4coder-linux-64-$(V_MAJ)-$(V_MIN)-$(V_PCH)-%.zip: %
|
||||
@echo === Creating $@ ===
|
||||
zip -j $@ $(PACKAGE_FILES)
|
||||
$(MAKE) clean
|
||||
|
||||
package: clean
|
||||
$(MAKE) alpha_zip
|
||||
$(MAKE) super_zip
|
||||
|
||||
.PHONY: debug alpha super all clean veryclean package alpha_zip super_zip
|
|
@ -599,6 +599,10 @@ binary_search(i32 *array, i32 value, i32 l_bound, i32 u_bound){
|
|||
i32 start = l_bound, end = u_bound;
|
||||
i32 i = 0;
|
||||
|
||||
if (value < 0){
|
||||
value = 0;
|
||||
}
|
||||
|
||||
for (;;){
|
||||
i = (start + end) >> 1;
|
||||
if (array[i] < value){
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
call "ctime" -begin 4ed_data.ctm
|
||||
|
||||
SET OPTS=/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /wd4390 /WX
|
||||
SET OPTS=/GR- /EHa- /nologo /FC
|
||||
SET OPTS=%OPTS% /GR- /EHa- /nologo /FC
|
||||
|
||||
SET FirstError=0
|
||||
|
||||
|
|
20
build.cpp
20
build.cpp
|
@ -557,10 +557,13 @@ build_cl(uint32_t flags,
|
|||
}
|
||||
|
||||
|
||||
// NOTE(inso): added ../code to GCC_OPTS to allow metagen to build.
|
||||
// this is currently needed because it is built with cwd ../meta but includes
|
||||
// 4cpp_lexer.h which is in code/ whereas metagen.cpp is in code/site
|
||||
|
||||
#define GCC_OPTS \
|
||||
"-Wno-write-strings -D_GNU_SOURCE -fPIC " \
|
||||
"-fno-threadsafe-statics -pthread"
|
||||
"-fno-threadsafe-statics -pthread -I../code"
|
||||
|
||||
#define GCC_INCLUDES \
|
||||
"-I../foreign"
|
||||
|
@ -823,20 +826,21 @@ do_buildsuper(char *cdir){
|
|||
//terminate_with_null(&str);
|
||||
//buildsuper(cdir, BUILD_DIR, str.str);
|
||||
#if defined(IS_WINDOWS)
|
||||
copy_sc(&str, "../code/internal_4coder_tests.cpp");
|
||||
//copy_sc(&str, "../code/internal_4coder_tests.cpp");
|
||||
//terminate_with_null(&str);
|
||||
//buildsuper(cdir, BUILD_DIR, str.str);
|
||||
copy_sc(&str, "../code/power/4coder_casey.cpp");
|
||||
terminate_with_null(&str);
|
||||
buildsuper(cdir, BUILD_DIR, str.str);
|
||||
//copy_sc(&str, "../4vim/4coder_chronal.cpp");
|
||||
//terminate_with_null(&str);
|
||||
//buildsuper(cdir, BUILD_DIR, str.str);
|
||||
#else
|
||||
copy_sc(&str, "../code/power/4coder_experiments.cpp");
|
||||
terminate_with_null(&str);
|
||||
buildsuper(cdir, BUILD_DIR, str.str);
|
||||
#endif
|
||||
//copy_sc(&str, "../code/power/4coder_casey.cpp");
|
||||
//terminate_with_null(&str);
|
||||
//buildsuper(cdir, BUILD_DIR, str.str);
|
||||
//copy_sc(&str, "../4vim/4coder_chronal.cpp");
|
||||
//terminate_with_null(&str);
|
||||
//buildsuper(cdir, BUILD_DIR, str.str);
|
||||
|
||||
END_TIME_SECTION("build custom");
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -0,0 +1,514 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 25.02.2016
|
||||
*
|
||||
* File editing view for 4coder
|
||||
*
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
#if !defined(ABSTRACT_DOCUMENT_H)
|
||||
#define ABSTRACT_DOCUMENT_H
|
||||
|
||||
#define NotImplemented Assert(!"Not Implemented!")
|
||||
|
||||
// Enriched Text
|
||||
|
||||
struct Enriched_Text{
|
||||
String source;
|
||||
};
|
||||
|
||||
static Enriched_Text
|
||||
load_enriched_text(Partition *part, char *directory, char *filename){
|
||||
Enriched_Text result = {0};
|
||||
|
||||
char space[256];
|
||||
String fname = make_fixed_width_string(space);
|
||||
append_sc(&fname, directory);
|
||||
append_sc(&fname, "\\");
|
||||
append_sc(&fname, filename);
|
||||
terminate_with_null(&fname);
|
||||
|
||||
result.source = file_dump(fname.str);
|
||||
return(result);
|
||||
}
|
||||
|
||||
// Document Declaration
|
||||
|
||||
enum{
|
||||
Doc_Root,
|
||||
Doc_Section,
|
||||
Doc_Todo,
|
||||
Doc_Enriched_Text,
|
||||
Doc_Element_List,
|
||||
Doc_Full_Elements,
|
||||
Doc_Table_Of_Contents
|
||||
};
|
||||
|
||||
struct Document_Item{
|
||||
Document_Item *next;
|
||||
Document_Item *parent;
|
||||
int32_t type;
|
||||
union{
|
||||
struct{
|
||||
Document_Item *first_child;
|
||||
Document_Item *last_child;
|
||||
String name;
|
||||
String id;
|
||||
} section;
|
||||
|
||||
struct{
|
||||
Meta_Unit *unit;
|
||||
} unit_elements;
|
||||
|
||||
struct{
|
||||
Enriched_Text *text;
|
||||
} text;
|
||||
};
|
||||
};
|
||||
static Document_Item null_document_item = {0};
|
||||
|
||||
struct Abstract_Document{
|
||||
// Document value members
|
||||
Document_Item *root_item;
|
||||
|
||||
// Document building members
|
||||
Partition *part;
|
||||
Document_Item *section_stack[16];
|
||||
int32_t section_top;
|
||||
};
|
||||
static Abstract_Document null_abstract_document = {0};
|
||||
|
||||
static void
|
||||
set_section_name(Partition *part, Document_Item *item, char *name){
|
||||
int32_t name_len = str_size(name);
|
||||
item->section.name = make_string_cap(push_array(part, char, name_len+1), 0, name_len+1);
|
||||
partition_align(part, 8);
|
||||
append_sc(&item->section.name, name);
|
||||
}
|
||||
|
||||
static void
|
||||
set_section_id(Partition *part, Document_Item *item, char *id){
|
||||
int32_t id_len = str_size(id);
|
||||
item->section.id = make_string_cap(push_array(part, char, id_len+1), 0, id_len+1);
|
||||
partition_align(part, 8);
|
||||
append_sc(&item->section.id, id);
|
||||
}
|
||||
|
||||
static void
|
||||
begin_document_description(Abstract_Document *doc, Partition *part, char *title){
|
||||
*doc = null_abstract_document;
|
||||
doc->part = part;
|
||||
|
||||
doc->root_item = push_struct(doc->part, Document_Item);
|
||||
*doc->root_item = null_document_item;
|
||||
doc->section_stack[doc->section_top] = doc->root_item;
|
||||
doc->root_item->type = Doc_Root;
|
||||
|
||||
set_section_name(doc->part, doc->root_item, title);
|
||||
}
|
||||
|
||||
static void
|
||||
end_document_description(Abstract_Document *doc){
|
||||
Assert(doc->section_top == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
append_child(Document_Item *parent, Document_Item *item){
|
||||
Assert(parent->type == Doc_Root || parent->type == Doc_Section);
|
||||
if (parent->section.last_child == 0){
|
||||
parent->section.first_child = item;
|
||||
}
|
||||
else{
|
||||
parent->section.last_child->next = item;
|
||||
}
|
||||
parent->section.last_child = item;
|
||||
item->parent = parent;
|
||||
}
|
||||
|
||||
static void
|
||||
begin_section(Abstract_Document *doc, char *title, char *id){
|
||||
Assert(doc->section_top+1 < ArrayCount(doc->section_stack));
|
||||
|
||||
Document_Item *parent = doc->section_stack[doc->section_top];
|
||||
Document_Item *section = push_struct(doc->part, Document_Item);
|
||||
*section = null_document_item;
|
||||
doc->section_stack[++doc->section_top] = section;
|
||||
|
||||
section->type = Doc_Section;
|
||||
|
||||
set_section_name(doc->part, section, title);
|
||||
if (id){
|
||||
set_section_id(doc->part, section, id);
|
||||
}
|
||||
|
||||
append_child(parent, section);
|
||||
}
|
||||
|
||||
static void
|
||||
end_section(Abstract_Document *doc){
|
||||
Assert(doc->section_top > 0);
|
||||
--doc->section_top;
|
||||
}
|
||||
|
||||
static void
|
||||
add_todo(Abstract_Document *doc){
|
||||
Document_Item *parent = doc->section_stack[doc->section_top];
|
||||
Document_Item *item = push_struct(doc->part, Document_Item);
|
||||
*item = null_document_item;
|
||||
item->type = Doc_Todo;
|
||||
|
||||
append_child(parent, item);
|
||||
}
|
||||
|
||||
static void
|
||||
add_element_list(Abstract_Document *doc, Meta_Unit *unit){
|
||||
Document_Item *parent = doc->section_stack[doc->section_top];
|
||||
Document_Item *item = push_struct(doc->part, Document_Item);
|
||||
*item = null_document_item;
|
||||
item->type = Doc_Element_List;
|
||||
item->unit_elements.unit = unit;
|
||||
|
||||
append_child(parent, item);
|
||||
}
|
||||
|
||||
static void
|
||||
add_full_elements(Abstract_Document *doc, Meta_Unit *unit){
|
||||
Document_Item *parent = doc->section_stack[doc->section_top];
|
||||
Document_Item *item = push_struct(doc->part, Document_Item);
|
||||
*item = null_document_item;
|
||||
item->type = Doc_Full_Elements;
|
||||
item->unit_elements.unit = unit;
|
||||
|
||||
append_child(parent, item);
|
||||
}
|
||||
|
||||
static void
|
||||
add_table_of_contents(Abstract_Document *doc){
|
||||
Document_Item *parent = doc->section_stack[doc->section_top];
|
||||
Document_Item *item = push_struct(doc->part, Document_Item);
|
||||
*item = null_document_item;
|
||||
item->type = Doc_Table_Of_Contents;
|
||||
|
||||
append_child(parent, item);
|
||||
}
|
||||
|
||||
static void
|
||||
add_enriched_text(Abstract_Document *doc, Enriched_Text *text){
|
||||
Assert(doc->section_top+1 < ArrayCount(doc->section_stack));
|
||||
|
||||
Document_Item *parent = doc->section_stack[doc->section_top];
|
||||
Document_Item *item = push_struct(doc->part, Document_Item);
|
||||
*item = null_document_item;
|
||||
item->type = Doc_Enriched_Text;
|
||||
item->text.text = text;
|
||||
|
||||
append_child(parent, item);
|
||||
}
|
||||
|
||||
// Document Generation
|
||||
|
||||
#define HTML_BACK_COLOR "#FAFAFA"
|
||||
#define HTML_TEXT_COLOR "#0D0D0D"
|
||||
#define HTML_CODE_BACK "#DFDFDF"
|
||||
#define HTML_EXAMPLE_BACK "#EFEFDF"
|
||||
|
||||
#define HTML_POP_COLOR_1 "#309030"
|
||||
#define HTML_POP_BACK_1 "#E0FFD0"
|
||||
#define HTML_VISITED_LINK "#A0C050"
|
||||
|
||||
#define HTML_POP_COLOR_2 "#005000"
|
||||
|
||||
#define HTML_CODE_STYLE "font-family: \"Courier New\", Courier, monospace; text-align: left;"
|
||||
|
||||
#define HTML_CODE_BLOCK_STYLE(back) \
|
||||
"margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; " \
|
||||
"background: "back"; padding: 0.25em;"
|
||||
|
||||
#define HTML_DESCRIPT_SECTION_STYLE HTML_CODE_BLOCK_STYLE(HTML_CODE_BACK)
|
||||
#define HTML_EXAMPLE_CODE_STYLE HTML_CODE_BLOCK_STYLE(HTML_EXAMPLE_BACK)
|
||||
|
||||
#define HTML_DOC_HEAD_OPEN "<div style='margin-top: 3mm; margin-bottom: 3mm; color: "HTML_POP_COLOR_1";'><b><i>"
|
||||
#define HTML_DOC_HEAD_CLOSE "</i></b></div>"
|
||||
|
||||
#define HTML_DOC_ITEM_HEAD_STYLE "font-weight: 600;"
|
||||
|
||||
#define HTML_DOC_ITEM_HEAD_INL_OPEN "<span style='"HTML_DOC_ITEM_HEAD_STYLE"'>"
|
||||
#define HTML_DOC_ITEM_HEAD_INL_CLOSE "</span>"
|
||||
|
||||
#define HTML_DOC_ITEM_HEAD_OPEN "<div style='"HTML_DOC_ITEM_HEAD_STYLE"'>"
|
||||
#define HTML_DOC_ITEM_HEAD_CLOSE "</div>"
|
||||
|
||||
#define HTML_DOC_ITEM_OPEN "<div style='margin-left: 5mm; margin-right: 5mm;'>"
|
||||
#define HTML_DOC_ITEM_CLOSE "</div>"
|
||||
|
||||
#define HTML_EXAMPLE_CODE_OPEN "<div style='"HTML_CODE_STYLE HTML_EXAMPLE_CODE_STYLE"'>"
|
||||
#define HTML_EXAMPLE_CODE_CLOSE "</div>"
|
||||
|
||||
struct Section_Counter{
|
||||
int32_t counter[16];
|
||||
int32_t nest_level;
|
||||
};
|
||||
|
||||
static void
|
||||
append_section_number(String *out, Section_Counter section_counter){
|
||||
for (int32_t i = 1; i <= section_counter.nest_level; ++i){
|
||||
append_int_to_str(out, section_counter.counter[i]);
|
||||
if (i != section_counter.nest_level){
|
||||
append_sc(out, ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
write_enriched_text_html(String *out, Enriched_Text *text){
|
||||
String source = text->source;
|
||||
|
||||
append_sc(out, "<div>");
|
||||
|
||||
for (String line = get_first_double_line(source);
|
||||
line.str;
|
||||
line = get_next_double_line(source, line)){
|
||||
String l = skip_chop_whitespace(line);
|
||||
append_sc(out, "<p>");
|
||||
|
||||
//append_ss(out, l);
|
||||
int32_t start = 0, i = 0;
|
||||
for (; i < l.size; ++i){
|
||||
if (l.str[i] == '\\'){
|
||||
append_ss(out, substr(l, start, i-start));
|
||||
|
||||
int32_t command_start = i+1;
|
||||
int32_t command_end = command_start;
|
||||
for (; command_end < l.size; ++command_end){
|
||||
if (!char_is_alpha_numeric(l.str[command_end])){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (command_end == command_start){
|
||||
if (command_end < l.size && l.str[command_end] == '\\'){
|
||||
++command_end;
|
||||
}
|
||||
}
|
||||
|
||||
String command_string = substr(l, command_start, command_end - command_start);
|
||||
|
||||
static String enriched_commands[] = {
|
||||
make_lit_string("\\"),
|
||||
make_lit_string("VERSION"),
|
||||
make_lit_string("CODE_STYLE"),
|
||||
};
|
||||
|
||||
int32_t match_index = 0;
|
||||
if (string_set_match(enriched_commands, ArrayCount(enriched_commands), command_string, &match_index)){
|
||||
switch (match_index){
|
||||
case 0: append_sc(out, "\\"); break;
|
||||
case 1: append_sc(out, VERSION); break;
|
||||
case 2: append_sc(out, "<span style='"HTML_CODE_STYLE"'> TEST </span>"); break;
|
||||
}
|
||||
}
|
||||
else{
|
||||
append_sc(out,"<span style='color:#F00'>! Doc generator error: unrecognized command !</span>");
|
||||
fprintf(stderr, "error: Unrecognized command %.*s\n", command_string.size, command_string.str);
|
||||
}
|
||||
|
||||
i = command_end;
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (start != i){
|
||||
append_ss(out, substr(l, start, i-start));
|
||||
}
|
||||
|
||||
append_sc(out, "</p>");
|
||||
}
|
||||
|
||||
append_sc(out, "</div>");
|
||||
}
|
||||
|
||||
static void
|
||||
doc_item_head_html(String *out, Document_Item *item, Section_Counter section_counter){
|
||||
switch (item->type){
|
||||
case Doc_Root:
|
||||
{
|
||||
append_sc(out,
|
||||
"<html lang=\"en-US\">"
|
||||
"<head>"
|
||||
"<title>");
|
||||
|
||||
append_ss(out, item->section.name);
|
||||
|
||||
append_sc(out,
|
||||
"</title>"
|
||||
"<style>"
|
||||
|
||||
"body { "
|
||||
"background: " HTML_BACK_COLOR "; "
|
||||
"color: " HTML_TEXT_COLOR "; "
|
||||
"}"
|
||||
|
||||
// H things
|
||||
"h1,h2,h3,h4 { "
|
||||
"color: " HTML_POP_COLOR_1 "; "
|
||||
"margin: 0; "
|
||||
"}"
|
||||
|
||||
"h2 { "
|
||||
"margin-top: 6mm; "
|
||||
"}"
|
||||
|
||||
"h3 { "
|
||||
"margin-top: 5mm; margin-bottom: 5mm; "
|
||||
"}"
|
||||
|
||||
"h4 { "
|
||||
"font-size: 1.1em; "
|
||||
"}"
|
||||
|
||||
// ANCHORS
|
||||
"a { "
|
||||
"color: " HTML_POP_COLOR_1 "; "
|
||||
"text-decoration: none; "
|
||||
"}"
|
||||
"a:visited { "
|
||||
"color: " HTML_VISITED_LINK "; "
|
||||
"}"
|
||||
"a:hover { "
|
||||
"background: " HTML_POP_BACK_1 "; "
|
||||
"}"
|
||||
|
||||
// LIST
|
||||
"ul { "
|
||||
"list-style: none; "
|
||||
"padding: 0; "
|
||||
"margin: 0; "
|
||||
"}"
|
||||
|
||||
"</style>"
|
||||
"</head>\n"
|
||||
"<body>"
|
||||
"<div style='font-family:Arial; margin: 0 auto; "
|
||||
"width: 800px; text-align: justify; line-height: 1.25;'>");
|
||||
|
||||
|
||||
append_sc(out, "<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>");
|
||||
append_ss(out, item->section.name);
|
||||
append_sc(out, "</h1>");
|
||||
}break;
|
||||
|
||||
case Doc_Section:
|
||||
{
|
||||
if (section_counter.nest_level <= 1){
|
||||
if (item->section.id.size > 0){
|
||||
append_sc(out, "\n<h2 id='section_");
|
||||
append_ss(out, item->section.id);
|
||||
append_sc(out, "'>§");
|
||||
}
|
||||
else{
|
||||
append_sc(out, "\n<h2>§");
|
||||
}
|
||||
append_section_number(out, section_counter);
|
||||
append_sc(out, " ");
|
||||
append_ss(out, item->section.name);
|
||||
append_sc(out, "</h2>");
|
||||
}
|
||||
else{
|
||||
if (item->section.id.size > 0){
|
||||
append_sc(out, "<h3 id='section_");
|
||||
append_ss(out, item->section.id);
|
||||
append_sc(out, "'>§");
|
||||
}
|
||||
else{
|
||||
append_sc(out, "<h3>§");
|
||||
}
|
||||
append_section_number(out, section_counter);
|
||||
append_sc(out, " ");
|
||||
append_ss(out, item->section.name);
|
||||
append_sc(out, "</h3>");
|
||||
}
|
||||
}break;
|
||||
|
||||
case Doc_Enriched_Text:
|
||||
{
|
||||
write_enriched_text_html(out, item->text.text);
|
||||
}break;
|
||||
|
||||
case Doc_Table_Of_Contents:
|
||||
{
|
||||
append_sc(out, "<h3 style='margin:0;'>Table of Contents</h3><ul>");
|
||||
|
||||
int32_t i = 1;
|
||||
for (Document_Item *toc_item = item->parent->section.first_child;
|
||||
toc_item != 0;
|
||||
toc_item = toc_item->next){
|
||||
if (toc_item->type == Doc_Section){
|
||||
if (toc_item->section.id.size > 0){
|
||||
append_sc(out, "<li><a href='#section_");
|
||||
append_ss(out, toc_item->section.id);
|
||||
append_sc(out, "'>§");
|
||||
}
|
||||
else{
|
||||
append_sc(out, "<li>§");
|
||||
}
|
||||
append_int_to_str (out, i);
|
||||
append_s_char (out, ' ');
|
||||
append_ss (out, toc_item->section.name);
|
||||
append_sc (out, "</a></li>");
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
append_sc(out, "</ul>");
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
doc_item_foot_html(String *out, Document_Item *item, Section_Counter section_counter){
|
||||
switch (item->type){
|
||||
case Doc_Root:
|
||||
{
|
||||
append_sc(out, "</div></body></html>");
|
||||
}break;
|
||||
|
||||
case Doc_Section: break;
|
||||
|
||||
case Doc_Table_Of_Contents: break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
generate_item_html(String *out, Document_Item *item, Section_Counter *section_counter){
|
||||
Section_Counter sc = *section_counter;
|
||||
doc_item_head_html(out, item, sc);
|
||||
|
||||
if (item->type == Doc_Root || item->type == Doc_Section){
|
||||
int32_t level = ++section_counter->nest_level;
|
||||
section_counter->counter[level] = 1;
|
||||
for (Document_Item *m = item->section.first_child;
|
||||
m != 0;
|
||||
m = m->next){
|
||||
generate_item_html(out, m, section_counter);
|
||||
}
|
||||
--section_counter->nest_level;
|
||||
++section_counter->counter[section_counter->nest_level];
|
||||
}
|
||||
|
||||
doc_item_foot_html(out, item, sc);
|
||||
}
|
||||
|
||||
static void
|
||||
generate_document_html(String *out, Abstract_Document *doc){
|
||||
Section_Counter section_counter = {0};
|
||||
section_counter.counter[section_counter.nest_level] = 1;
|
||||
generate_item_html(out, doc->root_item, §ion_counter);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// BOTTOM
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
@echo off
|
||||
|
||||
call "ctime" -begin 4ed_site.ctm
|
||||
|
||||
SET OPTS=/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /wd4390 /WX
|
||||
SET OPTS=%OPTS% /GR- /EHa- /nologo /FC
|
||||
SET OPTS=%OPTS% /I..\\..\\code
|
||||
|
||||
|
||||
SET FirstError=0
|
||||
|
||||
pushd ..\..\build\site
|
||||
cl %OPTS% ..\..\code\site\sitegen.cpp /Zi /Fesitegen
|
||||
if %ERRORLEVEL% neq 0 (set FirstError=1)
|
||||
popd
|
||||
|
||||
if %FirstError% neq 1 (
|
||||
..\..\build\site\sitegen.exe .. source_material ..\..\site
|
||||
)
|
||||
if %ERRORLEVEL% neq 0 (set FirstError=1)
|
||||
|
||||
call "ctime" -end 4ed_site.ctm %FirstError%
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 25.02.2016
|
||||
*
|
||||
* File editing view for 4coder
|
||||
*
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
#if !defined(OUT_CONTEXT_4CODER)
|
||||
#define OUT_CONTEXT_4CODER
|
||||
|
||||
typedef struct Out_Context{
|
||||
char out_directory_space[256];
|
||||
String out_directory;
|
||||
FILE *file;
|
||||
String *str;
|
||||
} Out_Context;
|
||||
|
||||
static void
|
||||
set_context_directory(Out_Context *context, char *dst_directory){
|
||||
context->out_directory = make_fixed_width_string(context->out_directory_space);
|
||||
copy_sc(&context->out_directory, dst_directory);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
begin_file_out(Out_Context *out_context, char *filename, String *out){
|
||||
char str_space[512];
|
||||
String name = make_fixed_width_string(str_space);
|
||||
if (out_context->out_directory.size > 0){
|
||||
append_ss(&name, out_context->out_directory);
|
||||
append_sc(&name, "\\");
|
||||
}
|
||||
append_sc(&name, filename);
|
||||
terminate_with_null(&name);
|
||||
|
||||
int32_t r = 0;
|
||||
out_context->file = fopen(name.str, "wb");
|
||||
out_context->str = out;
|
||||
out->size = 0;
|
||||
if (out_context->file){
|
||||
r = 1;
|
||||
}
|
||||
|
||||
return(r);
|
||||
}
|
||||
|
||||
static void
|
||||
dump_file_out(Out_Context out_context){
|
||||
fwrite(out_context.str->str, 1, out_context.str->size, out_context.file);
|
||||
out_context.str->size = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
end_file_out(Out_Context out_context){
|
||||
dump_file_out(out_context);
|
||||
fclose(out_context.file);
|
||||
}
|
||||
|
||||
static String
|
||||
make_out_string(int32_t x){
|
||||
String str;
|
||||
str.size = 0;
|
||||
str.memory_size = x;
|
||||
str.str = (char*)malloc(x);
|
||||
return(str);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,4 @@
|
|||
|
||||
This is the documentation for \VERSION. The documentation is still under construction so some of the links are linking to sections that have not been written yet. What is here should be correct and I suspect useful even without some of the other sections.
|
||||
|
||||
If you have questions or discover errors please contact \CODE_STYLE{editor@4coder.net} or to get help from members of the 4coder and handmade network community you can post on the 4coder forums hosted at \CODE_STYLE{4coder.handmade.network}.
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
This is the documentation for the 4cpp lexer version \VERSION. The documentation is the newest piece of this lexer project so it may still have problems. What is here should be correct and mostly complete.
|
||||
|
||||
If you have questions or discover errors please contact \CODE_STYLE{editor@4coder.net} or to get help from members of the 4coder and handmade network community you can post on the 4coder forums hosted at \CODE_STYLE{4coder.handmade.network}.
|
Loading…
Reference in New Issue