Changed the a lot of stuff over to umem

master
Allen Webster 2017-03-20 02:35:39 -04:00
parent fe7c0fe47e
commit 906f79ef8e
33 changed files with 1141 additions and 1110 deletions

View File

@ -1,15 +1,15 @@
struct Application_Links;
#define EXEC_COMMAND_SIG(n) bool32 n(Application_Links *app, Command_ID command_id)
#define EXEC_SYSTEM_COMMAND_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags)
#define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, int32_t clipboard_id, char *str, int32_t len)
#define CLIPBOARD_COUNT_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id)
#define CLIPBOARD_INDEX_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len)
#define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, int32_t clipboard_id, char *str, size_t len)
#define CLIPBOARD_COUNT_SIG(n) uint32_t n(Application_Links *app, uint32_t clipboard_id)
#define CLIPBOARD_INDEX_SIG(n) size_t n(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, size_t len)
#define GET_BUFFER_COUNT_SIG(n) int32_t n(Application_Links *app)
#define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app, Access_Flag access)
#define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer, Access_Flag access)
#define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, Buffer_ID buffer_id, Access_Flag access)
#define GET_BUFFER_BY_NAME_SIG(n) Buffer_Summary n(Application_Links *app, char *name, int32_t len, Access_Flag access)
#define BUFFER_READ_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out)
#define BUFFER_READ_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, size_t start, size_t end, char *out)
#define BUFFER_REPLACE_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, size_t start, size_t end, char *str, size_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, size_t str_len, Buffer_Edit *edits, uint32_t edit_count, Buffer_Batch_Edit_Type type)
@ -20,8 +20,8 @@ struct Application_Links;
#define BUFFER_GET_SETTING_SIG(n) bool32 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 BUFFER_READ_TOKENS_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, size_t start_token, size_t end_token, Cpp_Token *tokens_out)
#define BUFFER_GET_TOKEN_INDEX_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, size_t pos, Cpp_Get_Token_Result *get_result)
#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)
@ -41,9 +41,9 @@ struct Application_Links;
#define VIEW_SET_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x)
#define VIEW_SET_SCROLL_SIG(n) bool32 n(Application_Links *app, View_Summary *view, GUI_Scroll_Vars scroll)
#define VIEW_SET_MARK_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
#define VIEW_SET_HIGHLIGHT_SIG(n) bool32 n(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on)
#define VIEW_SET_HIGHLIGHT_SIG(n) bool32 n(Application_Links *app, View_Summary *view, size_t start, size_t end, bool32 turn_on)
#define VIEW_SET_BUFFER_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags)
#define VIEW_POST_FADE_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color)
#define VIEW_POST_FADE_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float seconds, size_t start, size_t end, int_color color)
#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type)
#define GET_COMMAND_INPUT_SIG(n) User_Input n(Application_Links *app)
#define GET_MOUSE_STATE_SIG(n) Mouse_State n(Application_Links *app)
@ -369,15 +369,15 @@ app_links->send_exit_signal_ = Send_Exit_Signal;} while(false)
#if defined(ALLOW_DEP_4CODER)
static inline bool32 exec_command(Application_Links *app, Command_ID command_id){return(app->exec_command(app, command_id));}
static inline bool32 exec_system_command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags){return(app->exec_system_command(app, view, buffer, path, path_len, command, command_len, flags));}
static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len){(app->clipboard_post(app, clipboard_id, str, len));}
static inline int32_t clipboard_count(Application_Links *app, int32_t clipboard_id){return(app->clipboard_count(app, clipboard_id));}
static inline int32_t clipboard_index(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len){return(app->clipboard_index(app, clipboard_id, item_index, out, len));}
static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, size_t len){(app->clipboard_post(app, clipboard_id, str, len));}
static inline uint32_t clipboard_count(Application_Links *app, uint32_t clipboard_id){return(app->clipboard_count(app, clipboard_id));}
static inline size_t clipboard_index(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, size_t len){return(app->clipboard_index(app, clipboard_id, item_index, out, len));}
static inline int32_t get_buffer_count(Application_Links *app){return(app->get_buffer_count(app));}
static inline Buffer_Summary get_buffer_first(Application_Links *app, Access_Flag access){return(app->get_buffer_first(app, access));}
static inline void get_buffer_next(Application_Links *app, Buffer_Summary *buffer, Access_Flag access){(app->get_buffer_next(app, buffer, access));}
static inline Buffer_Summary get_buffer(Application_Links *app, Buffer_ID buffer_id, Access_Flag access){return(app->get_buffer(app, buffer_id, access));}
static inline Buffer_Summary get_buffer_by_name(Application_Links *app, char *name, int32_t len, Access_Flag access){return(app->get_buffer_by_name(app, name, len, access));}
static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out){return(app->buffer_read_range(app, buffer, start, end, out));}
static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *buffer, size_t start, size_t end, char *out){return(app->buffer_read_range(app, buffer, start, end, out));}
static inline bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, size_t start, size_t end, char *str, size_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, size_t str_len, Buffer_Edit *edits, uint32_t edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit(app, buffer, str, str_len, edits, edit_count, type));}
@ -388,8 +388,8 @@ static inline bool32 buffer_remove_markers(Application_Links *app, Buffer_Summar
static inline bool32 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 bool32 buffer_read_tokens(Application_Links *app, Buffer_Summary *buffer, size_t start_token, size_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, size_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index(app, buffer, pos, get_result));}
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));}
@ -409,9 +409,9 @@ static inline bool32 view_compute_cursor(Application_Links *app, View_Summary *v
static inline bool32 view_set_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x){return(app->view_set_cursor(app, view, seek, set_preferred_x));}
static inline bool32 view_set_scroll(Application_Links *app, View_Summary *view, GUI_Scroll_Vars scroll){return(app->view_set_scroll(app, view, scroll));}
static inline bool32 view_set_mark(Application_Links *app, View_Summary *view, Buffer_Seek seek){return(app->view_set_mark(app, view, seek));}
static inline bool32 view_set_highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on){return(app->view_set_highlight(app, view, start, end, turn_on));}
static inline bool32 view_set_highlight(Application_Links *app, View_Summary *view, size_t start, size_t end, bool32 turn_on){return(app->view_set_highlight(app, view, start, end, turn_on));}
static inline bool32 view_set_buffer(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags){return(app->view_set_buffer(app, view, buffer_id, flags));}
static inline bool32 view_post_fade(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color){return(app->view_post_fade(app, view, seconds, start, end, color));}
static inline bool32 view_post_fade(Application_Links *app, View_Summary *view, float seconds, size_t start, size_t end, int_color color){return(app->view_post_fade(app, view, seconds, start, end, color));}
static inline User_Input get_user_input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type){return(app->get_user_input(app, get_type, abort_type));}
static inline User_Input get_command_input(Application_Links *app){return(app->get_command_input(app));}
static inline Mouse_State get_mouse_state(Application_Links *app){return(app->get_mouse_state(app));}
@ -441,15 +441,15 @@ static inline void send_exit_signal(Application_Links *app){(app->send_exit_sign
#else
static inline bool32 exec_command(Application_Links *app, Command_ID command_id){return(app->exec_command_(app, command_id));}
static inline bool32 exec_system_command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags){return(app->exec_system_command_(app, view, buffer, path, path_len, command, command_len, flags));}
static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len){(app->clipboard_post_(app, clipboard_id, str, len));}
static inline int32_t clipboard_count(Application_Links *app, int32_t clipboard_id){return(app->clipboard_count_(app, clipboard_id));}
static inline int32_t clipboard_index(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len){return(app->clipboard_index_(app, clipboard_id, item_index, out, len));}
static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, size_t len){(app->clipboard_post_(app, clipboard_id, str, len));}
static inline uint32_t clipboard_count(Application_Links *app, uint32_t clipboard_id){return(app->clipboard_count_(app, clipboard_id));}
static inline size_t clipboard_index(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, size_t len){return(app->clipboard_index_(app, clipboard_id, item_index, out, len));}
static inline int32_t get_buffer_count(Application_Links *app){return(app->get_buffer_count_(app));}
static inline Buffer_Summary get_buffer_first(Application_Links *app, Access_Flag access){return(app->get_buffer_first_(app, access));}
static inline void get_buffer_next(Application_Links *app, Buffer_Summary *buffer, Access_Flag access){(app->get_buffer_next_(app, buffer, access));}
static inline Buffer_Summary get_buffer(Application_Links *app, Buffer_ID buffer_id, Access_Flag access){return(app->get_buffer_(app, buffer_id, access));}
static inline Buffer_Summary get_buffer_by_name(Application_Links *app, char *name, int32_t len, Access_Flag access){return(app->get_buffer_by_name_(app, name, len, access));}
static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out){return(app->buffer_read_range_(app, buffer, start, end, out));}
static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *buffer, size_t start, size_t end, char *out){return(app->buffer_read_range_(app, buffer, start, end, out));}
static inline bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, size_t start, size_t end, char *str, size_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, size_t str_len, Buffer_Edit *edits, uint32_t edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit_(app, buffer, str, str_len, edits, edit_count, type));}
@ -460,8 +460,8 @@ static inline bool32 buffer_remove_markers(Application_Links *app, Buffer_Summar
static inline bool32 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 bool32 buffer_read_tokens(Application_Links *app, Buffer_Summary *buffer, size_t start_token, size_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, size_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index_(app, buffer, pos, get_result));}
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));}
@ -481,9 +481,9 @@ static inline bool32 view_compute_cursor(Application_Links *app, View_Summary *v
static inline bool32 view_set_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x){return(app->view_set_cursor_(app, view, seek, set_preferred_x));}
static inline bool32 view_set_scroll(Application_Links *app, View_Summary *view, GUI_Scroll_Vars scroll){return(app->view_set_scroll_(app, view, scroll));}
static inline bool32 view_set_mark(Application_Links *app, View_Summary *view, Buffer_Seek seek){return(app->view_set_mark_(app, view, seek));}
static inline bool32 view_set_highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on){return(app->view_set_highlight_(app, view, start, end, turn_on));}
static inline bool32 view_set_highlight(Application_Links *app, View_Summary *view, size_t start, size_t end, bool32 turn_on){return(app->view_set_highlight_(app, view, start, end, turn_on));}
static inline bool32 view_set_buffer(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags){return(app->view_set_buffer_(app, view, buffer_id, flags));}
static inline bool32 view_post_fade(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color){return(app->view_post_fade_(app, view, seconds, start, end, color));}
static inline bool32 view_post_fade(Application_Links *app, View_Summary *view, float seconds, size_t start, size_t end, int_color color){return(app->view_post_fade_(app, view, seconds, start, end, color));}
static inline User_Input get_user_input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type){return(app->get_user_input_(app, get_type, abort_type));}
static inline User_Input get_command_input(Application_Links *app){return(app->get_command_input_(app));}
static inline Mouse_State get_mouse_state(Application_Links *app){return(app->get_mouse_state_(app));}

View File

@ -399,15 +399,15 @@ Throughout the API ranges are thought of in the form [min,max) where max is "one
UNION Range{
STRUCT{
/* DOC(This is the smaller value in the range, it is also the 'start'.) */
int32_t min;
size_t min;
/* DOC(This is the larger value in the range, it is also the 'end'.) */
int32_t max;
size_t max;
};
STRUCT{
/* DOC(This is the start of the range, it is also the 'min'.) */
int32_t start;
size_t start;
/* DOC(This is the end of the range, it is also the 'max'.) */
int32_t end;
size_t end;
};
};
@ -482,7 +482,9 @@ ENUM(int32_t, Buffer_Seek_Type){
buffer_seek_unwrapped_xy,
/* DOC(This value indicates line-character positioning.
These coordinates are 1 based to match standard line numbering.) */
buffer_seek_line_char
buffer_seek_line_char,
/* DOC(This value indicates line-character positioning, but with characters counted from the end of the line instead of the beginning, so that 1 is the last character of the line.) */
buffer_seek_line_reverse_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.)
@ -614,7 +616,7 @@ DOC_SEE(buffer_add_markers)
*/
STRUCT Marker{
/* DOC(The current position of the marker measure in absolute byte positioning coordinates.) */
int32_t pos;
size_t pos;
/* DOC(When a marker is inside a range that gets edited, by default the marker 'leans_left' which means it goes to the beginning of the edited range. If the field lean_right is set to true, the marker will lean right with edits and will go to the end of edited range.) */
bool32 lean_right;
};
@ -733,12 +735,12 @@ STRUCT Buffer_Batch_Edit{
/* DOC(The pointer to the edit string buffer.) */
char *str;
/* DOC(The length of the edit string buffer.) */
int32_t str_len;
size_t str_len;
/* DOC(The array of edits to be applied.) */
Buffer_Edit *edits;
/* DOC(The number of edits in the array.) */
int32_t edit_count;
uint32_t edit_count;
};

View File

