Revert "Changed the a lot of stuff over to umem"

This reverts commit 906f79ef8e.
master
Allen Webster 2017-03-23 15:15:33 -04:00
parent c4fcde16e3
commit 51b59d31d1
33 changed files with 1110 additions and 1141 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, 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 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 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, size_t start, size_t end, char *out)
#define BUFFER_READ_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out)
#define BUFFER_REPLACE_RANGE_SIG(n) 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, 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 BUFFER_READ_TOKENS_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out)
#define BUFFER_GET_TOKEN_INDEX_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result)
#define BEGIN_BUFFER_CREATION_SIG(n) 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, size_t start, size_t end, bool32 turn_on)
#define VIEW_SET_HIGHLIGHT_SIG(n) bool32 n(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on)
#define VIEW_SET_BUFFER_SIG(n) 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, size_t start, size_t end, int_color color)
#define VIEW_POST_FADE_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color)
#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, 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, 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 void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len){(app->clipboard_post(app, clipboard_id, str, len));}
static inline int32_t clipboard_count(Application_Links *app, int32_t clipboard_id){return(app->clipboard_count(app, clipboard_id));}
static inline int32_t clipboard_index(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len){return(app->clipboard_index(app, clipboard_id, item_index, out, len));}
static inline int32_t get_buffer_count(Application_Links *app){return(app->get_buffer_count(app));}
static inline Buffer_Summary get_buffer_first(Application_Links *app, Access_Flag access){return(app->get_buffer_first(app, access));}
static inline void get_buffer_next(Application_Links *app, Buffer_Summary *buffer, Access_Flag access){(app->get_buffer_next(app, buffer, access));}
static inline Buffer_Summary get_buffer(Application_Links *app, Buffer_ID buffer_id, Access_Flag access){return(app->get_buffer(app, buffer_id, access));}
static inline Buffer_Summary get_buffer_by_name(Application_Links *app, char *name, int32_t len, Access_Flag access){return(app->get_buffer_by_name(app, name, len, access));}
static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *buffer, size_t start, size_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, int32_t start, int32_t end, char *out){return(app->buffer_read_range(app, buffer, start, end, out));}
static inline bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, 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, 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 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 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, 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_highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on){return(app->view_set_highlight(app, view, start, end, turn_on));}
static inline bool32 view_set_buffer(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags){return(app->view_set_buffer(app, view, buffer_id, flags));}
static inline bool32 view_post_fade(Application_Links *app, View_Summary *view, float seconds, size_t start, size_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, int32_t start, int32_t end, int_color color){return(app->view_post_fade(app, view, seconds, start, end, color));}
static inline User_Input get_user_input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type){return(app->get_user_input(app, get_type, abort_type));}
static inline User_Input get_command_input(Application_Links *app){return(app->get_command_input(app));}
static inline Mouse_State get_mouse_state(Application_Links *app){return(app->get_mouse_state(app));}
@ -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, 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 void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len){(app->clipboard_post_(app, clipboard_id, str, len));}
static inline int32_t clipboard_count(Application_Links *app, int32_t clipboard_id){return(app->clipboard_count_(app, clipboard_id));}
static inline int32_t clipboard_index(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len){return(app->clipboard_index_(app, clipboard_id, item_index, out, len));}
static inline int32_t get_buffer_count(Application_Links *app){return(app->get_buffer_count_(app));}
static inline Buffer_Summary get_buffer_first(Application_Links *app, Access_Flag access){return(app->get_buffer_first_(app, access));}
static inline void get_buffer_next(Application_Links *app, Buffer_Summary *buffer, Access_Flag access){(app->get_buffer_next_(app, buffer, access));}
static inline Buffer_Summary get_buffer(Application_Links *app, Buffer_ID buffer_id, Access_Flag access){return(app->get_buffer_(app, buffer_id, access));}
static inline Buffer_Summary get_buffer_by_name(Application_Links *app, char *name, int32_t len, Access_Flag access){return(app->get_buffer_by_name_(app, name, len, access));}
static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *buffer, size_t start, size_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, int32_t start, int32_t end, char *out){return(app->buffer_read_range_(app, buffer, start, end, out));}
static inline bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, 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, 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 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 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, 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_highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on){return(app->view_set_highlight_(app, view, start, end, turn_on));}
static inline bool32 view_set_buffer(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags){return(app->view_set_buffer_(app, view, buffer_id, flags));}
static inline bool32 view_post_fade(Application_Links *app, View_Summary *view, float seconds, size_t start, size_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, int32_t start, int32_t end, int_color color){return(app->view_post_fade_(app, view, seconds, start, end, color));}
static inline User_Input get_user_input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type){return(app->get_user_input_(app, get_type, abort_type));}
static inline User_Input get_command_input(Application_Links *app){return(app->get_command_input_(app));}
static inline Mouse_State get_mouse_state(Application_Links *app){return(app->get_mouse_state_(app));}

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'.) */
size_t min;
int32_t min;
/* DOC(This is the larger value in the range, it is also the 'end'.) */
size_t max;
int32_t max;
};
STRUCT{
/* DOC(This is the start of the range, it is also the 'min'.) */
size_t start;
int32_t start;
/* DOC(This is the end of the range, it is also the 'max'.) */
size_t end;
int32_t end;
};
};
@ -482,9 +482,7 @@ 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,
/* 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,
buffer_seek_line_char
};
/* DOC(Buffer_Seek describes the destination of a seek operation. There are helpers for concisely creating Buffer_Seek structs. They can be found in 4coder_buffer_types.h.)
@ -616,7 +614,7 @@ DOC_SEE(buffer_add_markers)
*/
STRUCT Marker{
/* DOC(The current position of the marker measure in absolute byte positioning coordinates.) */
size_t pos;
int32_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;
};
@ -735,12 +733,12 @@ STRUCT Buffer_Batch_Edit{
/* DOC(The pointer to the edit string buffer.) */
char *str;
/* DOC(The length of the edit string buffer.) */
size_t str_len;
int32_t str_len;
/* DOC(The array of edits to be applied.) */
Buffer_Edit *edits;
/* DOC(The number of edits in the array.) */
uint32_t edit_count;
int32_t edit_count;
};

View File