@ -28,31 +28,29 @@ TYPE: 'drop-in-command-pack'
//
struct Hard_Start_Result{
int32_t char_pos;
size_t char_pos;
int32_t indent_pos;
int32_t all_whitespace;
int32_t all_space;
bool32 all_whitespace;
bool32 all_space;
};
static Hard_Start_Result
buffer_find_hard_start(Application_Links *app, Buffer_Summary *buffer, int32_t line_start, int32_t tab_width){
buffer_find_hard_start(Application_Links *app, Buffer_Summary *buffer, size_t line_start, int32_t tab_width){
Hard_Start_Result result = {0};
char data_chunk[1024];
Stream_Chunk stream = {0};
char c;
tab_width -= 1;
result.all_space = 1;
result.indent_pos = 0;
result.char_pos = line_start;
tab_width -= 1;
char data_chunk[1024];
Stream_Chunk stream = {0};
stream.add_null = 1;
if (init_stream_chunk(&stream, app, buffer, line_start, data_chunk, sizeof(data_chunk))){
int32_t still_looping = 1;
do{
for (; result.char_pos < stream.end; ++result.char_pos){
c = stream.data[result.char_pos];
for (; result.char_pos < (size_t)stream.end; ++result.char_pos){
char c = stream.data[result.char_pos];
if (c == '\n' || c == 0){
result.all_whitespace = 1;
@ -88,26 +86,25 @@ struct Indent_Options{
};
static Buffer_Batch_Edit
make_batch_from_indent_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line_start, int32_t line_end, int32_t *indent_marks, Indent_Options opts){
make_batch_from_indent_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, size_t line_start, size_t line_end, int32_t *indent_marks, Indent_Options opts){
Buffer_Batch_Edit result = {0};
int32_t edit_max = line_end - line_start;
int32_t edit_count = 0;
size_t edit_max = line_end - line_start;
uint32_t edit_count = 0;
Buffer_Edit *edits = push_array(part, Buffer_Edit, edit_max);
char *str_base = (char*)part->base + part->pos;
int32_t str_size = 0;
size_t str_size = 0;
// NOTE(allen): Shift the array so that line_i can just operate in
// it's natural value range.
indent_marks -= line_start;
for (int32_t line_i = line_start; line_i < line_end; ++line_i){
int32_t line_start_pos = buffer_get_line_start(app, buffer, line_i);
Hard_Start_Result hard_start =
buffer_find_hard_start(app, buffer, line_start_pos, opts.tab_width);
for (size_t line_i = line_start; line_i < line_end; ++line_i){
size_t line_start_pos = buffer_get_line_start(app, buffer, line_i);
Hard_Start_Result hard_start = buffer_find_hard_start(app, buffer, line_start_pos, opts.tab_width);
int32_t correct_indentation = indent_marks[line_i];
if (hard_start.all_whitespace && opts.empty_blank_lines){
@ -159,13 +156,12 @@ make_batch_from_indent_marks(Application_Links *app, Partition *part, Buffer_Sum
}
static void
set_line_indents(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line_start, int32_t line_end, int32_t *indent_marks, Indent_Options opts){
set_line_indents(Application_Links *app, Partition *part, Buffer_Summary *buffer, size_t line_start, size_t line_end, int32_t *indent_marks, Indent_Options opts){
Buffer_Batch_Edit batch =
make_batch_from_indent_marks(app, part, buffer, line_start, line_end, indent_marks, opts);
if (batch.edit_count > 0){
buffer_batch_edit(app, buffer, batch.str, batch.str_len,
batch.edits, batch.edit_count, BatchEdit_PreserveTokens);
buffer_batch_edit(app, buffer, batch.str, batch.str_len, batch.edits, batch.edit_count, BatchEdit_PreserveTokens);
}
}
@ -196,7 +192,7 @@ seek_matching_token_backwards(Cpp_Token_Array tokens, Cpp_Token *token, Cpp_Toke
}
static Cpp_Token*
find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t line_start, int32_t tab_width, int32_t *current_indent_out){
find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, size_t line_start, int32_t tab_width, int32_t *current_indent_out){
Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_start);
if (token == 0 && tokens.count == 0){
@ -224,8 +220,8 @@ find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Arra
int32_t current_indent = 0;
int32_t found_safe_start_position = 0;
do{
int32_t line = buffer_get_line_index(app, buffer, token->start);
int32_t start = buffer_get_line_start(app, buffer, line);
size_t line = buffer_get_line_index(app, buffer, token->start);
size_t start = buffer_get_line_start(app, buffer, line);
Hard_Start_Result hard_start = buffer_find_hard_start(app, buffer, start, tab_width);
current_indent = hard_start.indent_pos;
@ -298,32 +294,30 @@ struct Indent_Parse_State{
};
static int32_t*
get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t line_start, int32_t line_end, bool32 exact_align, int32_t tab_width){
get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, Cpp_Token_Array tokens, size_t line_start, size_t line_end, bool32 exact_align, int32_t tab_width){
int32_t indent_mark_count = line_end - line_start;
size_t indent_mark_count = line_end - line_start;
int32_t *indent_marks = push_array(part, int32_t, indent_mark_count);
// Shift the array so line_index works correctly.
indent_marks -= line_start;
// Decide where to start indentation parsing.
Indent_Parse_State indent = {0};
Cpp_Token *token_ptr = find_anchor_token(app, buffer, tokens, line_start,
tab_width, &indent.current_indent);
Cpp_Token *token_ptr = find_anchor_token(app, buffer, tokens, line_start, tab_width, &indent.current_indent);
if (token_ptr == 0){
for (int32_t line_index = line_start; line_index < line_end; ++line_index){
for (size_t line_index = line_start; line_index < line_end; ++line_index){
indent_marks[line_index] = 0;
}
}
else{
int32_t line_index = buffer_get_line_index(app, buffer, token_ptr->start);
size_t line_index = buffer_get_line_index(app, buffer, token_ptr->start);
if (line_index > line_start){
line_index = line_start;
}
uint32_t next_line_start_pos = buffer_get_line_start(app, buffer, line_index+1);
size_t next_line_start_pos = buffer_get_line_start(app, buffer, line_index+1);
switch (token_ptr->type){
case CPP_TOKEN_BRACKET_OPEN: indent.current_indent += tab_width; break;
@ -353,8 +347,8 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
{
int32_t previous_indent = indent.previous_line_indent;
uint32_t this_line_start = buffer_get_line_start(app, buffer, line_index);
uint32_t next_line_start = buffer_get_line_start(app, buffer, line_index+1);
size_t this_line_start = buffer_get_line_start(app, buffer, line_index);
size_t next_line_start = buffer_get_line_start(app, buffer, line_index+1);
bool32 did_special_behavior = false;
@ -370,7 +364,7 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
this_indent = previous_indent;
}
else{
int32_t line_pos = hard_start.char_pos - this_line_start;
uint32_t line_pos = (uint32_t)(hard_start.char_pos - this_line_start);
this_indent = line_pos + indent.comment_shift;
if (this_indent < 0){
this_indent = 0;
@ -462,24 +456,24 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
case CPP_TOKEN_COMMENT:
{
int32_t line = buffer_get_line_index(app, buffer, token.start);
int32_t start = buffer_get_line_start(app, buffer, line);
indent.comment_shift = (indent.current_indent - (token.start - start));
indent.previous_comment_indent = (token.start - start);
size_t line = buffer_get_line_index(app, buffer, token.start);
size_t start = buffer_get_line_start(app, buffer, line);
int32_t char_pos = (int32_t)(token.start - start);
indent.comment_shift = (indent.current_indent - char_pos);
indent.previous_comment_indent = char_pos;
}break;
case CPP_TOKEN_PARENTHESE_OPEN:
if (!(token.flags & CPP_TFLAG_PP_BODY)){
if (indent.paren_nesting < ArrayCount(indent.paren_anchor_indent)){
int32_t line = buffer_get_line_index(app, buffer, token.start);
int32_t start = buffer_get_line_start(app, buffer, line);
int32_t char_pos = token.start - start;
size_t line = buffer_get_line_index(app, buffer, token.start);
size_t start = buffer_get_line_start(app, buffer, line);
int32_t char_pos = (int32_t)(token.start - start);
Hard_Start_Result hard_start =
buffer_find_hard_start(app, buffer, start, tab_width);
int32_t line_pos = hard_start.char_pos - start;
int32_t line_pos = (int32_t)(hard_start.char_pos - start);
indent.paren_anchor_indent[indent.paren_nesting] =
char_pos - line_pos + indent.previous_line_indent + 1;
@ -505,25 +499,21 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
}
static void
get_indent_lines_minimum(Application_Links *app, Buffer_Summary *buffer,
int32_t start_pos, int32_t end_pos,
int32_t *line_start_out, int32_t *line_end_out){
int32_t line_start = buffer_get_line_index(app, buffer, start_pos);
int32_t line_end = buffer_get_line_index(app, buffer, end_pos) + 1;
get_indent_lines_minimum(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, size_t end_pos, size_t *line_start_out, size_t *line_end_out){
size_t line_start = buffer_get_line_index(app, buffer, start_pos);
size_t line_end = buffer_get_line_index(app, buffer, end_pos) + 1;
*line_start_out = line_start;
*line_end_out = line_end;
}
static void
get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens,
int32_t start_pos, int32_t end_pos,
int32_t *line_start_out, int32_t *line_end_out){
int32_t line_start = buffer_get_line_index(app, buffer, start_pos);
int32_t line_end = buffer_get_line_index(app, buffer, end_pos);
get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, size_t start_pos, size_t end_pos, size_t *line_start_out, size_t *line_end_out){
size_t line_start = buffer_get_line_index(app, buffer, start_pos);
size_t line_end = buffer_get_line_index(app, buffer, end_pos);
for (;line_start > 0;){
uint32_t line_start_pos = 0;
size_t line_start_pos = 0;
Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_start, &line_start_pos);
if (token != 0 && token->start < line_start_pos){
line_start = buffer_get_line_index(app, buffer, token->start);
@ -534,7 +524,7 @@ get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cp
}
for (;line_end+1 < buffer->line_count;){
uint32_t next_line_start_pos = 0;
size_t next_line_start_pos = 0;
Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_end+1, &next_line_start_pos);
if (token && token->start < next_line_start_pos){
line_end = buffer_get_line_index(app, buffer, token->start+token->size);
@ -555,12 +545,11 @@ get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cp
}
static bool32
buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buffer,
int32_t start, int32_t end, int32_t tab_width, Auto_Indent_Flag flags){
buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buffer, size_t start, size_t end, int32_t tab_width, Auto_Indent_Flag flags){
bool32 result = 0;
bool32 result = false;
if (buffer->exists && buffer->tokens_are_ready){
result = 1;
result = true;
Temp_Memory temp = begin_temp_memory(part);
@ -573,7 +562,7 @@ buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buff
// Stage 2: Decide where the first and last lines are.
// The lines in the range [line_start,line_end) will be indented.
int32_t line_start = 0, line_end = 0;
size_t line_start = 0, line_end = 0;
if (flags & AutoIndent_FullTokens){
get_indent_lines_whole_tokens(app, buffer, tokens, start, end, &line_start, &line_end);
}
@ -585,8 +574,7 @@ buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buff
// Get an array representing how much each line in
// the range [line_start,line_end) should be indented.
int32_t *indent_marks =
get_indentation_marks(app, part, buffer, tokens, line_start, line_end,
(flags & AutoIndent_ExactAlignBlock), tab_width);
get_indentation_marks(app, part, buffer, tokens, line_start, line_end, (flags & AutoIndent_ExactAlignBlock), tab_width);
// Stage 4: Set the Line Indents
Indent_Options opts = {0};
@ -603,8 +591,7 @@ buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buff
}
static bool32
buffer_auto_indent(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end,
int32_t tab_width, Auto_Indent_Flag flags){
buffer_auto_indent(Application_Links *app, Buffer_Summary *buffer, size_t start, size_t end, int32_t tab_width, Auto_Indent_Flag flags){
bool32 result = buffer_auto_indent(app, &global_part, buffer, start, end, tab_width, flags);
return(result);
}

View File

@ -33,7 +33,7 @@ CUSTOM_COMMAND_SIG(write_character){
if (length != 0){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = view.cursor.pos;
size_t pos = view.cursor.pos;
Marker next_cursor_marker = {0};
next_cursor_marker.pos = character_pos_to_pos(app, &view, &buffer, view.cursor.character_pos);
@ -56,11 +56,12 @@ CUSTOM_COMMAND_SIG(delete_char){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start = view.cursor.pos;
Buffer_Seek seek = seek_character_pos(view.cursor.character_pos+1);
Full_Cursor cursor;
view_compute_cursor(app, &view, seek_character_pos(view.cursor.character_pos+1), &cursor);
int32_t end = cursor.pos;
view_compute_cursor(app, &view, seek, &cursor);
size_t start = view.cursor.pos;
size_t end = cursor.pos;
if (0 <= start && start < buffer.size){
buffer_replace_range(app, &buffer, start, end, 0, 0);
@ -72,15 +73,17 @@ CUSTOM_COMMAND_SIG(backspace_char){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t end = view.cursor.pos;
Buffer_Seek seek = seek_character_pos(view.cursor.character_pos-1);
Full_Cursor cursor;
view_compute_cursor(app, &view, seek_character_pos(view.cursor.character_pos-1), &cursor);
int32_t start = cursor.pos;
view_compute_cursor(app, &view, seek, &cursor);
size_t end = view.cursor.pos;
size_t start = cursor.pos;
if (0 < end && end <= buffer.size){
buffer_replace_range(app, &buffer, start, end, 0, 0);
view_set_cursor(app, &view, seek_character_pos(view.cursor.character_pos-1), true);
seek = seek_character_pos(view.cursor.character_pos-1);
view_set_cursor(app, &view, seek, true);
}
}
@ -94,8 +97,8 @@ CUSTOM_COMMAND_SIG(set_mark){
CUSTOM_COMMAND_SIG(cursor_mark_swap){
View_Summary view = get_active_view(app, AccessProtected);
int32_t cursor = view.cursor.pos;
int32_t mark = view.mark.pos;
size_t cursor = view.cursor.pos;
size_t mark = view.mark.pos;
view_set_cursor(app, &view, seek_pos(mark), true);
view_set_mark(app, &view, seek_pos(cursor));
@ -247,14 +250,14 @@ CUSTOM_COMMAND_SIG(page_down){
CUSTOM_COMMAND_SIG(move_left){
uint32_t access = AccessProtected;
View_Summary view = get_active_view(app, access);
int32_t new_pos = view.cursor.character_pos - 1;
size_t new_pos = view.cursor.character_pos - 1;
view_set_cursor(app, &view, seek_character_pos(new_pos), 1);
}
CUSTOM_COMMAND_SIG(move_right){
uint32_t access = AccessProtected;
View_Summary view = get_active_view(app, access);
int32_t new_pos = view.cursor.character_pos + 1;
size_t new_pos = view.cursor.character_pos + 1;
view_set_cursor(app, &view, seek_character_pos(new_pos), 1);
}
@ -274,7 +277,7 @@ CUSTOM_COMMAND_SIG(seek_whitespace_up){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = buffer_seek_whitespace_up(app, &buffer, view.cursor.pos);
size_t new_pos = buffer_seek_whitespace_up(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -283,7 +286,7 @@ CUSTOM_COMMAND_SIG(seek_whitespace_down){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = buffer_seek_whitespace_down(app, &buffer, view.cursor.pos);
size_t new_pos = buffer_seek_whitespace_down(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -292,7 +295,7 @@ CUSTOM_COMMAND_SIG(seek_end_of_textual_line){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = seek_line_end(app, &buffer, view.cursor.pos);
size_t new_pos = seek_line_end(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -301,7 +304,7 @@ CUSTOM_COMMAND_SIG(seek_beginning_of_textual_line){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = seek_line_beginning(app, &buffer, view.cursor.pos);
size_t new_pos = seek_line_beginning(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -347,7 +350,7 @@ CUSTOM_COMMAND_SIG(to_uppercase){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
Range range = get_range(&view);
int32_t size = range.max - range.min;
size_t size = range.max - range.min;
if (size <= app->memory_size){
char *mem = (char*)app->memory;
@ -365,7 +368,7 @@ CUSTOM_COMMAND_SIG(to_lowercase){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
Range range = get_range(&view);
int32_t size = range.max - range.min;
size_t size = range.max - range.min;
if (size <= app->memory_size){
char *mem = (char*)app->memory;
@ -565,7 +568,7 @@ CUSTOM_COMMAND_SIG(search);
CUSTOM_COMMAND_SIG(reverse_search);
static void
isearch(Application_Links *app, int32_t start_reversed){
isearch(Application_Links *app, bool32 start_reversed){
uint32_t access = AccessProtected;
View_Summary view = get_active_view(app, access);
@ -576,10 +579,10 @@ isearch(Application_Links *app, int32_t start_reversed){
Query_Bar bar = {0};
if (start_query_bar(app, &bar, 0) == 0) return;
int32_t reverse = start_reversed;
int32_t pos = view.cursor.pos;
int32_t start_pos = pos;
int32_t first_pos = pos;
bool32 reverse = start_reversed;
size_t pos = view.cursor.pos;
size_t start_pos = pos;
size_t first_pos = pos;
Range match = make_range(pos, pos);
char bar_string_space[256];
@ -642,16 +645,16 @@ isearch(Application_Links *app, int32_t start_reversed){
}
if (in.key.keycode != key_back){
int32_t new_pos;
char *str = bar.string.str;
size_t str_size = bar.string.size;
size_t new_pos = 0;
if (reverse){
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0,
bar.string.str, bar.string.size, &new_pos);
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0, str, str_size, &new_pos);
if (new_pos >= 0){
if (step_backward){
pos = new_pos;
start_pos = new_pos;
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0,
bar.string.str, bar.string.size, &new_pos);
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0, str, str_size, &new_pos);
if (new_pos < 0) new_pos = start_pos;
}
match.start = new_pos;
@ -659,14 +662,13 @@ isearch(Application_Links *app, int32_t start_reversed){
}
}
else{
buffer_seek_string_insensitive_forward(app, &buffer, start_pos + 1, 0,
bar.string.str, bar.string.size, &new_pos);
buffer_seek_string_insensitive_forward(app, &buffer, start_pos + 1, 0, str, str_size, &new_pos);
if (new_pos < buffer.size){
if (step_forward){
pos = new_pos;
start_pos = new_pos;
buffer_seek_string_insensitive_forward(app, &buffer, start_pos + 1, 0,
bar.string.str, bar.string.size, &new_pos);
str, str_size, &new_pos);
if (new_pos >= buffer.size) new_pos = start_pos;
}
match.start = new_pos;
@ -721,9 +723,8 @@ CUSTOM_COMMAND_SIG(replace_in_range){
Range range = get_range(&view);
int32_t pos, new_pos;
pos = range.min;
size_t pos = range.min;
size_t new_pos = 0;
buffer_seek_string_forward(app, &buffer, pos, 0, r.str, r.size, &new_pos);
while (new_pos + r.size <= range.end){
@ -751,25 +752,21 @@ CUSTOM_COMMAND_SIG(query_replace){
if (!query_user_string(app, &with)) return;
String r, w;
r = replace.string;
w = with.string;
String r = replace.string;
String w = with.string;
Query_Bar bar;
Buffer_Summary buffer;
View_Summary view;
int32_t pos, new_pos;
bar.prompt = make_lit_string("Replace? (y)es, (n)ext, (esc)\n");
bar.string = null_string;
start_query_bar(app, &bar, 0);
uint32_t access = AccessOpen;
view = get_active_view(app, access);
buffer = get_buffer(app, view.buffer_id, access);
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
pos = view.cursor.pos;
size_t pos = view.cursor.pos;
size_t new_pos = 0;
buffer_seek_string_forward(app, &buffer, pos, 0, r.str, r.size, &new_pos);
User_Input in = {0};

View File

@ -14,14 +14,14 @@ TYPE: 'drop-in-command-pack'
#include "4coder_helper/4coder_helper.h"
static bool32
clipboard_copy(Application_Links *app, int32_t start, int32_t end, Buffer_Summary *buffer_out, uint32_t access){
clipboard_copy(Application_Links *app, size_t start, size_t end, Buffer_Summary *buffer_out, uint32_t access){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
bool32 result = 0;
if (buffer.exists){
if (0 <= start && start <= end && end <= buffer.size){
int32_t size = (end - start);
size_t size = (end - start);
char *str = (char*)app->memory;
if (size <= app->memory_size){
@ -36,14 +36,16 @@ clipboard_copy(Application_Links *app, int32_t start, int32_t end, Buffer_Summar
return(result);
}
static int32_t
clipboard_cut(Application_Links *app, int32_t start, int32_t end, Buffer_Summary *buffer_out, uint32_t access){
static bool32
clipboard_cut(Application_Links *app, size_t start, size_t end, Buffer_Summary *buffer_out, uint32_t access){
Buffer_Summary buffer = {0};
int32_t result = false;
bool32 result = false;
if (clipboard_copy(app, start, end, &buffer, access)){
buffer_replace_range(app, &buffer, start, end, 0, 0);
if (buffer_out){*buffer_out = buffer;}
if (buffer_out){
*buffer_out = buffer;
}
}
return(result);
@ -74,7 +76,7 @@ CUSTOM_COMMAND_SIG(paste){
int32_t paste_index = 0;
view_paste_index[view.view_id].index = paste_index;
int32_t len = clipboard_index(app, 0, paste_index, 0, 0);
size_t len = clipboard_index(app, 0, paste_index, 0, 0);
char *str = 0;
if (len <= app->memory_size){
@ -85,7 +87,7 @@ CUSTOM_COMMAND_SIG(paste){
clipboard_index(app, 0, paste_index, str, len);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = view.cursor.pos;
size_t pos = view.cursor.pos;
buffer_replace_range(app, &buffer, pos, pos, str, len);
view_set_mark(app, &view, seek_pos(pos));
view_set_cursor(app, &view, seek_pos(pos + len), true);
@ -111,7 +113,7 @@ CUSTOM_COMMAND_SIG(paste_next){
int32_t paste_index = view_paste_index[view.view_id].index + 1;
view_paste_index[view.view_id].index = paste_index;
int32_t len = clipboard_index(app, 0, paste_index, 0, 0);
size_t len = clipboard_index(app, 0, paste_index, 0, 0);
char *str = 0;
if (len <= app->memory_size){
@ -123,7 +125,7 @@ CUSTOM_COMMAND_SIG(paste_next){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
Range range = get_range(&view);
int32_t pos = range.min;
size_t pos = range.min;
buffer_replace_range(app, &buffer, range.min, range.max, str, len);
view_set_cursor(app, &view, seek_pos(pos + len), true);

View File

@ -42,9 +42,9 @@ TYPE: 'major-system-include'
// Seeks Using Default Framework Memory
//
static int32_t
buffer_boundary_seek(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags){
int32_t result = buffer_boundary_seek(app, buffer, &global_part, start_pos, seek_forward, flags);
static size_t
buffer_boundary_seek(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags){
size_t result = buffer_boundary_seek(app, buffer, &global_part, start_pos, seek_forward, flags);
return(result);
}
@ -53,7 +53,7 @@ basic_seek(Application_Links *app, int32_t seek_type, uint32_t flags){
uint32_t access = AccessProtected;
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_type, flags);
size_t pos = buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_type, flags);
view_set_cursor(app, &view, seek_pos(pos), true);
}
@ -85,12 +85,10 @@ CUSTOM_COMMAND_SIG(backspace_word){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
if (buffer.exists){
int32_t pos2 = 0, pos1 = 0;
pos2 = view.cursor.pos;
size_t pos2 = view.cursor.pos;
exec_command(app, seek_alphanumeric_left);
refresh_view(app, &view);
pos1 = view.cursor.pos;
size_t pos1 = view.cursor.pos;
buffer_replace_range(app, &buffer, pos1, pos2, 0, 0);
}
@ -103,12 +101,10 @@ CUSTOM_COMMAND_SIG(delete_word){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
if (buffer.exists){
int32_t pos2 = 0, pos1 = 0;
pos1 = view.cursor.pos;
size_t pos1 = view.cursor.pos;
exec_command(app, seek_alphanumeric_right);
refresh_view(app, &view);
pos2 = view.cursor.pos;
size_t pos2 = view.cursor.pos;
buffer_replace_range(app, &buffer, pos1, pos2, 0, 0);
}
@ -116,12 +112,11 @@ CUSTOM_COMMAND_SIG(delete_word){
CUSTOM_COMMAND_SIG(snipe_token_or_word){
uint32_t access = AccessOpen;
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos1 = buffer_boundary_seek(app, &buffer, view.cursor.pos, 0, BoundaryToken | BoundaryWhitespace);
int32_t pos2 = buffer_boundary_seek(app, &buffer, pos1, 1, BoundaryToken | BoundaryWhitespace);
size_t pos1 = buffer_boundary_seek(app, &buffer, view.cursor.pos, 0, BoundaryToken | BoundaryWhitespace);
size_t pos2 = buffer_boundary_seek(app, &buffer, pos1, 1, BoundaryToken | BoundaryWhitespace);
Range range = make_range(pos1, pos2);
buffer_replace_range(app, &buffer, range.start, range.end, 0, 0);
@ -146,7 +141,7 @@ CUSTOM_COMMAND_SIG(duplicate_line){
++line_string.memory_size;
append_s_char(&line_string, '\n');
int32_t pos = buffer_get_line_end(app, &buffer, view.cursor.line) + 1;
size_t pos = buffer_get_line_end(app, &buffer, view.cursor.line) + 1;
buffer_replace_range(app, &buffer, pos, pos, line_string.str, line_string.size);
end_temp_memory(temp);
@ -159,8 +154,8 @@ CUSTOM_COMMAND_SIG(delete_line){
Partition *part = &global_part;
Temp_Memory temp = begin_temp_memory(part);
int32_t start = buffer_get_line_start(app, &buffer, view.cursor.line);
int32_t end = buffer_get_line_end(app, &buffer, view.cursor.line) + 1;
size_t start = buffer_get_line_start(app, &buffer, view.cursor.line);
size_t end = buffer_get_line_end(app, &buffer, view.cursor.line) + 1;
buffer_replace_range(app, &buffer, start, end, 0, 0);
@ -206,7 +201,7 @@ long_braces(Application_Links *app, char *text, int32_t size){
uint32_t access = AccessOpen;
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = view.cursor.pos;
size_t pos = view.cursor.pos;
buffer_replace_range(app, &buffer, pos, pos, text, size);
view_set_cursor(app, &view, seek_pos(pos + 2), true);
@ -338,13 +333,13 @@ file_name_in_quotes(Application_Links *app, String *file_name){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
if (buffer.file_name != 0){
int32_t pos = view.cursor.pos;
int32_t start = 0, end = 0;
size_t pos = view.cursor.pos;
size_t start = 0, end = 0;
buffer_seek_delimiter_forward(app, &buffer, pos, '"', &end);
buffer_seek_delimiter_backward(app, &buffer, pos, '"', &start);
++start;
int32_t size = end - start;
size_t size = end - start;
char short_file_name[128];
// NOTE(allen): This check is necessary because buffer_read_range
@ -354,7 +349,7 @@ file_name_in_quotes(Application_Links *app, String *file_name){
result = true;
copy_ss(file_name, make_string(buffer.file_name, buffer.file_name_len));
remove_last_folder(file_name);
append_ss(file_name, make_string(short_file_name, size));
append_ss(file_name, make_string(short_file_name, (int32_t)size));
}
}
}

View File

@ -245,8 +245,8 @@ list_all_functions(Application_Links *app, Partition *part, Buffer_Summary *buff
size_t sig_size = extra_memory->pos;
String sig = make_string(extra_memory->base, (int32_t)sig_size);
int32_t line_number = buffer_get_line_index(app, buffer, open_paren_pos);
int32_t line_number_len = int_to_str_size(line_number);
size_t line_number = buffer_get_line_index(app, buffer, open_paren_pos);
size_t line_number_len = int_to_str_size((int32_t)line_number);
size_t append_len = buffer_name.size + 1 + line_number_len + 1 + 1 + sig_size + 1;
@ -266,7 +266,7 @@ list_all_functions(Application_Links *app, Partition *part, Buffer_Summary *buff
String out = make_string(out_space, 0, (int32_t)append_len);
append(&out, buffer_name);
append(&out, ':');
append_int_to_str(&out, line_number);
append_int_to_str(&out, (int32_t)line_number);
append(&out, ':');
append(&out, ' ');
append(&out, sig);

View File

@ -148,7 +148,7 @@ query_user_number(Application_Links *app, Query_Bar *bar){
}
static char
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char result = ' ';
*buffer = get_buffer(app, buffer->buffer_id, AccessAll);
if (pos < buffer->size){
@ -188,7 +188,7 @@ create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buff
}
static Range
make_range(int32_t p1, int32_t p2){
make_range(size_t p1, size_t p2){
Range range;
if (p1 < p2){
range.min = p1;
@ -267,10 +267,10 @@ get_line_x_rect(View_Summary *view){
rect.y1 = view->cursor.line;
if (rect.y0 > rect.y1){
Swap(int32_t, rect.y0, rect.y1);
Swap(size_t, rect.y0, rect.y1);
}
if (rect.x0 > rect.x1){
Swap(int32_t, rect.x0, rect.x1);
Swap(size_t, rect.x0, rect.x1);
}
return(rect);

View File

@ -41,20 +41,20 @@ ms_style_verify(String line, int32_t paren_pos){
}
static int32_t
parse_jump_location(String line, Name_Based_Jump_Location *location, int32_t skip_sub_errors, int32_t *colon_char){
int32_t result = false;
parse_jump_location(String line, Name_Based_Jump_Location *location, int32_t skip_sub_errors, size_t *colon_char){
bool32 result = false;
int32_t whitespace_length = 0;
String original_line = line;
line = skip_chop_whitespace(line, &whitespace_length);
int32_t colon_pos = 0;
int32_t is_ms_style = 0;
bool32 is_ms_style = false;
int32_t paren_pos = find_s_char(line, 0, ')');
while (!is_ms_style && paren_pos < line.size){
if (ms_style_verify(line, paren_pos)){
is_ms_style = 1;
is_ms_style = true;
colon_pos = find_s_char(line, paren_pos, ':');
if (colon_pos < line.size){
String location_str = substr(line, 0, colon_pos);
@ -152,14 +152,14 @@ parse_jump_location(String line, Name_Based_Jump_Location *location, int32_t ski
return(result);
}
static int32_t
parse_jump_from_buffer_line(Application_Links *app, Partition *part, int32_t buffer_id, int32_t line, int32_t skip_sub_errors, Name_Based_Jump_Location *location){
static bool32
parse_jump_from_buffer_line(Application_Links *app, Partition *part, int32_t buffer_id, size_t line, int32_t skip_sub_errors, Name_Based_Jump_Location *location){
int32_t result = false;
bool32 result = false;
String line_str = {0};
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
if (read_line(app, part, &buffer, line, &line_str)){
int32_t colon_char = 0;
size_t colon_char = 0;
if (parse_jump_location(line_str, location, skip_sub_errors, &colon_char)){
result = true;
}

View File

@ -15,20 +15,17 @@
// Whitespace Based Seeks
//
static int32_t
seek_line_end(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
seek_line_end(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
size_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
int32_t still_looping;
char at_pos;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
still_looping = 1;
bool32 still_looping = true;
do{
for (; pos < stream.end; ++pos){
at_pos = stream.data[pos];
for (; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (at_pos == '\n'){
goto double_break;
}
@ -45,21 +42,18 @@ seek_line_end(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
return(pos);
}
static int32_t
seek_line_beginning(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
seek_line_beginning(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
size_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
int32_t still_looping;
char at_pos;
--pos;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
still_looping = 1;
bool32 still_looping = false;
do{
for (; pos >= stream.start; --pos){
at_pos = stream.data[pos];
for (; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (at_pos == '\n'){
goto double_break;
}
@ -83,15 +77,15 @@ static void
move_past_lead_whitespace(Application_Links *app, View_Summary *view, Buffer_Summary *buffer){
refresh_view(app, view);
int32_t new_pos = seek_line_beginning(app, buffer, view->cursor.pos);
char space[1024];
Stream_Chunk chunk = {0};
int32_t still_looping = false;
int32_t i = new_pos;
size_t new_pos = seek_line_beginning(app, buffer, view->cursor.pos);
size_t i = new_pos;
if (init_stream_chunk(&chunk, app, buffer, i, space, sizeof(space))){
bool32 still_looping = false;
do{
for (; i < chunk.end; ++i){
for (; i < (size_t)chunk.end; ++i){
char at_pos = chunk.data[i];
if (at_pos == '\n' || !char_is_whitespace(at_pos)){
goto break2;
@ -107,22 +101,20 @@ move_past_lead_whitespace(Application_Links *app, View_Summary *view, Buffer_Sum
}
}
static int32_t
buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
size_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
char at_pos;
--pos;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
// Step 1: Find the first non-whitespace character
// behind the current position.
int32_t still_looping = 1;
bool32 still_looping = true;
while (still_looping){
for (; pos >= stream.start; --pos){
at_pos = stream.data[pos];
for (; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (!char_is_whitespace(at_pos)){
goto double_break_1;
}
@ -138,8 +130,8 @@ buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int32_
// the next '\n'
int32_t no_hard = false;
while (still_looping){
for (; pos >= stream.start; --pos){
at_pos = stream.data[pos];
for (; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (at_pos == '\n'){
if (no_hard){
goto double_break_2;
@ -164,24 +156,19 @@ buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int32_
return(pos);
}
static int32_t
buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
size_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
int32_t no_hard;
int32_t prev_endline;
int32_t still_looping;
char at_pos;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
// step 1: find the first non-whitespace character
// ahead of the current position.
still_looping = true;
bool32 still_looping = true;
do{
for (; pos < stream.end; ++pos){
at_pos = stream.data[pos];
for (; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (!char_is_whitespace(at_pos)){
goto double_break_1;
}
@ -195,11 +182,12 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int3
// the prev_endline value. if another '\n' is found
// with non-whitespace then the previous line was
// all whitespace.
no_hard = false;
prev_endline = -1;
bool32 no_hard = false;
bool32 was_at_end = true;
size_t prev_endline = 0;
while(still_looping){
for (; pos < stream.end; ++pos){
at_pos = stream.data[pos];
for (; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (at_pos == '\n'){
if (no_hard){
goto double_break_2;
@ -207,6 +195,7 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int3
else{
no_hard = true;
prev_endline = pos;
was_at_end = false;
}
}
else if (!char_is_whitespace(at_pos)){
@ -217,7 +206,7 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int3
}
double_break_2:;
if (prev_endline == -1 || prev_endline+1 >= buffer->size){
if (was_at_end || prev_endline+1 >= buffer->size){
pos = buffer->size;
}
else{
@ -227,8 +216,8 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int3
return(pos);
}
static int32_t
buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -237,7 +226,7 @@ buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int
bool32 still_looping = 1;
do{
for (; pos < stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
if (!char_is_whitespace(stream.data[pos])){
goto double_break1;
}
@ -248,7 +237,7 @@ buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int
still_looping = 1;
do{
for (; pos < stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
if (char_is_whitespace(stream.data[pos])){
goto double_break2;
}
@ -261,8 +250,8 @@ buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int
return(pos);
}
static int32_t
buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -273,7 +262,7 @@ buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, int3
bool32 still_looping = 1;
do{
for (; pos >= stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
if (!char_is_whitespace(stream.data[pos])){
goto double_break1;
}
@ -284,7 +273,7 @@ buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, int3
still_looping = 1;
do{
for (; pos >= stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
if (char_is_whitespace(stream.data[pos])){
++pos;
goto double_break2;
@ -306,8 +295,8 @@ buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, int3
// Boundary Type Seeks
//
static int32_t
buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -316,7 +305,7 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i
bool32 still_looping = 1;
do{
for (; pos < stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
if (char_is_alpha_numeric_true(stream.data[pos])){
goto double_break1;
}
@ -327,7 +316,7 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i
still_looping = 1;
do{
for (; pos < stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
if (!char_is_alpha_numeric_true(stream.data[pos])){
goto double_break2;
}
@ -340,8 +329,8 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i
return(pos);
}
static int32_t
buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -352,7 +341,7 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in
bool32 still_looping = 1;
do{
for (; pos >= stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
if (char_is_alpha_numeric_true(stream.data[pos])){
goto double_break1;
}
@ -363,7 +352,7 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in
still_looping = 1;
do{
for (; pos >= stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
if (!char_is_alpha_numeric_true(stream.data[pos])){
++pos;
goto double_break2;
@ -381,8 +370,8 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in
return(pos);
}
static int32_t
buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t an_pos){
static size_t
buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t an_pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -397,7 +386,7 @@ buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, in
bool32 still_looping = 1;
do{
for (; pos < stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
c = stream.data[pos];
if (char_is_upper(c) && char_is_lower(pc)){
goto double_break1;
@ -416,8 +405,8 @@ buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, in
return(pos);
}
static int32_t
buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t an_pos){
static size_t
buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t an_pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -430,7 +419,7 @@ buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int
bool32 still_looping = 1;
do{
for (; pos >= stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
c = stream.data[pos];
if (char_is_upper(c) && char_is_lower(pc)){
goto double_break1;
@ -449,22 +438,22 @@ buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int
return(pos);
}
static int32_t
buffer_seek_alphanumeric_or_camel_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
int32_t an_pos = buffer_seek_alphanumeric_right(app, buffer, pos);
int32_t result = buffer_seek_range_camel_right(app, buffer, pos, an_pos);
static size_t
buffer_seek_alphanumeric_or_camel_right(Application_Links *app, Buffer_Summary *buffer, size_t pos){
size_t an_pos = buffer_seek_alphanumeric_right(app, buffer, pos);
size_t result = buffer_seek_range_camel_right(app, buffer, pos, an_pos);
return(result);
}
static int32_t
buffer_seek_alphanumeric_or_camel_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
int32_t an_pos = buffer_seek_alphanumeric_left(app, buffer, pos);
int32_t result = buffer_seek_range_camel_left(app, buffer, pos, an_pos);
static size_t
buffer_seek_alphanumeric_or_camel_left(Application_Links *app, Buffer_Summary *buffer, size_t pos){
size_t an_pos = buffer_seek_alphanumeric_left(app, buffer, pos);
size_t result = buffer_seek_range_camel_left(app, buffer, pos, an_pos);
return(result);
}
static int32_t
seek_token_left(Cpp_Token_Array *tokens, uint32_t pos){
static size_t
seek_token_left(Cpp_Token_Array *tokens, size_t pos){
Cpp_Get_Token_Result get = cpp_get_token(*tokens, pos);
if (get.token_index == -1){
get.token_index = 0;
@ -478,8 +467,8 @@ seek_token_left(Cpp_Token_Array *tokens, uint32_t pos){
return(token->start);
}
static int32_t
seek_token_right(Cpp_Token_Array *tokens, uint32_t pos){
static size_t
seek_token_right(Cpp_Token_Array *tokens, size_t pos){
Cpp_Get_Token_Result get = cpp_get_token(*tokens, pos);
if (get.in_whitespace){
++get.token_index;
@ -508,28 +497,26 @@ buffer_get_all_tokens(Application_Links *app, Partition *part, Buffer_Summary *b
return(array);
}
static int32_t
buffer_boundary_seek(Application_Links *app, Buffer_Summary *buffer, Partition *part, int32_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags)/*
static size_t
buffer_boundary_seek(Application_Links *app, Buffer_Summary *buffer, Partition *part, size_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags)/*
DOC_PARAM(buffer, The buffer parameter specifies the buffer through which to seek.)
DOC_PARAM(start_pos, The beginning position of the seek is specified by start_pos measured in absolute position.)
DOC_PARAM(seek_forward, If this parameter is non-zero it indicates that the seek should move foward through the buffer.)
DOC_PARAM(flags, This field specifies the types of boundaries at which the seek should stop.)
DOC_RETURN(This call returns the absolute position where the seek stopped.
If the seek goes below 0 the returned value is -1.
If the seek goes past the end the returned value is the size of the buffer.)
DOC_RETURN(This call returns the absolute position where the seek stopped. If the seek goes below 0 the returned value is -1. If the seek goes past the end the returned value is the size of the buffer.)
DOC_SEE(Seek_Boundary_Flag)
DOC_SEE(4coder_Buffer_Positioning_System)
*/{
int32_t result = 0;
size_t result = 0;
// TODO(allen): reduce duplication?
Temp_Memory temp = begin_temp_memory(part);
if (buffer->exists){
int32_t pos[4];
int32_t size = buffer->size;
int32_t new_pos = 0;
size_t pos[4];
size_t size = buffer->size;
size_t new_pos = 0;
if (start_pos < 0){
start_pos = 0;
@ -625,8 +612,8 @@ DOC_SEE(4coder_Buffer_Positioning_System)
// Character Seeks
//
void
buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, char delim, int32_t *result){
static void
buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, size_t pos, char delim, size_t *result){
if (buffer->exists){
char chunk[1024];
int32_t size = sizeof(chunk);
@ -635,7 +622,7 @@ buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, in
if (init_stream_chunk(&stream, app, buffer, pos, chunk, size)){
int32_t still_looping = 1;
do{
for(; pos < stream.end; ++pos){
for(; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (at_pos == delim){
*result = pos;
@ -653,7 +640,7 @@ buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, in
}
static void
buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, char delim, int32_t *result){
buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, size_t pos, char delim, size_t *result){
if (buffer->exists){
char chunk[1024];
int32_t size = sizeof(chunk);
@ -662,7 +649,7 @@ buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, i
if (init_stream_chunk(&stream, app, buffer, pos, chunk, size)){
int32_t still_looping = 1;
do{
for(; pos >= stream.start; --pos){
for(; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (at_pos == delim){
*result = pos;
@ -690,7 +677,7 @@ buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, i
// You can push it up or do something more clever by just
// replacing char read_buffer[512]; with more memory.
static void
buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t end, char *str, int32_t size, int32_t *result){
buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t end, char *str, size_t size, size_t *result){
char read_buffer[512];
if (buffer->size > end){
@ -703,19 +690,19 @@ buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, int32
if (size > 0 && size <= sizeof(read_buffer)){
if (buffer->exists){
String read_str = make_fixed_width_string(read_buffer);
String needle_str = make_string(str, size);
String needle_str = make_string(str, (int32_t)size);
char first_char = str[0];
read_str.size = size;
read_str.size = (int32_t)size;
char chunk[1024];
Stream_Chunk stream = {0};
stream.max_end = end;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, sizeof(chunk))){
int32_t still_looping = 1;
bool32 still_looping = 1;
do{
for(; pos < stream.end; ++pos){
for(; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (at_pos == first_char){
buffer_read_range(app, buffer, pos, pos+size, read_buffer);
@ -745,17 +732,17 @@ buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, int32
// You can push it up or do something more clever by just
// replacing char read_buffer[512]; with more memory.
static void
buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t min, char *str, int32_t size, int32_t *result){
buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t min, char *str, size_t size, size_t *result){
char read_buffer[512];
*result = min-1;
if (size > 0 && size <= sizeof(read_buffer)){
if (buffer->exists){
String read_str = make_fixed_width_string(read_buffer);
String needle_str = make_string(str, size);
String needle_str = make_string(str, (int32_t)size);
char first_char = str[0];
read_str.size = size;
read_str.size = (int32_t)size;
char chunk[1024];
Stream_Chunk stream = {0};
@ -764,7 +751,7 @@ buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, int3
if (init_stream_chunk(&stream, app, buffer, pos, chunk, sizeof(chunk))){
int32_t still_looping = 1;
do{
for(; pos >= stream.start; --pos){
for(; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (at_pos == first_char){
buffer_read_range(app, buffer, pos, pos+size, read_buffer);
@ -787,7 +774,7 @@ buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, int3
// You can push it up or do something more clever by just
// replacing char read_buffer[512]; with more memory.
static void
buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t end, char *str, int32_t size, int32_t *result){
buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t end, char *str, size_t size, size_t *result){
char read_buffer[512];
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
@ -801,32 +788,29 @@ buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *b
*result = end;
}
if (size > 0 && size <= sizeof(read_buffer)){
if (buffer->exists){
String read_str = make_fixed_width_string(read_buffer);
String needle_str = make_string(str, size);
char first_char = char_to_upper(str[0]);
read_str.size = size;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
int32_t still_looping = 1;
do{
for(; pos < stream.end; ++pos){
char at_pos = char_to_upper(stream.data[pos]);
if (at_pos == first_char){
buffer_read_range(app, buffer, pos, pos+size, read_buffer);
if (match_insensitive_ss(needle_str, read_str)){
*result = pos;
goto finished;
}
if (size > 0 && size <= sizeof(read_buffer) && buffer->exists){
String read_str = make_fixed_width_string(read_buffer);
String needle_str = make_string(str, (int32_t)size);
char first_char = char_to_upper(str[0]);
read_str.size = (int32_t)size;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
bool32 still_looping = true;
do{
for(; pos < (size_t)stream.end; ++pos){
char at_pos = char_to_upper(stream.data[pos]);
if (at_pos == first_char){
buffer_read_range(app, buffer, pos, pos+size, read_buffer);
if (match_insensitive_ss(needle_str, read_str)){
*result = pos;
goto finished;
}
}
still_looping = forward_stream_chunk(&stream);
}while (still_looping);
}
}
still_looping = forward_stream_chunk(&stream);
}while (still_looping);
}
finished:;
}
}
@ -835,7 +819,7 @@ buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *b
// You can push it up or do something more clever by just
// replacing char read_buffer[512]; with more memory.
static void
buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t min, char *str, int32_t size, int32_t *result){
buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t min, char *str, size_t size, size_t *result){
char read_buffer[512];
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
@ -843,32 +827,29 @@ buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *
stream.min_start = min;
*result = min-1;
if (size > 0 && size <= sizeof(read_buffer)){
if (buffer->exists){
String read_str = make_fixed_width_string(read_buffer);
String needle_str = make_string(str, size);
char first_char = char_to_upper(str[0]);
read_str.size = size;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
int32_t still_looping = 1;
do{
for(; pos >= stream.start; --pos){
char at_pos = char_to_upper(stream.data[pos]);
if (at_pos == first_char){
buffer_read_range(app, buffer, pos, pos+size, read_buffer);
if (match_insensitive_ss(needle_str, read_str)){
*result = pos;
goto finished;
}
if (size > 0 && size <= sizeof(read_buffer) && buffer->exists){
String read_str = make_fixed_width_string(read_buffer);
String needle_str = make_string(str, (int32_t)size);
char first_char = char_to_upper(str[0]);
read_str.size = (int32_t)size;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
int32_t still_looping = 1;
do{
for(; pos >= (size_t)stream.start; --pos){
char at_pos = char_to_upper(stream.data[pos]);
if (at_pos == first_char){
buffer_read_range(app, buffer, pos, pos+size, read_buffer);
if (match_insensitive_ss(needle_str, read_str)){
*result = pos;
goto finished;
}
}
still_looping = backward_stream_chunk(&stream);
}while (still_looping);
}
}
still_looping = backward_stream_chunk(&stream);
}while (still_looping);
}
finished:;
}
}
@ -878,23 +859,25 @@ buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *
// Buffer Line Positioning
//
static int32_t
read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line, String *str){
static bool32
read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, size_t line, String *str){
bool32 success = false;
Buffer_Seek seek_begin = seek_line_char(line, 1);
Buffer_Seek seek_end = seek_line_reverse_char(line, 1);
Partial_Cursor begin = {0};
Partial_Cursor end = {0};
int32_t success = 0;
if (buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &begin)){
if (buffer_compute_cursor(app, buffer, seek_line_char(line, -1), &end)){
if (begin.line == line){
if (buffer_compute_cursor(app, buffer, seek_begin, &begin)){
if (begin.line == line){
if (buffer_compute_cursor(app, buffer, seek_end, &end)){
if (0 <= begin.pos && begin.pos <= end.pos && end.pos <= buffer->size){
int32_t size = (end.pos - begin.pos);
*str = make_string(push_array(part, char, size+1), size+1);
size_t size = (end.pos - begin.pos);
*str = make_string(push_array(part, char, size+1), (int32_t)(size+1));
if (str->str){
success = 1;
success = true;
buffer_read_range(app, buffer, begin.pos, end.pos, str->str);
str->size = size;
str->size = (int32_t)size;
terminate_with_null(str);
}
}
@ -905,10 +888,10 @@ read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32
return(success);
}
static int32_t
buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, int32_t line){
static size_t
buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, size_t line){
Partial_Cursor partial_cursor;
int32_t result = buffer->size;
size_t result = buffer->size;
if (line <= buffer->line_count){
buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &partial_cursor);
result = partial_cursor.pos;
@ -916,36 +899,39 @@ buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, int32_t li
return(result);
}
static int32_t
buffer_get_line_end(Application_Links *app, Buffer_Summary *buffer, int32_t line){
static size_t
buffer_get_line_end(Application_Links *app, Buffer_Summary *buffer, size_t line){
Partial_Cursor partial_cursor;
int32_t result = buffer->size;
size_t result = buffer->size;
if (line <= buffer->line_count){
buffer_compute_cursor(app, buffer, seek_line_char(line, -1), &partial_cursor);
buffer_compute_cursor(app, buffer, seek_line_reverse_char(line, 1), &partial_cursor);
result = partial_cursor.pos;
}
return(result);
}
static bool32
buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, int32_t line){
buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, size_t line){
Partial_Cursor start, end;
bool32 result = 0;
if (line <= buffer->line_count){
buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &start);
buffer_compute_cursor(app, buffer, seek_line_char(line, -1), &end);
Buffer_Seek seek_start = seek_line_char(line, 1);
Buffer_Seek seek_end = seek_line_reverse_char(line, 1);
static const int32_t chunk_size = 1024;
buffer_compute_cursor(app, buffer, seek_start, &start);
buffer_compute_cursor(app, buffer, seek_end, &end);
static const size_t chunk_size = 1024;
char chunk[chunk_size];
Stream_Chunk stream = {0};
int32_t i = start.pos;
size_t i = start.pos;
stream.max_end = end.pos;
result = true;
if (init_stream_chunk(&stream, app, buffer, i, chunk, chunk_size)){
bool32 still_looping = false;
do{
for (;i < stream.end; ++i){
for (;i < (size_t)stream.end; ++i){
char c = stream.data[i];
if (!(c == ' ' || c == '\t' || c == '\r' || c == '\v' || c == '\n')){
result = false;
@ -960,16 +946,16 @@ buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, int32_t lin
return(result);
}
static int32_t
buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, size_t pos){
Partial_Cursor partial_cursor;
buffer_compute_cursor(app, buffer, seek_pos(pos), &partial_cursor);
return(partial_cursor.line);
}
static Cpp_Token*
get_first_token_at_line(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t line, uint32_t *line_start_out = 0){
int32_t line_start = buffer_get_line_start(app, buffer, line);
get_first_token_at_line(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, size_t line, size_t *line_start_out = 0){
size_t line_start = buffer_get_line_start(app, buffer, line);
Cpp_Get_Token_Result get = cpp_get_token(tokens, line_start);
if (get.in_whitespace){
@ -977,7 +963,7 @@ get_first_token_at_line(Application_Links *app, Buffer_Summary *buffer, Cpp_Toke
}
uint32_t target_token_index = (uint32_t)(get.token_index);
if (line_start_out){
if (line_start_out != 0){
*line_start_out = line_start;
}

View File

@ -67,6 +67,15 @@ seek_line_char(size_t line, size_t character){
return(result);
}
static Buffer_Seek
seek_line_reverse_char(size_t line, size_t character){
Buffer_Seek result;
result.type = buffer_seek_line_reverse_char;
result.line = line;
result.character = character;
return(result);
}
#endif
// BOTTOM

View File

@ -9,31 +9,32 @@
#include "4coder_helper/4coder_helper.h"
// TODO(allen): Rewrite the backward seek to get this on size_t instead of int64_t.
struct Stream_Chunk{
Application_Links *app;
Buffer_Summary *buffer;
char *base_data;
int32_t start, end;
int32_t min_start, max_end;
int64_t start, end;
int64_t min_start, max_end;
int64_t data_size;
bool32 add_null;
uint32_t data_size;
char *data;
};
static int32_t
round_down(int32_t x, int32_t b){
int32_t r = 0;
static uint64_t
round_down(uint64_t x, uint64_t b){
uint64_t r = 0;
if (x >= 0){
r = x - (x % b);
}
return(r);
}
static int32_t
round_up(int32_t x, int32_t b){
int32_t r = 0;
static uint64_t
round_up(uint64_t x, uint64_t b){
uint64_t r = 0;
if (x >= 0){
r = x - (x % b) + b;
}
@ -41,8 +42,7 @@ round_up(int32_t x, int32_t b){
}
static bool32
init_stream_chunk(Stream_Chunk *chunk, Application_Links *app, Buffer_Summary *buffer,
int32_t pos, char *data, uint32_t size){
init_stream_chunk(Stream_Chunk *chunk, Application_Links *app, Buffer_Summary *buffer, size_t pos, char *data, size_t size){
bool32 result = 0;
refresh_buffer(app, buffer);
@ -153,12 +153,12 @@ struct Stream_Tokens{
Cpp_Token *base_tokens;
Cpp_Token *tokens;
int32_t start, end;
int32_t count, token_count;
int64_t start, end;
int64_t count, token_count;
};
static bool32
init_stream_tokens(Stream_Tokens *stream, Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Token *data, int32_t count){
init_stream_tokens(Stream_Tokens *stream, Application_Links *app, Buffer_Summary *buffer, size_t pos, Cpp_Token *data, size_t count){
bool32 result = 0;
refresh_buffer(app, buffer);
@ -168,9 +168,9 @@ init_stream_tokens(Stream_Tokens *stream, Application_Links *app, Buffer_Summary
stream->app = app;
stream->buffer = buffer;
stream->base_tokens = data;
stream->count = count;
stream->start = round_down(pos, count);
stream->end = round_up(pos, count);
stream->count = (int64_t)count;
stream->start = (int64_t)round_down(pos, count);
stream->end = (int64_t)round_up(pos, count);
stream->token_count = token_count;
if (stream->start < 0){

View File

@ -22,10 +22,7 @@ CUSTOM_COMMAND_SIG(goto_jump_at_cursor){
View_Summary view = get_active_view(app, AccessProtected);
Name_Based_Jump_Location location = {0};
if (parse_jump_from_buffer_line(app, &global_part,
view.buffer_id, view.cursor.line, false,
&location)){
if (parse_jump_from_buffer_line(app, &global_part, view.buffer_id, view.cursor.line, false, &location)){
exec_command(app, change_active_panel);
view = get_active_view(app, AccessAll);
jump_to_location(app, &view, &location);
@ -39,13 +36,13 @@ CUSTOM_COMMAND_SIG(goto_jump_at_cursor){
// Error Jumping
//
static int32_t
seek_next_jump_in_buffer(Application_Links *app, Partition *part, int32_t buffer_id, int32_t first_line, bool32 skip_sub_errors, int32_t direction, int32_t *line_out, int32_t *colon_index_out, Name_Based_Jump_Location *location_out){
static bool32
seek_next_jump_in_buffer(Application_Links *app, Partition *part, int32_t buffer_id, size_t first_line, bool32 skip_sub_errors, int32_t direction, size_t *line_out, size_t *colon_index_out, Name_Based_Jump_Location *location_out){
Assert(direction == 1 || direction == -1);
int32_t result = false;
int32_t line = first_line;
bool32 result = false;
size_t line = first_line;
String line_str = {0};
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
for (;;){
@ -86,12 +83,12 @@ convert_name_based_to_id_based(Application_Links *app, Name_Based_Jump_Location
}
static int32_t
seek_next_jump_in_view(Application_Links *app, Partition *part, View_Summary *view, int32_t skip_sub_errors, int32_t direction, int32_t *line_out, int32_t *colon_index_out, Name_Based_Jump_Location *location_out){
seek_next_jump_in_view(Application_Links *app, Partition *part, View_Summary *view, bool32 skip_sub_errors, int32_t direction, size_t *line_out, size_t *colon_index_out, Name_Based_Jump_Location *location_out){
int32_t result = false;
Name_Based_Jump_Location location = {0};
int32_t line = view->cursor.line;
int32_t colon_index = 0;
size_t line = view->cursor.line;
size_t colon_index = 0;
if (seek_next_jump_in_buffer(app, part, view->buffer_id, line+direction, skip_sub_errors, direction, &line, &colon_index, &location)){
result = true;
*line_out = line;
@ -114,13 +111,13 @@ skip_this_jump(ID_Based_Jump_Location prev, ID_Based_Jump_Location jump){
return(result);
}
static int32_t
advance_cursor_in_jump_view(Application_Links *app, Partition *part, View_Summary *view, int32_t skip_repeats, int32_t skip_sub_error, int32_t direction, Name_Based_Jump_Location *location_out){
int32_t result = true;
static bool32
advance_cursor_in_jump_view(Application_Links *app, Partition *part, View_Summary *view, int32_t skip_repeats, bool32 skip_sub_error, int32_t direction, Name_Based_Jump_Location *location_out){
bool32 result = true;
Name_Based_Jump_Location location = {0};
ID_Based_Jump_Location jump = {0};
int32_t line = 0, colon_index = 0;
size_t line = 0, colon_index = 0;
do{
Temp_Memory temp = begin_temp_memory(part);

View File

@ -157,9 +157,9 @@ struct Bubble{
Bubble *next;
Bubble *prev2;
Bubble *next2;
i32_4tech size;
size_t size;
u32_4tech flags;
u32_4tech _unused_[4];
u8_4tech _unused_[20 - sizeof(size_t)];
};
struct General_Memory{
@ -214,8 +214,8 @@ general_sentinel_init(Bubble *bubble){
#define BUBBLE_MIN_SIZE 1024
static void
general_memory_attempt_split(General_Memory *general, Bubble *bubble, i32_4tech wanted_size){
i32_4tech remaining_size = bubble->size - wanted_size;
general_memory_attempt_split(General_Memory *general, Bubble *bubble, size_t wanted_size){
size_t remaining_size = bubble->size - wanted_size;
if (remaining_size >= BUBBLE_MIN_SIZE){
bubble->size = wanted_size;
Bubble *new_bubble = (Bubble*)((char*)(bubble + 1) + wanted_size);
@ -284,7 +284,7 @@ general_memory_check(General_Memory *general){}
#endif
static void*
general_memory_allocate(General_Memory *general, i32_4tech size){
general_memory_allocate(General_Memory *general, size_t size){
void *result = 0;
if (size < BUBBLE_MIN_SIZE) size = BUBBLE_MIN_SIZE;
for (Bubble *bubble = general->free_sentinel.next2;
@ -320,10 +320,10 @@ general_memory_free(General_Memory *general, void *memory){
}
static void*
general_memory_reallocate(General_Memory *general, void *old, i32_4tech old_size, i32_4tech size){
general_memory_reallocate(General_Memory *general, void *old, size_t old_size, size_t size){
void *result = old;
Bubble *bubble = ((Bubble*)old) - 1;
i32_4tech additional_space = size - bubble->size;
size_t additional_space = size - bubble->size;
if (additional_space > 0){
Bubble *next = bubble->next;
if (!(next->flags & MEM_BUBBLE_USED) &&
@ -341,7 +341,7 @@ general_memory_reallocate(General_Memory *general, void *old, i32_4tech old_size
}
inline void*
general_memory_reallocate_nocopy(General_Memory *general, void *old, i32_4tech size){
general_memory_reallocate_nocopy(General_Memory *general, void *old, size_t size){
void *result = general_memory_reallocate(general, old, 0, size);
return(result);
}

View File

@ -52,20 +52,20 @@ typedef i32_4tech Compare_Function(void *key, void *item, void *arg);
struct Table{
u32_4tech *hash_array;
char *data_array;
i32_4tech count, max;
i32_4tech item_size;
u32_4tech count, max;
u32_4tech item_size;
};
static i32_4tech
table_required_mem_size(i32_4tech table_size, i32_4tech item_size){
i32_4tech hash_size = ((table_size * sizeof(u32_4tech)) + 7) & ~7;
i32_4tech mem_size = hash_size + table_size * item_size;
static umem_4tech
table_required_mem_size(u32_4tech table_size, u32_4tech item_size){
u32_4tech hash_size = ((table_size * sizeof(u32_4tech)) + 7) & ~7;
umem_4tech mem_size = hash_size + table_size * item_size;
return(mem_size);
}
static void
table_init_memory(Table *table, void *memory, i32_4tech table_size, i32_4tech item_size){
i32_4tech hash_size = table_size * sizeof(u32_4tech);
table_init_memory(Table *table, void *memory, u32_4tech table_size, u32_4tech item_size){
umem_4tech hash_size = table_size * sizeof(u32_4tech);
hash_size = (hash_size + 7) & ~7;
table->hash_array = (u32_4tech*)memory;
@ -90,8 +90,8 @@ table_add(Table *table, void *item, void *arg, Hash_Function *hash_func, Compare
Assert(table->count * 8 < table->max * 7);
u32_4tech hash = (hash_func(item, arg) | TableHashMin);
i32_4tech i = hash % table->max;
i32_4tech start = i;
u32_4tech i = hash % table->max;
u32_4tech start = i;
u32_4tech *inspect = table->hash_array + i;
while (*inspect >= TableHashMin){
@ -120,8 +120,8 @@ table_find_pos(Table *table, void *search_key, void *arg, i32_4tech *pos, i32_4t
Assert((table->count - 1) * 8 < table->max * 7);
u32_4tech hash = (hash_func(search_key, arg) | TableHashMin);
i32_4tech i = hash % table->max;
i32_4tech start = i;
u32_4tech i = hash % table->max;
u32_4tech start = i;
u32_4tech *inspect = table->hash_array + i;
while (*inspect != TableHashEmpty){
@ -254,18 +254,17 @@ tbl_offset_string_compare(void *a, void *b, void *arg){
struct String_Space{
char *space;
i32_4tech pos;
i32_4tech new_pos;
i32_4tech max;
u32_4tech pos;
u32_4tech new_pos;
u32_4tech max;
};
static Offset_String
strspace_append(String_Space *space, char *str, i32_4tech len){
strspace_append(String_Space *space, char *str, u32_4tech len){
Offset_String result = {};
if (space->new_pos + len <= space->max){
result.offset = space->new_pos;
result.size = len;
memcpy(space->space + space->new_pos, str, len);
space->new_pos = space->pos + len;
}

View File

@ -40,10 +40,10 @@ struct Search_Range{
int32_t type;
uint32_t flags;
int32_t buffer;
int32_t start;
int32_t size;
int32_t mid_start;
int32_t mid_size;
size_t start;
size_t size;
size_t mid_start;
size_t mid_size;
};
struct Search_Set{
@ -54,29 +54,29 @@ struct Search_Set{
struct Search_Iter{
String word;
int32_t pos;
int32_t back_pos;
int32_t i;
int32_t range_initialized;
size_t pos;
size_t back_pos;
size_t i;
bool32 range_initialized;
};
struct Search_Match{
Buffer_Summary buffer;
int32_t start;
int32_t end;
int32_t found_match;
size_t start;
size_t end;
bool32 found_match;
};
static void
search_iter_init(General_Memory *general, Search_Iter *iter, int32_t size){
int32_t str_max = size*2;
search_iter_init(General_Memory *general, Search_Iter *iter, size_t size){
size_t str_max = size*2;
if (iter->word.str == 0){
iter->word.str = (char*)general_memory_allocate(general, str_max);
iter->word.memory_size = str_max;
iter->word.memory_size = (int32_t)str_max;
}
else if (iter->word.memory_size < size){
iter->word.str = (char*)general_memory_reallocate_nocopy(general, iter->word.str, str_max);
iter->word.memory_size = str_max;
iter->word.memory_size = (int32_t)str_max;
}
iter->i = 0;
iter->range_initialized = 0;
@ -91,8 +91,8 @@ search_set_init(General_Memory *general, Search_Set *set, int32_t range_count){
set->max = max;
}
else if (set->max < range_count){
set->ranges = (Search_Range*)general_memory_reallocate_nocopy(
general, set->ranges, sizeof(Search_Range)*max);
size_t mem_size = sizeof(Search_Range)*max;;
set->ranges = (Search_Range*)general_memory_reallocate_nocopy(general, set->ranges, mem_size);
set->max = max;
}
@ -100,9 +100,9 @@ search_set_init(General_Memory *general, Search_Set *set, int32_t range_count){
}
static void
search_hits_table_alloc(General_Memory *general, Table *hits, int32_t table_size){
search_hits_table_alloc(General_Memory *general, Table *hits, uint32_t table_size){
void *mem = 0;
int32_t mem_size = table_required_mem_size(table_size, sizeof(Offset_String));
size_t mem_size = table_required_mem_size(table_size, sizeof(Offset_String));
if (hits->hash_array == 0){
mem = general_memory_allocate(general, mem_size);
}
@ -113,12 +113,12 @@ search_hits_table_alloc(General_Memory *general, Table *hits, int32_t table_size
}
static void
search_hits_init(General_Memory *general, Table *hits, String_Space *str, int32_t table_size, int32_t str_size){
search_hits_init(General_Memory *general, Table *hits, String_Space *str, uint32_t table_size, uint32_t str_size){
if (hits->hash_array == 0){
search_hits_table_alloc(general, hits, table_size);
}
else{
int32_t mem_size = table_required_mem_size(table_size, sizeof(Offset_String));
size_t mem_size = table_required_mem_size(table_size, sizeof(Offset_String));
void *mem = general_memory_reallocate_nocopy(general, hits->hash_array, mem_size);
table_init_memory(hits, mem, table_size, sizeof(Offset_String));
}
@ -137,19 +137,18 @@ search_hits_init(General_Memory *general, Table *hits, String_Space *str, int32_
}
static int32_t
search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *str, int32_t len){
search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *str, uint32_t len){
int32_t result = false;
Assert(len != 0);
Offset_String ostring = strspace_append(space, str, len);
if (ostring.size == 0){
int32_t new_size = space->max*2;
uint32_t new_size = space->max*2;
if (new_size < space->max + len){
new_size = space->max + len;
}
space->space = (char*)general_memory_reallocate(
general, space->space, space->new_pos, new_size);
space->space = (char*)general_memory_reallocate(general, space->space, space->new_pos, new_size);
ostring = strspace_append(space, str, len);
}
@ -175,14 +174,14 @@ search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *
return(result);
}
static int32_t
buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char space[1024];
Stream_Chunk chunk = {0};
if (init_stream_chunk(&chunk, app, buffer, pos, space, sizeof(space))){
int32_t still_looping = true;
bool32 still_looping = true;
do{
for (; pos < chunk.end; ++pos){
for (; pos < (size_t)chunk.end; ++pos){
char at_pos = chunk.data[pos];
if (!char_is_alpha_numeric(at_pos)) goto double_break;
}
@ -208,13 +207,13 @@ enum{
};
static int32_t
match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Match *result_ptr, String word){
match_check(Application_Links *app, Search_Range *range, size_t *pos, Search_Match *result_ptr, String word){
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
int32_t end_pos = range->start + range->size;
size_t end_pos = range->start + range->size;
int32_t type = (range->flags & SearchFlag_MatchMask);
uint32_t type = (range->flags & SearchFlag_MatchMask);
switch (type){
case SearchFlag_MatchWholeWord:
@ -251,9 +250,7 @@ match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Ma
{
char prev = buffer_get_char(app, &result.buffer, result.start - 1);
if (!char_is_alpha_numeric(prev)){
result.end =
buffer_seek_alpha_numeric_end(
app, &result.buffer, result.start);
result.end =buffer_seek_alpha_numeric_end(app, &result.buffer, result.start);
if (result.end <= end_pos){
result.found_match = true;
@ -284,14 +281,14 @@ match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Ma
}
static int32_t
search_front_to_back_step(Application_Links *app, Search_Range *range, String word, int32_t *pos, Search_Match *result_ptr){
search_front_to_back_step(Application_Links *app, Search_Range *range, String word, size_t *pos, Search_Match *result_ptr){
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
int32_t end_pos = range->start + range->size;
size_t end_pos = range->start + range->size;
if (*pos + word.size < end_pos){
int32_t start_pos = *pos;
size_t start_pos = *pos;
if (start_pos < range->start){
start_pos = range->start;
}
@ -299,8 +296,11 @@ search_front_to_back_step(Application_Links *app, Search_Range *range, String wo
int32_t case_insensitive = (range->flags & SearchFlag_CaseInsensitive);
result.buffer = get_buffer(app, range->buffer, AccessAll);
char *word_str = word.str;
size_t word_size = (size_t)word.size;
if (case_insensitive){
buffer_seek_string_insensitive_forward(app, &result.buffer, start_pos, end_pos, word.str, word.size, &result.start);
buffer_seek_string_insensitive_forward(app, &result.buffer, start_pos, end_pos, word_str, word_size, &result.start);
}
else{
buffer_seek_string_forward(app, &result.buffer, start_pos, end_pos, word.str, word.size, &result.start);
@ -329,7 +329,7 @@ search_front_to_back_step(Application_Links *app, Search_Range *range, String wo
}
static int32_t
search_front_to_back(Application_Links *app, Search_Range *range, String word, int32_t *pos, Search_Match *result_ptr){
search_front_to_back(Application_Links *app, Search_Range *range, String word, size_t *pos, Search_Match *result_ptr){
int32_t found_match = FindResult_None;
for (;found_match == FindResult_None;){
found_match = search_front_to_back_step(app, range, word, pos, result_ptr);
@ -338,13 +338,13 @@ search_front_to_back(Application_Links *app, Search_Range *range, String word, i
}
static int32_t
search_back_to_front_step(Application_Links *app, Search_Range *range, String word, int32_t *pos, Search_Match *result_ptr){
search_back_to_front_step(Application_Links *app, Search_Range *range, String word, size_t *pos, Search_Match *result_ptr){
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
if (*pos > range->start){
int32_t start_pos = *pos;
size_t start_pos = *pos;
result.buffer = get_buffer(app, range->buffer, AccessAll);
buffer_seek_string_backward(app, &result.buffer,
@ -374,7 +374,7 @@ search_back_to_front_step(Application_Links *app, Search_Range *range, String wo
}
static int32_t
search_back_to_front(Application_Links *app, Search_Range *range, String word, int32_t *pos, Search_Match *result_ptr){
search_back_to_front(Application_Links *app, Search_Range *range, String word, size_t *pos, Search_Match *result_ptr){
int32_t found_match = FindResult_None;
for (;found_match == FindResult_None;){
found_match = search_back_to_front_step(app, range, word, pos, result_ptr);
@ -412,20 +412,12 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
switch (range->type){
case SearchRange_FrontToBack:
{
find_result =
search_front_to_back(app, range,
iter.word,
&iter.pos,
&result);
find_result = search_front_to_back(app, range, iter.word, &iter.pos, &result);
}break;
case SearchRange_BackToFront:
{
find_result =
search_back_to_front(app, range,
iter.word,
&iter.back_pos,
&result);
find_result = search_back_to_front(app, range, iter.word, &iter.back_pos, &result);
}break;
case SearchRange_Wave:
@ -437,26 +429,20 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
int32_t backward_result = FindResult_PastEnd;
if (iter.pos < range->start + range->size){
forward_result = search_front_to_back(app, range,
iter.word,
&iter.pos,
&forward_match);
forward_result = search_front_to_back(app, range, iter.word, &iter.pos, &forward_match);
}
if (iter.back_pos > range->start){
backward_result = search_back_to_front(app, range,
iter.word,
&iter.back_pos,
&backward_match);
backward_result = search_back_to_front(app, range, iter.word, &iter.back_pos, &backward_match);
}
if (forward_result == FindResult_FoundMatch){
if (backward_result == FindResult_FoundMatch){
find_result = FindResult_FoundMatch;
int32_t forward_start = range->mid_start + range->mid_size;
int32_t forward_distance = (forward_match.start - forward_start);
int32_t backward_distance = (range->mid_start - backward_match.end);
size_t forward_start = range->mid_start + range->mid_size;
size_t forward_distance = forward_match.start - forward_start;
size_t backward_distance = range->mid_start - backward_match.end;
if (backward_distance < forward_distance){
iter.pos = forward_match.start;
@ -589,8 +575,8 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
file_len = match.buffer.buffer_name_len;
}
int32_t line_num_len = int_to_str_size(word_pos.line);
int32_t column_num_len = int_to_str_size(word_pos.character);
int32_t line_num_len = int_to_str_size((int32_t)word_pos.line);
int32_t column_num_len = int_to_str_size((int32_t)word_pos.character);
Temp_Memory line_temp = begin_temp_memory(&line_part);
String line_str = {0};
@ -617,9 +603,9 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
String out_line = make_string_cap(spare, 0, str_len);
append_ss(&out_line, make_string(file_name, file_len));
append_s_char(&out_line, ':');
append_int_to_str(&out_line, word_pos.line);
append_int_to_str(&out_line, (int32_t)word_pos.line);
append_s_char(&out_line, ':');
append_int_to_str(&out_line, word_pos.character);
append_int_to_str(&out_line, (int32_t)word_pos.character);
append_s_char(&out_line, ':');
append_s_char(&out_line, ' ');
append_ss(&out_line, line_str);
@ -727,9 +713,9 @@ struct Word_Complete_State{
Search_Iter iter;
Table hits;
String_Space str;
int32_t word_start;
int32_t word_end;
int32_t initialized;
size_t word_start;
size_t word_end;
bool32 initialized;
};
static Word_Complete_State complete_state = {0};
@ -751,14 +737,13 @@ CUSTOM_COMMAND_SIG(word_complete){
do_init = true;
}
int32_t word_end = 0;
int32_t word_start = 0;
int32_t cursor_pos = 0;
int32_t size = 0;
size_t word_end = 0;
size_t word_start = 0;
size_t cursor_pos = 0;
size_t size = 0;
if (do_init){
// NOTE(allen): Get the range where the
// partial word is written.
// NOTE(allen): Get the range where the partial word is written.
word_end = view.cursor.pos;
word_start = word_end;
cursor_pos = word_end - 1;
@ -768,7 +753,7 @@ CUSTOM_COMMAND_SIG(word_complete){
if (init_stream_chunk(&chunk, app, &buffer, cursor_pos, space, sizeof(space))){
int32_t still_looping = true;
do{
for (; cursor_pos >= chunk.start; --cursor_pos){
for (; cursor_pos >= (size_t)chunk.start; --cursor_pos){
char c = chunk.data[cursor_pos];
if (char_is_alpha(c)){
word_start = cursor_pos;
@ -789,13 +774,12 @@ CUSTOM_COMMAND_SIG(word_complete){
return;
}
// NOTE(allen): Initialize the search iterator
// with the partial word.
// NOTE(allen): Initialize the search iterator with the partial word.
complete_state.initialized = true;
search_iter_init(&global_general, &complete_state.iter, size);
buffer_read_range(app, &buffer, word_start, word_end,
complete_state.iter.word.str);
complete_state.iter.word.size = size;
complete_state.iter.word.size = (int32_t)size;
// NOTE(allen): Initialize the set of ranges to be searched.
int32_t buffer_count = get_buffer_count(app);
@ -826,11 +810,8 @@ CUSTOM_COMMAND_SIG(word_complete){
complete_state.set.count = j;
// NOTE(allen): Initialize the search hit table.
search_hits_init(&global_general, &complete_state.hits, &complete_state.str,
100, (4 << 10));
search_hit_add(&global_general, &complete_state.hits, &complete_state.str,
complete_state.iter.word.str,
complete_state.iter.word.size);
search_hits_init(&global_general, &complete_state.hits, &complete_state.str, 100, (4 << 10));
search_hit_add(&global_general, &complete_state.hits, &complete_state.str, complete_state.iter.word.str, complete_state.iter.word.size);
complete_state.word_start = word_start;
complete_state.word_end = word_end;
@ -844,26 +825,20 @@ CUSTOM_COMMAND_SIG(word_complete){
// NOTE(allen): Iterate through matches.
if (size > 0){
for (;;){
int32_t match_size = 0;
Search_Match match =
search_next_match(app, &complete_state.set,
&complete_state.iter);
uint32_t match_size = 0;
Search_Match match = search_next_match(app, &complete_state.set, &complete_state.iter);
if (match.found_match){
match_size = match.end - match.start;
match_size = (uint32_t)(match.end - match.start);
Temp_Memory temp = begin_temp_memory(&global_part);
char *spare = push_array(&global_part, char, match_size);
buffer_read_range(app, &match.buffer,
match.start, match.end, spare);
buffer_read_range(app, &match.buffer, match.start, match.end, spare);
if (search_hit_add(&global_general, &complete_state.hits, &complete_state.str,
spare, match_size)){
buffer_replace_range(app, &buffer, word_start, word_end,
spare, match_size);
view_set_cursor(app, &view,
seek_pos(word_start + match_size),
true);
if (search_hit_add(&global_general, &complete_state.hits, &complete_state.str, spare, match_size)){
buffer_replace_range(app, &buffer, word_start, word_end, spare, match_size);
Buffer_Seek seek = seek_pos(word_start + match_size);
view_set_cursor(app, &view, seek, true);
complete_state.word_end = word_start + match_size;
complete_state.set.ranges[0].mid_size = match_size;

View File

@ -191,7 +191,7 @@ static String_And_Flag keywords[] = {
static i32_4tech keywords_count = sizeof(keywords)/sizeof(keywords[0]);
API_EXPORT FCPP_LINK Cpp_Get_Token_Result
cpp_get_token(Cpp_Token_Array array, u32_4tech pos)/*
cpp_get_token(Cpp_Token_Array array, umem_4tech 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.)
DOC_RETURN(A Cpp_Get_Token_Result struct is returned containing the index of a token and a flag indicating whether the pos is contained in the token or in whitespace after the token.)

22
4ed.cpp
View File

@ -343,8 +343,8 @@ COMMAND_DECL(reopen){
General_Memory *general = &models->mem.general;
File_Edit_Positions edit_poss[16];
int32_t line_number[16];
int32_t column_number[16];
umem line_number[16];
umem column_number[16];
View *vptrs[16];
i32 vptr_count = 0;
for (View_Iter iter = file_view_iter_init(&models->layout, file, 0);
@ -364,8 +364,8 @@ COMMAND_DECL(reopen){
for (i32 i = 0; i < vptr_count; ++i){
view_set_file(system, vptrs[i], file, models);
int32_t line = line_number[i];
int32_t character = column_number[i];
umem line = line_number[i];
umem character = column_number[i];
*vptrs[i]->edit_pos = edit_poss[i];
Full_Cursor cursor = view_compute_cursor(system, vptrs[i], seek_line_char(line, character), 0);
@ -488,14 +488,14 @@ case_change_range(System_Functions *system, Mem_Options *mem, View *view, Editin
file_update_history_before_edit(mem, file, step, 0, hist_normal);
u8 *data = (u8*)file->state.buffer.data;
for (i32 i = range.start; i < range.end; ++i){
for (umem i = range.start; i < range.end; ++i){
if (data[i] >= a && data[i] <= z){
data[i] += char_delta;
}
}
if (file->state.token_array.tokens){
file_relex_parallel(system, mem, file, range.start, range.end, 0);
file_relex_parallel(system, mem, file, (u32)range.start, (u32)range.end, 0);
}
}
}
@ -1552,7 +1552,7 @@ update_cli_handle_with_file(System_Functions *system, Models *models, CLI_Handle
system->cli_begin_update(cli);
if (system->cli_update_step(cli, dest, max, &amount)){
amount = eol_in_place_convert_in(dest, amount);
amount = (u32)eol_in_place_convert_in(dest, amount);
output_file_append(system, models, file, make_string(dest, amount), cursor_at_end);
result = 1;
}
@ -1591,7 +1591,7 @@ App_Step_Sig(app_step){
if (clipboard.str){
String *dest =working_set_next_clipboard_string(&models->mem.general, &models->working_set, clipboard.size);
dest->size = eol_convert_in(dest->str, clipboard.str, clipboard.size);
dest->size = (i32)eol_convert_in(dest->str, clipboard.str, clipboard.size);
}
// NOTE(allen): check files are up to date
@ -2503,16 +2503,16 @@ App_Step_Sig(app_step){
layout_compute_absolute_positions(&models->layout, absolute_positions);
mouse_position = (divider->v_divider)?(mx):(my);
layout_get_min_max(&models->layout, divider, absolute_positions, &min, &max);
absolute_positions[div_id] = clamp(min, mouse_position, max);
absolute_positions[div_id] = clamp_i32(min, mouse_position, max);
layout_update_all_positions(&models->layout, absolute_positions);
}
else{
if (divider->v_divider){
mouse_position = clamp(0, mx, models->layout.full_width);
mouse_position = clamp_i32(0, mx, models->layout.full_width);
}
else{
mouse_position = clamp(0, my, models->layout.full_height);
mouse_position = clamp_i32(0, my, models->layout.full_height);
}
divider->pos = layout_compute_position(&models->layout, divider, mouse_position);
}

View File

@ -347,17 +347,12 @@ DOC_SEE(Command_Line_Interface_Flag)
}
API_EXPORT void
Clipboard_Post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len)
Clipboard_Post(Application_Links *app, int32_t clipboard_id, char *str, size_t len)
/*
DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.)
DOC_PARAM(str, The str parameter specifies the string to be posted to the clipboard, it need not be null terminated.)
DOC_PARAM(len, The len parameter specifies the length of the str string.)
DOC
(
Stores the string str in the clipboard initially with index 0.
Also reports the copy to the operating system, so that it may
be pasted into other applications.
)
DOC(Stores the string str in the clipboard initially with index 0. Also reports the copy to the operating system, so that it may be pasted into other applications.)
DOC_SEE(The_4coder_Clipboard)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
@ -366,13 +361,13 @@ DOC_SEE(The_4coder_Clipboard)
General_Memory *general = &models->mem.general;
Working_Set *working = &models->working_set;
String *dest = working_set_next_clipboard_string(general, working, len);
copy_ss(dest, make_string(str, len));
String *dest = working_set_next_clipboard_string(general, working, (u32)len);
copy_ss(dest, make_string(str, (i32)len));
system->post_clipboard(*dest);
}
API_EXPORT int32_t
Clipboard_Count(Application_Links *app, int32_t clipboard_id)
API_EXPORT uint32_t
Clipboard_Count(Application_Links *app, uint32_t clipboard_id)
/*
DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.)
DOC(This call returns the number of items in the clipboard.)
@ -380,12 +375,12 @@ DOC_SEE(The_4coder_Clipboard)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
Working_Set *working = &cmd->models->working_set;
int32_t count = working->clipboard_size;
uint32_t count = working->clipboard_size;
return(count);
}
API_EXPORT int32_t
Clipboard_Index(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len)
API_EXPORT size_t
Clipboard_Index(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, size_t len)
/*
DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.)
DOC_PARAM(item_index, This parameter specifies which item to read, 0 is the most recent copy, 1 is the second most recent copy, etc.)
@ -400,12 +395,12 @@ DOC_SEE(The_4coder_Clipboard)
Command_Data *cmd = (Command_Data*)app->cmd_context;
Working_Set *working = &cmd->models->working_set;
int32_t size = 0;
size_t size = 0;
String *str = working_set_clipboard_index(working, item_index);
if (str){
size = str->size;
if (out){
String out_str = make_string_cap(out, 0, len);
String out_str = make_string_cap(out, 0, (i32)len);
copy_ss(&out_str, *str);
}
}
@ -550,7 +545,7 @@ DOC_SEE(Access_Flag)
}
API_EXPORT bool32
Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out)
Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, size_t start, size_t end, char *out)
/*
DOC_PARAM(buffer, This parameter specifies the buffer to read.)
DOC_PARAM(start, This parameter specifies absolute position of the first character in the read range.)
@ -593,32 +588,22 @@ DOC_PARAM(end, This parameter specifies the absolute position of the the charact
DOC_PARAM(str, This parameter specifies the the string to write into the range; it need not be null terminated.)
DOC_PARAM(len, This parameter specifies the length of the str string.)
DOC_RETURN(This call returns non-zero if the replacement succeeds.)
DOC
(
If this call succeeds it deletes the range from start to end
and writes str in the same position. If end == start then
this call is equivalent to inserting the string at start.
If len == 0 this call is equivalent to deleteing the range
from start to end.
DOC(If this call succeeds it deletes the range from start to end and writes str in the same position. If end == start then this call is equivalent to inserting the string at start. If len == 0 this call is equivalent to deleteing the range from start to end.
This call fails if the buffer does not exist, or if the replace
range is not within the bounds of the buffer.
)
This call fails if the buffer does not exist, or if the replace range is not within the bounds of the buffer.)
DOC_SEE(4coder_Buffer_Positioning_System)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
Editing_File *file = imp_get_file(cmd, buffer);
bool32 result = false;
int32_t size = 0;
if (file){
size = buffer_size(&file->state.buffer);
u32 size = buffer_size(&file->state.buffer);
if (0 <= start && start <= end && end <= size){
result = true;
file_replace_range(cmd->system, cmd->models,
file, start, end, str, len);
file_replace_range(cmd->system, cmd->models, file, (u32)start, (u32)end, str, (u32)len);
}
fill_buffer_summary(buffer, file, cmd);
}
@ -685,9 +670,9 @@ DOC_SEE(Buffer_Batch_Edit_Type)
Assert(inverse_edits);
char *inv_str = (char*)part->base + part->pos;
int32_t inv_str_max = part->max - part->pos;
umem inv_str_max = part->max - part->pos;
Edit_Spec spec = file_compute_edit(mem, file, edits, str, str_len, inverse_edits, inv_str, inv_str_max, edit_count, type);
Edit_Spec spec = file_compute_edit(mem, file, edits, str, str_len, inverse_edits, inv_str, (u32)inv_str_max, (u32)edit_count, type);
file_do_batch_edit(system, models, file, spec, hist_normal, type);
@ -1010,7 +995,7 @@ If the buffer does not exist or if it is not a lexed buffer, the return is zero.
}
API_EXPORT bool32
Buffer_Read_Tokens(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out)
Buffer_Read_Tokens(Application_Links *app, Buffer_Summary *buffer, size_t start_token, size_t end_token, Cpp_Token *tokens_out)
/*
DOC_PARAM(buffer, Specifies the buffer from which to read tokens.)
DOC_PARAM(first_token, Specifies the index of the first token to read.)
@ -1037,7 +1022,7 @@ The number of output tokens will be end_token - start_token.)
}
API_EXPORT bool32
Buffer_Get_Token_Index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result)
Buffer_Get_Token_Index(Application_Links *app, Buffer_Summary *buffer, size_t pos, Cpp_Get_Token_Result *get_result)
/*
DOC_PARAM(buffer, The buffer from which to get a token.)
DOC_PARAM(pos, The position in the buffer in absolute coordinates.)
@ -1831,32 +1816,26 @@ DOC_SEE(Buffer_Seek)
}
API_EXPORT bool32
View_Set_Highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on)/*
View_Set_Highlight(Application_Links *app, View_Summary *view, size_t start, size_t end, bool32 turn_on)/*
DOC_PARAM(view, The view parameter specifies the view in which to set the highlight.)
DOC_PARAM(start, This parameter specifies the absolute position of the first character of the highlight range.)
DOC_PARAM(end, This parameter specifies the absolute position of the character one past the end of the highlight range.)
DOC_PARAM(turn_on, This parameter indicates whether the highlight is being turned on or off.)
DOC_RETURN(This call returns non-zero on success.)
DOC
(
The highlight is mutually exclusive to the cursor. When the turn_on parameter
is set to true the highlight will be shown and the cursor will be hidden. After
that either setting the cursor with view_set_cursor or calling view_set_highlight
and the turn_on set to false, will switch back to showing the cursor.
)
DOC(The highlight is mutually exclusive to the cursor. When the turn_on parameter is set to true the highlight will be shown and the cursor will be hidden. After that either setting the cursor with view_set_cursor or calling view_set_highlight and the turn_on set to false, will switch back to showing the cursor.)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
System_Functions *system = cmd->system;
View *vptr = imp_get_view(cmd, view);
bool32 result = false;
if (vptr){
if (vptr != 0){
result = true;
if (turn_on){
view_set_temp_highlight(system, vptr, start, end);
}
else{
vptr->file_data.show_temp_highlight = 0;
vptr->file_data.show_temp_highlight = false;
}
fill_view_summary(system, view, vptr, cmd);
}
@ -1900,7 +1879,7 @@ DOC_SEE(Set_Buffer_Flag)
}
API_EXPORT bool32
View_Post_Fade(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color)
View_Post_Fade(Application_Links *app, View_Summary *view, float seconds, size_t start, size_t end, int_color color)
/*
DOC_PARAM(view, The view parameter specifies the view onto which the fade effect shall be posted.)
DOC_PARAM(seconds, This parameter specifies the number of seconds the fade effect should last.)
@ -1914,13 +1893,10 @@ DOC_SEE(int_color)
View *vptr = imp_get_view(cmd, view);
bool32 result = false;
int32_t size = end - start;
if (vptr){
if (size > 0){
result = true;
view_post_paste_effect(vptr, seconds, start, size, color | 0xFF000000);
}
size_t size = end - start;
if (vptr != 0 && size > 0){
result = true;
view_post_paste_effect(vptr, seconds, (u32)start, (u32)size, color | 0xFF000000);
}
return(result);

View File

@ -17,12 +17,12 @@
#include "4coder_helper/4coder_seek_types.h"
typedef struct Cursor_With_Index{
i32 pos;
umem pos;
i32 index;
} Cursor_With_Index;
inline void
write_cursor_with_index(Cursor_With_Index *positions, i32 *count, i32 pos){
write_cursor_with_index(Cursor_With_Index *positions, i32 *count, umem pos){
positions[(*count)].index = *count;
positions[(*count)].pos = pos;
++(*count);
@ -33,7 +33,7 @@ write_cursor_with_index(Cursor_With_Index *positions, i32 *count, i32 pos){
internal void
buffer_quick_sort_cursors(Cursor_With_Index *positions, i32 start, i32 pivot){
i32 mid = start;
i32 pivot_pos = positions[pivot].pos;
umem pivot_pos = positions[pivot].pos;
for (i32 i = mid; i < pivot; ++i){
if (positions[i].pos < pivot_pos){
CursorSwap__(positions[mid], positions[i]);
@ -100,15 +100,15 @@ buffer_update_cursors(Cursor_With_Index *sorted_positions, i32 count, i32 start,
}
}
internal i32
buffer_batch_debug_sort_check(Buffer_Edit *sorted_edits, i32 edit_count){
Buffer_Edit *edit = sorted_edits;
i32 i = 0, start_point = 0;
i32 result = 1;
internal b32
buffer_batch_debug_sort_check(Buffer_Edit *sorted_edits, u32 edit_count){
b32 result = true;
for (i = 0; i < edit_count; ++i, ++edit){
Buffer_Edit *edit = sorted_edits;
size_t start_point = 0;
for (u32 i = 0; i < edit_count; ++i, ++edit){
if (start_point > edit->start){
result = 0; break;
result = false; break;
}
start_point = (edit->end < edit->start + 1)?(edit->start + 1):(edit->end);
}
@ -117,13 +117,18 @@ buffer_batch_debug_sort_check(Buffer_Edit *sorted_edits, i32 edit_count){
}
internal i32
buffer_batch_edit_max_shift(Buffer_Edit *sorted_edits, i32 edit_count){
i32 i = 0;
i32 shift_total = 0, shift_max = 0;
buffer_batch_edit_max_shift(Buffer_Edit *sorted_edits, u32 edit_count){
Buffer_Edit *edit = sorted_edits;
for (i = 0; i < edit_count; ++i, ++edit){
shift_total += (edit->len - (edit->end - edit->start));
i32 shift_total = 0, shift_max = 0;
for (u32 i = 0; i < edit_count; ++i, ++edit){
umem target_length = edit->end - edit->start;
umem edit_length = edit->len;
if (edit_length > target_length){
shift_total += (i32)(edit_length - target_length);
}
else{
shift_total -= (i32)(target_length - edit_length);
}
if (shift_total > shift_max){
shift_max = shift_total;
}
@ -142,36 +147,50 @@ buffer_batch_edit_update_cursors(Cursor_With_Index *sorted_positions, i32 count,
if (lean_right){
for (; edit < end_edit && position < end_position; ++edit){
i32 start = edit->start;
i32 end = edit->end;
umem start = edit->start;
umem end = edit->end;
for (; position->pos < start && position < end_position; ++position){
position->pos += shift_amount;
}
i32 new_end = start + edit->len + shift_amount;
umem new_end = start + edit->len + shift_amount;
for (; position->pos <= end && position < end_position; ++position){
position->pos = new_end;
}
shift_amount += (edit->len - (end - start));
umem target_length = end - start;
umem edit_length = edit->len;
if (edit_length > target_length){
shift_amount += (i32)(edit_length - target_length);
}
else{
shift_amount -= (i32)(target_length - edit_length);
}
}
}
else{
for (; edit < end_edit && position < end_position; ++edit){
i32 start = edit->start;
i32 end = edit->end;
umem start = edit->start;
umem end = edit->end;
for (; position->pos < start && position < end_position; ++position){
position->pos += shift_amount;
}
i32 new_end = start + shift_amount;
umem new_end = start + shift_amount;
for (; position->pos <= end && position < end_position; ++position){
position->pos = new_end;
}
shift_amount += (edit->len - (end - start));
umem target_length = end - start;
umem edit_length = edit->len;
if (edit_length > target_length){
shift_amount += (i32)(edit_length - target_length);
}
else{
shift_amount -= (i32)(target_length - edit_length);
}
}
}
@ -180,7 +199,14 @@ buffer_batch_edit_update_cursors(Cursor_With_Index *sorted_positions, i32 count,
}
for (; edit < end_edit; ++edit){
shift_amount += (edit->len - (edit->end - edit->start));
umem target_length = edit->end - edit->start;
umem edit_length = edit->len;
if (edit_length > target_length){
shift_amount += (i32)(edit_length - target_length);
}
else{
shift_amount -= (i32)(target_length - edit_length);
}
}
return(shift_amount);
@ -288,9 +314,9 @@ typedef struct Gap_Buffer{
umem size2;
umem max;
umem *line_starts;
umem line_count;
umem line_max;
u32 *line_starts;
u32 line_count;
u32 line_max;
} Gap_Buffer;
inline b32
@ -300,11 +326,17 @@ buffer_good(Gap_Buffer *buffer){
}
inline umem
buffer_size(Gap_Buffer *buffer){
buffer_size_umem(Gap_Buffer *buffer){
umem size = buffer->size1 + buffer->size2;
return(size);
}
inline u32
buffer_size(Gap_Buffer *buffer){
umem size = buffer->size1 + buffer->size2;
return(u32)(size);
}
typedef struct Gap_Buffer_Init{
Gap_Buffer *buffer;
char *data;
@ -336,7 +368,7 @@ buffer_init_page_size(Gap_Buffer_Init *init){
}
internal void
buffer_init_provide_page(Gap_Buffer_Init *init, void *page, i32 page_size){
buffer_init_provide_page(Gap_Buffer_Init *init, void *page, umem page_size){
Gap_Buffer *buffer = init->buffer;
buffer->data = (char*)page;
buffer->max = page_size;
@ -456,9 +488,9 @@ buffer_stringify_next(Gap_Buffer_Stream *stream){
}
internal b32
buffer_replace_range(Gap_Buffer *buffer, umem start, umem end, char *str, umem len, i32 *shift_amount, void *scratch, umem scratch_memory, umem *request_amount){
buffer_replace_range(Gap_Buffer *buffer, u32 start, u32 end, char *str, u32 len, i32 *shift_amount, void *scratch, umem scratch_memory, umem *request_amount){
char *data = buffer->data;
umem size = buffer_size(buffer);
u32 size = buffer_size(buffer);
b32 result = false;
assert(0 <= start);
@ -508,7 +540,7 @@ buffer_replace_range(Gap_Buffer *buffer, umem start, umem end, char *str, umem l
}
typedef struct Buffer_Batch_State{
umem i;
u32 i;
i32 shift_total;
} Buffer_Batch_State;
@ -516,14 +548,18 @@ typedef struct Buffer_Batch_State{
internal b32
buffer_batch_edit_step(Buffer_Batch_State *state, Gap_Buffer *buffer, Buffer_Edit *sorted_edits, char *strings, u32 edit_count, void *scratch, umem scratch_size, umem *request_amount){
Buffer_Edit *edit = 0;
umem i = state->i;
u32 i = state->i;
i32 shift_total = state->shift_total;
i32 shift_amount = 0;
b32 result = false;
edit = sorted_edits + i;
for (; i < edit_count; ++i, ++edit){
result = buffer_replace_range(buffer, edit->start + shift_total, edit->end + shift_total, strings + edit->str_start, edit->len, &shift_amount, scratch, scratch_size, request_amount);
u32 start = (u32)(edit->start + shift_total);
u32 end = (u32)(edit->end + shift_total);
u32 len = (u32)(edit->len);
result = buffer_replace_range(buffer, start, end, strings + edit->str_start, len, &shift_amount, scratch, scratch_size, request_amount);
if (result){
break;
}
@ -539,7 +575,7 @@ buffer_batch_edit_step(Buffer_Batch_State *state, Gap_Buffer *buffer, Buffer_Edi
internal void*
buffer_edit_provide_memory(Gap_Buffer *buffer, void *new_data, umem new_max){
void *result = buffer->data;
umem size = buffer_size(buffer);
umem size = buffer_size_umem(buffer);
umem new_gap_size = new_max - size;
assert(new_max >= size);
@ -578,7 +614,7 @@ buffer_stringify(Gap_Buffer *buffer, umem start, umem end, char *out){
internal umem
buffer_convert_out(Gap_Buffer *buffer, char *dest, umem max){
Gap_Buffer_Stream stream = {0};
umem size = buffer_size(buffer);
u32 size = buffer_size(buffer);
assert(size + buffer->line_count <= max);
umem pos = 0;
@ -588,7 +624,7 @@ buffer_convert_out(Gap_Buffer *buffer, char *dest, umem max){
do{
umem chunk_size = stream.end - i;
umem out_size = 0;
i32 result = eol_convert_out(dest + pos, max - pos, stream.data + i, chunk_size, &out_size);
b32 result = eol_convert_out(dest + pos, max - pos, stream.data + i, chunk_size, &out_size);
assert(result);
i = stream.end;
pos += out_size;
@ -599,11 +635,11 @@ buffer_convert_out(Gap_Buffer *buffer, char *dest, umem max){
return(pos);
}
internal i32
buffer_count_newlines(Gap_Buffer *buffer, i32 start, i32 end){
internal u32
buffer_count_newlines(Gap_Buffer *buffer, u32 start, u32 end){
Gap_Buffer_Stream stream = {0};
i32 i = start;
i32 count = 0;
u32 i = start;
u32 count = 0;
assert(0 <= start);
assert(start <= end);
@ -623,9 +659,9 @@ buffer_count_newlines(Gap_Buffer *buffer, i32 start, i32 end){
}
typedef struct Buffer_Measure_Starts{
umem i;
umem count;
umem start;
u32 i;
u32 count;
u32 start;
} Buffer_Measure_Starts;
// TODO(allen): Rewrite this with a duff routine
@ -634,10 +670,10 @@ typedef struct Buffer_Measure_Starts{
internal b32
buffer_measure_starts(Buffer_Measure_Starts *state, Gap_Buffer *buffer){
Gap_Buffer_Stream stream = {0};
umem size = buffer_size(buffer);
umem start = state->start, i = state->i;
umem *start_ptr = buffer->line_starts + state->count;
umem *start_end = buffer->line_starts + buffer->line_max;
u32 size = (u32)buffer_size(buffer);
u32 start = state->start, i = state->i;
u32 *start_ptr = buffer->line_starts + state->count;
u32 *start_end = buffer->line_starts + buffer->line_max;
b32 result = true;
if (buffer_stringify_loop(&stream, buffer, i, size)){
@ -677,13 +713,13 @@ buffer_measure_starts(Buffer_Measure_Starts *state, Gap_Buffer *buffer){
}
internal void
buffer_measure_character_starts(System_Functions *system, Render_Font *font, Gap_Buffer *buffer, umem *character_starts, i32 mode, b32 virtual_white){
buffer_measure_character_starts(System_Functions *system, Render_Font *font, Gap_Buffer *buffer, u32 *character_starts, i32 mode, b32 virtual_white){
assert(mode == 0);
Gap_Buffer_Stream stream = {0};
umem line_index = 0;
umem character_index = 0;
u32 line_index = 0;
u32 character_index = 0;
character_starts[line_index++] = character_index;
@ -745,16 +781,16 @@ enum{
struct Buffer_Layout_Stop{
u32 status;
i32 line_index;
i32 wrap_line_index;
umem pos;
umem next_line_pos;
u32 line_index;
u32 wrap_line_index;
u32 pos;
u32 next_line_pos;
f32 x;
};
struct Buffer_Measure_Wrap_Params{
Gap_Buffer *buffer;
i32 *wrap_line_index;
u32 *wrap_line_index;
System_Functions *system;
Render_Font *font;
b32 virtual_white;
@ -762,18 +798,18 @@ struct Buffer_Measure_Wrap_Params{
struct Buffer_Measure_Wrap_State{
Gap_Buffer_Stream stream;
umem i;
umem size;
u32 i;
u32 size;
b32 still_looping;
i32 line_index;
u32 line_index;
i32 current_wrap_index;
u32 current_wrap_index;
f32 current_adv;
f32 x;
u32 wrap_unit_end;
b32 skipping_whitespace;
i32 wrap_unit_end;
b32 did_wrap;
b32 first_of_the_line;
@ -792,7 +828,7 @@ struct Buffer_Measure_Wrap_State{
#define DrReturn(n) { *S_ptr = S; S_ptr->__pc__ = -1; return(n); }
internal Buffer_Layout_Stop
buffer_measure_wrap_y(Buffer_Measure_Wrap_State *S_ptr, Buffer_Measure_Wrap_Params params, f32 line_shift, b32 do_wrap, i32 wrap_unit_end){
buffer_measure_wrap_y(Buffer_Measure_Wrap_State *S_ptr, Buffer_Measure_Wrap_Params params, f32 line_shift, b32 do_wrap, u32 wrap_unit_end){
Buffer_Measure_Wrap_State S = *S_ptr;
Buffer_Layout_Stop S_stop;
@ -803,7 +839,7 @@ buffer_measure_wrap_y(Buffer_Measure_Wrap_State *S_ptr, Buffer_Measure_Wrap_Para
DrCase(4);
}
S.size = buffer_size(params.buffer);
S.size = (u32)buffer_size(params.buffer);
if (params.virtual_white){
S_stop.status = BLStatus_NeedLineShift;
@ -920,9 +956,9 @@ buffer_measure_wrap_y(Buffer_Measure_Wrap_State *S_ptr, Buffer_Measure_Wrap_Para
#undef DrReturn
internal void
buffer_remeasure_starts(Gap_Buffer *buffer, umem start_line, umem end_line, i32 line_shift, i32 text_shift){
umem *starts = buffer->line_starts;
umem line_count = buffer->line_count;
buffer_remeasure_starts(Gap_Buffer *buffer, u32 start_line, u32 end_line, i32 line_shift, i32 text_shift){
u32 *starts = buffer->line_starts;
u32 line_count = buffer->line_count;
assert(0 <= start_line);
assert(start_line <= end_line);
@ -933,7 +969,7 @@ buffer_remeasure_starts(Gap_Buffer *buffer, umem start_line, umem end_line, i32
// Adjust
if (text_shift != 0){
umem line_i = end_line;
u32 line_i = end_line;
starts += line_i;
for (; line_i < line_count; ++line_i, ++starts){
*starts += text_shift;
@ -942,8 +978,8 @@ buffer_remeasure_starts(Gap_Buffer *buffer, umem start_line, umem end_line, i32
}
// Shift
umem new_line_count = line_count;
umem new_end_line = end_line;
u32 new_line_count = line_count;
u32 new_end_line = end_line;
if (line_shift != 0){
new_line_count += line_shift;
new_end_line += line_shift;
@ -954,12 +990,12 @@ buffer_remeasure_starts(Gap_Buffer *buffer, umem start_line, umem end_line, i32
// Iteration data (yikes! Need better loop system)
Gap_Buffer_Stream stream = {0};
umem size = buffer_size(buffer);
umem char_i = starts[start_line];
umem line_i = start_line;
u32 size = buffer_size(buffer);
u32 char_i = starts[start_line];
u32 line_i = start_line;
// Line start measurement
umem start = char_i;
u32 start = char_i;
if (buffer_stringify_loop(&stream, buffer, char_i, size)){
b32 still_looping = 0;
@ -993,10 +1029,10 @@ buffer_remeasure_starts(Gap_Buffer *buffer, umem start_line, umem end_line, i32
}
internal void
buffer_remeasure_character_starts(System_Functions *system, Render_Font *font, Gap_Buffer *buffer, umem start_line, umem end_line, i32 line_shift, umem *character_starts, i32 mode, b32 virtual_whitespace){
buffer_remeasure_character_starts(System_Functions *system, Render_Font *font, Gap_Buffer *buffer, u32 start_line, u32 end_line, i32 line_shift, u32 *character_starts, i32 mode, b32 virtual_whitespace){
assert(mode == 0);
umem new_line_count = buffer->line_count;
u32 new_line_count = buffer->line_count;
assert(0 <= start_line);
assert(start_line <= end_line);
@ -1005,8 +1041,8 @@ buffer_remeasure_character_starts(System_Functions *system, Render_Font *font, G
++end_line;
// Shift
umem line_count = new_line_count;
umem new_end_line = end_line;
u32 line_count = new_line_count;
u32 new_end_line = end_line;
if (line_shift != 0){
line_count -= line_shift;
new_end_line += line_shift;
@ -1016,13 +1052,13 @@ buffer_remeasure_character_starts(System_Functions *system, Render_Font *font, G
// Iteration data
Gap_Buffer_Stream stream = {0};
umem size = buffer_size(buffer);
umem char_i = buffer->line_starts[start_line];
umem line_i = start_line;
u32 size = buffer_size(buffer);
u32 char_i = buffer->line_starts[start_line];
u32 line_i = start_line;
// Character measurement
umem last_char_start = character_starts[line_i];
umem current_char_start = last_char_start;
u32 last_char_start = character_starts[line_i];
u32 current_char_start = last_char_start;
b32 skipping_whitespace = false;
if (virtual_whitespace){
@ -1076,8 +1112,8 @@ buffer_remeasure_character_starts(System_Functions *system, Render_Font *font, G
// Adjust
if (line_i <= new_end_line){
umem old_value = character_starts[line_i];
umem new_value = current_char_start;
u32 old_value = character_starts[line_i];
u32 new_value = current_char_start;
i32 character_shift = 0;
if (new_value > old_value){
character_shift = (i32)(new_value - old_value);
@ -1176,10 +1212,10 @@ buffer_remeasure_wrap_y(Gap_Buffer *buffer, umem start_line, umem end_line, i32
}
}
internal umem
binary_search(umem *array, umem value, umem l_bound, umem u_bound){
internal u32
binary_search(u32 *array, u32 value, u32 l_bound, u32 u_bound){
value = clamp_bottom(0, value);
umem start = l_bound, end = u_bound, i = 0;
u32 start = l_bound, end = u_bound, i = 0;
for (;;){
i = (start + end) >> 1;
if (array[i] < value){
@ -1200,34 +1236,34 @@ binary_search(umem *array, umem value, umem l_bound, umem u_bound){
return(i);
}
inline umem
buffer_get_line_index_range(Gap_Buffer *buffer, umem pos, umem l_bound, umem u_bound){
inline u32
buffer_get_line_index_range(Gap_Buffer *buffer, u32 pos, u32 l_bound, u32 u_bound){
assert(0 <= l_bound);
assert(l_bound <= u_bound);
assert(u_bound <= buffer->line_count);
assert(buffer->line_starts != 0);
umem i = binary_search(buffer->line_starts, pos, l_bound, u_bound);
u32 i = binary_search(buffer->line_starts, pos, l_bound, u_bound);
return(i);
}
inline umem
buffer_get_line_index(Gap_Buffer *buffer, umem pos){
umem result = buffer_get_line_index_range(buffer, pos, 0, buffer->line_count);
inline u32
buffer_get_line_index(Gap_Buffer *buffer, u32 pos){
u32 result = buffer_get_line_index_range(buffer, pos, 0, buffer->line_count);
return(result);
}
inline umem
buffer_get_line_index_from_character_pos(umem *character_starts, umem pos, umem l_bound, umem u_bound){
umem i = binary_search(character_starts, pos, l_bound, u_bound);
inline u32
buffer_get_line_index_from_character_pos(u32 *character_starts, u32 pos, u32 l_bound, u32 u_bound){
u32 i = binary_search(character_starts, pos, l_bound, u_bound);
return(i);
}
inline umem
buffer_get_line_index_from_wrapped_y(umem *wrap_line_index, f32 y, umem line_height, umem l_bound, umem u_bound){
umem wrap_index = floor32(y/line_height);
umem i = binary_search(wrap_line_index, wrap_index, l_bound, u_bound);
inline u32
buffer_get_line_index_from_wrapped_y(u32 *wrap_line_index, f32 y, i32 line_height, u32 l_bound, u32 u_bound){
u32 wrap_index = floor32(y/line_height);
u32 i = binary_search(wrap_line_index, wrap_index, l_bound, u_bound);
return(i);
}
@ -1235,10 +1271,10 @@ internal Partial_Cursor
buffer_partial_from_pos(Gap_Buffer *buffer, umem pos){
Partial_Cursor result = {0};
umem size = buffer_size(buffer);
u32 size = buffer_size(buffer);
pos = clamp_umem(0, pos, size);
umem line_index = buffer_get_line_index_range(buffer, pos, 0, buffer->line_count);
u32 line_index = buffer_get_line_index_range(buffer, (u32)pos, 0, (u32)buffer->line_count);
result.pos = pos;
result.line = line_index+1;
result.character = pos - buffer->line_starts[line_index] + 1;
@ -1247,10 +1283,10 @@ buffer_partial_from_pos(Gap_Buffer *buffer, umem pos){
}
internal Partial_Cursor
buffer_partial_from_line_character(Gap_Buffer *buffer, i32 line, i32 character){
buffer_partial_from_line_character(Gap_Buffer *buffer, umem line, umem character, b32 reversed){
Partial_Cursor result = {0};
i32 line_index = line - 1;
umem line_index = line - 1;
if (line_index >= buffer->line_count){
line_index = buffer->line_count - 1;
}
@ -1258,35 +1294,37 @@ buffer_partial_from_line_character(Gap_Buffer *buffer, i32 line, i32 character){
line_index = 0;
}
i32 size = buffer_size(buffer);
umem size = buffer_size(buffer);
i32 this_start = buffer->line_starts[line_index];
i32 max_character = (size-this_start) + 1;
umem this_start = buffer->line_starts[line_index];
umem max_character = (size-this_start) + 1;
if (line_index+1 < buffer->line_count){
i32 next_start = buffer->line_starts[line_index+1];
umem next_start = buffer->line_starts[line_index+1];
max_character = (next_start-this_start);
}
i32 adjusted_pos = 0;
umem adjusted_pos = 0;
if (character > 0){
if (character > max_character){
adjusted_pos = max_character - 1;
if (reversed){
if (character > max_character){
adjusted_pos = 0;
}
else{
adjusted_pos = max_character + character;
}
}
else{
adjusted_pos = character - 1;
if (character > max_character){
adjusted_pos = max_character - 1;
}
else{
adjusted_pos = character - 1;
}
}
}
else if (character == 0){
adjusted_pos = 0;
}
else{
if (-character > max_character){
adjusted_pos = 0;
}
else{
adjusted_pos = max_character + character;
}
}
result.pos = this_start + adjusted_pos;
result.line = line_index + 1;
@ -1300,8 +1338,8 @@ struct Buffer_Cursor_Seek_Params{
Buffer_Seek seek;
System_Functions *system;
Render_Font *font;
i32 *wrap_line_index;
i32 *character_starts;
u32 *wrap_line_index;
u32 *character_starts;
b32 virtual_white;
b32 return_hint;
Full_Cursor *cursor_out;
@ -1314,9 +1352,9 @@ struct Buffer_Cursor_Seek_State{
Gap_Buffer_Stream stream;
b32 still_looping;
i32 i;
i32 size;
i32 wrap_unit_end;
u32 i;
u32 size;
u32 wrap_unit_end;
b32 first_of_the_line;
b32 xy_seek;
@ -1340,7 +1378,7 @@ struct Buffer_Cursor_Seek_State{
#define DrReturn(n) { *S_ptr = S; S_ptr->__pc__ = -1; return(n); }
internal Buffer_Layout_Stop
buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params params, f32 line_shift, b32 do_wrap, i32 wrap_unit_end){
buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params params, f32 line_shift, b32 do_wrap, u32 wrap_unit_end){
Buffer_Cursor_Seek_State S = *S_ptr;
Buffer_Layout_Stop S_stop;
@ -1354,37 +1392,40 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
S.font_height = font_get_height(params.font);
S.xy_seek = (params.seek.type == buffer_seek_wrapped_xy || params.seek.type == buffer_seek_unwrapped_xy);
S.size = buffer_size(params.buffer);
S.size = (u32)buffer_size(params.buffer);
// Get cursor hint
{
i32 line_index = 0;
u32 line_index = 0;
switch (params.seek.type){
case buffer_seek_pos:
{
params.seek.pos = clamp(0, params.seek.pos, S.size);
params.seek.pos = clamp_u32(0, (u32)params.seek.pos, S.size);
line_index = buffer_get_line_index(params.buffer, params.seek.pos);
line_index = buffer_get_line_index(params.buffer, (u32)params.seek.pos);
}break;
case buffer_seek_character_pos:
{
i32 line_count = params.buffer->line_count;
i32 max_character = params.character_starts[line_count] - 1;
params.seek.pos = clamp(0, params.seek.pos, max_character);
u32 line_count = params.buffer->line_count;
u32 max_character = params.character_starts[line_count] - 1;
params.seek.pos = clamp_u32(0, (u32)params.seek.pos, max_character);
line_index = buffer_get_line_index_from_character_pos(params.character_starts, params.seek.pos, 0, params.buffer->line_count);
u32 *char_starts = params.character_starts;
u32 pos = (u32)params.seek.pos;
line_index = buffer_get_line_index_from_character_pos(char_starts, pos, 0, line_count);
}break;
case buffer_seek_line_char:
{
line_index = params.seek.line - 1;
line_index = (u32)params.seek.line - 1;
line_index = clamp_bottom(0, line_index);
}break;
case buffer_seek_unwrapped_xy:
{
line_index = (i32)(params.seek.y / S.font_height);
line_index = (u32)(params.seek.y / S.font_height);
line_index = clamp_bottom(0, line_index);
}break;
@ -1396,7 +1437,7 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
default: InvalidCodePath;
}
i32 safe_line_index = line_index;
umem safe_line_index = line_index;
if (line_index >= params.buffer->line_count){
safe_line_index = params.buffer->line_count-1;
}
@ -1418,8 +1459,8 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
// non-virtual character of the line.
if (params.virtual_white){
S_stop.status = BLStatus_NeedLineShift;
S_stop.line_index = S.next_cursor.line-1;
S_stop.wrap_line_index = S.next_cursor.wrap_line-1;
S_stop.line_index = (u32)(S.next_cursor.line-1);
S_stop.wrap_line_index = (u32)(S.next_cursor.wrap_line-1);
DrYield(1, S_stop);
S.next_cursor.unwrapped_x += line_shift;
@ -1495,7 +1536,7 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
}
// Main seek loop
S.i = S.next_cursor.pos;
S.i = (u32)S.next_cursor.pos;
S.stream = null_buffer_stream;
S.stream.use_termination_character = 1;
@ -1528,8 +1569,8 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
if (params.virtual_white){
S_stop.status = BLStatus_NeedLineShift;
S_stop.line_index = S.next_cursor.line-1;
S_stop.wrap_line_index = S.next_cursor.wrap_line-1;
S_stop.line_index = (u32)(S.next_cursor.line-1);
S_stop.wrap_line_index = (u32)(S.next_cursor.wrap_line-1);
DrYield(2, S_stop);
}
@ -1547,9 +1588,9 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
if (S.step.i >= S.wrap_unit_end){
S_stop.status = BLStatus_NeedWrapDetermination;
S_stop.line_index = S.next_cursor.line-1;
S_stop.wrap_line_index = S.next_cursor.wrap_line-1;
S_stop.pos = S.step.i;
S_stop.line_index = (u32)(S.next_cursor.line-1);
S_stop.wrap_line_index = (u32)(S.next_cursor.wrap_line-1);
S_stop.pos = (u32)(S.step.i);
S_stop.x = S.next_cursor.wrapped_x;
DrYield(4, S_stop);
@ -1561,8 +1602,8 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
++S.next_cursor.wrap_line;
if (params.virtual_white){
S_stop.status = BLStatus_NeedWrapLineShift;
S_stop.line_index = S.next_cursor.line-1;
S_stop.wrap_line_index = S.next_cursor.wrap_line-1;
S_stop.line_index = (u32)(S.next_cursor.line-1);
S_stop.wrap_line_index = (u32)(S.next_cursor.wrap_line-1);
DrYield(3, S_stop);
}
@ -1662,11 +1703,9 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
#undef DrReturn
internal void
buffer_invert_edit_shift(Gap_Buffer *buffer, Buffer_Edit edit, Buffer_Edit *inverse, char *strings,
i32 *str_pos, i32 max, i32 shift_amount){
i32 pos = *str_pos;
i32 len = edit.end - edit.start;
assert(pos >= 0);
buffer_invert_edit_shift(Gap_Buffer *buffer, Buffer_Edit edit, Buffer_Edit *inverse, char *strings, u32 *str_pos, u32 max, i32 shift_amount){
u32 pos = *str_pos;
u32 len = (u32)(edit.end - edit.start);
assert(pos + len <= max);
*str_pos = pos + len;
@ -1678,34 +1717,40 @@ buffer_invert_edit_shift(Gap_Buffer *buffer, Buffer_Edit edit, Buffer_Edit *inve
}
inline void
buffer_invert_edit(Gap_Buffer *buffer, Buffer_Edit edit, Buffer_Edit *inverse, char *strings,
i32 *str_pos, i32 max){
buffer_invert_edit(Gap_Buffer *buffer, Buffer_Edit edit, Buffer_Edit *inverse, char *strings, u32 *str_pos, u32 max){
buffer_invert_edit_shift(buffer, edit, inverse, strings, str_pos, max, 0);
}
typedef struct Buffer_Invert_Batch{
i32 i;
umem i;
i32 shift_amount;
i32 len;
u32 len;
} Buffer_Invert_Batch;
internal i32
buffer_invert_batch(Buffer_Invert_Batch *state, Gap_Buffer *buffer, Buffer_Edit *edits, i32 count,
Buffer_Edit *inverse, char *strings, i32 *str_pos, i32 max){
internal b32
buffer_invert_batch(Buffer_Invert_Batch *state, Gap_Buffer *buffer, Buffer_Edit *edits, u32 count, Buffer_Edit *inverse, char *strings, u32 *str_pos, u32 max){
i32 shift_amount = state->shift_amount;
i32 i = state->i;
umem i = state->i;
Buffer_Edit *edit = edits + i;
Buffer_Edit *inv_edit = inverse + i;
i32 result = 0;
b32 result = false;
for (; i < count; ++i, ++edit, ++inv_edit){
if (*str_pos + edit->end - edit->start <= max){
buffer_invert_edit_shift(buffer, *edit, inv_edit, strings, str_pos, max, shift_amount);
shift_amount += (edit->len - (edit->end - edit->start));
umem target_length = edit->end - edit->start;
umem edit_length = edit->len;
if (edit_length > target_length){
shift_amount += (i32)(edit_length - target_length);
}
else{
shift_amount -= (i32)(target_length - edit_length);
}
}
else{
result = 1;
state->len = edit->end - edit->start;
result = true;
state->len = (u32)(edit->end - edit->start);
}
}
@ -1762,8 +1807,8 @@ write_render_item(Render_Item_Write write, umem index, u32 codepoint, u32 flags)
struct Buffer_Render_Params{
Gap_Buffer *buffer;
Buffer_Render_Item *items;
i32 max;
i32 *count;
u32 max;
u32 *count;
f32 port_x;
f32 port_y;
f32 clip_w;
@ -1782,8 +1827,8 @@ struct Buffer_Render_Params{
struct Buffer_Render_State{
Gap_Buffer_Stream stream;
b32 still_looping;
i32 i;
i32 size;
umem i;
umem size;
f32 shift_x;
f32 shift_y;
@ -1793,11 +1838,11 @@ struct Buffer_Render_State{
Render_Item_Write write;
f32 byte_advance;
i32 line;
i32 wrap_line;
umem line;
umem wrap_line;
umem wrap_unit_end;
b32 skipping_whitespace;
b32 first_of_the_line;
i32 wrap_unit_end;
Translation_State tran;
Translation_Emits emits;
@ -1843,8 +1888,8 @@ buffer_render_data(Buffer_Render_State *S_ptr, Buffer_Render_Params params, f32
if (params.virtual_white){
S_stop.status = BLStatus_NeedLineShift;
S_stop.line_index = S.line;
S_stop.wrap_line_index = S.wrap_line;
S_stop.line_index = (u32)(S.line);
S_stop.wrap_line_index = (u32)(S.wrap_line);
DrYield(1, S_stop);
}
@ -1878,9 +1923,9 @@ buffer_render_data(Buffer_Render_State *S_ptr, Buffer_Render_Params params, f32
if (!S.behavior.do_newline && S.step.i >= S.wrap_unit_end){
S_stop.status = BLStatus_NeedWrapDetermination;
S_stop.line_index = S.line;
S_stop.wrap_line_index = S.wrap_line;
S_stop.pos = S.step.i;
S_stop.line_index = (u32)(S.line);
S_stop.wrap_line_index = (u32)(S.wrap_line);
S_stop.pos = (u32)(S.step.i);
S_stop.x = S.write.x - S.shift_x;
DrYield(4, S_stop);
@ -1889,8 +1934,8 @@ buffer_render_data(Buffer_Render_State *S_ptr, Buffer_Render_Params params, f32
if (do_wrap && !S.first_of_the_line){
if (params.virtual_white){
S_stop.status = BLStatus_NeedWrapLineShift;
S_stop.line_index = S.line;
S_stop.wrap_line_index = S.wrap_line + 1;
S_stop.line_index = (u32)(S.line);
S_stop.wrap_line_index = (u32)(S.wrap_line + 1);
DrYield(2, S_stop);
}
@ -1928,8 +1973,8 @@ buffer_render_data(Buffer_Render_State *S_ptr, Buffer_Render_Params params, f32
if (params.virtual_white){
S_stop.status = BLStatus_NeedLineShift;
S_stop.line_index = S.line+1;
S_stop.wrap_line_index = S.wrap_line+1;
S_stop.line_index = (u32)(S.line+1);
S_stop.wrap_line_index = (u32)(S.wrap_line+1);
DrYield(3, S_stop);
S.skipping_whitespace = 1;

View File

@ -21,7 +21,7 @@ enum Edit_Pos_Set_Type{
struct File_Edit_Positions{
GUI_Scroll_Vars scroll;
Full_Cursor cursor;
i32 mark;
umem mark;
f32 preferred_x;
i32 scroll_i;
i32 last_set_type;
@ -54,7 +54,7 @@ edit_pos_set_scroll(File_Edit_Positions *edit_pos, GUI_Scroll_Vars scroll){
//
struct Text_Effect{
i32 start, end;
u32 start, end;
u32 color;
f32 seconds_down, seconds_max;
};
@ -109,20 +109,20 @@ global_const Editing_File_Settings null_editing_file_settings = {0};
struct Editing_File_State{
Gap_Buffer buffer;
i32 *wrap_line_index;
i32 wrap_max;
u32 *wrap_line_index;
u32 wrap_max;
i32 *character_starts;
i32 character_start_max;
u32 *character_starts;
u32 character_start_max;
f32 *line_indents;
i32 line_indent_max;
u32 line_indent_max;
i32 wrap_line_count;
u32 wrap_line_count;
i32 *wrap_positions;
i32 wrap_position_count;
i32 wrap_position_max;
u32 *wrap_positions;
u32 wrap_position_count;
u32 wrap_position_max;
Undo_Data undo;
@ -385,14 +385,14 @@ edit_pos_get_new(Editing_File *file, i32 index){
//
inline Partial_Cursor
file_compute_cursor_from_pos(Editing_File *file, i32 pos){
file_compute_cursor_from_pos(Editing_File *file, umem pos){
Partial_Cursor result = buffer_partial_from_pos(&file->state.buffer, pos);
return(result);
}
inline Partial_Cursor
file_compute_cursor_from_line_character(Editing_File *file, i32 line, i32 character){
Partial_Cursor result = buffer_partial_from_line_character(&file->state.buffer, line, character);
file_compute_cursor_from_line_character(Editing_File *file, umem line, umem character, b32 reversed){
Partial_Cursor result = buffer_partial_from_line_character(&file->state.buffer, line, character, reversed);
return(result);
}
@ -407,7 +407,12 @@ file_compute_partial_cursor(Editing_File *file, Buffer_Seek seek, Partial_Cursor
case buffer_seek_line_char:
{
*cursor = file_compute_cursor_from_line_character(file, seek.line, seek.character);
*cursor = file_compute_cursor_from_line_character(file, seek.line, seek.character, true);
}break;
case buffer_seek_line_reverse_char:
{
*cursor = file_compute_cursor_from_line_character(file, seek.line, seek.character, false);
}break;
default:

View File

@ -146,7 +146,7 @@ struct File_Viewing_Data{
Editing_File *file;
Full_Cursor temp_highlight;
i32 temp_highlight_end_pos;
umem temp_highlight_end_pos;
b32 show_temp_highlight;
b32 show_whitespace;
@ -289,9 +289,9 @@ view_file_height(View *view){
return (result);
}
inline i32
inline size_t
view_get_cursor_pos(View *view){
i32 result = 0;
size_t result = 0;
if (view->file_data.show_temp_highlight){
result = view->file_data.temp_highlight.pos;
}
@ -402,14 +402,14 @@ view_compute_cursor(System_Functions *system, View *view, Buffer_Seek seek, b32
Buffer_Cursor_Seek_State state = {0};
Buffer_Layout_Stop stop = {0};
i32 size = buffer_size(params.buffer);
umem size = buffer_size(params.buffer);
f32 line_shift = 0.f;
b32 do_wrap = 0;
i32 wrap_unit_end = 0;
u32 wrap_unit_end = 0;
u32 wrap_array_index = 0;
b32 first_wrap_determination = 1;
i32 wrap_array_index = 0;
b32 do_wrap = false;
b32 first_wrap_determination = true;
do{
stop = buffer_cursor_seek(&state, params, line_shift, do_wrap, wrap_unit_end);
@ -478,15 +478,13 @@ view_compute_max_target_y(i32 lowest_line, i32 line_height, f32 view_height){
internal i32
file_compute_lowest_line(Editing_File *file, f32 font_height){
i32 lowest_line = 0;
Gap_Buffer *buffer = &file->state.buffer;
if (file->settings.unwrapped_lines){
lowest_line = buffer->line_count;
lowest_line = (i32)(buffer->line_count);
}
else{
lowest_line = file->state.wrap_line_index[buffer->line_count];
lowest_line = (i32)(file->state.wrap_line_index[buffer->line_count]);
}
return(lowest_line);
}
@ -531,7 +529,7 @@ view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){
}
}
target_y = clamp(0, target_y, max_y);
target_y = clamp_i32(0, target_y, max_y);
if (cursor_x >= target_x + max_x){
target_x = ceil32(cursor_x - max_x/2);
@ -621,7 +619,7 @@ view_set_cursor_and_scroll(View *view, Full_Cursor cursor, b32 set_preferred_x,
}
inline void
view_set_temp_highlight(System_Functions *system, View *view, i32 pos, i32 end_pos){
view_set_temp_highlight(System_Functions *system, View *view, umem pos, umem end_pos){
view->file_data.temp_highlight = view_compute_cursor(system, view, seek_pos(pos), 0);
view->file_data.temp_highlight_end_pos = end_pos;
view->file_data.show_temp_highlight = 1;
@ -743,9 +741,8 @@ save_file_to_name(System_Functions *system, Models *models, Editing_File *file,
models->hook_save_file(&models->app_links, file->id.id);
}
i32 max = 0, size = 0;
umem max = 0, size = 0;
b32 dos_write_mode = file->settings.dos_write_mode;
char *data = 0;
Gap_Buffer *buffer = &file->state.buffer;
if (dos_write_mode){
@ -755,8 +752,9 @@ save_file_to_name(System_Functions *system, Models *models, Editing_File *file,
max = buffer_size(buffer);
}
b32 used_general = 0;
Temp_Memory temp = begin_temp_memory(&mem->part);
char *data = 0;
b32 used_general = 0;
char empty = 0;
if (max == 0){
data = &empty;
@ -851,14 +849,14 @@ enum{
internal i32
file_grow_starts_as_needed(General_Memory *general, Gap_Buffer *buffer, i32 additional_lines){
b32 result = GROW_NOT_NEEDED;
i32 max = buffer->line_max;
i32 count = buffer->line_count;
i32 target_lines = count + additional_lines;
u32 max = buffer->line_max;
u32 count = buffer->line_count;
u32 target_lines = count + additional_lines;
if (target_lines > max || max == 0){
max = l_round_up_i32(target_lines + max, KB(1));
max = l_round_up_u32(target_lines + max, KB(1));
i32 *new_lines = (i32*)general_memory_reallocate(general, buffer->line_starts, sizeof(i32)*count, sizeof(f32)*max);
u32 *new_lines = (u32*)general_memory_reallocate(general, buffer->line_starts, sizeof(u32)*count, sizeof(u32)*max);
if (new_lines){
result = GROW_SUCCESS;
@ -879,7 +877,7 @@ file_update_cursor_positions(System_Functions *system, Models *models, Editing_F
for (View_Iter iter = file_view_iter_init(layout, file, 0);
file_view_iter_good(iter);
iter = file_view_iter_next(iter)){
i32 pos = view_get_cursor_pos(iter.view);
umem pos = view_get_cursor_pos(iter.view);
if (!iter.view->file_data.show_temp_highlight){
Full_Cursor cursor = view_compute_cursor(system, iter.view, seek_pos(pos), 0);
@ -898,20 +896,20 @@ file_update_cursor_positions(System_Functions *system, Models *models, Editing_F
internal void
file_measure_starts(General_Memory *general, Gap_Buffer *buffer){
if (!buffer->line_starts){
i32 max = buffer->line_max = KB(1);
buffer->line_starts = (i32*)general_memory_allocate(general, max*sizeof(i32));
TentativeAssert(buffer->line_starts);
u32 max = buffer->line_max = KB(1);
buffer->line_starts = (u32*)general_memory_allocate(general, max*sizeof(u32));
TentativeAssert(buffer->line_starts != 0);
// TODO(allen): when unable to allocate?
}
Buffer_Measure_Starts state = {0};
while (buffer_measure_starts(&state, buffer)){
i32 count = state.count;
i32 max = buffer->line_max;
u32 count = state.count;
u32 max = buffer->line_max;
max = ((max + 1) << 1);
{
i32 *new_lines = (i32*)general_memory_reallocate(general, buffer->line_starts, sizeof(i32)*count, sizeof(i32)*max);
u32 *new_lines = (u32*)general_memory_reallocate(general, buffer->line_starts, sizeof(u32)*count, sizeof(u32)*max);
// TODO(allen): when unable to grow?
TentativeAssert(new_lines);
@ -921,19 +919,18 @@ file_measure_starts(General_Memory *general, Gap_Buffer *buffer){
}
}
// NOTE(allen): These calls assumes that the buffer's line starts are already correct,
// and that the buffer's line_count is correct.
// NOTE(allen): These calls assumes that the buffer's line starts are already correct, and that the buffer's line_count is correct.
internal void
file_allocate_metadata_as_needed(General_Memory *general, Gap_Buffer *buffer, void **mem, i32 *mem_max_count, i32 count, i32 item_size){
file_allocate_metadata_as_needed(General_Memory *general, Gap_Buffer *buffer, void **mem, u32 *mem_max_count, u32 count, u32 item_size){
if (*mem == 0){
i32 max = ((count+1)*2);
u32 max = ((count+1)*2);
max = (max+(0x3FF))&(~(0x3FF));
*mem = general_memory_allocate(general, max*item_size);
*mem_max_count = max;
}
else if (*mem_max_count < count){
i32 old_max = *mem_max_count;
i32 max = ((count+1)*2);
u32 old_max = *mem_max_count;
u32 max = ((count+1)*2);
max = (max+(0x3FF))&(~(0x3FF));
void *new_mem = general_memory_reallocate(general, *mem, item_size*old_max, item_size*max);
@ -946,7 +943,7 @@ file_allocate_metadata_as_needed(General_Memory *general, Gap_Buffer *buffer, vo
inline void
file_allocate_character_starts_as_needed(General_Memory *general, Editing_File *file){
file_allocate_metadata_as_needed(general, &file->state.buffer, (void**)&file->state.character_starts, &file->state. character_start_max, file->state.buffer.line_count, sizeof(i32));
file_allocate_metadata_as_needed(general, &file->state.buffer, (void**)&file->state.character_starts, &file->state.character_start_max, file->state.buffer.line_count, sizeof(u32));
}
internal void
@ -992,9 +989,9 @@ struct Code_Wrap_State{
b32 in_pp_body;
Code_Wrap_X plane_wrap_x;
i32 *line_starts;
i32 line_index;
i32 next_line_start;
u32 *line_starts;
u32 line_index;
u32 next_line_start;
f32 x;
b32 consume_newline;
@ -1394,7 +1391,7 @@ struct Wrap_Current_Shift{
};
internal Wrap_Current_Shift
get_current_shift(Code_Wrap_State *wrap_state, i32 next_line_start){
get_current_shift(Code_Wrap_State *wrap_state, u32 next_line_start){
Wrap_Current_Shift result = {0};
result.shift = wrap_state->wrap_x.paren_nesting[wrap_state->wrap_x.paren_safe_top];
@ -1592,7 +1589,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
if (use_tokens){
Code_Wrap_State original_wrap_state = wrap_state;
i32 next_line_start = buffer_size(params.buffer);
u32 next_line_start = buffer_size(params.buffer);
if (stop.line_index+1 < params.buffer->line_count){
next_line_start = params.buffer->line_starts[stop.line_index+1];
}
@ -1628,16 +1625,12 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
if (wrap_state.token_ptr->type == CPP_TOKEN_COMMENT ||
wrap_state.token_ptr->type == CPP_TOKEN_STRING_CONSTANT){
i32 i = wrap_state.token_ptr->start;
i32 end_i = i + wrap_state.token_ptr->size;
if (i < wrap_state.i){
i = wrap_state.i;
}
u32 i = wrap_state.token_ptr->start;
u32 end_i = i + wrap_state.token_ptr->size;
if (end_i > wrap_state.next_line_start){
end_i = wrap_state.next_line_start;
}
i = clamp_bottom((u32)wrap_state.i, i);
end_i = clamp_top(end_i, (u32)wrap_state.next_line_start);
f32 x = wrap_state.x;
@ -1736,12 +1729,12 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
current_shift = get_current_shift(&wrap_state, next_line_start);
b32 next_token_is_on_line = 0;
b32 next_token_is_on_line = false;
if (wrap_state.token_ptr->start < next_line_start){
next_token_is_on_line = 1;
next_token_is_on_line = true;
}
i32 next_wrap_position = step.position_end;
u32 next_wrap_position = (u32)step.position_end;
f32 wrap_x = step.final_x;
if (wrap_state.token_ptr->start > step.position_start && next_wrap_position < wrap_state.token_ptr->start && next_token_is_on_line){
next_wrap_position = wrap_state.token_ptr->start;
@ -1930,8 +1923,6 @@ file_set_min_base_width(System_Functions *system, Models *models, Editing_File *
internal void
file_create_from_string(System_Functions *system, Models *models, Editing_File *file, String val, b8 read_only = 0){
//Font_Set *font_set = models->font_set;
General_Memory *general = &models->mem.general;
Partition *part = &models->mem.part;
Open_File_Hook_Function *hook_open_file = models->hook_open_file;
@ -1940,8 +1931,8 @@ file_create_from_string(System_Functions *system, Models *models, Editing_File *
file->state = null_editing_file_state;
Gap_Buffer_Init init = buffer_begin_init(&file->state.buffer, val.str, val.size);
for (; buffer_init_need_more(&init); ){
i32 page_size = buffer_init_page_size(&init);
page_size = l_round_up_i32(page_size, KB(4));
umem page_size = buffer_init_page_size(&init);
page_size = l_round_up_umem(page_size, KB(4));
if (page_size < KB(4)){
page_size = KB(4);
}
@ -1954,7 +1945,7 @@ file_create_from_string(System_Functions *system, Models *models, Editing_File *
b32 init_success = buffer_end_init(&init, part->base + part->pos, scratch_size);
AllowLocal(init_success); Assert(init_success);
if (buffer_size(&file->state.buffer) < val.size){
if (buffer_size(&file->state.buffer) < (u32)val.size){
file->settings.dos_write_mode = 1;
}
file_synchronize_times(system, file);
@ -2054,11 +2045,10 @@ Job_Callback_Sig(job_full_lex){
General_Memory *general = (General_Memory*)data[1];
Gap_Buffer *buffer = &file->state.buffer;
i32 text_size = buffer_size(buffer);
u32 text_size = buffer_size(buffer);
u32 aligned_buffer_size = (text_size + 3)&(~3);
i32 aligned_buffer_size = (text_size + 3)&(~3);
while (memory->size < aligned_buffer_size){
while (memory->size < (umem)aligned_buffer_size){
system->grow_thread_memory(memory);
}
@ -2073,7 +2063,7 @@ Job_Callback_Sig(job_full_lex){
// TODO(allen): deduplicate this against relex
char *chunks[3];
i32 chunk_sizes[3];
umem chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
@ -2088,10 +2078,10 @@ Job_Callback_Sig(job_full_lex){
do{
char *chunk = chunks[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
umem chunk_size = chunk_sizes[chunk_index];
i32 result =
cpp_lex_step(&lex, chunk, chunk_size, text_size, &tokens, 2048);
cpp_lex_step(&lex, chunk, (i32)chunk_size, text_size, &tokens, 2048);
switch (result){
case LexResult_NeedChunk: ++chunk_index; break;
@ -2215,7 +2205,7 @@ file_first_lex_serial(Mem_Options *mem, Editing_File *file){
// TODO(allen): deduplicate this against relex
char *chunks[3];
i32 chunk_sizes[3];
umem chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
@ -2232,9 +2222,9 @@ file_first_lex_serial(Mem_Options *mem, Editing_File *file){
do{
char *chunk = chunks[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
umem chunk_size = chunk_sizes[chunk_index];
i32 result = cpp_lex_step(&lex, chunk, chunk_size, text_size, &tokens, NO_OUT_LIMIT);
i32 result = cpp_lex_step(&lex, chunk, (i32)chunk_size, text_size, &tokens, NO_OUT_LIMIT);
switch (result){
case LexResult_NeedChunk: ++chunk_index; break;
@ -2291,7 +2281,7 @@ file_first_lex_serial(Mem_Options *mem, Editing_File *file){
}
internal b32
file_relex_parallel(System_Functions *system, Mem_Options *mem, Editing_File *file, i32 start_i, i32 end_i, i32 shift_amount){
file_relex_parallel(System_Functions *system, Mem_Options *mem, Editing_File *file, u32 start_i, u32 end_i, i32 shift_amount){
General_Memory *general = &mem->general;
Partition *part = &mem->part;
@ -2323,7 +2313,7 @@ file_relex_parallel(System_Functions *system, Mem_Options *mem, Editing_File *fi
Cpp_Relex_Data state = cpp_relex_init(array, start_i, end_i, shift_amount);
char *chunks[3];
i32 chunk_sizes[3];
umem chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
@ -2336,17 +2326,16 @@ file_relex_parallel(System_Functions *system, Mem_Options *mem, Editing_File *fi
i32 chunk_index = 0;
char *chunk = chunks[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
umem chunk_size = chunk_sizes[chunk_index];
while (!cpp_relex_is_start_chunk(&state, chunk, chunk_size)){
while (!cpp_relex_is_start_chunk(&state, chunk, (i32)chunk_size)){
++chunk_index;
chunk = chunks[chunk_index];
chunk_size = chunk_sizes[chunk_index];
}
for(;;){
Cpp_Lex_Result lex_result =
cpp_relex_step(&state, chunk, chunk_size, size, array, &relex_array);
Cpp_Lex_Result lex_result =cpp_relex_step(&state, chunk, (i32)chunk_size, size, array, &relex_array);
switch (lex_result){
case LexResult_NeedChunk:
@ -2366,7 +2355,7 @@ file_relex_parallel(System_Functions *system, Mem_Options *mem, Editing_File *fi
doublebreak:;
if (inline_lex){
i32 new_count = cpp_relex_get_new_count(&state, array->count, &relex_array);
u32 new_count = cpp_relex_get_new_count(&state, array->count, &relex_array);
if (new_count > array->max_count){
i32 new_max = l_round_up_i32(new_count, KB(1));
array->tokens = (Cpp_Token*)
@ -2432,10 +2421,13 @@ file_relex_serial(Mem_Options *mem, Editing_File *file, i32 start_i, i32 end_i,
Gap_Buffer *buffer = &file->state.buffer;
Cpp_Token_Array *array = &file->state.token_array;
umem remaining = partition_remaining(part);
umem token_size = sizeof(Cpp_Token);
Temp_Memory temp = begin_temp_memory(part);
Cpp_Token_Array relex_array;
relex_array.count = 0;
relex_array.max_count = partition_remaining(part) / sizeof(Cpp_Token);
relex_array.max_count = (u32)(remaining/token_size);
relex_array.tokens = push_array(part, Cpp_Token, relex_array.max_count);
i32 size = buffer_size(buffer);
@ -2443,7 +2435,7 @@ file_relex_serial(Mem_Options *mem, Editing_File *file, i32 start_i, i32 end_i,
Cpp_Relex_Data state = cpp_relex_init(array, start_i, end_i, shift_amount);
char *chunks[3];
i32 chunk_sizes[3];
umem chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
@ -2454,18 +2446,18 @@ file_relex_serial(Mem_Options *mem, Editing_File *file, i32 start_i, i32 end_i,
chunks[2] = 0;
chunk_sizes[2] = 0;
i32 chunk_index = 0;
umem chunk_index = 0;
char *chunk = chunks[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
umem chunk_size = chunk_sizes[chunk_index];
while (!cpp_relex_is_start_chunk(&state, chunk, chunk_size)){
while (!cpp_relex_is_start_chunk(&state, chunk, (i32)chunk_size)){
++chunk_index;
chunk = chunks[chunk_index];
chunk_size = chunk_sizes[chunk_index];
}
for(;;){
Cpp_Lex_Result lex_result = cpp_relex_step(&state, chunk, chunk_size, size, array, &relex_array);
Cpp_Lex_Result lex_result = cpp_relex_step(&state, chunk, (i32)chunk_size, size, array, &relex_array);
switch (lex_result){
case LexResult_NeedChunk:
@ -2482,7 +2474,7 @@ file_relex_serial(Mem_Options *mem, Editing_File *file, i32 start_i, i32 end_i,
doublebreak:;
i32 new_count = cpp_relex_get_new_count(&state, array->count, &relex_array);
if (new_count > array->max_count){
if ((u32)new_count > array->max_count){
i32 new_max = l_round_up_i32(new_count, KB(1));
array->tokens = (Cpp_Token*)general_memory_reallocate(general, array->tokens, array->count*sizeof(Cpp_Token), new_max*sizeof(Cpp_Token));
array->max_count = new_max;
@ -2496,10 +2488,10 @@ file_relex_serial(Mem_Options *mem, Editing_File *file, i32 start_i, i32 end_i,
}
internal void
undo_stack_grow_string(General_Memory *general, Edit_Stack *stack, i32 extra_size){
i32 old_max = stack->max;
undo_stack_grow_string(General_Memory *general, Edit_Stack *stack, umem extra_size){
u32 old_max = stack->max;
u8 *old_str = stack->strings;
i32 new_max = old_max*2 + extra_size;
u32 new_max = old_max*2 + (u32)(extra_size);
u8 *new_str = (u8*)general_memory_reallocate(general, old_str, old_max, new_max);
stack->strings = new_str;
stack->max = new_max;
@ -2516,27 +2508,27 @@ undo_stack_grow_edits(General_Memory *general, Edit_Stack *stack){
}
internal void
child_stack_grow_string(General_Memory *general, Small_Edit_Stack *stack, i32 extra_size){
i32 old_max = stack->max;
child_stack_grow_string(General_Memory *general, Small_Edit_Stack *stack, umem extra_size){
umem old_max = stack->max;
u8 *old_str = stack->strings;
i32 new_max = old_max*2 + extra_size;
umem new_max = old_max*2 + extra_size;
u8 *new_str = (u8*)general_memory_reallocate(general, old_str, old_max, new_max);
stack->strings = new_str;
stack->max = new_max;
stack->max = (u32)new_max;
}
internal void
child_stack_grow_edits(General_Memory *general, Small_Edit_Stack *stack, i32 amount){
i32 old_max = stack->edit_max;
child_stack_grow_edits(General_Memory *general, Small_Edit_Stack *stack, umem amount){
umem old_max = stack->edit_max;
Buffer_Edit *old_eds = stack->edits;
i32 new_max = old_max*2 + amount;
umem new_max = old_max*2 + amount;
Buffer_Edit *new_eds = (Buffer_Edit*)general_memory_reallocate(general, old_eds, old_max*sizeof(Buffer_Edit), new_max*sizeof(Buffer_Edit));
stack->edits = new_eds;
stack->edit_max = new_max;
stack->edit_max = (u32)new_max;
}
internal i32
undo_children_push(General_Memory *general, Small_Edit_Stack *children, Buffer_Edit *edits, i32 edit_count, u8 *strings, i32 string_size){
undo_children_push(General_Memory *general, Small_Edit_Stack *children, Buffer_Edit *edits, u32 edit_count, u8 *strings, umem string_size){
i32 result = children->edit_count;
if (children->edit_count + edit_count > children->edit_max){
child_stack_grow_edits(general, children, edit_count);
@ -2551,12 +2543,12 @@ undo_children_push(General_Memory *general, Small_Edit_Stack *children, Buffer_E
Buffer_Edit *edit = children->edits + children->edit_count;
i32 start_pos = children->size;
for (i32 i = 0; i < edit_count; ++i, ++edit){
for (u32 i = 0; i < edit_count; ++i, ++edit){
edit->str_start += start_pos;
}
children->edit_count += edit_count;
children->size += string_size;
children->size += (u32)string_size;
return result;
}
@ -2636,7 +2628,7 @@ undo_stack_pop(Edit_Stack *stack){
if (stack->edit_count > 0){
Edit_Step *edit = stack->edits + (--stack->edit_count);
if (edit->child_count == 0){
stack->size -= edit->edit.len;
stack->size -= (u32)edit->edit.len;
}
}
}
@ -2679,7 +2671,7 @@ file_post_redo(General_Memory *general, Editing_File *file, Edit_Step step){
}
inline void
file_post_history_block(Editing_File *file, i32 pos){
file_post_history_block(Editing_File *file, u32 pos){
Assert(file->state.undo.history_head_block < pos);
Assert(pos < file->state.undo.history.edit_count);
@ -2788,7 +2780,7 @@ view_cursor_move(View *view, Full_Cursor cursor){
}
inline void
view_cursor_move(System_Functions *system, View *view, i32 pos){
view_cursor_move(System_Functions *system, View *view, umem pos){
Full_Cursor cursor = view_compute_cursor(system, view, seek_pos(pos), 0);
view_cursor_move(view, cursor);
}
@ -2950,8 +2942,8 @@ file_update_history_before_edit(Mem_Options *mem, Editing_File *file, Edit_Step
if (restore_redos){
Edit_Step *redo_start = redo_end;
i32 steps_of_redo = 0;
i32 strings_of_redo = 0;
u32 steps_of_redo = 0;
u32 strings_of_redo = 0;
{
i32 undo_count = 0;
while (redo_start->type == ED_REDO || redo_start->type == ED_UNDO){
@ -2961,7 +2953,7 @@ file_update_history_before_edit(Mem_Options *mem, Editing_File *file, Edit_Step
}
else{
++steps_of_redo;
strings_of_redo += redo_start->edit.len;
strings_of_redo += (u32)redo_start->edit.len;
}
}
else{
@ -2975,11 +2967,15 @@ file_update_history_before_edit(Mem_Options *mem, Editing_File *file, Edit_Step
++redo_start;
++redo_end;
if (file->state.undo.redo.edit_count + steps_of_redo > file->state.undo.redo.edit_max)
if (file->state.undo.redo.edit_count + steps_of_redo > file->state.undo.redo.edit_max){
undo_stack_grow_edits(general, &file->state.undo.redo);
}
if (file->state.undo.redo.size + strings_of_redo > file->state.undo.redo.max)
if (file->state.undo.redo.size + strings_of_redo > file->state.undo.redo.max){
undo_stack_grow_string(general, &file->state.undo.redo, strings_of_redo);
}
u8 *str_src = file->state.undo.history.strings + redo_end->edit.str_start;
u8 *str_dest_base = file->state.undo.redo.strings;
@ -2989,8 +2985,8 @@ file_update_history_before_edit(Mem_Options *mem, Editing_File *file, Edit_Step
Edit_Step *edit_dest = file->state.undo.redo.edits + file->state.undo.redo.edit_count + steps_of_redo;
{
i32 undo_count = 0;
for (i32 i = 0; i < steps_of_redo;){
u32 undo_count = 0;
for (u32 i = 0; i < steps_of_redo;){
--edit_src;
str_src -= edit_src->edit.len;
if (edit_src->type == ED_REDO){
@ -3003,7 +2999,7 @@ file_update_history_before_edit(Mem_Options *mem, Editing_File *file, Edit_Step
--edit_dest;
*edit_dest = *edit_src;
str_redo_pos -= edit_dest->edit.len;
str_redo_pos -= (u32)edit_dest->edit.len;
edit_dest->edit.str_start = str_redo_pos;
memcpy(str_dest_base + str_redo_pos, str_src, edit_dest->edit.len);
@ -3161,13 +3157,13 @@ file_edit_cursor_fix(System_Functions *system, Models *models, Editing_File *fil
if (view->file_data.file == file){
Assert(view->edit_pos);
i32 cursor_pos = cursors[cursor_count++].pos;
umem cursor_pos = cursors[cursor_count++].pos;
Full_Cursor new_cursor = view_compute_cursor(system, view, seek_pos(cursor_pos), 0);
GUI_Scroll_Vars scroll = view->edit_pos->scroll;
view->edit_pos->mark = cursors[cursor_count++].pos;
i32 new_scroll_i = cursors[cursor_count++].pos;
i32 new_scroll_i = (i32)cursors[cursor_count++].pos;
if (view->edit_pos->scroll_i != new_scroll_i){
view->edit_pos->scroll_i = new_scroll_i;
@ -3223,14 +3219,14 @@ file_do_single_edit(System_Functions *system, Models *models, Editing_File *file
Partition *part = &mem->part;
char *str = (char*)spec.str;
i32 start = spec.step.edit.start;
i32 end = spec.step.edit.end;
i32 str_len = spec.step.edit.len;
u32 start = (u32)spec.step.edit.start;
u32 end = (u32)spec.step.edit.end;
u32 str_len = (u32)spec.step.edit.len;
i32 scratch_size = partition_remaining(part);
umem scratch_size = partition_remaining(part);
Assert(scratch_size > 0);
i32 request_amount = 0;
umem request_amount = 0;
Assert(end <= buffer_size(&file->state.buffer));
while (buffer_replace_range(&file->state.buffer, start, end, str, str_len, &shift_amount, part->base + part->pos, scratch_size, &request_amount)){
void *new_data = 0;
@ -3285,8 +3281,7 @@ file_do_single_edit(System_Functions *system, Models *models, Editing_File *file
}
internal void
file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file,
Edit_Spec spec, History_Mode history_mode, i32 batch_type){
file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file, Edit_Spec spec, History_Mode history_mode, i32 batch_type){
Mem_Options *mem = &models->mem;
General_Memory *general = &mem->general;
@ -3306,9 +3301,9 @@ file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file,
Assert(spec.step.first_child < file->state.undo.children.edit_count);
Assert(batch_size >= 0);
i32 scratch_size = partition_remaining(part);
Buffer_Batch_State state = {};
i32 request_amount = 0;
u32 scratch_size = (u32)partition_remaining(part);
Buffer_Batch_State state = {0};
umem request_amount = 0;
while (buffer_batch_edit_step(&state, &file->state.buffer, batch,
(char*)str_base, batch_size, part->base + part->pos,
scratch_size, &request_amount)){
@ -3334,10 +3329,10 @@ file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file,
Buffer_Edit *last_edit = batch + batch_size - 1;
if (!file->settings.virtual_white){
file_relex_parallel(system, mem, file, first_edit->start, last_edit->end, shift_total);
file_relex_parallel(system, mem, file, (u32)first_edit->start, (u32)last_edit->end, shift_total);
}
else{
file_relex_serial(mem, file, first_edit->start, last_edit->end, shift_total);
file_relex_serial(mem, file, (u32)first_edit->start, (u32)last_edit->end, shift_total);
}
}
}break;
@ -3359,13 +3354,27 @@ file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file,
for (; token < end_token; ++token){
original = *token;
for (; edit < end_edit && edit->start <= original.start; ++edit){
local_shift = (edit->len - (edit->end - edit->start));
umem target_length = edit->end - edit->start;
umem edit_length = edit->len;
if (edit_length > target_length){
local_shift = (i32)(edit_length - target_length);
}
else{
local_shift = -(i32)(target_length - edit_length);
}
shift_amount += local_shift;
}
token->start += shift_amount;
local_shift = 0;
for (; edit < end_edit && edit->start < original.start + original.size; ++edit){
local_shift += (edit->len - (edit->end - edit->start));
umem target_length = edit->end - edit->start;
umem edit_length = edit->len;
if (edit_length > target_length){
local_shift = (i32)(edit_length - target_length);
}
else{
local_shift = -(i32)(target_length - edit_length);
}
}
token->size += local_shift;
shift_amount += local_shift;
@ -3423,7 +3432,7 @@ view_replace_range(System_Functions *system, Models *models, View *view,
}
inline void
view_post_paste_effect(View *view, f32 seconds, i32 start, i32 size, u32 color){
view_post_paste_effect(View *view, f32 seconds, u32 start, u32 size, u32 color){
Editing_File *file = view->file_data.file;
file->state.paste_effect.start = start;
@ -3445,7 +3454,7 @@ main_style(Models *models){
internal void
apply_history_edit(System_Functions *system, Models *models, Editing_File *file, View *view, Edit_Stack *stack, Edit_Step step, History_Mode history_mode){
Edit_Spec spec = {};
Edit_Spec spec = {0};
spec.step = step;
if (step.child_count == 0){
@ -3459,7 +3468,7 @@ apply_history_edit(System_Functions *system, Models *models, Editing_File *file,
view->edit_pos->mark = view->edit_pos->cursor.pos;
Style *style = main_style(models);
view_post_paste_effect(view, 0.333f, step.edit.start, step.edit.len, style->main.undo_color);
view_post_paste_effect(view, 0.333f, (u32)step.edit.start, (u32)step.edit.len, style->main.undo_color);
}
}
else{
@ -3490,11 +3499,11 @@ view_history_step(System_Functions *system, Models *models, View *view, History_
Assert(file);
Assert(view->edit_pos);
b32 do_history_step = 0;
b32 do_history_step = false;
Edit_Step step = {};
if (history_mode == hist_backward){
if (file->state.undo.edit_history_cursor > 0){
do_history_step = 1;
do_history_step = true;
step = file->state.undo.history.edits[--file->state.undo.edit_history_cursor];
}
}
@ -3502,9 +3511,9 @@ view_history_step(System_Functions *system, Models *models, View *view, History_
if (file->state.undo.edit_history_cursor < file->state.undo.history.edit_count){
Assert(((file->state.undo.history.edit_count - file->state.undo.edit_history_cursor) & 1) == 0);
step = file->state.undo.history.edits[--file->state.undo.history.edit_count];
file->state.undo.history.size -= step.edit.len;
file->state.undo.history.size -= (u32)step.edit.len;
++file->state.undo.edit_history_cursor;
do_history_step = 1;
do_history_step = true;
}
}
@ -3516,7 +3525,7 @@ view_history_step(System_Functions *system, Models *models, View *view, History_
}
internal String*
working_set_next_clipboard_string(General_Memory *general, Working_Set *working, i32 str_size){
working_set_next_clipboard_string(General_Memory *general, Working_Set *working, u32 str_size){
String *result = 0;
i32 clipboard_current = working->clipboard_current;
if (working->clipboard_size == 0){
@ -3585,22 +3594,22 @@ working_set_clipboard_roll_down(Working_Set *working){
internal void
clipboard_copy(System_Functions *system, General_Memory *general, Working_Set *working, Range range, Editing_File *file){
i32 size = range.end - range.start;
String *dest = working_set_next_clipboard_string(general, working, size);
umem size = range.end - range.start;
String *dest = working_set_next_clipboard_string(general, working, (u32)size);
buffer_stringify(&file->state.buffer, range.start, range.end, dest->str);
dest->size = size;
dest->size = (i32)size;
system->post_clipboard(*dest);
}
internal Edit_Spec
file_compute_edit(Mem_Options *mem, Editing_File *file, Buffer_Edit *edits, char *str_base, i32 str_size, Buffer_Edit *inverse_array, char *inv_str, i32 inv_max, i32 edit_count, i32 batch_type){
file_compute_edit(Mem_Options *mem, Editing_File *file, Buffer_Edit *edits, char *str_base, umem str_size, Buffer_Edit *inverse_array, char *inv_str, u32 inv_max, u32 edit_count, i32 batch_type){
General_Memory *general = &mem->general;
i32 inv_str_pos = 0;
u32 inv_str_pos = 0;
Buffer_Invert_Batch state = {};
if (buffer_invert_batch(&state, &file->state.buffer, edits, edit_count,
inverse_array, inv_str, &inv_str_pos, inv_max)){
Assert(0);
InvalidCodePath;
}
i32 first_child = undo_children_push(general, &file->state.undo.children, edits, edit_count, (u8*)(str_base), str_size);
@ -4465,8 +4474,7 @@ show_gui_line(GUI_Target *target, String *string, i32 indent_level, i32 h_align,
}
internal void
show_gui_int(GUI_Target *target, String *string,
i32 indent_level, i32 h_align, char *message, i32 x){
show_gui_int(GUI_Target *target, String *string, i32 indent_level, i32 h_align, char *message, i32 x){
string->size = 0;
append_label(string, indent_level, message);
append_padding(string, '-', h_align);
@ -4476,8 +4484,7 @@ show_gui_int(GUI_Target *target, String *string,
}
internal void
show_gui_u64(GUI_Target *target, String *string,
i32 indent_level, i32 h_align, char *message, u64 x){
show_gui_u64(GUI_Target *target, String *string, i32 indent_level, i32 h_align, char *message, u64 x){
string->size = 0;
append_label(string, indent_level, message);
append_padding(string, '-', h_align);
@ -4487,8 +4494,17 @@ show_gui_u64(GUI_Target *target, String *string,
}
internal void
show_gui_int_int(GUI_Target *target, String *string,
i32 indent_level, i32 h_align, char *message, i32 x, i32 m){
show_gui_umem(GUI_Target *target, String *string, i32 indent_level, i32 h_align, char *message, umem x){
string->size = 0;
append_label(string, indent_level, message);
append_padding(string, '-', h_align);
append_s_char(string, ' ');
append_u64_to_str(string, x);
gui_do_text_field(target, *string, null_string);
}
internal void
show_gui_int_int(GUI_Target *target, String *string, i32 indent_level, i32 h_align, char *message, i32 x, i32 m){
string->size = 0;
append_label(string, indent_level, message);
append_padding(string, '-', h_align);
@ -4538,13 +4554,11 @@ show_gui_scroll(GUI_Target *target, String *string,
}
internal void
show_gui_cursor(GUI_Target *target, String *string,
i32 indent_level, i32 h_align, char *message,
Full_Cursor cursor){
show_gui_line (target, string, indent_level, 0, message, 0);
show_gui_int (target, string, indent_level+1, h_align, " pos ", cursor.pos);
show_gui_int (target, string, indent_level+1, h_align, " line ", cursor.line);
show_gui_int (target, string, indent_level+1, h_align, " column ", cursor.character);
show_gui_cursor(GUI_Target *target, String *string, i32 indent_level, i32 h_align, char *message,Full_Cursor cursor){
show_gui_line (target, string, indent_level , 0, message, 0);
show_gui_umem (target, string, indent_level+1, h_align, " pos ", cursor.pos);
show_gui_umem (target, string, indent_level+1, h_align, " line ", cursor.line);
show_gui_umem (target, string, indent_level+1, h_align, " column ", cursor.character);
show_gui_float(target, string, indent_level+1, h_align, " unwrapped_x ", cursor.unwrapped_x);
show_gui_float(target, string, indent_level+1, h_align, " unwrapped_y ", cursor.unwrapped_y);
show_gui_float(target, string, indent_level+1, h_align, " wrapped_x ", cursor.wrapped_x);
@ -5366,9 +5380,9 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
string.size = 0;
append_ss(&string, make_lit_string("part memory: "));
append_int_to_str(&string, part->pos);
append_int_to_str(&string, (i32)part->pos);
append_s_char(&string, '/');
append_int_to_str(&string, part->max);
append_int_to_str(&string, (i32)part->max);
gui_do_text_field(target, string, empty_str);
#if !defined(FED_DEBUG_MEM_H)
@ -5383,7 +5397,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
append_ss(&string, make_lit_string(" free: "));
}
append_int_to_str(&string, bubble->size);
append_int_to_str(&string, (i32)bubble->size);
append_padding(&string, ' ', 40);
gui_do_text_field(target, string, empty_str);
}
@ -5456,6 +5470,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
#define SHOW_GUI_INT(n, h, str, v) show_gui_int(target, &string, n, h, " " str " ", v)
#define SHOW_GUI_INT_INT(n, h, str, v, m) show_gui_int_int(target, &string, n, h, " " str " ", v, m)
#define SHOW_GUI_U64(n, h, str, v) show_gui_u64(target, &string, n, h, " " str " ", v)
#define SHOW_GUI_UMEM(n, h, str, v) show_gui_umem(target, &string, n, h, " " str " ", v)
#define SHOW_GUI_ID(n, h, str, v) show_gui_id(target, &string, n, h, " " str, v)
#define SHOW_GUI_FLOAT(n, h, str, v) show_gui_float(target, &string, n, h, " " str " ", v)
#define SHOW_GUI_BOOL(n, h, str, v) do { if (v) { show_gui_line(target, &string, n, h, " " str " ", "true"); }\
@ -5495,8 +5510,8 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
SHOW_GUI_LINE(1, "file data:");
SHOW_GUI_BOOL(2, h_align, "has file", view_ptr->file_data.file);
SHOW_GUI_BOOL(2, h_align, "show temp highlight", view_ptr->file_data.show_temp_highlight);
SHOW_GUI_INT (2, h_align, "start temp highlight", view_ptr->file_data.temp_highlight.pos);
SHOW_GUI_INT (2, h_align, "end temp highlight", view_ptr->file_data.temp_highlight_end_pos);
SHOW_GUI_UMEM(2, h_align, "start temp highlight", view_ptr->file_data.temp_highlight.pos);
SHOW_GUI_UMEM(2, h_align, "end temp highlight", view_ptr->file_data.temp_highlight_end_pos);
SHOW_GUI_BOOL(2, h_align, "show whitespace", view_ptr->file_data.show_whitespace);
SHOW_GUI_BOOL(2, h_align, "locked", view_ptr->file_data.file_locked);
@ -5514,7 +5529,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
SHOW_GUI_BLANK (2);
SHOW_GUI_CURSOR(2, h_align, "cursor:", edit_pos->cursor);
SHOW_GUI_BLANK (2);
SHOW_GUI_INT (2, h_align, "mark", edit_pos->mark);
SHOW_GUI_UMEM (2, h_align, "mark", edit_pos->mark);
SHOW_GUI_FLOAT (2, h_align, "preferred_x", edit_pos->preferred_x);
SHOW_GUI_INT (2, h_align, "scroll_i", edit_pos->scroll_i);
}
@ -5528,9 +5543,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
SHOW_GUI_BLANK (0);
SHOW_GUI_LINE (1, "gui target");
SHOW_GUI_INT_INT(2, h_align, "gui partition",
view_ptr->gui_target.push.pos,
view_ptr->gui_target.push.max);
SHOW_GUI_INT_INT(2, h_align, "gui partition", (int32_t)view_ptr->gui_target.push.pos, (int32_t)view_ptr->gui_target.push.max);
SHOW_GUI_BLANK (2);
SHOW_GUI_ID (2, h_align, "active", view_ptr->gui_target.active);
@ -5666,7 +5679,7 @@ do_step_file_view(System_Functions *system, View *view, i32_Rect rect, b32 is_ac
GUI_Target *target = &view->gui_target;
GUI_Interpret_Result interpret_result = {0};
vars.target_y = clamp(0, vars.target_y, max_y);
vars.target_y = clamp_i32(0, vars.target_y, max_y);
result.vars = vars;
result.region = region;
@ -5799,7 +5812,7 @@ do_step_file_view(System_Functions *system, View *view, i32_Rect rect, b32 is_ac
if (gui_id_eq(target->mouse_hot, id)){
v = unlerp(gui_session.scroll_top, (f32)my,
gui_session.scroll_bottom);
v = clamp(0.f, v, 1.f);
v = clamp_f32(0.f, v, 1.f);
result.vars.target_y = round32(lerp(0.f, v, (f32)max_y));
gui_activate_scrolling(target);
@ -5814,7 +5827,7 @@ do_step_file_view(System_Functions *system, View *view, i32_Rect rect, b32 is_ac
result.vars.target_y += user_input->mouse.wheel*target->delta;
result.vars.target_y =
clamp(0, result.vars.target_y, max_y);
clamp_i32(0, result.vars.target_y, max_y);
gui_activate_scrolling(target);
result.is_animating = 1;
}
@ -5914,7 +5927,9 @@ draw_file_loaded(System_Functions *system, View *view, i32_Rect rect, b32 is_act
f32 left_side_space = 0;
i32 max = partition_remaining(part) / sizeof(Buffer_Render_Item);
umem remaining = partition_remaining(part);
umem render_item_size = sizeof(Buffer_Render_Item);
u32 max = (u32)(remaining / render_item_size);
Buffer_Render_Item *items = push_array(part, Buffer_Render_Item, max);
Font_ID font_id = file->settings.font_id;
@ -5936,9 +5951,9 @@ draw_file_loaded(System_Functions *system, View *view, i32_Rect rect, b32 is_act
render_cursor = view_compute_cursor(system, view, seek_unwrapped_xy(0, scroll_y, 0), 1);
}
view->edit_pos->scroll_i = render_cursor.pos;
view->edit_pos->scroll_i = (i32)render_cursor.pos;
i32 count = 0;
u32 count = 0;
{
b32 wrapped = !file->settings.unwrapped_lines;
@ -5965,11 +5980,11 @@ draw_file_loaded(System_Functions *system, View *view, i32_Rect rect, b32 is_act
Buffer_Layout_Stop stop = {0};
f32 line_shift = 0.f;
b32 do_wrap = 0;
i32 wrap_unit_end = 0;
b32 do_wrap = false;
u32 wrap_unit_end = 0;
b32 first_wrap_determination = 1;
i32 wrap_array_index = 0;
b32 first_wrap_determination = true;
u32 wrap_array_index = 0;
do{
stop = buffer_render_data(&state, params, line_shift, do_wrap, wrap_unit_end);
@ -6006,22 +6021,22 @@ draw_file_loaded(System_Functions *system, View *view, i32_Rect rect, b32 is_act
}while(stop.status != BLStatus_Finished);
}
i32 cursor_begin = 0, cursor_end = 0;
u32 cursor_begin = 0, cursor_end = 0;
u32 cursor_color = 0, at_cursor_color = 0;
if (view->file_data.show_temp_highlight){
cursor_begin = view->file_data.temp_highlight.pos;
cursor_end = view->file_data.temp_highlight_end_pos;
cursor_begin = (u32)view->file_data.temp_highlight.pos;
cursor_end = (u32)view->file_data.temp_highlight_end_pos;
cursor_color = style->main.highlight_color;
at_cursor_color = style->main.at_highlight_color;
}
else{
cursor_begin = view->edit_pos->cursor.pos;
cursor_begin = (u32)view->edit_pos->cursor.pos;
cursor_end = cursor_begin + 1;
cursor_color = style->main.cursor_color;
at_cursor_color = style->main.at_cursor_color;
}
i32 token_i = 0;
u32 token_i = 0;
u32 main_color = style->main.default_color;
u32 special_color = style->main.special_character_color;
u32 ghost_color = style->main.ghost_character_color;
@ -6034,12 +6049,12 @@ draw_file_loaded(System_Functions *system, View *view, i32_Rect rect, b32 is_act
u32 mark_color = style->main.mark_color;
Buffer_Render_Item *item = items;
Buffer_Render_Item *item_end = item + count;
i32 prev_ind = -1;
umem prev_ind = max_umem;
u32 highlight_color = 0;
u32 highlight_this_color = 0;
for (; item < item_end; ++item){
i32 ind = item->index;
umem ind = item->index;
highlight_this_color = 0;
if (tokens_use && ind != prev_ind){
Cpp_Token current_token = token_array.tokens[token_i-1];
@ -6219,9 +6234,9 @@ draw_file_bar(System_Functions *system, Render_Target *target, View *view, Editi
char bar_space[526];
String bar_text = make_fixed_width_string(bar_space);
append_ss (&bar_text, make_lit_string(" L#"));
append_int_to_str(&bar_text, view->edit_pos->cursor.line);
append_int_to_str(&bar_text, (int32_t)view->edit_pos->cursor.line);
append_ss (&bar_text, make_lit_string(" C#"));
append_int_to_str(&bar_text, view->edit_pos->cursor.character);
append_int_to_str(&bar_text, (int32_t)view->edit_pos->cursor.character);
append_ss(&bar_text, make_lit_string(" -"));

View File

@ -504,16 +504,16 @@ layout_update_pos_step(Editing_Layout *layout, i32 divider_id, i32_Rect rect, i3
i32 pos = abs_pos[divider_id];
i32_Rect r1 = rect, r2 = rect;
f32 lpos = unlerp((f32)p0, (f32)pos, (f32)p1);
lpos = clamp(0.f, lpos, 1.f);
lpos = clamp_f32(0.f, lpos, 1.f);
div->pos = lpos;
if (div->v_divider){
pos = clamp(r1.x0, pos, r2.x1);
pos = clamp_i32(r1.x0, pos, r2.x1);
r1.x1 = pos; r2.x0 = pos;
}
else{
pos = clamp(r1.y0, pos, r2.y1);
pos = clamp_i32(r1.y0, pos, r2.y1);
r1.y1 = pos; r2.y0 = pos;
}

View File

@ -432,21 +432,21 @@ unlerp(f32 a, f32 x, f32 b){
}
inline f32
clamp(f32 a, f32 n, f32 z){
clamp_f32(f32 a, f32 n, f32 z){
if (n < a) n = a;
else if (n > z) n = z;
return (n);
}
inline i32
clamp(i32 a, i32 n, i32 z){
clamp_i32(i32 a, i32 n, i32 z){
if (n < a) n = a;
else if (n > z) n = z;
return (n);
}
inline u32
clamp(u32 a, u32 n, u32 z){
clamp_u32(u32 a, u32 n, u32 z){
if (n < a) n = a;
else if (n > z) n = z;
return (n);

View File

@ -47,7 +47,7 @@ typedef Sys_Load_File_Sig(System_Load_File);
#define Sys_Load_Close_Sig(name) b32 name(Plat_Handle handle)
typedef Sys_Load_Close_Sig(System_Load_Close);
#define Sys_Save_File_Sig(name) b32 name(char *filename, char *buffer, u32 size)
#define Sys_Save_File_Sig(name) b32 name(char *filename, char *buffer, umem size)
typedef Sys_Save_File_Sig(System_Save_File);
// file changes

View File

@ -26,33 +26,33 @@ struct Edit_Step{
struct{
b32 can_merge;
Buffer_Edit edit;
i32 next_block;
i32 prev_block;
u32 next_block;
u32 prev_block;
};
struct{
i32 first_child;
i32 inverse_first_child;
i32 inverse_child_count;
i32 special_type;
u32 first_child;
u32 inverse_first_child;
u32 inverse_child_count;
u32 special_type;
};
};
i32 child_count;
u32 child_count;
};
struct Edit_Stack{
u8 *strings;
i32 size, max;
u32 size, max;
Edit_Step *edits;
i32 edit_count, edit_max;
u32 edit_count, edit_max;
};
struct Small_Edit_Stack{
u8 *strings;
i32 size, max;
u32 size, max;
Buffer_Edit *edits;
i32 edit_count, edit_max;
u32 edit_count, edit_max;
};
struct Undo_Data{
@ -61,8 +61,9 @@ struct Undo_Data{
Edit_Stack history;
Small_Edit_Stack children;
i32 history_block_count, history_head_block;
i32 edit_history_cursor;
u32 history_block_count;
u32 history_head_block;
u32 edit_history_cursor;
b32 current_block_normal;
};

View File

@ -204,7 +204,7 @@ working_set_init(Working_Set *working_set, Partition *partition, General_Memory
{
i32 item_size = sizeof(File_Name_Entry);
i32 table_size = working_set->file_max;
i32 mem_size = table_required_mem_size(table_size, item_size);
umem mem_size = table_required_mem_size(table_size, item_size);
void *mem = general_memory_allocate(general, mem_size);
memset(mem, 0, mem_size);
table_init_memory(&working_set->canon_table, mem, table_size, item_size);
@ -212,9 +212,9 @@ working_set_init(Working_Set *working_set, Partition *partition, General_Memory
// NOTE(allen): init name table
{
i32 item_size = sizeof(File_Name_Entry);
i32 table_size = working_set->file_max;
i32 mem_size = table_required_mem_size(table_size, item_size);
u32 item_size = sizeof(File_Name_Entry);
u32 table_size = working_set->file_max;
umem mem_size = table_required_mem_size(table_size, item_size);
void *mem = general_memory_allocate(general, mem_size);
memset(mem, 0, mem_size);
table_init_memory(&working_set->name_table, mem, table_size, item_size);
@ -225,8 +225,8 @@ inline void
working_set__grow_if_needed(Table *table, General_Memory *general, void *arg, Hash_Function *hash_func, Compare_Function *comp_func){
if (table_at_capacity(table)){
Table btable = {0};
i32 new_max = table->max * 2;
i32 mem_size = table_required_mem_size(new_max, table->item_size);
u32 new_max = table->max * 2;
umem mem_size = table_required_mem_size(new_max, table->item_size);
void *mem = general_memory_allocate(general, mem_size);
table_init_memory(&btable, mem, new_max, table->item_size);
table_clear(&btable);

View File

@ -135,6 +135,18 @@ inline u32 round_up_pot_u32(u32 x){
#define min_u32 ((u32)0)
#define min_u64 ((u64)0)
#if defined(FTECH_32_BIT)
#define max_imem max_i64
#define min_imem min_i64
#define max_umem max_u64
#define min_umem min_u64
#else
#define max_imem max_i32
#define min_imem min_i32
#define max_umem max_u32
#define min_umem min_u32
#endif
#define Bit_0 (1 << 0)
#define Bit_1 (1 << 1)
#define Bit_2 (1 << 2)

View File

@ -16,6 +16,7 @@ Allen Webster
#include "4coder_default_include.cpp"
#if 0
#include <assert.h>
#include <stdio.h>
@ -224,12 +225,17 @@ CUSTOM_COMMAND_SIG(run_all_tests){
exec_command(app, load_unicode_file);
exec_command(app, edit_giant_file);
}
#endif
static void
test_get_bindings(Bind_Helper *context){
#if 0
begin_map(context, mapid_global);
bind(context, key_f3, MDFR_NONE, run_all_tests);
end_map(context);
#endif
}
#define BIND_4CODER_TESTS(context) test_get_bindings(context)

View File

@ -1,12 +1,10 @@
#include <string.h>
// Link to the memcpy symbol with version 2.2.5 instead of the newer 2.14 one
// since they are functionaly equivalent, but using the old one allows 4coder
// to run on older distros without glibc >= 2.14
// Link to the memcpy symbol with version 2.2.5 instead of the newer 2.14 one since they are functionaly equivalent, but using the old one allows 4coder to run on older distros without glibc >= 2.14
extern "C" {
asm (".symver memcpy, memcpy@GLIBC_2.2.5");
void *__wrap_memcpy(void *dest, const void *src, size_t n){
return memcpy(dest, src, n);
}
asm (".symver memcpy, memcpy@GLIBC_2.2.5");
void *__wrap_memcpy(void *dest, const void *src, size_t n){
return memcpy(dest, src, n);
}
}

View File

@ -23,7 +23,7 @@ TYPE: 'build-target'
#include <string.h>
static float
get_line_y(Application_Links *app, View_Summary *view, int32_t line){
get_line_y(Application_Links *app, View_Summary *view, size_t line){
Full_Cursor cursor = {0};
view_compute_cursor(app, view, seek_line_char(line, 1), &cursor);
float y = cursor.wrapped_y;
@ -37,26 +37,30 @@ CUSTOM_COMMAND_SIG(kill_rect){
View_Summary view = get_active_view(app, AccessOpen);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
i32_Rect rect = get_line_x_rect(&view);
pos_Rect rect = get_line_x_rect(&view);
bool32 unwrapped = view.unwrapped_lines;
for (int32_t line = rect.y1; line >= rect.y0; --line){
int32_t start = 0;
int32_t end = 0;
int32_t line_count = (int32_t)(rect.y1 - rect.y0 + 1);
for (int32_t line_i = line_count; line_i >= 0; --line_i){
size_t line = rect.y0 + line_i;
size_t start = 0;
size_t end = 0;
bool32 success = 1;
bool32 success = true;
Full_Cursor cursor = {0};
float y = get_line_y(app, &view, line);
if (success){
success = view_compute_cursor(app, &view, seek_xy((float)rect.x0, y, 0, unwrapped), &cursor);
Buffer_Seek seek = seek_xy((float)rect.x0, y, 0, unwrapped);
success = view_compute_cursor(app, &view, seek, &cursor);
}
start = cursor.pos;
if (success){
success = view_compute_cursor(app, &view, seek_xy((float)rect.x1, y, 0, unwrapped), &cursor);
Buffer_Seek seek = seek_xy((float)rect.x0, y, 0, unwrapped);
success = view_compute_cursor(app, &view, seek, &cursor);
}
end = cursor.pos;
@ -67,16 +71,19 @@ CUSTOM_COMMAND_SIG(kill_rect){
}
static void
pad_buffer_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line, char padchar, int32_t target){
pad_buffer_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, size_t line, char padchar, size_t target){
Partial_Cursor start = {0};
Partial_Cursor end = {0};
if (buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &start)){
if (buffer_compute_cursor(app, buffer, seek_line_char(line, 65536), &end)){
if (start.line == line){
Buffer_Seek seek_start = seek_line_char(line, 1);
Buffer_Seek seek_end = seek_line_reverse_char(line, 1);
if (buffer_compute_cursor(app, buffer, seek_start, &start)){
if (start.line == line){
if (buffer_compute_cursor(app, buffer, seek_end, &end)){
if (end.character-1 < target){
Temp_Memory temp = begin_temp_memory(part);
int32_t size = target - (end.character-1);
size_t size = target - (end.character-1);
char *str = push_array(part, char, size);
memset(str, ' ', size);
buffer_replace_range(app, buffer, end.pos, end.pos, str, size);
@ -130,14 +137,14 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
Buffer_Rect rect = get_rect(&view);
int32_t start_line = view.cursor.line;
int32_t pos = view.cursor.character-1;
size_t start_line = view.cursor.line;
size_t pos = view.cursor.character-1;
for (int32_t i = rect.line0; i <= rect.line1; ++i){
for (size_t i = rect.line0; i <= rect.line1; ++i){
pad_buffer_line(app, &global_part, &buffer, i, ' ', pos);
}
int32_t line_count = rect.line1 - rect.line0 + 1;
int32_t line_count = (int32_t)(rect.line1 - rect.line0 + 1);
for (;;){
User_Input in = get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
@ -150,10 +157,12 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
Buffer_Edit *edit = push_array(part, Buffer_Edit, line_count);
Buffer_Edit *edits = edit;
for (int32_t i = rect.line0; i <= rect.line1; ++i){
for (int32_t i = 0; i <= line_count; ++i){
size_t line = i + rect.line0;
Partial_Cursor cursor = {0};
if (buffer_compute_cursor(app, &buffer, seek_line_char(i, pos+1), &cursor)){
Buffer_Seek seek = seek_line_char(line, pos+1);
if (buffer_compute_cursor(app, &buffer, seek, &cursor)){
edit->str_start = 0;
edit->len = 1;
edit->start = cursor.pos;
@ -178,10 +187,12 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
Buffer_Edit *edit = push_array(part, Buffer_Edit, line_count);
Buffer_Edit *edits = edit;
for (int32_t i = rect.line0; i <= rect.line1; ++i){
for (int32_t i = 0; i <= line_count; ++i){
size_t line = i + rect.line0;
Partial_Cursor cursor = {0};
if (buffer_compute_cursor(app, &buffer, seek_line_char(i, pos+1), &cursor)){
Buffer_Seek seek = seek_line_char(line, pos+1);
if (buffer_compute_cursor(app, &buffer, seek, &cursor)){
edit->str_start = 0;
edit->len = 0;
edit->start = cursor.pos-1;
@ -216,11 +227,11 @@ enum{
};
static bool32
find_scope_top(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
find_scope_top(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
int32_t position = 0;
size_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index;
@ -276,11 +287,11 @@ find_scope_top(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos
}
static bool32
find_scope_bottom(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
find_scope_bottom(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
int32_t position = 0;
size_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index+1;
@ -337,11 +348,11 @@ find_scope_bottom(Application_Links *app, Buffer_Summary *buffer, int32_t start_
}
static bool32
find_next_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
find_next_scope(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
int32_t position = 0;
size_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index+1;
@ -417,11 +428,11 @@ find_next_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_po
}
static bool32
find_prev_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
find_prev_scope(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
int32_t position = 0;
size_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index-1;
@ -496,7 +507,7 @@ find_prev_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_po
}
static void
view_set_to_region(Application_Links *app, View_Summary *view, int32_t major_pos, int32_t minor_pos, float normalized_threshold){
view_set_to_region(Application_Links *app, View_Summary *view, size_t major_pos, size_t minor_pos, float normalized_threshold){
Range range = make_range(major_pos, minor_pos);
bool32 bottom_major = false;
if (major_pos == range.max){
@ -551,8 +562,8 @@ CUSTOM_COMMAND_SIG(highlight_surrounding_scope){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_scope_top(app, &buffer, start_pos, FindScope_Parent, &top)){
view_set_cursor(app, &view, seek_pos(top), true);
if (find_scope_bottom(app, &buffer, start_pos, FindScope_Parent | FindScope_EndOfToken, &bottom)){
@ -571,8 +582,8 @@ CUSTOM_COMMAND_SIG(highlight_first_child_scope){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_next_scope(app, &buffer, start_pos, 0, &top)){
if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){
view_set_cursor(app, &view, seek_pos(top), true);
@ -587,8 +598,8 @@ CUSTOM_COMMAND_SIG(highlight_next_sibling_scope){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_next_scope(app, &buffer, start_pos, FindScope_NextSibling, &top)){
if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){
view_set_cursor(app, &view, seek_pos(top), true);
@ -603,8 +614,8 @@ CUSTOM_COMMAND_SIG(highlight_prev_sibling_scope){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_prev_scope(app, &buffer, start_pos, FindScope_NextSibling, &top)){
if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){
view_set_cursor(app, &view, seek_pos(top), true);
@ -619,8 +630,8 @@ CUSTOM_COMMAND_SIG(highlight_next_scope_absolute){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_next_scope(app, &buffer, start_pos, 0, &top)){
if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){
view_set_cursor(app, &view, seek_pos(top), true);
@ -635,8 +646,8 @@ CUSTOM_COMMAND_SIG(highlight_prev_scope_absolute){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_prev_scope(app, &buffer, start_pos, 0, &top)){
if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){
view_set_cursor(app, &view, seek_pos(top), true);
@ -660,7 +671,6 @@ CUSTOM_COMMAND_SIG(place_in_scope){
range.max = buffer_get_line_end(app, &buffer, lines.max);
bool32 do_full = false;
if (lines.min < lines.max){
do_full = true;
}
@ -687,11 +697,11 @@ CUSTOM_COMMAND_SIG(place_in_scope){
--max_adjustment;
}
int32_t min_pos = range.min + min_adjustment;
int32_t max_pos = range.max + max_adjustment;
size_t min_pos = range.min + min_adjustment;
size_t max_pos = range.max + max_adjustment;
int32_t cursor_pos = min_pos;
int32_t mark_pos = max_pos;
size_t cursor_pos = min_pos;
size_t mark_pos = max_pos;
if (view.cursor.pos > view.mark.pos){
cursor_pos = max_pos;
@ -725,13 +735,11 @@ CUSTOM_COMMAND_SIG(delete_current_scope){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t top = view.cursor.pos;
int32_t bottom = view.mark.pos;
size_t top = view.cursor.pos;
size_t bottom = view.mark.pos;
if (top > bottom){
int32_t x = top;
top = bottom;
bottom = x;
Swap(size_t, top, bottom);
}
if (buffer_get_char(app, &buffer, top) == '{' && buffer_get_char(app, &buffer, bottom-1) == '}'){
@ -940,10 +948,10 @@ parse_statement_down(Application_Links *app, Statement_Parser *parser, Cpp_Token
}
static bool32
find_whole_statement_down(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t *start_out, int32_t *end_out){
find_whole_statement_down(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t *start_out, size_t *end_out){
bool32 result = false;
int32_t start = pos;
int32_t end = start;
size_t start = pos;
size_t end = start;
Cpp_Get_Token_Result get_result = {0};
@ -982,13 +990,11 @@ CUSTOM_COMMAND_SIG(scope_absorb_down){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t top = view.cursor.pos;
int32_t bottom = view.mark.pos;
size_t top = view.cursor.pos;
size_t bottom = view.mark.pos;
if (top > bottom){
int32_t x = top;
top = bottom;
bottom = x;
Swap(size_t, top, bottom);
}
Partition *part = &global_part;
@ -1000,7 +1006,8 @@ CUSTOM_COMMAND_SIG(scope_absorb_down){
char *string_space = push_array(part, char, range.end - range.start);
buffer_read_range(app, &buffer, range.start, range.end, string_space);
String string = make_string(string_space, range.end - range.start);
int32_t string_length = (int32_t)(range.end - range.start);
String string = make_string(string_space, string_length);
string = skip_chop_whitespace(string);
int32_t newline_count = 0;

View File

@ -14,9 +14,9 @@ TYPE: 'drop-in-command-pack'
#include "4coder_helper/4coder_helper.h"
#include "4coder_helper/4coder_streaming.h"
static int32_t
get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, int32_t *numeric_start, int32_t *numeric_end){
int32_t result = 0;
static bool32
get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, size_t *numeric_start, size_t *numeric_end){
bool32 result = false;
char current = buffer_get_char(app, buffer, start_pos);
@ -25,16 +25,16 @@ get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, int
int32_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
int32_t pos = start_pos;
size_t pos = start_pos;
int32_t pos1 = 0;
int32_t pos2 = 0;
size_t pos1 = 0;
size_t pos2 = 0;
if (init_stream_chunk(&stream, app, buffer, start_pos, chunk, chunk_size)){
int32_t still_looping = 1;
while (still_looping){
for (; pos >= stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (!char_is_numeric(at_pos)){
++pos;
@ -50,7 +50,7 @@ get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, int
still_looping = 1;
while (still_looping){
for (; pos < stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (!char_is_numeric(at_pos)){
goto double_break_2;
@ -61,7 +61,7 @@ get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, int
double_break_2:;
pos2 = pos;
result = 1;
result = true;
*numeric_start = pos1;
*numeric_end = pos2;
}
@ -72,18 +72,19 @@ get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, int
}
struct Miblo_Number_Info{
int32_t start, end;
size_t start, end;
int32_t x;
};
static int32_t
get_numeric_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Miblo_Number_Info *info){
int32_t result = 0;
static bool32
get_numeric_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t pos, Miblo_Number_Info *info){
bool32 result = false;
int32_t numeric_start = 0, numeric_end = 0;
size_t numeric_start = 0, numeric_end = 0;
if (get_numeric_string_at_cursor(app, buffer, pos, &numeric_start, &numeric_end)){
int32_t string_length = (int32_t)(numeric_end - numeric_start);
char numeric_string[1024];
String str = make_string(numeric_string, numeric_end - numeric_start, sizeof(numeric_string));
String str = make_string(numeric_string, string_length, sizeof(numeric_string));
if (str.size < str.memory_size){
buffer_read_range(app, buffer, numeric_start, numeric_end, numeric_string);
@ -93,7 +94,7 @@ get_numeric_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t po
info->start = numeric_start;
info->end = numeric_end;
info->x = x;
result = 1;
result = true;
}
}
@ -131,9 +132,9 @@ CUSTOM_COMMAND_SIG(miblo_decrement_basic){
// NOTE(allen): miblo time stamp format
// (h+:)?m?m:ss
static int32_t
get_timestamp_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, int32_t *timestamp_start, int32_t *timestamp_end){
int32_t result = 0;
static bool32
get_timestamp_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, size_t *timestamp_start, size_t *timestamp_end){
bool32 result = false;
char current = buffer_get_char(app, buffer, start_pos);
@ -142,16 +143,16 @@ get_timestamp_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, i
int32_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
int32_t pos = start_pos;
size_t pos = start_pos;
int32_t pos1 = 0;
int32_t pos2 = 0;
size_t pos1 = 0;
size_t pos2 = 0;
if (init_stream_chunk(&stream, app, buffer, start_pos, chunk, chunk_size)){
int32_t still_looping = 1;
while (still_looping){
for (; pos >= stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (!(char_is_numeric(at_pos) || at_pos == ':')){
++pos;
@ -167,7 +168,7 @@ get_timestamp_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, i
still_looping = 1;
while (still_looping){
for (; pos < stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (!(char_is_numeric(at_pos) || at_pos == ':')){
goto double_break_2;
@ -178,7 +179,7 @@ get_timestamp_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, i
double_break_2:;
pos2 = pos;
result = 1;
result = true;
*timestamp_start = pos1;
*timestamp_end = pos2;
}
@ -271,18 +272,19 @@ timestamp_to_str(String *dest, Miblo_Timestamp t){
}
struct Miblo_Timestamp_Info{
int32_t start, end;
size_t start, end;
Miblo_Timestamp time;
};
static int32_t
get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Miblo_Timestamp_Info *info){
int32_t result = 0;
static bool32
get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t pos, Miblo_Timestamp_Info *info){
bool32 result = false;
int32_t timestamp_start = 0, timestamp_end = 0;
size_t timestamp_start = 0, timestamp_end = 0;
if (get_timestamp_string_at_cursor(app, buffer, pos, &timestamp_start, &timestamp_end)){
int32_t string_length = (int32_t)(timestamp_end - timestamp_start);
char timestamp_string[1024];
String str = make_string(timestamp_string, timestamp_end - timestamp_start, sizeof(timestamp_string));
String str = make_string(timestamp_string, string_length, sizeof(timestamp_string));
if (str.size < str.memory_size){
buffer_read_range(app, buffer, timestamp_start, timestamp_end, timestamp_string);
@ -296,10 +298,10 @@ get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t
if (count_colons == 1 || count_colons == 2){
Miblo_Timestamp t = {0};
int32_t success = 0;
bool32 success = false;
int32_t i = 0;
int32_t number_start[3], number_end[3];
size_t i = 0;
size_t number_start[3], number_end[3];
for (int32_t k = 0; k < 3; ++k){
number_start[k] = i;
for (; i <= str.size; ++i){
@ -315,27 +317,42 @@ get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t
}
if (count_colons == 2){
t.hour = str_to_int(make_string(str.str + number_start[0], number_end[0] - number_start[0]));
if (number_end[1] - number_start[1] == 2){
int32_t number_length = (int32_t)(number_end[0] - number_start[0]);
String number_string = make_string(str.str + number_start[0], number_length);
t.hour = str_to_int(number_string);
number_length = (int32_t)(number_end[1] - number_start[1]);
if (number_length == 2){
t.minute = str_to_int(make_string(str.str + number_start[1], number_end[1] - number_start[1]));
number_string = make_string(str.str + number_start[1], number_length);
t.minute = str_to_int(number_string);
if (number_end[2] - number_start[2] == 2){
t.second = str_to_int(make_string(str.str + number_start[2], number_end[2] - number_start[2]));
number_length = (int32_t)(number_end[2] - number_start[2]);
if (number_length == 2){
success = 1;
number_string = make_string(str.str + number_start[2], number_length);
t.second = str_to_int(number_string);
success = true;
}
}
}
else{
if (number_end[0] - number_start[0] == 2 || number_end[0] - number_start[0] == 1){
t.minute = str_to_int(make_string(str.str + number_start[0], number_end[0] - number_start[0]));
int32_t number_length = (int32_t)(number_end[0] - number_start[0]);
if (number_length == 2 || number_length == 1){
if (number_end[1] - number_start[1] == 2){
t.second = str_to_int(make_string(str.str + number_start[1], number_end[1] - number_start[1]));
String number_string = make_string(str.str + number_start[0], number_length);
t.minute = str_to_int(number_string);
number_length = (int32_t)(number_end[1] - number_start[1]);
if (number_length == 2){
success = 1;
number_string = make_string(str.str + number_start[1], number_length);
t.second = str_to_int(number_string);
success = true;
}
}
}
@ -344,7 +361,7 @@ get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t
info->start = timestamp_start;
info->end = timestamp_end;
info->time = t;
result = 1;
result = true;
}
}
}

BIN
vc140.pdb Normal file

Binary file not shown.