@ -28,29 +28,31 @@ TYPE: 'drop-in-command-pack'
//
struct Hard_Start_Result{
size_t char_pos;
int32_t char_pos;
int32_t indent_pos;
bool32 all_whitespace;
bool32 all_space;
int32_t all_whitespace;
int32_t all_space;
};
static Hard_Start_Result
buffer_find_hard_start(Application_Links *app, Buffer_Summary *buffer, size_t line_start, int32_t tab_width){
buffer_find_hard_start(Application_Links *app, Buffer_Summary *buffer, int32_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 < (size_t)stream.end; ++result.char_pos){
char c = stream.data[result.char_pos];
for (; result.char_pos < stream.end; ++result.char_pos){
c = stream.data[result.char_pos];
if (c == '\n' || c == 0){
result.all_whitespace = 1;
@ -86,25 +88,26 @@ struct Indent_Options{
};
static Buffer_Batch_Edit
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){
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){
Buffer_Batch_Edit result = {0};
size_t edit_max = line_end - line_start;
uint32_t edit_count = 0;
int32_t edit_max = line_end - line_start;
int32_t edit_count = 0;
Buffer_Edit *edits = push_array(part, Buffer_Edit, edit_max);
char *str_base = (char*)part->base + part->pos;
size_t str_size = 0;
int32_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 (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);
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);
int32_t correct_indentation = indent_marks[line_i];
if (hard_start.all_whitespace && opts.empty_blank_lines){
@ -156,12 +159,13 @@ 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, size_t line_start, size_t line_end, int32_t *indent_marks, Indent_Options opts){
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){
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);
}
}
@ -192,7 +196,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, size_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, int32_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){
@ -220,8 +224,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{
size_t line = buffer_get_line_index(app, buffer, token->start);
size_t start = buffer_get_line_start(app, buffer, line);
int32_t line = buffer_get_line_index(app, buffer, token->start);
int32_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;
@ -294,30 +298,32 @@ struct Indent_Parse_State{
};
static int32_t*
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){
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){
size_t indent_mark_count = line_end - line_start;
int32_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 (size_t line_index = line_start; line_index < line_end; ++line_index){
for (int32_t line_index = line_start; line_index < line_end; ++line_index){
indent_marks[line_index] = 0;
}
}
else{
size_t line_index = buffer_get_line_index(app, buffer, token_ptr->start);
int32_t line_index = buffer_get_line_index(app, buffer, token_ptr->start);
if (line_index > line_start){
line_index = line_start;
}
size_t next_line_start_pos = buffer_get_line_start(app, buffer, line_index+1);
uint32_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;
@ -347,8 +353,8 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
{
int32_t previous_indent = indent.previous_line_indent;
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);
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);
bool32 did_special_behavior = false;
@ -364,7 +370,7 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
this_indent = previous_indent;
}
else{
uint32_t line_pos = (uint32_t)(hard_start.char_pos - this_line_start);
int32_t line_pos = hard_start.char_pos - this_line_start;
this_indent = line_pos + indent.comment_shift;
if (this_indent < 0){
this_indent = 0;
@ -456,24 +462,24 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
case CPP_TOKEN_COMMENT:
{
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;
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);
}break;
case CPP_TOKEN_PARENTHESE_OPEN:
if (!(token.flags & CPP_TFLAG_PP_BODY)){
if (indent.paren_nesting < ArrayCount(indent.paren_anchor_indent)){
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);
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;
Hard_Start_Result hard_start =
buffer_find_hard_start(app, buffer, start, tab_width);
int32_t line_pos = (int32_t)(hard_start.char_pos - start);
int32_t line_pos = hard_start.char_pos - start;
indent.paren_anchor_indent[indent.paren_nesting] =
char_pos - line_pos + indent.previous_line_indent + 1;
@ -499,21 +505,25 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
}
static void
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;
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;
*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, 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);
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);
for (;line_start > 0;){
size_t line_start_pos = 0;
uint32_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);
@ -524,7 +534,7 @@ get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cp
}
for (;line_end+1 < buffer->line_count;){
size_t next_line_start_pos = 0;
uint32_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);
@ -545,11 +555,12 @@ 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, size_t start, size_t end, int32_t tab_width, Auto_Indent_Flag flags){
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){
bool32 result = false;
bool32 result = 0;
if (buffer->exists && buffer->tokens_are_ready){
result = true;
result = 1;
Temp_Memory temp = begin_temp_memory(part);
@ -562,7 +573,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.
size_t line_start = 0, line_end = 0;
int32_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);
}
@ -574,7 +585,8 @@ 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};
@ -591,7 +603,8 @@ buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buff
}
static bool32
buffer_auto_indent(Application_Links *app, Buffer_Summary *buffer, size_t start, size_t end, int32_t tab_width, Auto_Indent_Flag flags){
buffer_auto_indent(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_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);
size_t pos = view.cursor.pos;
int32_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,12 +56,11 @@ CUSTOM_COMMAND_SIG(delete_char){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
Buffer_Seek seek = seek_character_pos(view.cursor.character_pos+1);
Full_Cursor cursor;
view_compute_cursor(app, &view, seek, &cursor);
int32_t start = view.cursor.pos;
size_t start = view.cursor.pos;
size_t end = cursor.pos;
Full_Cursor cursor;
view_compute_cursor(app, &view, seek_character_pos(view.cursor.character_pos+1), &cursor);
int32_t end = cursor.pos;
if (0 <= start && start < buffer.size){
buffer_replace_range(app, &buffer, start, end, 0, 0);
@ -73,17 +72,15 @@ CUSTOM_COMMAND_SIG(backspace_char){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
Buffer_Seek seek = seek_character_pos(view.cursor.character_pos-1);
Full_Cursor cursor;
view_compute_cursor(app, &view, seek, &cursor);
int32_t end = view.cursor.pos;
size_t end = view.cursor.pos;
size_t start = cursor.pos;
Full_Cursor cursor;
view_compute_cursor(app, &view, seek_character_pos(view.cursor.character_pos-1), &cursor);
int32_t start = cursor.pos;
if (0 < end && end <= buffer.size){
buffer_replace_range(app, &buffer, start, end, 0, 0);
seek = seek_character_pos(view.cursor.character_pos-1);
view_set_cursor(app, &view, seek, true);
view_set_cursor(app, &view, seek_character_pos(view.cursor.character_pos-1), true);
}
}
@ -97,8 +94,8 @@ CUSTOM_COMMAND_SIG(set_mark){
CUSTOM_COMMAND_SIG(cursor_mark_swap){
View_Summary view = get_active_view(app, AccessProtected);
size_t cursor = view.cursor.pos;
size_t mark = view.mark.pos;
int32_t cursor = view.cursor.pos;
int32_t mark = view.mark.pos;
view_set_cursor(app, &view, seek_pos(mark), true);
view_set_mark(app, &view, seek_pos(cursor));
@ -250,14 +247,14 @@ CUSTOM_COMMAND_SIG(page_down){
CUSTOM_COMMAND_SIG(move_left){
uint32_t access = AccessProtected;
View_Summary view = get_active_view(app, access);
size_t new_pos = view.cursor.character_pos - 1;
int32_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);
size_t new_pos = view.cursor.character_pos + 1;
int32_t new_pos = view.cursor.character_pos + 1;
view_set_cursor(app, &view, seek_character_pos(new_pos), 1);
}
@ -277,7 +274,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);
size_t new_pos = buffer_seek_whitespace_up(app, &buffer, view.cursor.pos);
int32_t new_pos = buffer_seek_whitespace_up(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -286,7 +283,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);
size_t new_pos = buffer_seek_whitespace_down(app, &buffer, view.cursor.pos);
int32_t new_pos = buffer_seek_whitespace_down(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -295,7 +292,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);
size_t new_pos = seek_line_end(app, &buffer, view.cursor.pos);
int32_t new_pos = seek_line_end(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -304,7 +301,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);
size_t new_pos = seek_line_beginning(app, &buffer, view.cursor.pos);
int32_t new_pos = seek_line_beginning(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -350,7 +347,7 @@ CUSTOM_COMMAND_SIG(to_uppercase){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
Range range = get_range(&view);
size_t size = range.max - range.min;
int32_t size = range.max - range.min;
if (size <= app->memory_size){
char *mem = (char*)app->memory;
@ -368,7 +365,7 @@ CUSTOM_COMMAND_SIG(to_lowercase){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
Range range = get_range(&view);
size_t size = range.max - range.min;
int32_t size = range.max - range.min;
if (size <= app->memory_size){
char *mem = (char*)app->memory;
@ -568,7 +565,7 @@ CUSTOM_COMMAND_SIG(search);
CUSTOM_COMMAND_SIG(reverse_search);
static void
isearch(Application_Links *app, bool32 start_reversed){
isearch(Application_Links *app, int32_t start_reversed){
uint32_t access = AccessProtected;
View_Summary view = get_active_view(app, access);
@ -579,10 +576,10 @@ isearch(Application_Links *app, bool32 start_reversed){
Query_Bar bar = {0};
if (start_query_bar(app, &bar, 0) == 0) return;
bool32 reverse = start_reversed;
size_t pos = view.cursor.pos;
size_t start_pos = pos;
size_t first_pos = pos;
int32_t reverse = start_reversed;
int32_t pos = view.cursor.pos;
int32_t start_pos = pos;
int32_t first_pos = pos;
Range match = make_range(pos, pos);
char bar_string_space[256];
@ -645,16 +642,16 @@ isearch(Application_Links *app, bool32 start_reversed){
}
if (in.key.keycode != key_back){
char *str = bar.string.str;
size_t str_size = bar.string.size;
size_t new_pos = 0;
int32_t new_pos;
if (reverse){
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0, str, str_size, &new_pos);
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0,
bar.string.str, bar.string.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, str, str_size, &new_pos);
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0,
bar.string.str, bar.string.size, &new_pos);
if (new_pos < 0) new_pos = start_pos;
}
match.start = new_pos;
@ -662,13 +659,14 @@ isearch(Application_Links *app, bool32 start_reversed){
}
}
else{
buffer_seek_string_insensitive_forward(app, &buffer, start_pos + 1, 0, str, str_size, &new_pos);
buffer_seek_string_insensitive_forward(app, &buffer, start_pos + 1, 0,
bar.string.str, bar.string.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,
str, str_size, &new_pos);
bar.string.str, bar.string.size, &new_pos);
if (new_pos >= buffer.size) new_pos = start_pos;
}
match.start = new_pos;
@ -723,8 +721,9 @@ CUSTOM_COMMAND_SIG(replace_in_range){
Range range = get_range(&view);
size_t pos = range.min;
size_t new_pos = 0;
int32_t pos, new_pos;
pos = range.min;
buffer_seek_string_forward(app, &buffer, pos, 0, r.str, r.size, &new_pos);
while (new_pos + r.size <= range.end){
@ -752,21 +751,25 @@ CUSTOM_COMMAND_SIG(query_replace){
if (!query_user_string(app, &with)) return;
String r = replace.string;
String w = with.string;
String r, w;
r = replace.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_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
view = get_active_view(app, access);
buffer = get_buffer(app, view.buffer_id, access);
size_t pos = view.cursor.pos;
size_t new_pos = 0;
pos = view.cursor.pos;
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, size_t start, size_t end, Buffer_Summary *buffer_out, uint32_t access){
clipboard_copy(Application_Links *app, int32_t start, int32_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){
size_t size = (end - start);
int32_t size = (end - start);
char *str = (char*)app->memory;
if (size <= app->memory_size){
@ -36,16 +36,14 @@ clipboard_copy(Application_Links *app, size_t start, size_t end, Buffer_Summary
return(result);
}
static bool32
clipboard_cut(Application_Links *app, size_t start, size_t end, Buffer_Summary *buffer_out, uint32_t access){
static int32_t
clipboard_cut(Application_Links *app, int32_t start, int32_t end, Buffer_Summary *buffer_out, uint32_t access){
Buffer_Summary buffer = {0};
bool32 result = false;
int32_t 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);
@ -76,7 +74,7 @@ CUSTOM_COMMAND_SIG(paste){
int32_t paste_index = 0;
view_paste_index[view.view_id].index = paste_index;
size_t len = clipboard_index(app, 0, paste_index, 0, 0);
int32_t len = clipboard_index(app, 0, paste_index, 0, 0);
char *str = 0;
if (len <= app->memory_size){
@ -87,7 +85,7 @@ CUSTOM_COMMAND_SIG(paste){
clipboard_index(app, 0, paste_index, str, len);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
size_t pos = view.cursor.pos;
int32_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);
@ -113,7 +111,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;
size_t len = clipboard_index(app, 0, paste_index, 0, 0);
int32_t len = clipboard_index(app, 0, paste_index, 0, 0);
char *str = 0;
if (len <= app->memory_size){
@ -125,7 +123,7 @@ CUSTOM_COMMAND_SIG(paste_next){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
Range range = get_range(&view);
size_t pos = range.min;
int32_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 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);
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);
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);
size_t pos = buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_type, flags);
int32_t pos = buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_type, flags);
view_set_cursor(app, &view, seek_pos(pos), true);
}
@ -85,10 +85,12 @@ CUSTOM_COMMAND_SIG(backspace_word){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
if (buffer.exists){
size_t pos2 = view.cursor.pos;
int32_t pos2 = 0, pos1 = 0;
pos2 = view.cursor.pos;
exec_command(app, seek_alphanumeric_left);
refresh_view(app, &view);
size_t pos1 = view.cursor.pos;
pos1 = view.cursor.pos;
buffer_replace_range(app, &buffer, pos1, pos2, 0, 0);
}
@ -101,10 +103,12 @@ CUSTOM_COMMAND_SIG(delete_word){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
if (buffer.exists){
size_t pos1 = view.cursor.pos;
int32_t pos2 = 0, pos1 = 0;
pos1 = view.cursor.pos;
exec_command(app, seek_alphanumeric_right);
refresh_view(app, &view);
size_t pos2 = view.cursor.pos;
pos2 = view.cursor.pos;
buffer_replace_range(app, &buffer, pos1, pos2, 0, 0);
}
@ -112,11 +116,12 @@ 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);
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);
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);
Range range = make_range(pos1, pos2);
buffer_replace_range(app, &buffer, range.start, range.end, 0, 0);
@ -141,7 +146,7 @@ CUSTOM_COMMAND_SIG(duplicate_line){
++line_string.memory_size;
append_s_char(&line_string, '\n');
size_t pos = buffer_get_line_end(app, &buffer, view.cursor.line) + 1;
int32_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);
@ -154,8 +159,8 @@ CUSTOM_COMMAND_SIG(delete_line){
Partition *part = &global_part;
Temp_Memory temp = begin_temp_memory(part);
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;
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;
buffer_replace_range(app, &buffer, start, end, 0, 0);
@ -201,7 +206,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);
size_t pos = view.cursor.pos;
int32_t pos = view.cursor.pos;
buffer_replace_range(app, &buffer, pos, pos, text, size);
view_set_cursor(app, &view, seek_pos(pos + 2), true);
@ -333,13 +338,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){
size_t pos = view.cursor.pos;
size_t start = 0, end = 0;
int32_t pos = view.cursor.pos;
int32_t start = 0, end = 0;
buffer_seek_delimiter_forward(app, &buffer, pos, '"', &end);
buffer_seek_delimiter_backward(app, &buffer, pos, '"', &start);
++start;
size_t size = end - start;
int32_t size = end - start;
char short_file_name[128];
// NOTE(allen): This check is necessary because buffer_read_range
@ -349,7 +354,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, (int32_t)size));
append_ss(file_name, make_string(short_file_name, 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);
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);
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 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, (int32_t)line_number);
append_int_to_str(&out, 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, size_t pos){
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int32_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(size_t p1, size_t p2){
make_range(int32_t p1, int32_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(size_t, rect.y0, rect.y1);
Swap(int32_t, rect.y0, rect.y1);
}
if (rect.x0 > rect.x1){
Swap(size_t, rect.x0, rect.x1);
Swap(int32_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, size_t *colon_char){
bool32 result = false;
parse_jump_location(String line, Name_Based_Jump_Location *location, int32_t skip_sub_errors, int32_t *colon_char){
int32_t result = false;
int32_t whitespace_length = 0;
String original_line = line;
line = skip_chop_whitespace(line, &whitespace_length);
int32_t colon_pos = 0;
bool32 is_ms_style = false;
int32_t is_ms_style = 0;
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 = true;
is_ms_style = 1;
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 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){
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){
bool32 result = false;
int32_t result = false;
String line_str = {0};
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
if (read_line(app, part, &buffer, line, &line_str)){
size_t colon_char = 0;
int32_t colon_char = 0;
if (parse_jump_location(line_str, location, skip_sub_errors, &colon_char)){
result = true;
}

View File

@ -15,17 +15,20 @@
// Whitespace Based Seeks
//
static size_t
seek_line_end(Application_Links *app, Buffer_Summary *buffer, size_t pos){
static int32_t
seek_line_end(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char chunk[1024];
size_t chunk_size = sizeof(chunk);
int32_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)){
bool32 still_looping = true;
still_looping = 1;
do{
for (; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
for (; pos < stream.end; ++pos){
at_pos = stream.data[pos];
if (at_pos == '\n'){
goto double_break;
}
@ -42,18 +45,21 @@ seek_line_end(Application_Links *app, Buffer_Summary *buffer, size_t pos){
return(pos);
}
static size_t
seek_line_beginning(Application_Links *app, Buffer_Summary *buffer, size_t pos){
static int32_t
seek_line_beginning(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char chunk[1024];
size_t chunk_size = sizeof(chunk);
int32_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)){
bool32 still_looping = false;
still_looping = 1;
do{
for (; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
for (; pos >= stream.start; --pos){
at_pos = stream.data[pos];
if (at_pos == '\n'){
goto double_break;
}
@ -77,15 +83,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;
size_t new_pos = seek_line_beginning(app, buffer, view->cursor.pos);
size_t i = new_pos;
int32_t i = new_pos;
if (init_stream_chunk(&chunk, app, buffer, i, space, sizeof(space))){
bool32 still_looping = false;
do{
for (; i < (size_t)chunk.end; ++i){
for (; i < chunk.end; ++i){
char at_pos = chunk.data[i];
if (at_pos == '\n' || !char_is_whitespace(at_pos)){
goto break2;
@ -101,20 +107,22 @@ move_past_lead_whitespace(Application_Links *app, View_Summary *view, Buffer_Sum
}
}
static size_t
buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, size_t pos){
static int32_t
buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char chunk[1024];
size_t chunk_size = sizeof(chunk);
int32_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.
bool32 still_looping = true;
int32_t still_looping = 1;
while (still_looping){
for (; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
for (; pos >= stream.start; --pos){
at_pos = stream.data[pos];
if (!char_is_whitespace(at_pos)){
goto double_break_1;
}
@ -130,8 +138,8 @@ buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, size_t
// the next '\n'
int32_t no_hard = false;
while (still_looping){
for (; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
for (; pos >= stream.start; --pos){
at_pos = stream.data[pos];
if (at_pos == '\n'){
if (no_hard){
goto double_break_2;
@ -156,19 +164,24 @@ buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, size_t
return(pos);
}
static size_t
buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, size_t pos){
static int32_t
buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char chunk[1024];
size_t chunk_size = sizeof(chunk);
int32_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.
bool32 still_looping = true;
still_looping = true;
do{
for (; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
for (; pos < stream.end; ++pos){
at_pos = stream.data[pos];
if (!char_is_whitespace(at_pos)){
goto double_break_1;
}
@ -182,12 +195,11 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, size
// the prev_endline value. if another '\n' is found
// with non-whitespace then the previous line was
// all whitespace.
bool32 no_hard = false;
bool32 was_at_end = true;
size_t prev_endline = 0;
no_hard = false;
prev_endline = -1;
while(still_looping){
for (; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
for (; pos < stream.end; ++pos){
at_pos = stream.data[pos];
if (at_pos == '\n'){
if (no_hard){
goto double_break_2;
@ -195,7 +207,6 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, size
else{
no_hard = true;
prev_endline = pos;
was_at_end = false;
}
}
else if (!char_is_whitespace(at_pos)){
@ -206,7 +217,7 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, size
}
double_break_2:;
if (was_at_end || prev_endline+1 >= buffer->size){
if (prev_endline == -1 || prev_endline+1 >= buffer->size){
pos = buffer->size;
}
else{
@ -216,8 +227,8 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, size
return(pos);
}
static size_t
buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, size_t pos){
static int32_t
buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -226,7 +237,7 @@ buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, siz
bool32 still_looping = 1;
do{
for (; pos < (size_t)stream.end; ++pos){
for (; pos < stream.end; ++pos){
if (!char_is_whitespace(stream.data[pos])){
goto double_break1;
}
@ -237,7 +248,7 @@ buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, siz
still_looping = 1;
do{
for (; pos < (size_t)stream.end; ++pos){
for (; pos < stream.end; ++pos){
if (char_is_whitespace(stream.data[pos])){
goto double_break2;
}
@ -250,8 +261,8 @@ buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, siz
return(pos);
}
static size_t
buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, size_t pos){
static int32_t
buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -262,7 +273,7 @@ buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, size
bool32 still_looping = 1;
do{
for (; pos >= (size_t)stream.start; --pos){
for (; pos >= stream.start; --pos){
if (!char_is_whitespace(stream.data[pos])){
goto double_break1;
}
@ -273,7 +284,7 @@ buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, size
still_looping = 1;
do{
for (; pos >= (size_t)stream.start; --pos){
for (; pos >= stream.start; --pos){
if (char_is_whitespace(stream.data[pos])){
++pos;
goto double_break2;
@ -295,8 +306,8 @@ buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, size
// Boundary Type Seeks
//
static size_t
buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, size_t pos){
static int32_t
buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -305,7 +316,7 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, s
bool32 still_looping = 1;
do{
for (; pos < (size_t)stream.end; ++pos){
for (; pos < stream.end; ++pos){
if (char_is_alpha_numeric_true(stream.data[pos])){
goto double_break1;
}
@ -316,7 +327,7 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, s
still_looping = 1;
do{
for (; pos < (size_t)stream.end; ++pos){
for (; pos < stream.end; ++pos){
if (!char_is_alpha_numeric_true(stream.data[pos])){
goto double_break2;
}
@ -329,8 +340,8 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, s
return(pos);
}
static size_t
buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, size_t pos){
static int32_t
buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -341,7 +352,7 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, si
bool32 still_looping = 1;
do{
for (; pos >= (size_t)stream.start; --pos){
for (; pos >= stream.start; --pos){
if (char_is_alpha_numeric_true(stream.data[pos])){
goto double_break1;
}
@ -352,7 +363,7 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, si
still_looping = 1;
do{
for (; pos >= (size_t)stream.start; --pos){
for (; pos >= stream.start; --pos){
if (!char_is_alpha_numeric_true(stream.data[pos])){
++pos;
goto double_break2;
@ -370,8 +381,8 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, si
return(pos);
}
static size_t
buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t an_pos){
static int32_t
buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t an_pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -386,7 +397,7 @@ buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, si
bool32 still_looping = 1;
do{
for (; pos < (size_t)stream.end; ++pos){
for (; pos < stream.end; ++pos){
c = stream.data[pos];
if (char_is_upper(c) && char_is_lower(pc)){
goto double_break1;
@ -405,8 +416,8 @@ buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, si
return(pos);
}
static size_t
buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t an_pos){
static int32_t
buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t an_pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -419,7 +430,7 @@ buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, siz
bool32 still_looping = 1;
do{
for (; pos >= (size_t)stream.start; --pos){
for (; pos >= stream.start; --pos){
c = stream.data[pos];
if (char_is_upper(c) && char_is_lower(pc)){
goto double_break1;
@ -438,22 +449,22 @@ buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, siz
return(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);
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);
return(result);
}
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);
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);
return(result);
}
static size_t
seek_token_left(Cpp_Token_Array *tokens, size_t pos){
static int32_t
seek_token_left(Cpp_Token_Array *tokens, uint32_t pos){
Cpp_Get_Token_Result get = cpp_get_token(*tokens, pos);
if (get.token_index == -1){
get.token_index = 0;
@ -467,8 +478,8 @@ seek_token_left(Cpp_Token_Array *tokens, size_t pos){
return(token->start);
}
static size_t
seek_token_right(Cpp_Token_Array *tokens, size_t pos){
static int32_t
seek_token_right(Cpp_Token_Array *tokens, uint32_t pos){
Cpp_Get_Token_Result get = cpp_get_token(*tokens, pos);
if (get.in_whitespace){
++get.token_index;
@ -497,26 +508,28 @@ buffer_get_all_tokens(Application_Links *app, Partition *part, Buffer_Summary *b
return(array);
}
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)/*
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)/*
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)
*/{
size_t result = 0;
int32_t result = 0;
// TODO(allen): reduce duplication?
Temp_Memory temp = begin_temp_memory(part);
if (buffer->exists){
size_t pos[4];
size_t size = buffer->size;
size_t new_pos = 0;
int32_t pos[4];
int32_t size = buffer->size;
int32_t new_pos = 0;
if (start_pos < 0){
start_pos = 0;
@ -612,8 +625,8 @@ DOC_SEE(4coder_Buffer_Positioning_System)
// Character Seeks
//
static void
buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, size_t pos, char delim, size_t *result){
void
buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, char delim, int32_t *result){
if (buffer->exists){
char chunk[1024];
int32_t size = sizeof(chunk);
@ -622,7 +635,7 @@ buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, si
if (init_stream_chunk(&stream, app, buffer, pos, chunk, size)){
int32_t still_looping = 1;
do{
for(; pos < (size_t)stream.end; ++pos){
for(; pos < stream.end; ++pos){
char at_pos = stream.data[pos];
if (at_pos == delim){
*result = pos;
@ -640,7 +653,7 @@ buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, si
}
static void
buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, size_t pos, char delim, size_t *result){
buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, char delim, int32_t *result){
if (buffer->exists){
char chunk[1024];
int32_t size = sizeof(chunk);
@ -649,7 +662,7 @@ buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, s
if (init_stream_chunk(&stream, app, buffer, pos, chunk, size)){
int32_t still_looping = 1;
do{
for(; pos >= (size_t)stream.start; --pos){
for(; pos >= stream.start; --pos){
char at_pos = stream.data[pos];
if (at_pos == delim){
*result = pos;
@ -677,7 +690,7 @@ buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, s
// 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, size_t pos, size_t end, char *str, size_t size, size_t *result){
buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t end, char *str, int32_t size, int32_t *result){
char read_buffer[512];
if (buffer->size > end){
@ -690,19 +703,19 @@ buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, size_
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, (int32_t)size);
String needle_str = make_string(str, size);
char first_char = str[0];
read_str.size = (int32_t)size;
read_str.size = size;
char chunk[1024];
Stream_Chunk stream = {0};
stream.max_end = end;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, sizeof(chunk))){
bool32 still_looping = 1;
int32_t still_looping = 1;
do{
for(; pos < (size_t)stream.end; ++pos){
for(; pos < stream.end; ++pos){
char at_pos = stream.data[pos];
if (at_pos == first_char){
buffer_read_range(app, buffer, pos, pos+size, read_buffer);
@ -732,17 +745,17 @@ buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, size_
// 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, size_t pos, size_t min, char *str, size_t size, size_t *result){
buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t min, char *str, int32_t size, int32_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, (int32_t)size);
String needle_str = make_string(str, size);
char first_char = str[0];
read_str.size = (int32_t)size;
read_str.size = size;
char chunk[1024];
Stream_Chunk stream = {0};
@ -751,7 +764,7 @@ buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, size
if (init_stream_chunk(&stream, app, buffer, pos, chunk, sizeof(chunk))){
int32_t still_looping = 1;
do{
for(; pos >= (size_t)stream.start; --pos){
for(; pos >= stream.start; --pos){
char at_pos = stream.data[pos];
if (at_pos == first_char){
buffer_read_range(app, buffer, pos, pos+size, read_buffer);
@ -774,7 +787,7 @@ buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, size
// 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, size_t pos, size_t end, char *str, size_t size, size_t *result){
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){
char read_buffer[512];
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
@ -788,29 +801,32 @@ buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *b
*result = end;
}
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;
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;
}
}
}
}
still_looping = forward_stream_chunk(&stream);
}while (still_looping);
still_looping = forward_stream_chunk(&stream);
}while (still_looping);
}
}
finished:;
}
}
@ -819,7 +835,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, size_t pos, size_t min, char *str, size_t size, size_t *result){
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){
char read_buffer[512];
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
@ -827,29 +843,32 @@ buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *
stream.min_start = min;
*result = min-1;
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;
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;
}
}
}
}
still_looping = backward_stream_chunk(&stream);
}while (still_looping);
still_looping = backward_stream_chunk(&stream);
}while (still_looping);
}
}
finished:;
}
}
@ -859,25 +878,23 @@ buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *
// Buffer Line Positioning
//
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);
static int32_t
read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line, String *str){
Partial_Cursor begin = {0};
Partial_Cursor end = {0};
if (buffer_compute_cursor(app, buffer, seek_begin, &begin)){
if (begin.line == line){
if (buffer_compute_cursor(app, buffer, seek_end, &end)){
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 (0 <= begin.pos && begin.pos <= end.pos && end.pos <= buffer->size){
size_t size = (end.pos - begin.pos);
*str = make_string(push_array(part, char, size+1), (int32_t)(size+1));
int32_t size = (end.pos - begin.pos);
*str = make_string(push_array(part, char, size+1), size+1);
if (str->str){
success = true;
success = 1;
buffer_read_range(app, buffer, begin.pos, end.pos, str->str);
str->size = (int32_t)size;
str->size = size;
terminate_with_null(str);
}
}
@ -888,10 +905,10 @@ read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, size_
return(success);
}
static size_t
buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, size_t line){
static int32_t
buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, int32_t line){
Partial_Cursor partial_cursor;
size_t result = buffer->size;
int32_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;
@ -899,39 +916,36 @@ buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, size_t lin
return(result);
}
static size_t
buffer_get_line_end(Application_Links *app, Buffer_Summary *buffer, size_t line){
static int32_t
buffer_get_line_end(Application_Links *app, Buffer_Summary *buffer, int32_t line){
Partial_Cursor partial_cursor;
size_t result = buffer->size;
int32_t result = buffer->size;
if (line <= buffer->line_count){
buffer_compute_cursor(app, buffer, seek_line_reverse_char(line, 1), &partial_cursor);
buffer_compute_cursor(app, buffer, seek_line_char(line, -1), &partial_cursor);
result = partial_cursor.pos;
}
return(result);
}
static bool32
buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, size_t line){
buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, int32_t line){
Partial_Cursor start, end;
bool32 result = 0;
if (line <= buffer->line_count){
Buffer_Seek seek_start = seek_line_char(line, 1);
Buffer_Seek seek_end = seek_line_reverse_char(line, 1);
buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &start);
buffer_compute_cursor(app, buffer, seek_line_char(line, -1), &end);
buffer_compute_cursor(app, buffer, seek_start, &start);
buffer_compute_cursor(app, buffer, seek_end, &end);
static const size_t chunk_size = 1024;
static const int32_t chunk_size = 1024;
char chunk[chunk_size];
Stream_Chunk stream = {0};
size_t i = start.pos;
int32_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 < (size_t)stream.end; ++i){
for (;i < stream.end; ++i){
char c = stream.data[i];
if (!(c == ' ' || c == '\t' || c == '\r' || c == '\v' || c == '\n')){
result = false;
@ -946,16 +960,16 @@ buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, size_t line
return(result);
}
static size_t
buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, size_t pos){
static int32_t
buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, int32_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, size_t line, size_t *line_start_out = 0){
size_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, int32_t line, uint32_t *line_start_out = 0){
int32_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){
@ -963,7 +977,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 != 0){
if (line_start_out){
*line_start_out = line_start;
}

View File

@ -67,15 +67,6 @@ 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,32 +9,31 @@
#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;
int64_t start, end;
int64_t min_start, max_end;
int64_t data_size;
int32_t start, end;
int32_t min_start, max_end;
bool32 add_null;
uint32_t data_size;
char *data;
};
static uint64_t
round_down(uint64_t x, uint64_t b){
uint64_t r = 0;
static int32_t
round_down(int32_t x, int32_t b){
int32_t r = 0;
if (x >= 0){
r = x - (x % b);
}
return(r);
}
static uint64_t
round_up(uint64_t x, uint64_t b){
uint64_t r = 0;
static int32_t
round_up(int32_t x, int32_t b){
int32_t r = 0;
if (x >= 0){
r = x - (x % b) + b;
}
@ -42,7 +41,8 @@ round_up(uint64_t x, uint64_t b){
}
static bool32
init_stream_chunk(Stream_Chunk *chunk, Application_Links *app, Buffer_Summary *buffer, size_t pos, char *data, size_t size){
init_stream_chunk(Stream_Chunk *chunk, Application_Links *app, Buffer_Summary *buffer,
int32_t pos, char *data, uint32_t size){
bool32 result = 0;
refresh_buffer(app, buffer);
@ -153,12 +153,12 @@ struct Stream_Tokens{
Cpp_Token *base_tokens;
Cpp_Token *tokens;
int64_t start, end;
int64_t count, token_count;
int32_t start, end;
int32_t count, token_count;
};
static bool32
init_stream_tokens(Stream_Tokens *stream, Application_Links *app, Buffer_Summary *buffer, size_t pos, Cpp_Token *data, size_t count){
init_stream_tokens(Stream_Tokens *stream, Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Token *data, int32_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 = (int64_t)count;
stream->start = (int64_t)round_down(pos, count);
stream->end = (int64_t)round_up(pos, count);
stream->count = count;
stream->start = round_down(pos, count);
stream->end = round_up(pos, count);
stream->token_count = token_count;
if (stream->start < 0){

View File

@ -22,7 +22,10 @@ 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);
@ -36,13 +39,13 @@ CUSTOM_COMMAND_SIG(goto_jump_at_cursor){
// Error Jumping
//
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){
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){
Assert(direction == 1 || direction == -1);
bool32 result = false;
size_t line = first_line;
int32_t result = false;
int32_t line = first_line;
String line_str = {0};
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
for (;;){
@ -83,12 +86,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, bool32 skip_sub_errors, int32_t direction, size_t *line_out, size_t *colon_index_out, Name_Based_Jump_Location *location_out){
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){
int32_t result = false;
Name_Based_Jump_Location location = {0};
size_t line = view->cursor.line;
size_t colon_index = 0;
int32_t line = view->cursor.line;
int32_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;
@ -111,13 +114,13 @@ skip_this_jump(ID_Based_Jump_Location prev, ID_Based_Jump_Location jump){
return(result);
}
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;
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;
Name_Based_Jump_Location location = {0};
ID_Based_Jump_Location jump = {0};
size_t line = 0, colon_index = 0;
int32_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;
size_t size;
i32_4tech size;
u32_4tech flags;
u8_4tech _unused_[20 - sizeof(size_t)];
u32_4tech _unused_[4];
};
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, size_t wanted_size){
size_t remaining_size = bubble->size - wanted_size;
general_memory_attempt_split(General_Memory *general, Bubble *bubble, i32_4tech wanted_size){
i32_4tech 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, size_t size){
general_memory_allocate(General_Memory *general, i32_4tech 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, size_t old_size, size_t size){
general_memory_reallocate(General_Memory *general, void *old, i32_4tech old_size, i32_4tech size){
void *result = old;
Bubble *bubble = ((Bubble*)old) - 1;
size_t additional_space = size - bubble->size;
i32_4tech 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, size_t old_size, s
}
inline void*
general_memory_reallocate_nocopy(General_Memory *general, void *old, size_t size){
general_memory_reallocate_nocopy(General_Memory *general, void *old, i32_4tech 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;
u32_4tech count, max;
u32_4tech item_size;
i32_4tech count, max;
i32_4tech 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;
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;
return(mem_size);
}
static void
table_init_memory(Table *table, void *memory, u32_4tech table_size, u32_4tech item_size){
umem_4tech hash_size = table_size * sizeof(u32_4tech);
table_init_memory(Table *table, void *memory, i32_4tech table_size, i32_4tech item_size){
i32_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);
u32_4tech i = hash % table->max;
u32_4tech start = i;
i32_4tech i = hash % table->max;
i32_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);
u32_4tech i = hash % table->max;
u32_4tech start = i;
i32_4tech i = hash % table->max;
i32_4tech start = i;
u32_4tech *inspect = table->hash_array + i;
while (*inspect != TableHashEmpty){
@ -254,17 +254,18 @@ tbl_offset_string_compare(void *a, void *b, void *arg){
struct String_Space{
char *space;
u32_4tech pos;
u32_4tech new_pos;
u32_4tech max;
i32_4tech pos;
i32_4tech new_pos;
i32_4tech max;
};
static Offset_String
strspace_append(String_Space *space, char *str, u32_4tech len){
strspace_append(String_Space *space, char *str, i32_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;
size_t start;
size_t size;
size_t mid_start;
size_t mid_size;
int32_t start;
int32_t size;
int32_t mid_start;
int32_t mid_size;
};
struct Search_Set{
@ -54,29 +54,29 @@ struct Search_Set{
struct Search_Iter{
String word;
size_t pos;
size_t back_pos;
size_t i;
bool32 range_initialized;
int32_t pos;
int32_t back_pos;
int32_t i;
int32_t range_initialized;
};
struct Search_Match{
Buffer_Summary buffer;
size_t start;
size_t end;
bool32 found_match;
int32_t start;
int32_t end;
int32_t found_match;
};
static void
search_iter_init(General_Memory *general, Search_Iter *iter, size_t size){
size_t str_max = size*2;
search_iter_init(General_Memory *general, Search_Iter *iter, int32_t size){
int32_t str_max = size*2;
if (iter->word.str == 0){
iter->word.str = (char*)general_memory_allocate(general, str_max);
iter->word.memory_size = (int32_t)str_max;
iter->word.memory_size = 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 = (int32_t)str_max;
iter->word.memory_size = 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){
size_t mem_size = sizeof(Search_Range)*max;;
set->ranges = (Search_Range*)general_memory_reallocate_nocopy(general, set->ranges, mem_size);
set->ranges = (Search_Range*)general_memory_reallocate_nocopy(
general, set->ranges, sizeof(Search_Range)*max);
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, uint32_t table_size){
search_hits_table_alloc(General_Memory *general, Table *hits, int32_t table_size){
void *mem = 0;
size_t mem_size = table_required_mem_size(table_size, sizeof(Offset_String));
int32_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, uint32_t table_siz
}
static void
search_hits_init(General_Memory *general, Table *hits, String_Space *str, uint32_t table_size, uint32_t str_size){
search_hits_init(General_Memory *general, Table *hits, String_Space *str, int32_t table_size, int32_t str_size){
if (hits->hash_array == 0){
search_hits_table_alloc(general, hits, table_size);
}
else{
size_t mem_size = table_required_mem_size(table_size, sizeof(Offset_String));
int32_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,18 +137,19 @@ search_hits_init(General_Memory *general, Table *hits, String_Space *str, uint32
}
static int32_t
search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *str, uint32_t len){
search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *str, int32_t len){
int32_t result = false;
Assert(len != 0);
Offset_String ostring = strspace_append(space, str, len);
if (ostring.size == 0){
uint32_t new_size = space->max*2;
int32_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);
}
@ -174,14 +175,14 @@ search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *
return(result);
}
static size_t
buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, size_t pos){
static int32_t
buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char space[1024];
Stream_Chunk chunk = {0};
if (init_stream_chunk(&chunk, app, buffer, pos, space, sizeof(space))){
bool32 still_looping = true;
int32_t still_looping = true;
do{
for (; pos < (size_t)chunk.end; ++pos){
for (; pos < chunk.end; ++pos){
char at_pos = chunk.data[pos];
if (!char_is_alpha_numeric(at_pos)) goto double_break;
}
@ -207,13 +208,13 @@ enum{
};
static int32_t
match_check(Application_Links *app, Search_Range *range, size_t *pos, Search_Match *result_ptr, String word){
match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Match *result_ptr, String word){
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
size_t end_pos = range->start + range->size;
int32_t end_pos = range->start + range->size;
uint32_t type = (range->flags & SearchFlag_MatchMask);
int32_t type = (range->flags & SearchFlag_MatchMask);
switch (type){
case SearchFlag_MatchWholeWord:
@ -250,7 +251,9 @@ match_check(Application_Links *app, Search_Range *range, size_t *pos, Search_Mat
{
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;
@ -281,14 +284,14 @@ match_check(Application_Links *app, Search_Range *range, size_t *pos, Search_Mat
}
static int32_t
search_front_to_back_step(Application_Links *app, Search_Range *range, String word, size_t *pos, Search_Match *result_ptr){
search_front_to_back_step(Application_Links *app, Search_Range *range, String word, int32_t *pos, Search_Match *result_ptr){
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
size_t end_pos = range->start + range->size;
int32_t end_pos = range->start + range->size;
if (*pos + word.size < end_pos){
size_t start_pos = *pos;
int32_t start_pos = *pos;
if (start_pos < range->start){
start_pos = range->start;
}
@ -296,11 +299,8 @@ 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, size_t *pos, Search_Match *result_ptr){
search_front_to_back(Application_Links *app, Search_Range *range, String word, int32_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, s
}
static int32_t
search_back_to_front_step(Application_Links *app, Search_Range *range, String word, size_t *pos, Search_Match *result_ptr){
search_back_to_front_step(Application_Links *app, Search_Range *range, String word, int32_t *pos, Search_Match *result_ptr){
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
if (*pos > range->start){
size_t start_pos = *pos;
int32_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, size_t *pos, Search_Match *result_ptr){
search_back_to_front(Application_Links *app, Search_Range *range, String word, int32_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,12 +412,20 @@ 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:
@ -429,20 +437,26 @@ 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;
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;
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);
if (backward_distance < forward_distance){
iter.pos = forward_match.start;
@ -575,8 +589,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((int32_t)word_pos.line);
int32_t column_num_len = int_to_str_size((int32_t)word_pos.character);
int32_t line_num_len = int_to_str_size(word_pos.line);
int32_t column_num_len = int_to_str_size(word_pos.character);
Temp_Memory line_temp = begin_temp_memory(&line_part);
String line_str = {0};
@ -603,9 +617,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, (int32_t)word_pos.line);
append_int_to_str(&out_line, word_pos.line);
append_s_char(&out_line, ':');
append_int_to_str(&out_line, (int32_t)word_pos.character);
append_int_to_str(&out_line, word_pos.character);
append_s_char(&out_line, ':');
append_s_char(&out_line, ' ');
append_ss(&out_line, line_str);
@ -713,9 +727,9 @@ struct Word_Complete_State{
Search_Iter iter;
Table hits;
String_Space str;
size_t word_start;
size_t word_end;
bool32 initialized;
int32_t word_start;
int32_t word_end;
int32_t initialized;
};
static Word_Complete_State complete_state = {0};
@ -737,13 +751,14 @@ CUSTOM_COMMAND_SIG(word_complete){
do_init = true;
}
size_t word_end = 0;
size_t word_start = 0;
size_t cursor_pos = 0;
size_t size = 0;
int32_t word_end = 0;
int32_t word_start = 0;
int32_t cursor_pos = 0;
int32_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;
@ -753,7 +768,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 >= (size_t)chunk.start; --cursor_pos){
for (; cursor_pos >= chunk.start; --cursor_pos){
char c = chunk.data[cursor_pos];
if (char_is_alpha(c)){
word_start = cursor_pos;
@ -774,12 +789,13 @@ 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 = (int32_t)size;
complete_state.iter.word.size = size;
// NOTE(allen): Initialize the set of ranges to be searched.
int32_t buffer_count = get_buffer_count(app);
@ -810,8 +826,11 @@ 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;
@ -825,20 +844,26 @@ CUSTOM_COMMAND_SIG(word_complete){
// NOTE(allen): Iterate through matches.
if (size > 0){
for (;;){
uint32_t match_size = 0;
Search_Match match = search_next_match(app, &complete_state.set, &complete_state.iter);
int32_t match_size = 0;
Search_Match match =
search_next_match(app, &complete_state.set,
&complete_state.iter);
if (match.found_match){
match_size = (uint32_t)(match.end - match.start);
match_size = 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);
Buffer_Seek seek = seek_pos(word_start + match_size);
view_set_cursor(app, &view, seek, 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);
view_set_cursor(app, &view,
seek_pos(word_start + match_size),
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, umem_4tech pos)/*
cpp_get_token(Cpp_Token_Array array, u32_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];
umem line_number[16];
umem column_number[16];
int32_t line_number[16];
int32_t 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);
umem line = line_number[i];
umem character = column_number[i];
int32_t line = line_number[i];
int32_t 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 (umem i = range.start; i < range.end; ++i){
for (i32 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, (u32)range.start, (u32)range.end, 0);
file_relex_parallel(system, mem, file, range.start, 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 = (u32)eol_in_place_convert_in(dest, amount);
amount = 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 = (i32)eol_convert_in(dest->str, clipboard.str, clipboard.size);
dest->size = 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_i32(min, mouse_position, max);
absolute_positions[div_id] = clamp(min, mouse_position, max);
layout_update_all_positions(&models->layout, absolute_positions);
}
else{
if (divider->v_divider){
mouse_position = clamp_i32(0, mx, models->layout.full_width);
mouse_position = clamp(0, mx, models->layout.full_width);
}
else{
mouse_position = clamp_i32(0, my, models->layout.full_height);
mouse_position = clamp(0, my, models->layout.full_height);
}
divider->pos = layout_compute_position(&models->layout, divider, mouse_position);
}

View File

@ -347,12 +347,17 @@ DOC_SEE(Command_Line_Interface_Flag)
}
API_EXPORT void
Clipboard_Post(Application_Links *app, int32_t clipboard_id, char *str, size_t len)
Clipboard_Post(Application_Links *app, int32_t clipboard_id, char *str, int32_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;
@ -361,13 +366,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, (u32)len);
copy_ss(dest, make_string(str, (i32)len));
String *dest = working_set_next_clipboard_string(general, working, len);
copy_ss(dest, make_string(str, len));
system->post_clipboard(*dest);
}
API_EXPORT uint32_t
Clipboard_Count(Application_Links *app, uint32_t clipboard_id)
API_EXPORT int32_t
Clipboard_Count(Application_Links *app, int32_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.)
@ -375,12 +380,12 @@ DOC_SEE(The_4coder_Clipboard)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
Working_Set *working = &cmd->models->working_set;
uint32_t count = working->clipboard_size;
int32_t count = working->clipboard_size;
return(count);
}
API_EXPORT size_t
Clipboard_Index(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, size_t len)
API_EXPORT int32_t
Clipboard_Index(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_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.)
@ -395,12 +400,12 @@ DOC_SEE(The_4coder_Clipboard)
Command_Data *cmd = (Command_Data*)app->cmd_context;
Working_Set *working = &cmd->models->working_set;
size_t size = 0;
int32_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, (i32)len);
String out_str = make_string_cap(out, 0, len);
copy_ss(&out_str, *str);
}
}
@ -545,7 +550,7 @@ DOC_SEE(Access_Flag)
}
API_EXPORT bool32
Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, size_t start, size_t end, char *out)
Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_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.)
@ -588,22 +593,32 @@ 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){
u32 size = buffer_size(&file->state.buffer);
size = buffer_size(&file->state.buffer);
if (0 <= start && start <= end && end <= size){
result = true;
file_replace_range(cmd->system, cmd->models, file, (u32)start, (u32)end, str, (u32)len);
file_replace_range(cmd->system, cmd->models,
file, start, end, str, len);
}
fill_buffer_summary(buffer, file, cmd);
}
@ -670,9 +685,9 @@ DOC_SEE(Buffer_Batch_Edit_Type)
Assert(inverse_edits);
char *inv_str = (char*)part->base + part->pos;
umem inv_str_max = part->max - part->pos;
int32_t inv_str_max = part->max - part->pos;
Edit_Spec spec = file_compute_edit(mem, file, edits, str, str_len, inverse_edits, inv_str, (u32)inv_str_max, (u32)edit_count, type);
Edit_Spec spec = file_compute_edit(mem, file, edits, str, str_len, inverse_edits, inv_str, inv_str_max, edit_count, type);
file_do_batch_edit(system, models, file, spec, hist_normal, type);
@ -995,7 +1010,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, size_t start_token, size_t end_token, Cpp_Token *tokens_out)
Buffer_Read_Tokens(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out)
/*
DOC_PARAM(buffer, Specifies the buffer from which to read tokens.)
DOC_PARAM(first_token, Specifies the index of the first token to read.)
@ -1022,7 +1037,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, size_t pos, Cpp_Get_Token_Result *get_result)
Buffer_Get_Token_Index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result)
/*
DOC_PARAM(buffer, The buffer from which to get a token.)
DOC_PARAM(pos, The position in the buffer in absolute coordinates.)
@ -1816,26 +1831,32 @@ DOC_SEE(Buffer_Seek)
}
API_EXPORT bool32
View_Set_Highlight(Application_Links *app, View_Summary *view, size_t start, size_t end, bool32 turn_on)/*
View_Set_Highlight(Application_Links *app, View_Summary *view, int32_t start, int32_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 != 0){
if (vptr){
result = true;
if (turn_on){
view_set_temp_highlight(system, vptr, start, end);
}
else{
vptr->file_data.show_temp_highlight = false;
vptr->file_data.show_temp_highlight = 0;
}
fill_view_summary(system, view, vptr, cmd);
}
@ -1879,7 +1900,7 @@ DOC_SEE(Set_Buffer_Flag)
}
API_EXPORT bool32
View_Post_Fade(Application_Links *app, View_Summary *view, float seconds, size_t start, size_t end, int_color color)
View_Post_Fade(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_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.)
@ -1893,10 +1914,13 @@ DOC_SEE(int_color)
View *vptr = imp_get_view(cmd, view);
bool32 result = false;
size_t size = end - start;
if (vptr != 0 && size > 0){
result = true;
view_post_paste_effect(vptr, seconds, (u32)start, (u32)size, color | 0xFF000000);
int32_t size = end - start;
if (vptr){
if (size > 0){
result = true;
view_post_paste_effect(vptr, seconds, start, size, color | 0xFF000000);
}
}
return(result);

View File

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

View File

@ -146,7 +146,7 @@ struct File_Viewing_Data{
Editing_File *file;
Full_Cursor temp_highlight;
umem temp_highlight_end_pos;
i32 temp_highlight_end_pos;
b32 show_temp_highlight;
b32 show_whitespace;
@ -289,9 +289,9 @@ view_file_height(View *view){
return (result);
}
inline size_t
inline i32
view_get_cursor_pos(View *view){
size_t result = 0;
i32 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};
umem size = buffer_size(params.buffer);
i32 size = buffer_size(params.buffer);
f32 line_shift = 0.f;
u32 wrap_unit_end = 0;
u32 wrap_array_index = 0;
b32 do_wrap = 0;
i32 wrap_unit_end = 0;
b32 do_wrap = false;
b32 first_wrap_determination = true;
b32 first_wrap_determination = 1;
i32 wrap_array_index = 0;
do{
stop = buffer_cursor_seek(&state, params, line_shift, do_wrap, wrap_unit_end);
@ -478,13 +478,15 @@ 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 = (i32)(buffer->line_count);
lowest_line = buffer->line_count;
}
else{
lowest_line = (i32)(file->state.wrap_line_index[buffer->line_count]);
lowest_line = file->state.wrap_line_index[buffer->line_count];
}
return(lowest_line);
}
@ -529,7 +531,7 @@ view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){
}
}
target_y = clamp_i32(0, target_y, max_y);
target_y = clamp(0, target_y, max_y);
if (cursor_x >= target_x + max_x){
target_x = ceil32(cursor_x - max_x/2);
@ -619,7 +621,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, umem pos, umem end_pos){
view_set_temp_highlight(System_Functions *system, View *view, i32 pos, i32 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;
@ -741,8 +743,9 @@ save_file_to_name(System_Functions *system, Models *models, Editing_File *file,
models->hook_save_file(&models->app_links, file->id.id);
}
umem max = 0, size = 0;
i32 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){
@ -752,9 +755,8 @@ save_file_to_name(System_Functions *system, Models *models, Editing_File *file,
max = buffer_size(buffer);
}
Temp_Memory temp = begin_temp_memory(&mem->part);
char *data = 0;
b32 used_general = 0;
Temp_Memory temp = begin_temp_memory(&mem->part);
char empty = 0;
if (max == 0){
data = &empty;
@ -849,14 +851,14 @@ enum{
internal i32
file_grow_starts_as_needed(General_Memory *general, Gap_Buffer *buffer, i32 additional_lines){
b32 result = GROW_NOT_NEEDED;
u32 max = buffer->line_max;
u32 count = buffer->line_count;
u32 target_lines = count + additional_lines;
i32 max = buffer->line_max;
i32 count = buffer->line_count;
i32 target_lines = count + additional_lines;
if (target_lines > max || max == 0){
max = l_round_up_u32(target_lines + max, KB(1));
max = l_round_up_i32(target_lines + max, KB(1));
u32 *new_lines = (u32*)general_memory_reallocate(general, buffer->line_starts, sizeof(u32)*count, sizeof(u32)*max);
i32 *new_lines = (i32*)general_memory_reallocate(general, buffer->line_starts, sizeof(i32)*count, sizeof(f32)*max);
if (new_lines){
result = GROW_SUCCESS;
@ -877,7 +879,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)){
umem pos = view_get_cursor_pos(iter.view);
i32 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);
@ -896,20 +898,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){
u32 max = buffer->line_max = KB(1);
buffer->line_starts = (u32*)general_memory_allocate(general, max*sizeof(u32));
TentativeAssert(buffer->line_starts != 0);
i32 max = buffer->line_max = KB(1);
buffer->line_starts = (i32*)general_memory_allocate(general, max*sizeof(i32));
TentativeAssert(buffer->line_starts);
// TODO(allen): when unable to allocate?
}
Buffer_Measure_Starts state = {0};
while (buffer_measure_starts(&state, buffer)){
u32 count = state.count;
u32 max = buffer->line_max;
i32 count = state.count;
i32 max = buffer->line_max;
max = ((max + 1) << 1);
{
u32 *new_lines = (u32*)general_memory_reallocate(general, buffer->line_starts, sizeof(u32)*count, sizeof(u32)*max);
i32 *new_lines = (i32*)general_memory_reallocate(general, buffer->line_starts, sizeof(i32)*count, sizeof(i32)*max);
// TODO(allen): when unable to grow?
TentativeAssert(new_lines);
@ -919,18 +921,19 @@ 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, u32 *mem_max_count, u32 count, u32 item_size){
file_allocate_metadata_as_needed(General_Memory *general, Gap_Buffer *buffer, void **mem, i32 *mem_max_count, i32 count, i32 item_size){
if (*mem == 0){
u32 max = ((count+1)*2);
i32 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){
u32 old_max = *mem_max_count;
u32 max = ((count+1)*2);
i32 old_max = *mem_max_count;
i32 max = ((count+1)*2);
max = (max+(0x3FF))&(~(0x3FF));
void *new_mem = general_memory_reallocate(general, *mem, item_size*old_max, item_size*max);
@ -943,7 +946,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(u32));
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));
}
internal void
@ -989,9 +992,9 @@ struct Code_Wrap_State{
b32 in_pp_body;
Code_Wrap_X plane_wrap_x;
u32 *line_starts;
u32 line_index;
u32 next_line_start;
i32 *line_starts;
i32 line_index;
i32 next_line_start;
f32 x;
b32 consume_newline;
@ -1391,7 +1394,7 @@ struct Wrap_Current_Shift{
};
internal Wrap_Current_Shift
get_current_shift(Code_Wrap_State *wrap_state, u32 next_line_start){
get_current_shift(Code_Wrap_State *wrap_state, i32 next_line_start){
Wrap_Current_Shift result = {0};
result.shift = wrap_state->wrap_x.paren_nesting[wrap_state->wrap_x.paren_safe_top];
@ -1589,7 +1592,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
if (use_tokens){
Code_Wrap_State original_wrap_state = wrap_state;
u32 next_line_start = buffer_size(params.buffer);
i32 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];
}
@ -1625,12 +1628,16 @@ 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;
u32 i = wrap_state.token_ptr->start;
u32 end_i = i + wrap_state.token_ptr->size;
if (i < wrap_state.i){
i = wrap_state.i;
}
i = clamp_bottom((u32)wrap_state.i, i);
end_i = clamp_top(end_i, (u32)wrap_state.next_line_start);
if (end_i > wrap_state.next_line_start){
end_i = wrap_state.next_line_start;
}
f32 x = wrap_state.x;
@ -1729,12 +1736,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 = false;
b32 next_token_is_on_line = 0;
if (wrap_state.token_ptr->start < next_line_start){
next_token_is_on_line = true;
next_token_is_on_line = 1;
}
u32 next_wrap_position = (u32)step.position_end;
i32 next_wrap_position = 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;
@ -1923,6 +1930,8 @@ 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;
@ -1931,8 +1940,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); ){
umem page_size = buffer_init_page_size(&init);
page_size = l_round_up_umem(page_size, KB(4));
i32 page_size = buffer_init_page_size(&init);
page_size = l_round_up_i32(page_size, KB(4));
if (page_size < KB(4)){
page_size = KB(4);
}
@ -1945,7 +1954,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) < (u32)val.size){
if (buffer_size(&file->state.buffer) < val.size){
file->settings.dos_write_mode = 1;
}
file_synchronize_times(system, file);
@ -2045,10 +2054,11 @@ Job_Callback_Sig(job_full_lex){
General_Memory *general = (General_Memory*)data[1];
Gap_Buffer *buffer = &file->state.buffer;
u32 text_size = buffer_size(buffer);
u32 aligned_buffer_size = (text_size + 3)&(~3);
i32 text_size = buffer_size(buffer);
while (memory->size < (umem)aligned_buffer_size){
i32 aligned_buffer_size = (text_size + 3)&(~3);
while (memory->size < aligned_buffer_size){
system->grow_thread_memory(memory);
}
@ -2063,7 +2073,7 @@ Job_Callback_Sig(job_full_lex){
// TODO(allen): deduplicate this against relex
char *chunks[3];
umem chunk_sizes[3];
i32 chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
@ -2078,10 +2088,10 @@ Job_Callback_Sig(job_full_lex){
do{
char *chunk = chunks[chunk_index];
umem chunk_size = chunk_sizes[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
i32 result =
cpp_lex_step(&lex, chunk, (i32)chunk_size, text_size, &tokens, 2048);
cpp_lex_step(&lex, chunk, chunk_size, text_size, &tokens, 2048);
switch (result){
case LexResult_NeedChunk: ++chunk_index; break;
@ -2205,7 +2215,7 @@ file_first_lex_serial(Mem_Options *mem, Editing_File *file){
// TODO(allen): deduplicate this against relex
char *chunks[3];
umem chunk_sizes[3];
i32 chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
@ -2222,9 +2232,9 @@ file_first_lex_serial(Mem_Options *mem, Editing_File *file){
do{
char *chunk = chunks[chunk_index];
umem chunk_size = chunk_sizes[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
i32 result = cpp_lex_step(&lex, chunk, (i32)chunk_size, text_size, &tokens, NO_OUT_LIMIT);
i32 result = cpp_lex_step(&lex, chunk, chunk_size, text_size, &tokens, NO_OUT_LIMIT);
switch (result){
case LexResult_NeedChunk: ++chunk_index; break;
@ -2281,7 +2291,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, u32 start_i, u32 end_i, i32 shift_amount){
file_relex_parallel(System_Functions *system, Mem_Options *mem, Editing_File *file, i32 start_i, i32 end_i, i32 shift_amount){
General_Memory *general = &mem->general;
Partition *part = &mem->part;
@ -2313,7 +2323,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];
umem chunk_sizes[3];
i32 chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
@ -2326,16 +2336,17 @@ file_relex_parallel(System_Functions *system, Mem_Options *mem, Editing_File *fi
i32 chunk_index = 0;
char *chunk = chunks[chunk_index];
umem chunk_size = chunk_sizes[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
while (!cpp_relex_is_start_chunk(&state, chunk, (i32)chunk_size)){
while (!cpp_relex_is_start_chunk(&state, chunk, 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, (i32)chunk_size, size, array, &relex_array);
Cpp_Lex_Result lex_result =
cpp_relex_step(&state, chunk, chunk_size, size, array, &relex_array);
switch (lex_result){
case LexResult_NeedChunk:
@ -2355,7 +2366,7 @@ file_relex_parallel(System_Functions *system, Mem_Options *mem, Editing_File *fi
doublebreak:;
if (inline_lex){
u32 new_count = cpp_relex_get_new_count(&state, array->count, &relex_array);
i32 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*)
@ -2421,13 +2432,10 @@ 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 = (u32)(remaining/token_size);
relex_array.max_count = partition_remaining(part) / sizeof(Cpp_Token);
relex_array.tokens = push_array(part, Cpp_Token, relex_array.max_count);
i32 size = buffer_size(buffer);
@ -2435,7 +2443,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];
umem chunk_sizes[3];
i32 chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
@ -2446,18 +2454,18 @@ file_relex_serial(Mem_Options *mem, Editing_File *file, i32 start_i, i32 end_i,
chunks[2] = 0;
chunk_sizes[2] = 0;
umem chunk_index = 0;
i32 chunk_index = 0;
char *chunk = chunks[chunk_index];
umem chunk_size = chunk_sizes[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
while (!cpp_relex_is_start_chunk(&state, chunk, (i32)chunk_size)){
while (!cpp_relex_is_start_chunk(&state, chunk, 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, (i32)chunk_size, size, array, &relex_array);
Cpp_Lex_Result lex_result = cpp_relex_step(&state, chunk, chunk_size, size, array, &relex_array);
switch (lex_result){
case LexResult_NeedChunk:
@ -2474,7 +2482,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 ((u32)new_count > array->max_count){
if (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;
@ -2488,10 +2496,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, umem extra_size){
u32 old_max = stack->max;
undo_stack_grow_string(General_Memory *general, Edit_Stack *stack, i32 extra_size){
i32 old_max = stack->max;
u8 *old_str = stack->strings;
u32 new_max = old_max*2 + (u32)(extra_size);
i32 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;
@ -2508,27 +2516,27 @@ undo_stack_grow_edits(General_Memory *general, Edit_Stack *stack){
}
internal void
child_stack_grow_string(General_Memory *general, Small_Edit_Stack *stack, umem extra_size){
umem old_max = stack->max;
child_stack_grow_string(General_Memory *general, Small_Edit_Stack *stack, i32 extra_size){
i32 old_max = stack->max;
u8 *old_str = stack->strings;
umem new_max = old_max*2 + extra_size;
i32 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 = (u32)new_max;
stack->max = new_max;
}
internal void
child_stack_grow_edits(General_Memory *general, Small_Edit_Stack *stack, umem amount){
umem old_max = stack->edit_max;
child_stack_grow_edits(General_Memory *general, Small_Edit_Stack *stack, i32 amount){
i32 old_max = stack->edit_max;
Buffer_Edit *old_eds = stack->edits;
umem new_max = old_max*2 + amount;
i32 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 = (u32)new_max;
stack->edit_max = new_max;
}
internal i32
undo_children_push(General_Memory *general, Small_Edit_Stack *children, Buffer_Edit *edits, u32 edit_count, u8 *strings, umem string_size){
undo_children_push(General_Memory *general, Small_Edit_Stack *children, Buffer_Edit *edits, i32 edit_count, u8 *strings, i32 string_size){
i32 result = children->edit_count;
if (children->edit_count + edit_count > children->edit_max){
child_stack_grow_edits(general, children, edit_count);
@ -2543,12 +2551,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 (u32 i = 0; i < edit_count; ++i, ++edit){
for (i32 i = 0; i < edit_count; ++i, ++edit){
edit->str_start += start_pos;
}
children->edit_count += edit_count;
children->size += (u32)string_size;
children->size += string_size;
return result;
}
@ -2628,7 +2636,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 -= (u32)edit->edit.len;
stack->size -= edit->edit.len;
}
}
}
@ -2671,7 +2679,7 @@ file_post_redo(General_Memory *general, Editing_File *file, Edit_Step step){
}
inline void
file_post_history_block(Editing_File *file, u32 pos){
file_post_history_block(Editing_File *file, i32 pos){
Assert(file->state.undo.history_head_block < pos);
Assert(pos < file->state.undo.history.edit_count);
@ -2780,7 +2788,7 @@ view_cursor_move(View *view, Full_Cursor cursor){
}
inline void
view_cursor_move(System_Functions *system, View *view, umem pos){
view_cursor_move(System_Functions *system, View *view, i32 pos){
Full_Cursor cursor = view_compute_cursor(system, view, seek_pos(pos), 0);
view_cursor_move(view, cursor);
}
@ -2942,8 +2950,8 @@ file_update_history_before_edit(Mem_Options *mem, Editing_File *file, Edit_Step
if (restore_redos){
Edit_Step *redo_start = redo_end;
u32 steps_of_redo = 0;
u32 strings_of_redo = 0;
i32 steps_of_redo = 0;
i32 strings_of_redo = 0;
{
i32 undo_count = 0;
while (redo_start->type == ED_REDO || redo_start->type == ED_UNDO){
@ -2953,7 +2961,7 @@ file_update_history_before_edit(Mem_Options *mem, Editing_File *file, Edit_Step
}
else{
++steps_of_redo;
strings_of_redo += (u32)redo_start->edit.len;
strings_of_redo += redo_start->edit.len;
}
}
else{
@ -2967,15 +2975,11 @@ 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;
@ -2985,8 +2989,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;
{
u32 undo_count = 0;
for (u32 i = 0; i < steps_of_redo;){
i32 undo_count = 0;
for (i32 i = 0; i < steps_of_redo;){
--edit_src;
str_src -= edit_src->edit.len;
if (edit_src->type == ED_REDO){
@ -2999,7 +3003,7 @@ file_update_history_before_edit(Mem_Options *mem, Editing_File *file, Edit_Step
--edit_dest;
*edit_dest = *edit_src;
str_redo_pos -= (u32)edit_dest->edit.len;
str_redo_pos -= 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);
@ -3157,13 +3161,13 @@ file_edit_cursor_fix(System_Functions *system, Models *models, Editing_File *fil
if (view->file_data.file == file){
Assert(view->edit_pos);
umem cursor_pos = cursors[cursor_count++].pos;
i32 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 = (i32)cursors[cursor_count++].pos;
i32 new_scroll_i = cursors[cursor_count++].pos;
if (view->edit_pos->scroll_i != new_scroll_i){
view->edit_pos->scroll_i = new_scroll_i;
@ -3219,14 +3223,14 @@ file_do_single_edit(System_Functions *system, Models *models, Editing_File *file
Partition *part = &mem->part;
char *str = (char*)spec.str;
u32 start = (u32)spec.step.edit.start;
u32 end = (u32)spec.step.edit.end;
u32 str_len = (u32)spec.step.edit.len;
i32 start = spec.step.edit.start;
i32 end = spec.step.edit.end;
i32 str_len = spec.step.edit.len;
umem scratch_size = partition_remaining(part);
i32 scratch_size = partition_remaining(part);
Assert(scratch_size > 0);
umem request_amount = 0;
i32 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;
@ -3281,7 +3285,8 @@ 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;
@ -3301,9 +3306,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);
u32 scratch_size = (u32)partition_remaining(part);
Buffer_Batch_State state = {0};
umem request_amount = 0;
i32 scratch_size = partition_remaining(part);
Buffer_Batch_State state = {};
i32 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)){
@ -3329,10 +3334,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, (u32)first_edit->start, (u32)last_edit->end, shift_total);
file_relex_parallel(system, mem, file, first_edit->start, last_edit->end, shift_total);
}
else{
file_relex_serial(mem, file, (u32)first_edit->start, (u32)last_edit->end, shift_total);
file_relex_serial(mem, file, first_edit->start, last_edit->end, shift_total);
}
}
}break;
@ -3354,27 +3359,13 @@ 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){
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);
}
local_shift = (edit->len - (edit->end - edit->start));
shift_amount += local_shift;
}
token->start += shift_amount;
local_shift = 0;
for (; edit < end_edit && edit->start < original.start + original.size; ++edit){
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);
}
local_shift += (edit->len - (edit->end - edit->start));
}
token->size += local_shift;
shift_amount += local_shift;
@ -3432,7 +3423,7 @@ view_replace_range(System_Functions *system, Models *models, View *view,
}
inline void
view_post_paste_effect(View *view, f32 seconds, u32 start, u32 size, u32 color){
view_post_paste_effect(View *view, f32 seconds, i32 start, i32 size, u32 color){
Editing_File *file = view->file_data.file;
file->state.paste_effect.start = start;
@ -3454,7 +3445,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 = {0};
Edit_Spec spec = {};
spec.step = step;
if (step.child_count == 0){
@ -3468,7 +3459,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, (u32)step.edit.start, (u32)step.edit.len, style->main.undo_color);
view_post_paste_effect(view, 0.333f, step.edit.start, step.edit.len, style->main.undo_color);
}
}
else{
@ -3499,11 +3490,11 @@ view_history_step(System_Functions *system, Models *models, View *view, History_
Assert(file);
Assert(view->edit_pos);
b32 do_history_step = false;
b32 do_history_step = 0;
Edit_Step step = {};
if (history_mode == hist_backward){
if (file->state.undo.edit_history_cursor > 0){
do_history_step = true;
do_history_step = 1;
step = file->state.undo.history.edits[--file->state.undo.edit_history_cursor];
}
}
@ -3511,9 +3502,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 -= (u32)step.edit.len;
file->state.undo.history.size -= step.edit.len;
++file->state.undo.edit_history_cursor;
do_history_step = true;
do_history_step = 1;
}
}
@ -3525,7 +3516,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, u32 str_size){
working_set_next_clipboard_string(General_Memory *general, Working_Set *working, i32 str_size){
String *result = 0;
i32 clipboard_current = working->clipboard_current;
if (working->clipboard_size == 0){
@ -3594,22 +3585,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){
umem size = range.end - range.start;
String *dest = working_set_next_clipboard_string(general, working, (u32)size);
i32 size = range.end - range.start;
String *dest = working_set_next_clipboard_string(general, working, size);
buffer_stringify(&file->state.buffer, range.start, range.end, dest->str);
dest->size = (i32)size;
dest->size = size;
system->post_clipboard(*dest);
}
internal Edit_Spec
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){
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){
General_Memory *general = &mem->general;
u32 inv_str_pos = 0;
i32 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)){
InvalidCodePath;
Assert(0);
}
i32 first_child = undo_children_push(general, &file->state.undo.children, edits, edit_count, (u8*)(str_base), str_size);
@ -4474,7 +4465,8 @@ 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);
@ -4484,7 +4476,8 @@ show_gui_int(GUI_Target *target, String *string, i32 indent_level, i32 h_align,
}
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);
@ -4494,17 +4487,8 @@ show_gui_u64(GUI_Target *target, String *string, i32 indent_level, i32 h_align,
}
internal void
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){
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);
@ -4554,11 +4538,13 @@ 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_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_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_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);
@ -5380,9 +5366,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, (i32)part->pos);
append_int_to_str(&string, part->pos);
append_s_char(&string, '/');
append_int_to_str(&string, (i32)part->max);
append_int_to_str(&string, part->max);
gui_do_text_field(target, string, empty_str);
#if !defined(FED_DEBUG_MEM_H)
@ -5397,7 +5383,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, (i32)bubble->size);
append_int_to_str(&string, bubble->size);
append_padding(&string, ' ', 40);
gui_do_text_field(target, string, empty_str);
}
@ -5470,7 +5456,6 @@ 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"); }\
@ -5510,8 +5495,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_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_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_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);
@ -5529,7 +5514,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_UMEM (2, h_align, "mark", edit_pos->mark);
SHOW_GUI_INT (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);
}
@ -5543,7 +5528,9 @@ 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", (int32_t)view_ptr->gui_target.push.pos, (int32_t)view_ptr->gui_target.push.max);
SHOW_GUI_INT_INT(2, h_align, "gui partition",
view_ptr->gui_target.push.pos,
view_ptr->gui_target.push.max);
SHOW_GUI_BLANK (2);
SHOW_GUI_ID (2, h_align, "active", view_ptr->gui_target.active);
@ -5679,7 +5666,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_i32(0, vars.target_y, max_y);
vars.target_y = clamp(0, vars.target_y, max_y);
result.vars = vars;
result.region = region;
@ -5812,7 +5799,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_f32(0.f, v, 1.f);
v = clamp(0.f, v, 1.f);
result.vars.target_y = round32(lerp(0.f, v, (f32)max_y));
gui_activate_scrolling(target);
@ -5827,7 +5814,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_i32(0, result.vars.target_y, max_y);
clamp(0, result.vars.target_y, max_y);
gui_activate_scrolling(target);
result.is_animating = 1;
}
@ -5927,9 +5914,7 @@ draw_file_loaded(System_Functions *system, View *view, i32_Rect rect, b32 is_act
f32 left_side_space = 0;
umem remaining = partition_remaining(part);
umem render_item_size = sizeof(Buffer_Render_Item);
u32 max = (u32)(remaining / render_item_size);
i32 max = partition_remaining(part) / sizeof(Buffer_Render_Item);
Buffer_Render_Item *items = push_array(part, Buffer_Render_Item, max);
Font_ID font_id = file->settings.font_id;
@ -5951,9 +5936,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 = (i32)render_cursor.pos;
view->edit_pos->scroll_i = render_cursor.pos;
u32 count = 0;
i32 count = 0;
{
b32 wrapped = !file->settings.unwrapped_lines;
@ -5980,11 +5965,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 = false;
u32 wrap_unit_end = 0;
b32 do_wrap = 0;
i32 wrap_unit_end = 0;
b32 first_wrap_determination = true;
u32 wrap_array_index = 0;
b32 first_wrap_determination = 1;
i32 wrap_array_index = 0;
do{
stop = buffer_render_data(&state, params, line_shift, do_wrap, wrap_unit_end);
@ -6021,22 +6006,22 @@ draw_file_loaded(System_Functions *system, View *view, i32_Rect rect, b32 is_act
}while(stop.status != BLStatus_Finished);
}
u32 cursor_begin = 0, cursor_end = 0;
i32 cursor_begin = 0, cursor_end = 0;
u32 cursor_color = 0, at_cursor_color = 0;
if (view->file_data.show_temp_highlight){
cursor_begin = (u32)view->file_data.temp_highlight.pos;
cursor_end = (u32)view->file_data.temp_highlight_end_pos;
cursor_begin = view->file_data.temp_highlight.pos;
cursor_end = view->file_data.temp_highlight_end_pos;
cursor_color = style->main.highlight_color;
at_cursor_color = style->main.at_highlight_color;
}
else{
cursor_begin = (u32)view->edit_pos->cursor.pos;
cursor_begin = view->edit_pos->cursor.pos;
cursor_end = cursor_begin + 1;
cursor_color = style->main.cursor_color;
at_cursor_color = style->main.at_cursor_color;
}
u32 token_i = 0;
i32 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;
@ -6049,12 +6034,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;
umem prev_ind = max_umem;
i32 prev_ind = -1;
u32 highlight_color = 0;
u32 highlight_this_color = 0;
for (; item < item_end; ++item){
umem ind = item->index;
i32 ind = item->index;
highlight_this_color = 0;
if (tokens_use && ind != prev_ind){
Cpp_Token current_token = token_array.tokens[token_i-1];
@ -6234,9 +6219,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, (int32_t)view->edit_pos->cursor.line);
append_int_to_str(&bar_text, view->edit_pos->cursor.line);
append_ss (&bar_text, make_lit_string(" C#"));
append_int_to_str(&bar_text, (int32_t)view->edit_pos->cursor.character);
append_int_to_str(&bar_text, 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_f32(0.f, lpos, 1.f);
lpos = clamp(0.f, lpos, 1.f);
div->pos = lpos;
if (div->v_divider){
pos = clamp_i32(r1.x0, pos, r2.x1);
pos = clamp(r1.x0, pos, r2.x1);
r1.x1 = pos; r2.x0 = pos;
}
else{
pos = clamp_i32(r1.y0, pos, r2.y1);
pos = clamp(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(f32 a, f32 n, f32 z){
clamp(f32 a, f32 n, f32 z){
if (n < a) n = a;
else if (n > z) n = z;
return (n);
}
inline i32
clamp_i32(i32 a, i32 n, i32 z){
clamp(i32 a, i32 n, i32 z){
if (n < a) n = a;
else if (n > z) n = z;
return (n);
}
inline u32
clamp_u32(u32 a, u32 n, u32 z){
clamp(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, umem size)
#define Sys_Save_File_Sig(name) b32 name(char *filename, char *buffer, u32 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;
u32 next_block;
u32 prev_block;
i32 next_block;
i32 prev_block;
};
struct{
u32 first_child;
u32 inverse_first_child;
u32 inverse_child_count;
u32 special_type;
i32 first_child;
i32 inverse_first_child;
i32 inverse_child_count;
i32 special_type;
};
};
u32 child_count;
i32 child_count;
};
struct Edit_Stack{
u8 *strings;
u32 size, max;
i32 size, max;
Edit_Step *edits;
u32 edit_count, edit_max;
i32 edit_count, edit_max;
};
struct Small_Edit_Stack{
u8 *strings;
u32 size, max;
i32 size, max;
Buffer_Edit *edits;
u32 edit_count, edit_max;
i32 edit_count, edit_max;
};
struct Undo_Data{
@ -61,9 +61,8 @@ struct Undo_Data{
Edit_Stack history;
Small_Edit_Stack children;
u32 history_block_count;
u32 history_head_block;
u32 edit_history_cursor;
i32 history_block_count, history_head_block;
i32 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;
umem mem_size = table_required_mem_size(table_size, item_size);
i32 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
{
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);
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);
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};
u32 new_max = table->max * 2;
umem mem_size = table_required_mem_size(new_max, table->item_size);
i32 new_max = table->max * 2;
i32 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,18 +135,6 @@ 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,7 +16,6 @@ Allen Webster
#include "4coder_default_include.cpp"
#if 0
#include <assert.h>
#include <stdio.h>
@ -225,17 +224,12 @@ 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,10 +1,12 @@
#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, size_t line){
get_line_y(Application_Links *app, View_Summary *view, int32_t line){
Full_Cursor cursor = {0};
view_compute_cursor(app, view, seek_line_char(line, 1), &cursor);
float y = cursor.wrapped_y;
@ -37,30 +37,26 @@ CUSTOM_COMMAND_SIG(kill_rect){
View_Summary view = get_active_view(app, AccessOpen);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
pos_Rect rect = get_line_x_rect(&view);
i32_Rect rect = get_line_x_rect(&view);
bool32 unwrapped = view.unwrapped_lines;
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;
for (int32_t line = rect.y1; line >= rect.y0; --line){
int32_t start = 0;
int32_t end = 0;
bool32 success = true;
bool32 success = 1;
Full_Cursor cursor = {0};
float y = get_line_y(app, &view, line);
if (success){
Buffer_Seek seek = seek_xy((float)rect.x0, y, 0, unwrapped);
success = view_compute_cursor(app, &view, seek, &cursor);
success = view_compute_cursor(app, &view, seek_xy((float)rect.x0, y, 0, unwrapped), &cursor);
}
start = cursor.pos;
if (success){
Buffer_Seek seek = seek_xy((float)rect.x0, y, 0, unwrapped);
success = view_compute_cursor(app, &view, seek, &cursor);
success = view_compute_cursor(app, &view, seek_xy((float)rect.x1, y, 0, unwrapped), &cursor);
}
end = cursor.pos;
@ -71,19 +67,16 @@ CUSTOM_COMMAND_SIG(kill_rect){
}
static void
pad_buffer_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, size_t line, char padchar, size_t target){
pad_buffer_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line, char padchar, int32_t target){
Partial_Cursor start = {0};
Partial_Cursor end = {0};
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 (buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &start)){
if (buffer_compute_cursor(app, buffer, seek_line_char(line, 65536), &end)){
if (start.line == line){
if (end.character-1 < target){
Temp_Memory temp = begin_temp_memory(part);
size_t size = target - (end.character-1);
int32_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);
@ -137,14 +130,14 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
Buffer_Rect rect = get_rect(&view);
size_t start_line = view.cursor.line;
size_t pos = view.cursor.character-1;
int32_t start_line = view.cursor.line;
int32_t pos = view.cursor.character-1;
for (size_t i = rect.line0; i <= rect.line1; ++i){
for (int32_t i = rect.line0; i <= rect.line1; ++i){
pad_buffer_line(app, &global_part, &buffer, i, ' ', pos);
}
int32_t line_count = (int32_t)(rect.line1 - rect.line0 + 1);
int32_t line_count = rect.line1 - rect.line0 + 1;
for (;;){
User_Input in = get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
@ -157,12 +150,10 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
Buffer_Edit *edit = push_array(part, Buffer_Edit, line_count);
Buffer_Edit *edits = edit;
for (int32_t i = 0; i <= line_count; ++i){
size_t line = i + rect.line0;
for (int32_t i = rect.line0; i <= rect.line1; ++i){
Partial_Cursor cursor = {0};
Buffer_Seek seek = seek_line_char(line, pos+1);
if (buffer_compute_cursor(app, &buffer, seek, &cursor)){
if (buffer_compute_cursor(app, &buffer, seek_line_char(i, pos+1), &cursor)){
edit->str_start = 0;
edit->len = 1;
edit->start = cursor.pos;
@ -187,12 +178,10 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
Buffer_Edit *edit = push_array(part, Buffer_Edit, line_count);
Buffer_Edit *edits = edit;
for (int32_t i = 0; i <= line_count; ++i){
size_t line = i + rect.line0;
for (int32_t i = rect.line0; i <= rect.line1; ++i){
Partial_Cursor cursor = {0};
Buffer_Seek seek = seek_line_char(line, pos+1);
if (buffer_compute_cursor(app, &buffer, seek, &cursor)){
if (buffer_compute_cursor(app, &buffer, seek_line_char(i, pos+1), &cursor)){
edit->str_start = 0;
edit->len = 0;
edit->start = cursor.pos-1;
@ -227,11 +216,11 @@ enum{
};
static bool32
find_scope_top(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
find_scope_top(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
size_t position = 0;
int32_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index;
@ -287,11 +276,11 @@ find_scope_top(Application_Links *app, Buffer_Summary *buffer, size_t start_pos,
}
static bool32
find_scope_bottom(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
find_scope_bottom(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
size_t position = 0;
int32_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index+1;
@ -348,11 +337,11 @@ find_scope_bottom(Application_Links *app, Buffer_Summary *buffer, size_t start_p
}
static bool32
find_next_scope(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
find_next_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
size_t position = 0;
int32_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index+1;
@ -428,11 +417,11 @@ find_next_scope(Application_Links *app, Buffer_Summary *buffer, size_t start_pos
}
static bool32
find_prev_scope(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
find_prev_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
size_t position = 0;
int32_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index-1;
@ -507,7 +496,7 @@ find_prev_scope(Application_Links *app, Buffer_Summary *buffer, size_t start_pos
}
static void
view_set_to_region(Application_Links *app, View_Summary *view, size_t major_pos, size_t minor_pos, float normalized_threshold){
view_set_to_region(Application_Links *app, View_Summary *view, int32_t major_pos, int32_t minor_pos, float normalized_threshold){
Range range = make_range(major_pos, minor_pos);
bool32 bottom_major = false;
if (major_pos == range.max){
@ -562,8 +551,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);
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
int32_t start_pos = view.cursor.pos;
int32_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)){
@ -582,8 +571,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);
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
int32_t start_pos = view.cursor.pos;
int32_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);
@ -598,8 +587,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);
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
int32_t start_pos = view.cursor.pos;
int32_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);
@ -614,8 +603,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);
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
int32_t start_pos = view.cursor.pos;
int32_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);
@ -630,8 +619,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);
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
int32_t start_pos = view.cursor.pos;
int32_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);
@ -646,8 +635,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);
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
int32_t start_pos = view.cursor.pos;
int32_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);
@ -671,6 +660,7 @@ 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;
}
@ -697,11 +687,11 @@ CUSTOM_COMMAND_SIG(place_in_scope){
--max_adjustment;
}
size_t min_pos = range.min + min_adjustment;
size_t max_pos = range.max + max_adjustment;
int32_t min_pos = range.min + min_adjustment;
int32_t max_pos = range.max + max_adjustment;
size_t cursor_pos = min_pos;
size_t mark_pos = max_pos;
int32_t cursor_pos = min_pos;
int32_t mark_pos = max_pos;
if (view.cursor.pos > view.mark.pos){
cursor_pos = max_pos;
@ -735,11 +725,13 @@ CUSTOM_COMMAND_SIG(delete_current_scope){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
size_t top = view.cursor.pos;
size_t bottom = view.mark.pos;
int32_t top = view.cursor.pos;
int32_t bottom = view.mark.pos;
if (top > bottom){
Swap(size_t, top, bottom);
int32_t x = top;
top = bottom;
bottom = x;
}
if (buffer_get_char(app, &buffer, top) == '{' && buffer_get_char(app, &buffer, bottom-1) == '}'){
@ -948,10 +940,10 @@ parse_statement_down(Application_Links *app, Statement_Parser *parser, Cpp_Token
}
static bool32
find_whole_statement_down(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t *start_out, size_t *end_out){
find_whole_statement_down(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t *start_out, int32_t *end_out){
bool32 result = false;
size_t start = pos;
size_t end = start;
int32_t start = pos;
int32_t end = start;
Cpp_Get_Token_Result get_result = {0};
@ -990,11 +982,13 @@ CUSTOM_COMMAND_SIG(scope_absorb_down){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
size_t top = view.cursor.pos;
size_t bottom = view.mark.pos;
int32_t top = view.cursor.pos;
int32_t bottom = view.mark.pos;
if (top > bottom){
Swap(size_t, top, bottom);
int32_t x = top;
top = bottom;
bottom = x;
}
Partition *part = &global_part;
@ -1006,8 +1000,7 @@ 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);
int32_t string_length = (int32_t)(range.end - range.start);
String string = make_string(string_space, string_length);
String string = make_string(string_space, range.end - range.start);
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 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;
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;
char current = buffer_get_char(app, buffer, start_pos);
@ -25,16 +25,16 @@ get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, siz
int32_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
size_t pos = start_pos;
int32_t pos = start_pos;
size_t pos1 = 0;
size_t pos2 = 0;
int32_t pos1 = 0;
int32_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 >= (size_t)stream.start; --pos){
for (; pos >= 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, siz
still_looping = 1;
while (still_looping){
for (; pos < (size_t)stream.end; ++pos){
for (; pos < 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, siz
double_break_2:;
pos2 = pos;
result = true;
result = 1;
*numeric_start = pos1;
*numeric_end = pos2;
}
@ -72,19 +72,18 @@ get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, siz
}
struct Miblo_Number_Info{
size_t start, end;
int32_t start, end;
int32_t x;
};
static bool32
get_numeric_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t pos, Miblo_Number_Info *info){
bool32 result = false;
static int32_t
get_numeric_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Miblo_Number_Info *info){
int32_t result = 0;
size_t numeric_start = 0, numeric_end = 0;
int32_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, string_length, sizeof(numeric_string));
String str = make_string(numeric_string, numeric_end - numeric_start, sizeof(numeric_string));
if (str.size < str.memory_size){
buffer_read_range(app, buffer, numeric_start, numeric_end, numeric_string);
@ -94,7 +93,7 @@ get_numeric_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t pos
info->start = numeric_start;
info->end = numeric_end;
info->x = x;
result = true;
result = 1;
}
}
@ -132,9 +131,9 @@ CUSTOM_COMMAND_SIG(miblo_decrement_basic){
// NOTE(allen): miblo time stamp format
// (h+:)?m?m:ss
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;
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;
char current = buffer_get_char(app, buffer, start_pos);
@ -143,16 +142,16 @@ get_timestamp_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, s
int32_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
size_t pos = start_pos;
int32_t pos = start_pos;
size_t pos1 = 0;
size_t pos2 = 0;
int32_t pos1 = 0;
int32_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 >= (size_t)stream.start; --pos){
for (; pos >= stream.start; --pos){
char at_pos = stream.data[pos];
if (!(char_is_numeric(at_pos) || at_pos == ':')){
++pos;
@ -168,7 +167,7 @@ get_timestamp_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, s
still_looping = 1;
while (still_looping){
for (; pos < (size_t)stream.end; ++pos){
for (; pos < stream.end; ++pos){
char at_pos = stream.data[pos];
if (!(char_is_numeric(at_pos) || at_pos == ':')){
goto double_break_2;
@ -179,7 +178,7 @@ get_timestamp_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, s
double_break_2:;
pos2 = pos;
result = true;
result = 1;
*timestamp_start = pos1;
*timestamp_end = pos2;
}
@ -272,19 +271,18 @@ timestamp_to_str(String *dest, Miblo_Timestamp t){
}
struct Miblo_Timestamp_Info{
size_t start, end;
int32_t start, end;
Miblo_Timestamp time;
};
static bool32
get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t pos, Miblo_Timestamp_Info *info){
bool32 result = false;
static int32_t
get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Miblo_Timestamp_Info *info){
int32_t result = 0;
size_t timestamp_start = 0, timestamp_end = 0;
int32_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, string_length, sizeof(timestamp_string));
String str = make_string(timestamp_string, timestamp_end - timestamp_start, sizeof(timestamp_string));
if (str.size < str.memory_size){
buffer_read_range(app, buffer, timestamp_start, timestamp_end, timestamp_string);
@ -298,10 +296,10 @@ get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t p
if (count_colons == 1 || count_colons == 2){
Miblo_Timestamp t = {0};
bool32 success = false;
int32_t success = 0;
size_t i = 0;
size_t number_start[3], number_end[3];
int32_t i = 0;
int32_t number_start[3], number_end[3];
for (int32_t k = 0; k < 3; ++k){
number_start[k] = i;
for (; i <= str.size; ++i){
@ -317,42 +315,27 @@ get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t p
}
if (count_colons == 2){
t.hour = 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]);
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){
if (number_end[1] - number_start[1] == 2){
number_string = make_string(str.str + number_start[1], number_length);
t.minute = str_to_int(number_string);
t.minute = str_to_int(make_string(str.str + number_start[1], number_end[1] - number_start[1]));
number_length = (int32_t)(number_end[2] - number_start[2]);
if (number_length == 2){
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_string = make_string(str.str + number_start[2], number_length);
t.second = str_to_int(number_string);
success = true;
success = 1;
}
}
}
else{
int32_t number_length = (int32_t)(number_end[0] - number_start[0]);
if (number_length == 2 || number_length == 1){
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]));
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){
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]));
number_string = make_string(str.str + number_start[1], number_length);
t.second = str_to_int(number_string);
success = true;
success = 1;
}
}
}
@ -361,7 +344,7 @@ get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t p
info->start = timestamp_start;
info->end = timestamp_end;
info->time = t;
result = true;
result = 1;
}
}
}

BIN
vc140.pdb

Binary file not shown.