Revert "finished platform layer, it's fucked, rolling back"

unfucking things
This reverts commit c492bfdb4e.
master
Allen Webster 2017-03-23 15:14:39 -04:00
parent c492bfdb4e
commit db39b1ea90
38 changed files with 604 additions and 1513 deletions

View File

@ -1,9 +1,9 @@
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, uint32_t len)
#define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, int32_t clipboard_id, char *str, size_t len)
#define CLIPBOARD_COUNT_SIG(n) uint32_t n(Application_Links *app, uint32_t clipboard_id)
#define CLIPBOARD_INDEX_SIG(n) uint32_t n(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, uint32_t len)
#define CLIPBOARD_INDEX_SIG(n) size_t n(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, size_t len)
#define GET_BUFFER_COUNT_SIG(n) int32_t n(Application_Links *app)
#define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app, Access_Flag access)
#define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer, Access_Flag access)
@ -369,9 +369,9 @@ 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, uint32_t len){(app->clipboard_post(app, clipboard_id, str, len));}
static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, size_t len){(app->clipboard_post(app, clipboard_id, str, len));}
static inline uint32_t clipboard_count(Application_Links *app, uint32_t clipboard_id){return(app->clipboard_count(app, clipboard_id));}
static inline uint32_t clipboard_index(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, uint32_t len){return(app->clipboard_index(app, clipboard_id, item_index, out, len));}
static inline size_t clipboard_index(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, size_t len){return(app->clipboard_index(app, clipboard_id, item_index, out, len));}
static inline int32_t get_buffer_count(Application_Links *app){return(app->get_buffer_count(app));}
static inline Buffer_Summary get_buffer_first(Application_Links *app, Access_Flag access){return(app->get_buffer_first(app, access));}
static inline void get_buffer_next(Application_Links *app, Buffer_Summary *buffer, Access_Flag access){(app->get_buffer_next(app, buffer, access));}
@ -441,9 +441,9 @@ 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, uint32_t len){(app->clipboard_post_(app, clipboard_id, str, len));}
static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, size_t len){(app->clipboard_post_(app, clipboard_id, str, len));}
static inline uint32_t clipboard_count(Application_Links *app, uint32_t clipboard_id){return(app->clipboard_count_(app, clipboard_id));}
static inline uint32_t clipboard_index(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, uint32_t len){return(app->clipboard_index_(app, clipboard_id, item_index, out, len));}
static inline size_t clipboard_index(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, size_t len){return(app->clipboard_index_(app, clipboard_id, item_index, out, len));}
static inline int32_t get_buffer_count(Application_Links *app){return(app->get_buffer_count_(app));}
static inline Buffer_Summary get_buffer_first(Application_Links *app, Access_Flag access){return(app->get_buffer_first_(app, access));}
static inline void get_buffer_next(Application_Links *app, Buffer_Summary *buffer, Access_Flag access){(app->get_buffer_next_(app, buffer, access));}

View File

@ -399,15 +399,15 @@ Throughout the API ranges are thought of in the form [min,max) where max is "one
UNION Range{
STRUCT{
/* DOC(This is the smaller value in the range, it is also the 'start'.) */
int32_t min;
size_t min;
/* DOC(This is the larger value in the range, it is also the 'end'.) */
int32_t max;
size_t max;
};
STRUCT{
/* DOC(This is the start of the range, it is also the 'min'.) */
int32_t start;
size_t start;
/* DOC(This is the end of the range, it is also the 'max'.) */
int32_t end;
size_t end;
};
};
@ -496,7 +496,7 @@ STRUCT Buffer_Seek{
UNION{
STRUCT {
/* DOC(The pos field specified the pos when the seek is in absolute position.) */
int32_t pos;
size_t pos;
};
STRUCT {
/* DOC(For xy coordinate seeks, rounding down means that any x in the box of the character lands on that character. For instance when clicking rounding down is the user's expected behavior. Not rounding down means that the right hand portion of the character's box, which is closer to the next character, will land on that next character. The unrounded behavior is the expected behavior when moving vertically and keeping the preferred x.) */
@ -508,9 +508,9 @@ STRUCT Buffer_Seek{
};
STRUCT {
/* DOC(The line number of a line-character type seek.) */
int32_t line;
size_t line;
/* DOC(The character number of a line-character type seek.) */
int32_t character;
size_t character;
};
};
};
@ -519,15 +519,15 @@ STRUCT Buffer_Seek{
DOC_SEE(4coder_Buffer_Positioning_System) */
STRUCT Full_Cursor{
/* DOC(This field contains the cursor's position in absolute byte index positioning.) */
int32_t pos;
size_t pos;
/* DOC(This field contains the cursor's position in apparent character index positioning.) */
int32_t character_pos;
size_t character_pos;
/* DOC(This field contains the number of the line where the cursor is located. This field is one based.) */
int32_t line;
size_t line;
/* DOC(This field contains the number of the character from the beginninf of the line where the cursor is located. This field is one based.) */
int32_t character;
size_t character;
/* DOC(This field contains the number of the line where the cursor is located, taking the line wrapping into account. This field is one based.) */
int32_t wrap_line;
size_t wrap_line;
/* DOC(This field contains the x position measured with unwrapped lines.) */
float unwrapped_x;
/* DOC(This field contains the y position measured with unwrapped lines.) */
@ -542,24 +542,24 @@ STRUCT Full_Cursor{
DOC_SEE(4coder_Buffer_Positioning_System) */
STRUCT Partial_Cursor{
/* DOC(This field contains the cursor's position in absolute byte index positioning.) */
int32_t pos;
size_t pos;
/* DOC(This field contains the number of the character from the beginninf of the line
where the cursor is located. This field is one based.) */
int32_t line;
size_t line;
/* DOC(This field contains the number of the column where the cursor is located. This field is one based.) */
int32_t character;
size_t character;
};
/* DOC(Buffer_Edit describes a range of a buffer and string to replace that range. A Buffer_Edit has to be paired with a string that contains the actual text that will be replaced into the buffer.) */
STRUCT Buffer_Edit{
/* DOC(The str_start field specifies the first character in the accompanying string that corresponds with this edit.) */
int32_t str_start;
size_t str_start;
/* DOC(The len field specifies the length of the string being written into the buffer.) */
int32_t len;
size_t len;
/* DOC(The start field specifies the start of the range in the buffer to replace in absolute position.) */
int32_t start;
size_t start;
/* DOC(The end field specifies one past the end of the range in the buffer to replace in absolute position.) */
int32_t end;
size_t end;
};
/* DOC(Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.)
@ -616,7 +616,7 @@ DOC_SEE(buffer_add_markers)
*/
STRUCT Marker{
/* DOC(The current position of the marker measure in absolute byte positioning coordinates.) */
int32_t pos;
size_t pos;
/* DOC(When a marker is inside a range that gets edited, by default the marker 'leans_left' which means it goes to the beginning of the edited range. If the field lean_right is set to true, the marker will lean right with edits and will go to the end of edited range.) */
bool32 lean_right;
};
@ -638,10 +638,10 @@ STRUCT i32_Rect{
GLOBAL_VAR i32_Rect null_i32_rect = {0};
STRUCT pos_Rect{
int32_t x0;
int32_t y0;
int32_t x1;
int32_t y1;
size_t x0;
size_t y0;
size_t x1;
size_t y1;
};
GLOBAL_VAR pos_Rect null_pos_rect = {0};
@ -735,7 +735,7 @@ STRUCT Buffer_Batch_Edit{
/* DOC(The pointer to the edit string buffer.) */
char *str;
/* DOC(The length of the edit string buffer.) */
int32_t str_len;
size_t str_len;
/* DOC(The array of edits to be applied.) */
Buffer_Edit *edits;

View File

@ -2,7 +2,6 @@
#define MINOR 0
#define PATCH 18
// strings
#define VN__(a,b,c) #a"."#b"."#c
#define VN_(a,b,c) VN__(a,b,c)
#define VERSION_NUMBER VN_(MAJOR,MINOR,PATCH)
@ -15,18 +14,3 @@
#endif
#define VERSION VERSION_STRING VERSION_TYPE
// long strings
#define L_VN__(a,b,c) L#a L"." L#b L"." L#c
#define L_VN_(a,b,c) L_VN__(a,b,c)
#define L_VERSION_NUMBER L_VN_(MAJOR, MINOR, PATCH)
#define L_VERSION_STRING L"alpha " L_VERSION_NUMBER
#if defined(FRED_SUPER)
#define L_VERSION_TYPE L" super!"
#else
#define L_VERSION_TYPE
#endif
#define L_VERSION L_VERSION_STRING L_VERSION_TYPE

View File

@ -28,14 +28,14 @@ TYPE: 'drop-in-command-pack'
//
struct Hard_Start_Result{
int32_t char_pos;
size_t char_pos;
int32_t indent_pos;
bool32 all_whitespace;
bool32 all_space;
};
static Hard_Start_Result
buffer_find_hard_start(Application_Links *app, Buffer_Summary *buffer, int32_t line_start, int32_t tab_width){
buffer_find_hard_start(Application_Links *app, Buffer_Summary *buffer, size_t line_start, int32_t tab_width){
Hard_Start_Result result = {0};
result.all_space = 1;
result.indent_pos = 0;
@ -49,7 +49,7 @@ buffer_find_hard_start(Application_Links *app, Buffer_Summary *buffer, int32_t l
if (init_stream_chunk(&stream, app, buffer, line_start, data_chunk, sizeof(data_chunk))){
int32_t still_looping = 1;
do{
for (; result.char_pos < stream.end; ++result.char_pos){
for (; result.char_pos < (size_t)stream.end; ++result.char_pos){
char c = stream.data[result.char_pos];
if (c == '\n' || c == 0){
@ -86,24 +86,24 @@ struct Indent_Options{
};
static Buffer_Batch_Edit
make_batch_from_indent_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line_start, int32_t line_end, int32_t *indent_marks, Indent_Options opts){
make_batch_from_indent_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, size_t line_start, size_t line_end, int32_t *indent_marks, Indent_Options opts){
Buffer_Batch_Edit result = {0};
uint32_t edit_max = line_end - line_start;
size_t edit_max = line_end - line_start;
uint32_t edit_count = 0;
Buffer_Edit *edits = push_array(part, Buffer_Edit, edit_max);
char *str_base = (char*)part->base + part->pos;
int32_t str_size = 0;
size_t str_size = 0;
// NOTE(allen): Shift the array so that line_i can just operate in
// it's natural value range.
indent_marks -= line_start;
for (int32_t line_i = line_start; line_i < line_end; ++line_i){
int32_t line_start_pos = buffer_get_line_start(app, buffer, line_i);
for (size_t line_i = line_start; line_i < line_end; ++line_i){
size_t line_start_pos = buffer_get_line_start(app, buffer, line_i);
Hard_Start_Result hard_start = buffer_find_hard_start(app, buffer, line_start_pos, opts.tab_width);
int32_t correct_indentation = indent_marks[line_i];
@ -156,7 +156,7 @@ make_batch_from_indent_marks(Application_Links *app, Partition *part, Buffer_Sum
}
static void
set_line_indents(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line_start, int32_t line_end, int32_t *indent_marks, Indent_Options opts){
set_line_indents(Application_Links *app, Partition *part, Buffer_Summary *buffer, size_t line_start, size_t line_end, int32_t *indent_marks, Indent_Options opts){
Buffer_Batch_Edit batch =
make_batch_from_indent_marks(app, part, buffer, line_start, line_end, indent_marks, opts);
@ -192,7 +192,7 @@ seek_matching_token_backwards(Cpp_Token_Array tokens, Cpp_Token *token, Cpp_Toke
}
static Cpp_Token*
find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t line_start, int32_t tab_width, int32_t *current_indent_out){
find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, size_t line_start, int32_t tab_width, int32_t *current_indent_out){
Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_start);
if (token == 0 && tokens.count == 0){
@ -220,8 +220,8 @@ find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Arra
int32_t current_indent = 0;
int32_t found_safe_start_position = 0;
do{
int32_t line = buffer_get_line_index(app, buffer, token->start);
int32_t start = buffer_get_line_start(app, buffer, line);
size_t line = buffer_get_line_index(app, buffer, token->start);
size_t start = buffer_get_line_start(app, buffer, line);
Hard_Start_Result hard_start = buffer_find_hard_start(app, buffer, start, tab_width);
current_indent = hard_start.indent_pos;
@ -294,9 +294,9 @@ struct Indent_Parse_State{
};
static int32_t*
get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t line_start, int32_t line_end, bool32 exact_align, int32_t tab_width){
get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, Cpp_Token_Array tokens, size_t line_start, size_t line_end, bool32 exact_align, int32_t tab_width){
int32_t indent_mark_count = line_end - line_start;
size_t indent_mark_count = line_end - line_start;
int32_t *indent_marks = push_array(part, int32_t, indent_mark_count);
// Shift the array so line_index works correctly.
indent_marks -= line_start;
@ -306,18 +306,18 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
Cpp_Token *token_ptr = find_anchor_token(app, buffer, tokens, line_start, tab_width, &indent.current_indent);
if (token_ptr == 0){
for (int32_t line_index = line_start; line_index < line_end; ++line_index){
for (size_t line_index = line_start; line_index < line_end; ++line_index){
indent_marks[line_index] = 0;
}
}
else{
int32_t line_index = buffer_get_line_index(app, buffer, token_ptr->start);
size_t line_index = buffer_get_line_index(app, buffer, token_ptr->start);
if (line_index > line_start){
line_index = line_start;
}
int32_t next_line_start_pos = buffer_get_line_start(app, buffer, line_index+1);
size_t next_line_start_pos = buffer_get_line_start(app, buffer, line_index+1);
switch (token_ptr->type){
case CPP_TOKEN_BRACKET_OPEN: indent.current_indent += tab_width; break;
@ -347,8 +347,8 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
{
int32_t previous_indent = indent.previous_line_indent;
int32_t this_line_start = buffer_get_line_start(app, buffer, line_index);
int32_t next_line_start = buffer_get_line_start(app, buffer, line_index+1);
size_t this_line_start = buffer_get_line_start(app, buffer, line_index);
size_t next_line_start = buffer_get_line_start(app, buffer, line_index+1);
bool32 did_special_behavior = false;
@ -456,8 +456,8 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
case CPP_TOKEN_COMMENT:
{
int32_t line = buffer_get_line_index(app, buffer, token.start);
int32_t start = buffer_get_line_start(app, buffer, line);
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;
@ -466,8 +466,8 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
case CPP_TOKEN_PARENTHESE_OPEN:
if (!(token.flags & CPP_TFLAG_PP_BODY)){
if (indent.paren_nesting < ArrayCount(indent.paren_anchor_indent)){
int32_t line = buffer_get_line_index(app, buffer, token.start);
int32_t start = buffer_get_line_start(app, buffer, line);
size_t line = buffer_get_line_index(app, buffer, token.start);
size_t start = buffer_get_line_start(app, buffer, line);
int32_t char_pos = (int32_t)(token.start - start);
Hard_Start_Result hard_start =
@ -499,21 +499,21 @@ get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *b
}
static void
get_indent_lines_minimum(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, int32_t end_pos, int32_t *line_start_out, int32_t *line_end_out){
int32_t line_start = buffer_get_line_index(app, buffer, start_pos);
int32_t line_end = buffer_get_line_index(app, buffer, end_pos) + 1;
get_indent_lines_minimum(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, size_t end_pos, size_t *line_start_out, size_t *line_end_out){
size_t line_start = buffer_get_line_index(app, buffer, start_pos);
size_t line_end = buffer_get_line_index(app, buffer, end_pos) + 1;
*line_start_out = line_start;
*line_end_out = line_end;
}
static void
get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t start_pos, int32_t end_pos, int32_t *line_start_out, int32_t *line_end_out){
int32_t line_start = buffer_get_line_index(app, buffer, start_pos);
int32_t line_end = buffer_get_line_index(app, buffer, end_pos);
get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, size_t start_pos, size_t end_pos, size_t *line_start_out, size_t *line_end_out){
size_t line_start = buffer_get_line_index(app, buffer, start_pos);
size_t line_end = buffer_get_line_index(app, buffer, end_pos);
for (;line_start > 0;){
int32_t line_start_pos = 0;
size_t line_start_pos = 0;
Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_start, &line_start_pos);
if (token != 0 && token->start < line_start_pos){
line_start = buffer_get_line_index(app, buffer, token->start);
@ -524,7 +524,7 @@ get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cp
}
for (;line_end+1 < buffer->line_count;){
int32_t next_line_start_pos = 0;
size_t next_line_start_pos = 0;
Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_end+1, &next_line_start_pos);
if (token && token->start < next_line_start_pos){
line_end = buffer_get_line_index(app, buffer, token->start+token->size);
@ -545,7 +545,7 @@ get_indent_lines_whole_tokens(Application_Links *app, Buffer_Summary *buffer, Cp
}
static bool32
buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t start, int32_t end, int32_t tab_width, Auto_Indent_Flag flags){
buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buffer, size_t start, size_t end, int32_t tab_width, Auto_Indent_Flag flags){
bool32 result = false;
if (buffer->exists && buffer->tokens_are_ready){
@ -562,7 +562,7 @@ buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buff
// Stage 2: Decide where the first and last lines are.
// The lines in the range [line_start,line_end) will be indented.
int32_t line_start = 0, line_end = 0;
size_t line_start = 0, line_end = 0;
if (flags & AutoIndent_FullTokens){
get_indent_lines_whole_tokens(app, buffer, tokens, start, end, &line_start, &line_end);
}
@ -591,7 +591,7 @@ buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buff
}
static bool32
buffer_auto_indent(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, int32_t tab_width, Auto_Indent_Flag flags){
buffer_auto_indent(Application_Links *app, Buffer_Summary *buffer, size_t start, size_t end, int32_t tab_width, Auto_Indent_Flag flags){
bool32 result = buffer_auto_indent(app, &global_part, buffer, start, end, tab_width, flags);
return(result);
}

View File

@ -33,7 +33,7 @@ CUSTOM_COMMAND_SIG(write_character){
if (length != 0){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = view.cursor.pos;
size_t pos = view.cursor.pos;
Marker next_cursor_marker = {0};
next_cursor_marker.pos = character_pos_to_pos(app, &view, &buffer, view.cursor.character_pos);
@ -60,8 +60,8 @@ CUSTOM_COMMAND_SIG(delete_char){
Full_Cursor cursor;
view_compute_cursor(app, &view, seek, &cursor);
int32_t start = view.cursor.pos;
int32_t end = cursor.pos;
size_t start = view.cursor.pos;
size_t end = cursor.pos;
if (0 <= start && start < buffer.size){
buffer_replace_range(app, &buffer, start, end, 0, 0);
@ -77,8 +77,8 @@ CUSTOM_COMMAND_SIG(backspace_char){
Full_Cursor cursor;
view_compute_cursor(app, &view, seek, &cursor);
int32_t end = view.cursor.pos;
int32_t start = cursor.pos;
size_t end = view.cursor.pos;
size_t start = cursor.pos;
if (0 < end && end <= buffer.size){
buffer_replace_range(app, &buffer, start, end, 0, 0);
@ -97,8 +97,8 @@ CUSTOM_COMMAND_SIG(set_mark){
CUSTOM_COMMAND_SIG(cursor_mark_swap){
View_Summary view = get_active_view(app, AccessProtected);
int32_t cursor = view.cursor.pos;
int32_t mark = view.mark.pos;
size_t cursor = view.cursor.pos;
size_t mark = view.mark.pos;
view_set_cursor(app, &view, seek_pos(mark), true);
view_set_mark(app, &view, seek_pos(cursor));
@ -250,14 +250,14 @@ CUSTOM_COMMAND_SIG(page_down){
CUSTOM_COMMAND_SIG(move_left){
uint32_t access = AccessProtected;
View_Summary view = get_active_view(app, access);
int32_t new_pos = view.cursor.character_pos - 1;
size_t new_pos = view.cursor.character_pos - 1;
view_set_cursor(app, &view, seek_character_pos(new_pos), 1);
}
CUSTOM_COMMAND_SIG(move_right){
uint32_t access = AccessProtected;
View_Summary view = get_active_view(app, access);
int32_t new_pos = view.cursor.character_pos + 1;
size_t new_pos = view.cursor.character_pos + 1;
view_set_cursor(app, &view, seek_character_pos(new_pos), 1);
}
@ -277,7 +277,7 @@ CUSTOM_COMMAND_SIG(seek_whitespace_up){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = buffer_seek_whitespace_up(app, &buffer, view.cursor.pos);
size_t new_pos = buffer_seek_whitespace_up(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -286,7 +286,7 @@ CUSTOM_COMMAND_SIG(seek_whitespace_down){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = buffer_seek_whitespace_down(app, &buffer, view.cursor.pos);
size_t new_pos = buffer_seek_whitespace_down(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -295,7 +295,7 @@ CUSTOM_COMMAND_SIG(seek_end_of_textual_line){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = seek_line_end(app, &buffer, view.cursor.pos);
size_t new_pos = seek_line_end(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -304,7 +304,7 @@ CUSTOM_COMMAND_SIG(seek_beginning_of_textual_line){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t new_pos = seek_line_beginning(app, &buffer, view.cursor.pos);
size_t new_pos = seek_line_beginning(app, &buffer, view.cursor.pos);
view_set_cursor(app, &view, seek_pos(new_pos), true);
}
@ -350,7 +350,7 @@ CUSTOM_COMMAND_SIG(to_uppercase){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
Range range = get_range(&view);
int32_t size = range.max - range.min;
size_t size = range.max - range.min;
if (size <= app->memory_size){
char *mem = (char*)app->memory;
@ -368,7 +368,7 @@ CUSTOM_COMMAND_SIG(to_lowercase){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
Range range = get_range(&view);
int32_t size = range.max - range.min;
size_t size = range.max - range.min;
if (size <= app->memory_size){
char *mem = (char*)app->memory;
@ -580,9 +580,9 @@ isearch(Application_Links *app, bool32 start_reversed){
if (start_query_bar(app, &bar, 0) == 0) return;
bool32 reverse = start_reversed;
int32_t pos = view.cursor.pos;
int32_t start_pos = pos;
int32_t first_pos = pos;
size_t pos = view.cursor.pos;
size_t start_pos = pos;
size_t first_pos = pos;
Range match = make_range(pos, pos);
char bar_string_space[256];
@ -646,8 +646,8 @@ isearch(Application_Links *app, bool32 start_reversed){
if (in.key.keycode != key_back){
char *str = bar.string.str;
int32_t str_size = bar.string.size;
int32_t new_pos = 0;
size_t str_size = bar.string.size;
size_t new_pos = 0;
if (reverse){
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0, str, str_size, &new_pos);
if (new_pos >= 0){
@ -723,8 +723,8 @@ CUSTOM_COMMAND_SIG(replace_in_range){
Range range = get_range(&view);
int32_t pos = range.min;
int32_t new_pos = 0;
size_t pos = range.min;
size_t new_pos = 0;
buffer_seek_string_forward(app, &buffer, pos, 0, r.str, r.size, &new_pos);
while (new_pos + r.size <= range.end){
@ -765,8 +765,8 @@ CUSTOM_COMMAND_SIG(query_replace){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = view.cursor.pos;
int32_t new_pos = 0;
size_t pos = view.cursor.pos;
size_t new_pos = 0;
buffer_seek_string_forward(app, &buffer, pos, 0, r.str, r.size, &new_pos);
User_Input in = {0};

View File

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

View File

@ -42,9 +42,9 @@ TYPE: 'major-system-include'
// Seeks Using Default Framework Memory
//
static int32_t
buffer_boundary_seek(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags){
int32_t result = buffer_boundary_seek(app, buffer, &global_part, start_pos, seek_forward, flags);
static size_t
buffer_boundary_seek(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags){
size_t result = buffer_boundary_seek(app, buffer, &global_part, start_pos, seek_forward, flags);
return(result);
}
@ -53,7 +53,7 @@ basic_seek(Application_Links *app, int32_t seek_type, uint32_t flags){
uint32_t access = AccessProtected;
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_type, flags);
size_t pos = buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_type, flags);
view_set_cursor(app, &view, seek_pos(pos), true);
}
@ -115,8 +115,8 @@ CUSTOM_COMMAND_SIG(snipe_token_or_word){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos1 = buffer_boundary_seek(app, &buffer, view.cursor.pos, 0, BoundaryToken | BoundaryWhitespace);
int32_t pos2 = buffer_boundary_seek(app, &buffer, pos1, 1, BoundaryToken | BoundaryWhitespace);
size_t pos1 = buffer_boundary_seek(app, &buffer, view.cursor.pos, 0, BoundaryToken | BoundaryWhitespace);
size_t pos2 = buffer_boundary_seek(app, &buffer, pos1, 1, BoundaryToken | BoundaryWhitespace);
Range range = make_range(pos1, pos2);
buffer_replace_range(app, &buffer, range.start, range.end, 0, 0);
@ -201,7 +201,7 @@ long_braces(Application_Links *app, char *text, int32_t size){
uint32_t access = AccessOpen;
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t pos = view.cursor.pos;
size_t pos = view.cursor.pos;
buffer_replace_range(app, &buffer, pos, pos, text, size);
view_set_cursor(app, &view, seek_pos(pos + 2), true);
@ -333,13 +333,13 @@ file_name_in_quotes(Application_Links *app, String *file_name){
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
if (buffer.file_name != 0){
int32_t pos = view.cursor.pos;
int32_t start = 0, end = 0;
size_t pos = view.cursor.pos;
size_t start = 0, end = 0;
buffer_seek_delimiter_forward(app, &buffer, pos, '"', &end);
buffer_seek_delimiter_backward(app, &buffer, pos, '"', &start);
++start;
int32_t size = end - start;
size_t size = end - start;
char short_file_name[128];
// NOTE(allen): This check is necessary because buffer_read_range

View File

@ -148,7 +148,7 @@ query_user_number(Application_Links *app, Query_Bar *bar){
}
static char
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char result = ' ';
*buffer = get_buffer(app, buffer->buffer_id, AccessAll);
if (pos < buffer->size){
@ -188,7 +188,7 @@ create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buff
}
static Range
make_range(int32_t p1, int32_t p2){
make_range(size_t p1, size_t p2){
Range range;
if (p1 < p2){
range.min = p1;
@ -212,9 +212,9 @@ adjust_all_buffer_wrap_widths(Application_Links *app, int32_t wrap_width, int32_
}
// TODO(allen): Setup buffer seeking to do character_pos and get View_Summary out of this parameter list.
static int32_t
character_pos_to_pos(Application_Links *app, View_Summary *view, Buffer_Summary *buffer, int32_t character_pos){
int32_t result = 0;
static size_t
character_pos_to_pos(Application_Links *app, View_Summary *view, Buffer_Summary *buffer, size_t character_pos){
size_t result = 0;
Full_Cursor cursor = {0};
if (view_compute_cursor(app, view, seek_character_pos(character_pos), &cursor)){
result = cursor.pos;
@ -223,8 +223,8 @@ character_pos_to_pos(Application_Links *app, View_Summary *view, Buffer_Summary
}
struct Buffer_Rect{
int32_t char0, line0;
int32_t char1, line1;
size_t char0, line0;
size_t char1, line1;
};
#ifndef Swap
@ -242,10 +242,10 @@ get_rect(View_Summary *view){
rect.line1 = view->cursor.line;
if (rect.line0 > rect.line1){
Swap(int32_t, rect.line0, rect.line1);
Swap(size_t, rect.line0, rect.line1);
}
if (rect.char0 > rect.char1){
Swap(int32_t, rect.char0, rect.char1);
Swap(size_t, rect.char0, rect.char1);
}
return(rect);
@ -256,21 +256,21 @@ get_line_x_rect(View_Summary *view){
pos_Rect rect = {0};
if (view->unwrapped_lines){
rect.x0 = (int32_t)view->mark.unwrapped_x;
rect.x1 = (int32_t)view->cursor.unwrapped_x;
rect.x0 = (size_t)view->mark.unwrapped_x;
rect.x1 = (size_t)view->cursor.unwrapped_x;
}
else{
rect.x0 = (int32_t)view->mark.wrapped_x;
rect.x1 = (int32_t)view->cursor.wrapped_x;
rect.x0 = (size_t)view->mark.wrapped_x;
rect.x1 = (size_t)view->cursor.wrapped_x;
}
rect.y0 = view->mark.line;
rect.y1 = view->cursor.line;
if (rect.y0 > rect.y1){
Swap(int32_t, rect.y0, rect.y1);
Swap(size_t, rect.y0, rect.y1);
}
if (rect.x0 > rect.x1){
Swap(int32_t, rect.x0, rect.x1);
Swap(size_t, rect.x0, rect.x1);
}
return(rect);

View File

@ -41,7 +41,7 @@ ms_style_verify(String line, int32_t paren_pos){
}
static int32_t
parse_jump_location(String line, Name_Based_Jump_Location *location, int32_t skip_sub_errors, int32_t *colon_char){
parse_jump_location(String line, Name_Based_Jump_Location *location, int32_t skip_sub_errors, size_t *colon_char){
bool32 result = false;
int32_t whitespace_length = 0;
@ -153,13 +153,13 @@ parse_jump_location(String line, Name_Based_Jump_Location *location, int32_t ski
}
static bool32
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){
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){
bool32 result = false;
String line_str = {0};
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
if (read_line(app, part, &buffer, line, &line_str)){
int32_t colon_char = 0;
size_t colon_char = 0;
if (parse_jump_location(line_str, location, skip_sub_errors, &colon_char)){
result = true;
}

View File

@ -15,16 +15,16 @@
// Whitespace Based Seeks
//
static int32_t
seek_line_end(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
seek_line_end(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
size_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
bool32 still_looping = true;
do{
for (; pos < (int32_t)stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (at_pos == '\n'){
goto double_break;
@ -42,17 +42,17 @@ seek_line_end(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
return(pos);
}
static int32_t
seek_line_beginning(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
seek_line_beginning(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
size_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
--pos;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
bool32 still_looping = false;
do{
for (; pos >= (int32_t)stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (at_pos == '\n'){
goto double_break;
@ -80,12 +80,12 @@ move_past_lead_whitespace(Application_Links *app, View_Summary *view, Buffer_Sum
char space[1024];
Stream_Chunk chunk = {0};
int32_t new_pos = seek_line_beginning(app, buffer, view->cursor.pos);
int32_t i = new_pos;
size_t new_pos = seek_line_beginning(app, buffer, view->cursor.pos);
size_t i = new_pos;
if (init_stream_chunk(&chunk, app, buffer, i, space, sizeof(space))){
bool32 still_looping = false;
do{
for (; i < (int32_t)chunk.end; ++i){
for (; i < (size_t)chunk.end; ++i){
char at_pos = chunk.data[i];
if (at_pos == '\n' || !char_is_whitespace(at_pos)){
goto break2;
@ -101,10 +101,10 @@ move_past_lead_whitespace(Application_Links *app, View_Summary *view, Buffer_Sum
}
}
static int32_t
buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
size_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
--pos;
@ -113,7 +113,7 @@ buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int32_
// behind the current position.
bool32 still_looping = true;
while (still_looping){
for (; pos >= (int32_t)stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (!char_is_whitespace(at_pos)){
goto double_break_1;
@ -130,7 +130,7 @@ buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int32_
// the next '\n'
int32_t no_hard = false;
while (still_looping){
for (; pos >= (int32_t)stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (at_pos == '\n'){
if (no_hard){
@ -156,10 +156,10 @@ buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int32_
return(pos);
}
static int32_t
buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
size_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
@ -167,7 +167,7 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int3
// ahead of the current position.
bool32 still_looping = true;
do{
for (; pos < (int32_t)stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (!char_is_whitespace(at_pos)){
goto double_break_1;
@ -184,9 +184,9 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int3
// all whitespace.
bool32 no_hard = false;
bool32 was_at_end = true;
int32_t prev_endline = 0;
size_t prev_endline = 0;
while(still_looping){
for (; pos < (int32_t)stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (at_pos == '\n'){
if (no_hard){
@ -216,8 +216,8 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int3
return(pos);
}
static int32_t
buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -226,7 +226,7 @@ buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int
bool32 still_looping = 1;
do{
for (; pos < (int32_t)stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
if (!char_is_whitespace(stream.data[pos])){
goto double_break1;
}
@ -237,7 +237,7 @@ buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int
still_looping = 1;
do{
for (; pos < (int32_t)stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
if (char_is_whitespace(stream.data[pos])){
goto double_break2;
}
@ -250,8 +250,8 @@ buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int
return(pos);
}
static int32_t
buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -262,7 +262,7 @@ buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, int3
bool32 still_looping = 1;
do{
for (; pos >= (int32_t)stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
if (!char_is_whitespace(stream.data[pos])){
goto double_break1;
}
@ -273,7 +273,7 @@ buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, int3
still_looping = 1;
do{
for (; pos >= (int32_t)stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
if (char_is_whitespace(stream.data[pos])){
++pos;
goto double_break2;
@ -295,8 +295,8 @@ buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, int3
// Boundary Type Seeks
//
static int32_t
buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -305,7 +305,7 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i
bool32 still_looping = 1;
do{
for (; pos < (int32_t)stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
if (char_is_alpha_numeric_true(stream.data[pos])){
goto double_break1;
}
@ -316,7 +316,7 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i
still_looping = 1;
do{
for (; pos < (int32_t)stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
if (!char_is_alpha_numeric_true(stream.data[pos])){
goto double_break2;
}
@ -329,8 +329,8 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i
return(pos);
}
static int32_t
buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -341,7 +341,7 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in
bool32 still_looping = 1;
do{
for (; pos >= (int32_t)stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
if (char_is_alpha_numeric_true(stream.data[pos])){
goto double_break1;
}
@ -352,7 +352,7 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in
still_looping = 1;
do{
for (; pos >= (int32_t)stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
if (!char_is_alpha_numeric_true(stream.data[pos])){
++pos;
goto double_break2;
@ -370,8 +370,8 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in
return(pos);
}
static int32_t
buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t an_pos){
static size_t
buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t an_pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -386,7 +386,7 @@ buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, in
bool32 still_looping = 1;
do{
for (; pos < (int32_t)stream.end; ++pos){
for (; pos < (size_t)stream.end; ++pos){
c = stream.data[pos];
if (char_is_upper(c) && char_is_lower(pc)){
goto double_break1;
@ -405,8 +405,8 @@ buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, in
return(pos);
}
static int32_t
buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t an_pos){
static size_t
buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t an_pos){
char data_chunk[1024];
Stream_Chunk stream = {0};
@ -419,7 +419,7 @@ buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int
bool32 still_looping = 1;
do{
for (; pos >= (int32_t)stream.start; --pos){
for (; pos >= (size_t)stream.start; --pos){
c = stream.data[pos];
if (char_is_upper(c) && char_is_lower(pc)){
goto double_break1;
@ -438,22 +438,22 @@ buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int
return(pos);
}
static int32_t
buffer_seek_alphanumeric_or_camel_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
int32_t an_pos = buffer_seek_alphanumeric_right(app, buffer, pos);
int32_t result = buffer_seek_range_camel_right(app, buffer, pos, an_pos);
static size_t
buffer_seek_alphanumeric_or_camel_right(Application_Links *app, Buffer_Summary *buffer, size_t pos){
size_t an_pos = buffer_seek_alphanumeric_right(app, buffer, pos);
size_t result = buffer_seek_range_camel_right(app, buffer, pos, an_pos);
return(result);
}
static int32_t
buffer_seek_alphanumeric_or_camel_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
int32_t an_pos = buffer_seek_alphanumeric_left(app, buffer, pos);
int32_t result = buffer_seek_range_camel_left(app, buffer, pos, an_pos);
static size_t
buffer_seek_alphanumeric_or_camel_left(Application_Links *app, Buffer_Summary *buffer, size_t pos){
size_t an_pos = buffer_seek_alphanumeric_left(app, buffer, pos);
size_t result = buffer_seek_range_camel_left(app, buffer, pos, an_pos);
return(result);
}
static int32_t
seek_token_left(Cpp_Token_Array *tokens, int32_t pos){
static size_t
seek_token_left(Cpp_Token_Array *tokens, size_t pos){
Cpp_Get_Token_Result get = cpp_get_token(*tokens, pos);
if (get.token_index == -1){
get.token_index = 0;
@ -467,8 +467,8 @@ seek_token_left(Cpp_Token_Array *tokens, int32_t pos){
return(token->start);
}
static int32_t
seek_token_right(Cpp_Token_Array *tokens, int32_t pos){
static size_t
seek_token_right(Cpp_Token_Array *tokens, size_t pos){
Cpp_Get_Token_Result get = cpp_get_token(*tokens, pos);
if (get.in_whitespace){
++get.token_index;
@ -497,8 +497,8 @@ buffer_get_all_tokens(Application_Links *app, Partition *part, Buffer_Summary *b
return(array);
}
static int32_t
buffer_boundary_seek(Application_Links *app, Buffer_Summary *buffer, Partition *part, int32_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags)/*
static size_t
buffer_boundary_seek(Application_Links *app, Buffer_Summary *buffer, Partition *part, size_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags)/*
DOC_PARAM(buffer, The buffer parameter specifies the buffer through which to seek.)
DOC_PARAM(start_pos, The beginning position of the seek is specified by start_pos measured in absolute position.)
DOC_PARAM(seek_forward, If this parameter is non-zero it indicates that the seek should move foward through the buffer.)
@ -509,14 +509,14 @@ DOC_RETURN(This call returns the absolute position where the seek stopped. If th
DOC_SEE(Seek_Boundary_Flag)
DOC_SEE(4coder_Buffer_Positioning_System)
*/{
int32_t result = 0;
size_t result = 0;
// TODO(allen): reduce duplication?
Temp_Memory temp = begin_temp_memory(part);
if (buffer->exists){
int32_t pos[4];
int32_t size = buffer->size;
int32_t new_pos = 0;
size_t pos[4];
size_t size = buffer->size;
size_t new_pos = 0;
if (start_pos < 0){
start_pos = 0;
@ -613,7 +613,7 @@ DOC_SEE(4coder_Buffer_Positioning_System)
//
static void
buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, char delim, int32_t *result){
buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, size_t pos, char delim, size_t *result){
if (buffer->exists){
char chunk[1024];
int32_t size = sizeof(chunk);
@ -622,7 +622,7 @@ buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, in
if (init_stream_chunk(&stream, app, buffer, pos, chunk, size)){
int32_t still_looping = 1;
do{
for(; pos < (int32_t)stream.end; ++pos){
for(; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (at_pos == delim){
*result = pos;
@ -640,7 +640,7 @@ buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, in
}
static void
buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, char delim, int32_t *result){
buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, size_t pos, char delim, size_t *result){
if (buffer->exists){
char chunk[1024];
int32_t size = sizeof(chunk);
@ -649,7 +649,7 @@ buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, i
if (init_stream_chunk(&stream, app, buffer, pos, chunk, size)){
int32_t still_looping = 1;
do{
for(; pos >= (int32_t)stream.start; --pos){
for(; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (at_pos == delim){
*result = pos;
@ -677,7 +677,7 @@ buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, i
// You can push it up or do something more clever by just
// replacing char read_buffer[512]; with more memory.
static void
buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t end, char *str, int32_t size, int32_t *result){
buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t end, char *str, size_t size, size_t *result){
char read_buffer[512];
if (buffer->size > end){
@ -702,7 +702,7 @@ buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, int32
if (init_stream_chunk(&stream, app, buffer, pos, chunk, sizeof(chunk))){
bool32 still_looping = 1;
do{
for(; pos < (int32_t)stream.end; ++pos){
for(; pos < (size_t)stream.end; ++pos){
char at_pos = stream.data[pos];
if (at_pos == first_char){
buffer_read_range(app, buffer, pos, pos+size, read_buffer);
@ -732,7 +732,7 @@ buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, int32
// You can push it up or do something more clever by just
// replacing char read_buffer[512]; with more memory.
static void
buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t min, char *str, int32_t size, int32_t *result){
buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t min, char *str, size_t size, size_t *result){
char read_buffer[512];
*result = min-1;
@ -751,7 +751,7 @@ buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, int3
if (init_stream_chunk(&stream, app, buffer, pos, chunk, sizeof(chunk))){
int32_t still_looping = 1;
do{
for(; pos >= (int32_t)stream.start; --pos){
for(; pos >= (size_t)stream.start; --pos){
char at_pos = stream.data[pos];
if (at_pos == first_char){
buffer_read_range(app, buffer, pos, pos+size, read_buffer);
@ -774,7 +774,7 @@ buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, int3
// You can push it up or do something more clever by just
// replacing char read_buffer[512]; with more memory.
static void
buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t end, char *str, int32_t size, int32_t *result){
buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t end, char *str, size_t size, size_t *result){
char read_buffer[512];
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
@ -798,7 +798,7 @@ buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *b
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
bool32 still_looping = true;
do{
for(; pos < (int32_t)stream.end; ++pos){
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);
@ -819,7 +819,7 @@ buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *b
// You can push it up or do something more clever by just
// replacing char read_buffer[512]; with more memory.
static void
buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t min, char *str, int32_t size, int32_t *result){
buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t min, char *str, size_t size, size_t *result){
char read_buffer[512];
char chunk[1024];
int32_t chunk_size = sizeof(chunk);
@ -837,7 +837,7 @@ buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
int32_t still_looping = 1;
do{
for(; pos >= (int32_t)stream.start; --pos){
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);
@ -860,7 +860,7 @@ buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *
//
static bool32
read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line, String *str){
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);
@ -872,7 +872,7 @@ read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32
if (begin.line == line){
if (buffer_compute_cursor(app, buffer, seek_end, &end)){
if (0 <= begin.pos && begin.pos <= end.pos && end.pos <= buffer->size){
int32_t size = (end.pos - begin.pos);
size_t size = (end.pos - begin.pos);
*str = make_string(push_array(part, char, size+1), (int32_t)(size+1));
if (str->str){
success = true;
@ -888,10 +888,10 @@ read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32
return(success);
}
static int32_t
buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, int32_t line){
static size_t
buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, size_t line){
Partial_Cursor partial_cursor;
int32_t result = buffer->size;
size_t result = buffer->size;
if (line <= buffer->line_count){
buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &partial_cursor);
result = partial_cursor.pos;
@ -899,10 +899,10 @@ buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, int32_t li
return(result);
}
static int32_t
buffer_get_line_end(Application_Links *app, Buffer_Summary *buffer, int32_t line){
static size_t
buffer_get_line_end(Application_Links *app, Buffer_Summary *buffer, size_t line){
Partial_Cursor partial_cursor;
int32_t result = buffer->size;
size_t result = buffer->size;
if (line <= buffer->line_count){
buffer_compute_cursor(app, buffer, seek_line_reverse_char(line, 1), &partial_cursor);
result = partial_cursor.pos;
@ -911,7 +911,7 @@ buffer_get_line_end(Application_Links *app, Buffer_Summary *buffer, int32_t line
}
static bool32
buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, int32_t line){
buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, size_t line){
Partial_Cursor start, end;
bool32 result = 0;
if (line <= buffer->line_count){
@ -921,17 +921,17 @@ buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, int32_t lin
buffer_compute_cursor(app, buffer, seek_start, &start);
buffer_compute_cursor(app, buffer, seek_end, &end);
static const int32_t chunk_size = 1024;
static const size_t chunk_size = 1024;
char chunk[chunk_size];
Stream_Chunk stream = {0};
int32_t i = start.pos;
size_t i = start.pos;
stream.max_end = end.pos;
result = true;
if (init_stream_chunk(&stream, app, buffer, i, chunk, chunk_size)){
bool32 still_looping = false;
do{
for (;i < (int32_t)stream.end; ++i){
for (;i < (size_t)stream.end; ++i){
char c = stream.data[i];
if (!(c == ' ' || c == '\t' || c == '\r' || c == '\v' || c == '\n')){
result = false;
@ -946,16 +946,16 @@ buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, int32_t lin
return(result);
}
static int32_t
buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, size_t pos){
Partial_Cursor partial_cursor;
buffer_compute_cursor(app, buffer, seek_pos(pos), &partial_cursor);
return(partial_cursor.line);
}
static Cpp_Token*
get_first_token_at_line(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t line, int32_t *line_start_out = 0){
int32_t line_start = buffer_get_line_start(app, buffer, line);
get_first_token_at_line(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, size_t line, size_t *line_start_out = 0){
size_t line_start = buffer_get_line_start(app, buffer, line);
Cpp_Get_Token_Result get = cpp_get_token(tokens, line_start);
if (get.in_whitespace){

View File

@ -13,7 +13,7 @@
#define FRED_BUFFER_TYPES_H
static Buffer_Seek
seek_pos(int32_t pos){
seek_pos(size_t pos){
Buffer_Seek result;
result.type = buffer_seek_pos;
result.pos = pos;
@ -21,7 +21,7 @@ seek_pos(int32_t pos){
}
static Buffer_Seek
seek_character_pos(int32_t pos){
seek_character_pos(size_t pos){
Buffer_Seek result;
result.type = buffer_seek_character_pos;
result.pos = pos;
@ -59,7 +59,7 @@ seek_xy(float x, float y, bool32 round_down, bool32 unwrapped){
}
static Buffer_Seek
seek_line_char(int32_t line, int32_t character){
seek_line_char(size_t line, size_t character){
Buffer_Seek result;
result.type = buffer_seek_line_char;
result.line = line;
@ -68,7 +68,7 @@ seek_line_char(int32_t line, int32_t character){
}
static Buffer_Seek
seek_line_reverse_char(int32_t line, int32_t character){
seek_line_reverse_char(size_t line, size_t character){
Buffer_Seek result;
result.type = buffer_seek_line_reverse_char;
result.line = line;

View File

@ -37,12 +37,12 @@ CUSTOM_COMMAND_SIG(goto_jump_at_cursor){
//
static bool32
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){
seek_next_jump_in_buffer(Application_Links *app, Partition *part, int32_t buffer_id, size_t first_line, bool32 skip_sub_errors, int32_t direction, size_t *line_out, size_t *colon_index_out, Name_Based_Jump_Location *location_out){
Assert(direction == 1 || direction == -1);
bool32 result = false;
int32_t line = first_line;
size_t line = first_line;
String line_str = {0};
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
for (;;){
@ -83,12 +83,12 @@ convert_name_based_to_id_based(Application_Links *app, Name_Based_Jump_Location
}
static int32_t
seek_next_jump_in_view(Application_Links *app, Partition *part, View_Summary *view, bool32 skip_sub_errors, int32_t direction, int32_t *line_out, int32_t *colon_index_out, Name_Based_Jump_Location *location_out){
seek_next_jump_in_view(Application_Links *app, Partition *part, View_Summary *view, bool32 skip_sub_errors, int32_t direction, size_t *line_out, size_t *colon_index_out, Name_Based_Jump_Location *location_out){
int32_t result = false;
Name_Based_Jump_Location location = {0};
int32_t line = view->cursor.line;
int32_t colon_index = 0;
size_t line = view->cursor.line;
size_t colon_index = 0;
if (seek_next_jump_in_buffer(app, part, view->buffer_id, line+direction, skip_sub_errors, direction, &line, &colon_index, &location)){
result = true;
*line_out = line;
@ -117,7 +117,7 @@ advance_cursor_in_jump_view(Application_Links *app, Partition *part, View_Summar
Name_Based_Jump_Location location = {0};
ID_Based_Jump_Location jump = {0};
int32_t line = 0, colon_index = 0;
size_t line = 0, colon_index = 0;
do{
Temp_Memory temp = begin_temp_memory(part);

View File

@ -117,7 +117,7 @@ table_add(Table *table, void *item, void *arg, Hash_Function *hash_func, Compare
static i32_4tech
table_find_pos(Table *table, void *search_key, void *arg, i32_4tech *pos, i32_4tech *index, Hash_Function *hash_func, Compare_Function *comp_func){
Assert(((table->count!=0)?(table->count - 1):0) * 8 < table->max * 7);
Assert((table->count - 1) * 8 < table->max * 7);
u32_4tech hash = (hash_func(search_key, arg) | TableHashMin);
u32_4tech i = hash % table->max;

View File

@ -281,10 +281,10 @@ utf8_to_utf16_minimal_checking(u16_4tech *dst, umem_4tech max_wchars, u8_4tech *
static umem_4tech
utf16_to_utf8_minimal_checking(u8_4tech *dst, umem_4tech max_chars, u16_4tech *src, umem_4tech length, b32_4tech *error){
u16_4tech *s = src;
u16_4tech *s_end = s + length;
u16_4tech *s_end = s + max_chars;
u8_4tech *d = dst;
u8_4tech *d_end = d + max_chars;
u8_4tech *d_end = d + length;
umem_4tech limit = length;
umem_4tech needed_max = 0;

View File

@ -40,10 +40,10 @@ struct Search_Range{
int32_t type;
uint32_t flags;
int32_t buffer;
int32_t start;
int32_t size;
int32_t mid_start;
int32_t mid_size;
size_t start;
size_t size;
size_t mid_start;
size_t mid_size;
};
struct Search_Set{
@ -54,22 +54,22 @@ struct Search_Set{
struct Search_Iter{
String word;
int32_t pos;
int32_t back_pos;
int32_t i;
size_t pos;
size_t back_pos;
size_t i;
bool32 range_initialized;
};
struct Search_Match{
Buffer_Summary buffer;
int32_t start;
int32_t end;
size_t start;
size_t end;
bool32 found_match;
};
static void
search_iter_init(General_Memory *general, Search_Iter *iter, int32_t size){
int32_t str_max = size*2;
search_iter_init(General_Memory *general, Search_Iter *iter, size_t size){
size_t str_max = size*2;
if (iter->word.str == 0){
iter->word.str = (char*)general_memory_allocate(general, str_max);
iter->word.memory_size = (int32_t)str_max;
@ -91,7 +91,7 @@ search_set_init(General_Memory *general, Search_Set *set, int32_t range_count){
set->max = max;
}
else if (set->max < range_count){
int32_t mem_size = sizeof(Search_Range)*max;;
size_t mem_size = sizeof(Search_Range)*max;;
set->ranges = (Search_Range*)general_memory_reallocate_nocopy(general, set->ranges, mem_size);
set->max = max;
}
@ -174,14 +174,14 @@ search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *
return(result);
}
static int32_t
buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
static size_t
buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, size_t pos){
char space[1024];
Stream_Chunk chunk = {0};
if (init_stream_chunk(&chunk, app, buffer, pos, space, sizeof(space))){
bool32 still_looping = true;
do{
for (; pos < (int32_t)chunk.end; ++pos){
for (; pos < (size_t)chunk.end; ++pos){
char at_pos = chunk.data[pos];
if (!char_is_alpha_numeric(at_pos)) goto double_break;
}
@ -207,11 +207,11 @@ enum{
};
static int32_t
match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Match *result_ptr, String word){
match_check(Application_Links *app, Search_Range *range, size_t *pos, Search_Match *result_ptr, String word){
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
int32_t end_pos = range->start + range->size;
size_t end_pos = range->start + range->size;
uint32_t type = (range->flags & SearchFlag_MatchMask);
@ -281,14 +281,14 @@ match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Ma
}
static int32_t
search_front_to_back_step(Application_Links *app, Search_Range *range, String word, int32_t *pos, Search_Match *result_ptr){
search_front_to_back_step(Application_Links *app, Search_Range *range, String word, size_t *pos, Search_Match *result_ptr){
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
int32_t end_pos = range->start + range->size;
size_t end_pos = range->start + range->size;
if (*pos + word.size < end_pos){
int32_t start_pos = *pos;
size_t start_pos = *pos;
if (start_pos < range->start){
start_pos = range->start;
}
@ -298,7 +298,7 @@ search_front_to_back_step(Application_Links *app, Search_Range *range, String wo
result.buffer = get_buffer(app, range->buffer, AccessAll);
char *word_str = word.str;
int32_t word_size = (int32_t)word.size;
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);
}
@ -329,7 +329,7 @@ search_front_to_back_step(Application_Links *app, Search_Range *range, String wo
}
static int32_t
search_front_to_back(Application_Links *app, Search_Range *range, String word, int32_t *pos, Search_Match *result_ptr){
search_front_to_back(Application_Links *app, Search_Range *range, String word, size_t *pos, Search_Match *result_ptr){
int32_t found_match = FindResult_None;
for (;found_match == FindResult_None;){
found_match = search_front_to_back_step(app, range, word, pos, result_ptr);
@ -338,13 +338,13 @@ search_front_to_back(Application_Links *app, Search_Range *range, String word, i
}
static int32_t
search_back_to_front_step(Application_Links *app, Search_Range *range, String word, int32_t *pos, Search_Match *result_ptr){
search_back_to_front_step(Application_Links *app, Search_Range *range, String word, size_t *pos, Search_Match *result_ptr){
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
if (*pos > range->start){
int32_t start_pos = *pos;
size_t start_pos = *pos;
result.buffer = get_buffer(app, range->buffer, AccessAll);
buffer_seek_string_backward(app, &result.buffer,
@ -374,7 +374,7 @@ search_back_to_front_step(Application_Links *app, Search_Range *range, String wo
}
static int32_t
search_back_to_front(Application_Links *app, Search_Range *range, String word, int32_t *pos, Search_Match *result_ptr){
search_back_to_front(Application_Links *app, Search_Range *range, String word, size_t *pos, Search_Match *result_ptr){
int32_t found_match = FindResult_None;
for (;found_match == FindResult_None;){
found_match = search_back_to_front_step(app, range, word, pos, result_ptr);
@ -440,9 +440,9 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
if (backward_result == FindResult_FoundMatch){
find_result = FindResult_FoundMatch;
int32_t forward_start = range->mid_start + range->mid_size;
int32_t forward_distance = forward_match.start - forward_start;
int32_t backward_distance = range->mid_start - backward_match.end;
size_t forward_start = range->mid_start + range->mid_size;
size_t forward_distance = forward_match.start - forward_start;
size_t backward_distance = range->mid_start - backward_match.end;
if (backward_distance < forward_distance){
iter.pos = forward_match.start;
@ -713,8 +713,8 @@ struct Word_Complete_State{
Search_Iter iter;
Table hits;
String_Space str;
int32_t word_start;
int32_t word_end;
size_t word_start;
size_t word_end;
bool32 initialized;
};
@ -737,10 +737,10 @@ CUSTOM_COMMAND_SIG(word_complete){
do_init = true;
}
int32_t word_end = 0;
int32_t word_start = 0;
int32_t cursor_pos = 0;
int32_t size = 0;
size_t word_end = 0;
size_t word_start = 0;
size_t cursor_pos = 0;
size_t size = 0;
if (do_init){
// NOTE(allen): Get the range where the partial word is written.
@ -753,7 +753,7 @@ CUSTOM_COMMAND_SIG(word_complete){
if (init_stream_chunk(&chunk, app, &buffer, cursor_pos, space, sizeof(space))){
int32_t still_looping = true;
do{
for (; cursor_pos >= (int32_t)chunk.start; --cursor_pos){
for (; cursor_pos >= (size_t)chunk.start; --cursor_pos){
char c = chunk.data[cursor_pos];
if (char_is_alpha(c)){
word_start = cursor_pos;

View File

@ -349,7 +349,7 @@ cpp_lex_nonalloc_null_end_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, u32_4tech s
u8_4tech c = 0;
i32_4tech end_pos = size + S.chunk_pos;
u32_4tech end_pos = size + S.chunk_pos;
chunk -= S.chunk_pos;
switch (S.__pc__){
@ -970,7 +970,7 @@ cpp_lex_nonalloc_null_end_out_limit(Cpp_Lex_Data *S_ptr, char *chunk, i32_4tech
}
FCPP_LINK Cpp_Lex_Result
cpp_lex_nonalloc_no_null_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, i32_4tech size, i32_4tech full_size,
cpp_lex_nonalloc_no_null_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, u32_4tech size, u32_4tech full_size,
Cpp_Token_Array *token_array_out){
Cpp_Lex_Result result = 0;
if (S_ptr->pos >= full_size){
@ -1157,7 +1157,7 @@ cpp_index_array(Cpp_Token_Array *array, i32_4tech file_size, u32_4tech index){
}
API_EXPORT FCPP_LINK Cpp_Relex_Range
cpp_get_relex_range(Cpp_Token_Array *array, i32_4tech start_pos, i32_4tech end_pos)
cpp_get_relex_range(Cpp_Token_Array *array, u32_4tech start_pos, u32_4tech end_pos)
/*
DOC_PARAM(array, A pointer to the token array that will be modified by the relex, this array should already contain the tokens for the previous state of the file.)
DOC_PARAM(start_pos, The start position of the edited region of the file. The start and end points are based on the edited region of the file before the edit.)

View File

@ -237,10 +237,10 @@ STRUCT Cpp_Token{
Cpp_Token_Type type;
/* DOC(The start field indicates the index of the first character of this token's lexeme.) */
int32_t start;
uint32_t start;
/* DOC(The size field indicates the number of bytes in this token's lexeme.) */
int32_t size;
uint32_t size;
/* DOC(The state_flags should not be used outside of the lexer's implementation.) */
uint16_t state_flags;
@ -291,10 +291,10 @@ STRUCT Cpp_Get_Token_Result{
uint32_t in_whitespace;
/* DOC(If the token_index refers to an actual token, this is the start value of the token. Otherwise this is zero.) */
int32_t token_start;
uint32_t token_start;
/* DOC(If the token_index refers to an actual token, this is the start+size value of the token. Otherwise this is zero.) */
int32_t token_end;
uint32_t token_end;
};
/* DOC(Cpp_Relex_Range is the return result of the cpp_get_relex_range call.)
@ -321,12 +321,12 @@ DOC_SEE(cpp_lex_data_init)
HIDE_MEMBERS() */
STRUCT Cpp_Lex_Data{
char tb[32];
int32_t tb_pos;
int32_t token_start;
uint32_t tb_pos;
uint32_t token_start;
int32_t pos;
int32_t pos_overide;
int32_t chunk_pos;
uint32_t pos;
uint32_t pos_overide;
uint32_t chunk_pos;
Cpp_Lex_FSM fsm;
uint8_t white_done;

14
4ed.cpp
View File

@ -343,8 +343,8 @@ COMMAND_DECL(reopen){
General_Memory *general = &models->mem.general;
File_Edit_Positions edit_poss[16];
i32 line_number[16];
i32 column_number[16];
umem line_number[16];
umem column_number[16];
View *vptrs[16];
i32 vptr_count = 0;
for (View_Iter iter = file_view_iter_init(&models->layout, file, 0);
@ -364,8 +364,8 @@ COMMAND_DECL(reopen){
for (i32 i = 0; i < vptr_count; ++i){
view_set_file(system, vptrs[i], file, models);
i32 line = line_number[i];
i32 character = column_number[i];
umem line = line_number[i];
umem character = column_number[i];
*vptrs[i]->edit_pos = edit_poss[i];
Full_Cursor cursor = view_compute_cursor(system, vptrs[i], seek_line_char(line, character), 0);
@ -1597,8 +1597,8 @@ App_Step_Sig(app_step){
// NOTE(allen): check files are up to date
{
b32 mem_too_small = 0;
umem size = 0;
umem buffer_size = KB(32);
i32 size = 0;
i32 buffer_size = KB(32);
Partition *part = &models->mem.part;
Temp_Memory temp = begin_temp_memory(part);
@ -1612,7 +1612,7 @@ App_Step_Sig(app_step){
for (;system->get_file_change(buffer, buffer_size, &mem_too_small, &size);){
Assert(!mem_too_small);
Editing_File_Canon_Name canon;
if (get_canon_name(system, &canon, make_string(buffer, (i32)size))){
if (get_canon_name(system, &canon, make_string(buffer, size))){
Editing_File *file = working_set_canon_contains(working_set, canon.name);
if (file){
if (file->state.ignore_behind_os == 0){

View File

@ -347,7 +347,7 @@ DOC_SEE(Command_Line_Interface_Flag)
}
API_EXPORT void
Clipboard_Post(Application_Links *app, int32_t clipboard_id, char *str, uint32_t len)
Clipboard_Post(Application_Links *app, int32_t clipboard_id, char *str, size_t len)
/*
DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.)
DOC_PARAM(str, The str parameter specifies the string to be posted to the clipboard, it need not be null terminated.)
@ -379,8 +379,8 @@ DOC_SEE(The_4coder_Clipboard)
return(count);
}
API_EXPORT uint32_t
Clipboard_Index(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, uint32_t len)
API_EXPORT size_t
Clipboard_Index(Application_Links *app, uint32_t clipboard_id, uint32_t item_index, char *out, size_t len)
/*
DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.)
DOC_PARAM(item_index, This parameter specifies which item to read, 0 is the most recent copy, 1 is the second most recent copy, etc.)
@ -395,7 +395,7 @@ DOC_SEE(The_4coder_Clipboard)
Command_Data *cmd = (Command_Data*)app->cmd_context;
Working_Set *working = &cmd->models->working_set;
u32 size = 0;
size_t size = 0;
String *str = working_set_clipboard_index(working, item_index);
if (str){
size = str->size;

View File

@ -62,7 +62,7 @@
#include "4ed_file_view.cpp"
#include "4ed.cpp"
#include "4ed_font_static_functions.cpp"
#include "font/4coder_font_static_functions.cpp"
// BOTTOM

View File

@ -13,7 +13,7 @@
// Buffer low level operations
//
#include "4ed_font_data.h"
#include "font/4coder_font_data.h"
#include "4coder_helper/4coder_seek_types.h"
typedef struct Cursor_With_Index{
@ -314,9 +314,9 @@ typedef struct Gap_Buffer{
u32 size2;
u32 max;
i32 *line_starts;
i32 line_count;
i32 line_max;
u32 *line_starts;
u32 line_count;
u32 line_max;
} Gap_Buffer;
inline b32
@ -338,7 +338,7 @@ typedef struct Gap_Buffer_Init{
} Gap_Buffer_Init;
internal Gap_Buffer_Init
buffer_begin_init(Gap_Buffer *buffer, char *data, u32 size){
buffer_begin_init(Gap_Buffer *buffer, char *data, i32 size){
Gap_Buffer_Init init;
init.buffer = buffer;
init.data = data;
@ -349,7 +349,7 @@ buffer_begin_init(Gap_Buffer *buffer, char *data, u32 size){
internal b32
buffer_init_need_more(Gap_Buffer_Init *init){
b32 result = true;
if (init->buffer->data != 0){
if (init->buffer->data){
result = false;
}
return(result);
@ -369,15 +369,15 @@ buffer_init_provide_page(Gap_Buffer_Init *init, void *page, u32 page_size){
}
internal b32
buffer_end_init(Gap_Buffer_Init *init){
buffer_end_init(Gap_Buffer_Init *init, void *scratch, u32 scratch_size){
Gap_Buffer *buffer = init->buffer;
b32 result = false;
if (buffer->data != 0 && buffer->max >= init->size){
i32 size = init->size;
i32 size2 = size*2;
i32 osize1 = size - size2;
i32 size1 = osize1;
if (buffer->data && buffer->max >= init->size){
u32 size = init->size;
u32 size2 = size*2;
u32 osize1 = size - size2;
u32 size1 = osize1;
if (size1 > 0){
size1 = eol_convert_in(buffer->data, init->data, size1);
@ -400,8 +400,8 @@ buffer_end_init(Gap_Buffer_Init *init){
typedef struct Gap_Buffer_Stream{
Gap_Buffer *buffer;
char *data;
i32 end;
i32 absolute_end;
u32 end;
u32 absolute_end;
b32 separated;
b32 use_termination_character;
char terminator;
@ -629,15 +629,15 @@ buffer_convert_out(Gap_Buffer *buffer, char *dest, u32 max){
return(pos);
}
internal i32
buffer_count_newlines(Gap_Buffer *buffer, i32 start, i32 end){
internal u32
buffer_count_newlines(Gap_Buffer *buffer, u32 start, u32 end){
Gap_Buffer_Stream stream = {0};
i32 i = start;
i32 count = 0;
u32 i = start;
u32 count = 0;
assert(0 <= start);
assert(start <= end);
assert(end <= (i32)buffer_size(buffer));
assert(end <= buffer_size(buffer));
if (buffer_stringify_loop(&stream, buffer, i, end)){
b32 still_looping = 0;
@ -653,9 +653,9 @@ buffer_count_newlines(Gap_Buffer *buffer, i32 start, i32 end){
}
typedef struct Buffer_Measure_Starts{
i32 i;
i32 count;
i32 start;
u32 i;
u32 count;
u32 start;
} Buffer_Measure_Starts;
// TODO(allen): Rewrite this with a duff routine
@ -664,10 +664,10 @@ typedef struct Buffer_Measure_Starts{
internal b32
buffer_measure_starts(Buffer_Measure_Starts *state, Gap_Buffer *buffer){
Gap_Buffer_Stream stream = {0};
i32 size = (i32)buffer_size(buffer);
i32 start = state->start, i = state->i;
i32 *start_ptr = buffer->line_starts + state->count;
i32 *start_end = buffer->line_starts + buffer->line_max;
u32 size = (u32)buffer_size(buffer);
u32 start = state->start, i = state->i;
u32 *start_ptr = buffer->line_starts + state->count;
u32 *start_end = buffer->line_starts + buffer->line_max;
b32 result = true;
if (buffer_stringify_loop(&stream, buffer, i, size)){
@ -707,13 +707,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, i32 *character_starts, i32 mode, b32 virtual_white){
buffer_measure_character_starts(System_Functions *system, Render_Font *font, Gap_Buffer *buffer, u32 *character_starts, i32 mode, b32 virtual_white){
assert(mode == 0);
Gap_Buffer_Stream stream = {0};
i32 line_index = 0;
i32 character_index = 0;
u32 line_index = 0;
u32 character_index = 0;
character_starts[line_index++] = character_index;
@ -728,8 +728,8 @@ buffer_measure_character_starts(System_Functions *system, Render_Font *font, Gap
stream.use_termination_character = 1;
stream.terminator = '\n';
i32 size = (i32)buffer_size(buffer);
i32 i = 0;
u32 size = buffer_size(buffer);
u32 i = 0;
if (buffer_stringify_loop(&stream, buffer, i, size)){
b32 still_looping = false;
do{
@ -774,17 +774,17 @@ enum{
};
struct Buffer_Layout_Stop{
i32 status;
i32 line_index;
i32 wrap_line_index;
i32 pos;
i32 next_line_pos;
u32 status;
u32 line_index;
u32 wrap_line_index;
u32 pos;
u32 next_line_pos;
f32 x;
};
struct Buffer_Measure_Wrap_Params{
Gap_Buffer *buffer;
i32 *wrap_line_index;
u32 *wrap_line_index;
System_Functions *system;
Render_Font *font;
b32 virtual_white;
@ -792,17 +792,17 @@ struct Buffer_Measure_Wrap_Params{
struct Buffer_Measure_Wrap_State{
Gap_Buffer_Stream stream;
i32 i;
i32 size;
u32 i;
u32 size;
b32 still_looping;
i32 line_index;
u32 line_index;
i32 current_wrap_index;
u32 current_wrap_index;
f32 current_adv;
f32 x;
i32 wrap_unit_end;
u32 wrap_unit_end;
b32 skipping_whitespace;
b32 did_wrap;
b32 first_of_the_line;
@ -950,9 +950,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, i32 start_line, i32 end_line, i32 line_shift, i32 text_shift){
i32 *starts = buffer->line_starts;
i32 line_count = buffer->line_count;
buffer_remeasure_starts(Gap_Buffer *buffer, u32 start_line, u32 end_line, i32 line_shift, i32 text_shift){
u32 *starts = buffer->line_starts;
u32 line_count = buffer->line_count;
assert(0 <= start_line);
assert(start_line <= end_line);
@ -963,7 +963,7 @@ buffer_remeasure_starts(Gap_Buffer *buffer, i32 start_line, i32 end_line, i32 li
// Adjust
if (text_shift != 0){
i32 line_i = end_line;
u32 line_i = end_line;
starts += line_i;
for (; line_i < line_count; ++line_i, ++starts){
*starts += text_shift;
@ -972,8 +972,8 @@ buffer_remeasure_starts(Gap_Buffer *buffer, i32 start_line, i32 end_line, i32 li
}
// Shift
i32 new_line_count = line_count;
i32 new_end_line = end_line;
u32 new_line_count = line_count;
u32 new_end_line = end_line;
if (line_shift != 0){
new_line_count += line_shift;
new_end_line += line_shift;
@ -984,12 +984,12 @@ buffer_remeasure_starts(Gap_Buffer *buffer, i32 start_line, i32 end_line, i32 li
// Iteration data (yikes! Need better loop system)
Gap_Buffer_Stream stream = {0};
i32 size = buffer_size(buffer);
i32 char_i = starts[start_line];
i32 line_i = start_line;
u32 size = buffer_size(buffer);
u32 char_i = starts[start_line];
u32 line_i = start_line;
// Line start measurement
i32 start = char_i;
u32 start = char_i;
if (buffer_stringify_loop(&stream, buffer, char_i, size)){
b32 still_looping = 0;
@ -1023,10 +1023,10 @@ buffer_remeasure_starts(Gap_Buffer *buffer, i32 start_line, i32 end_line, i32 li
}
internal void
buffer_remeasure_character_starts(System_Functions *system, Render_Font *font, Gap_Buffer *buffer, i32 start_line, i32 end_line, i32 line_shift, i32 *character_starts, i32 mode, b32 virtual_whitespace){
buffer_remeasure_character_starts(System_Functions *system, Render_Font *font, Gap_Buffer *buffer, u32 start_line, u32 end_line, i32 line_shift, u32 *character_starts, i32 mode, b32 virtual_whitespace){
assert(mode == 0);
i32 new_line_count = buffer->line_count;
u32 new_line_count = buffer->line_count;
assert(0 <= start_line);
assert(start_line <= end_line);
@ -1035,23 +1035,24 @@ buffer_remeasure_character_starts(System_Functions *system, Render_Font *font, G
++end_line;
// Shift
i32 line_count = new_line_count;
i32 new_end_line = end_line;
u32 line_count = new_line_count;
u32 new_end_line = end_line;
if (line_shift != 0){
line_count -= line_shift;
new_end_line += line_shift;
memmove(character_starts + end_line + line_shift, character_starts + end_line, sizeof(i32)*(line_count - end_line + 1));
}
// Iteration data
Gap_Buffer_Stream stream = {0};
i32 size = buffer_size(buffer);
i32 char_i = buffer->line_starts[start_line];
i32 line_i = start_line;
u32 size = buffer_size(buffer);
u32 char_i = buffer->line_starts[start_line];
u32 line_i = start_line;
// Character measurement
i32 last_char_start = character_starts[line_i];
i32 current_char_start = last_char_start;
u32 last_char_start = character_starts[line_i];
u32 current_char_start = last_char_start;
b32 skipping_whitespace = false;
if (virtual_whitespace){
@ -1062,7 +1063,7 @@ buffer_remeasure_character_starts(System_Functions *system, Render_Font *font, G
Translation_State tran = {0};
Translation_Emits emits = {0};
stream.use_termination_character = true;
stream.use_termination_character = 1;
stream.terminator = '\n';
if (buffer_stringify_loop(&stream, buffer, char_i, size)){
b32 still_looping = 0;
@ -1125,8 +1126,8 @@ buffer_remeasure_character_starts(System_Functions *system, Render_Font *font, G
}
internal void
buffer_remeasure_wrap_y(Gap_Buffer *buffer, i32 start_line, i32 end_line, i32 line_shift, f32 *wraps, f32 font_height, f32 *adv, f32 max_width){
i32 new_line_count = buffer->line_count;
buffer_remeasure_wrap_y(Gap_Buffer *buffer, u32 start_line, u32 end_line, i32 line_shift, f32 *wraps, f32 font_height, f32 *adv, f32 max_width){
u32 new_line_count = buffer->line_count;
assert(0 <= start_line);
assert(start_line <= end_line);
@ -1135,8 +1136,8 @@ buffer_remeasure_wrap_y(Gap_Buffer *buffer, i32 start_line, i32 end_line, i32 li
++end_line;
// Shift
i32 line_count = new_line_count;
i32 new_end_line = end_line;
u32 line_count = new_line_count;
u32 new_end_line = end_line;
if (line_shift != 0){
line_count -= line_shift;
new_end_line += line_shift;
@ -1146,9 +1147,9 @@ buffer_remeasure_wrap_y(Gap_Buffer *buffer, i32 start_line, i32 end_line, i32 li
// Iteration data (yikes! Need better loop system)
Gap_Buffer_Stream stream = {0};
i32 size = buffer_size(buffer);
i32 char_i = buffer->line_starts[start_line];
i32 line_i = start_line;
u32 size = buffer_size(buffer);
u32 char_i = buffer->line_starts[start_line];
u32 line_i = start_line;
// Line wrap measurement
f32 last_wrap = wraps[line_i];
@ -1205,10 +1206,10 @@ buffer_remeasure_wrap_y(Gap_Buffer *buffer, i32 start_line, i32 end_line, i32 li
}
}
internal i32
binary_search(i32 *array, i32 value, i32 l_bound, i32 u_bound){
internal u32
binary_search(u32 *array, u32 value, u32 l_bound, u32 u_bound){
value = clamp_bottom(0, value);
i32 start = l_bound, end = u_bound, i = 0;
u32 start = l_bound, end = u_bound, i = 0;
for (;;){
i = (start + end) >> 1;
if (array[i] < value){
@ -1229,34 +1230,34 @@ binary_search(i32 *array, i32 value, i32 l_bound, i32 u_bound){
return(i);
}
inline i32
buffer_get_line_index_range(Gap_Buffer *buffer, i32 pos, i32 l_bound, i32 u_bound){
inline u32
buffer_get_line_index_range(Gap_Buffer *buffer, u32 pos, u32 l_bound, u32 u_bound){
assert(0 <= l_bound);
assert(l_bound <= u_bound);
assert(u_bound <= buffer->line_count);
assert(buffer->line_starts != 0);
i32 i = binary_search(buffer->line_starts, pos, l_bound, u_bound);
u32 i = binary_search(buffer->line_starts, pos, l_bound, u_bound);
return(i);
}
inline i32
buffer_get_line_index(Gap_Buffer *buffer, i32 pos){
i32 result = buffer_get_line_index_range(buffer, pos, 0, buffer->line_count);
inline u32
buffer_get_line_index(Gap_Buffer *buffer, u32 pos){
u32 result = buffer_get_line_index_range(buffer, pos, 0, buffer->line_count);
return(result);
}
inline i32
buffer_get_line_index_from_character_pos(i32 *character_starts, i32 pos, i32 l_bound, i32 u_bound){
i32 i = binary_search(character_starts, pos, l_bound, u_bound);
inline u32
buffer_get_line_index_from_character_pos(u32 *character_starts, u32 pos, u32 l_bound, u32 u_bound){
u32 i = binary_search(character_starts, pos, l_bound, u_bound);
return(i);
}
inline i32
buffer_get_line_index_from_wrapped_y(i32 *wrap_line_index, f32 y, i32 line_height, i32 l_bound, i32 u_bound){
i32 wrap_index = floor32(y/line_height);
i32 i = binary_search(wrap_line_index, wrap_index, l_bound, u_bound);
inline u32
buffer_get_line_index_from_wrapped_y(u32 *wrap_line_index, f32 y, i32 line_height, u32 l_bound, u32 u_bound){
u32 wrap_index = floor32(y/line_height);
u32 i = binary_search(wrap_line_index, wrap_index, l_bound, u_bound);
return(i);
}
@ -1276,10 +1277,10 @@ buffer_partial_from_pos(Gap_Buffer *buffer, u32 pos){
}
internal Partial_Cursor
buffer_partial_from_line_character(Gap_Buffer *buffer, i32 line, i32 character, b32 reversed){
buffer_partial_from_line_character(Gap_Buffer *buffer, u32 line, u32 character, b32 reversed){
Partial_Cursor result = {0};
i32 line_index = line - 1;
u32 line_index = line - 1;
if (line_index >= buffer->line_count){
line_index = buffer->line_count - 1;
}
@ -1287,16 +1288,16 @@ buffer_partial_from_line_character(Gap_Buffer *buffer, i32 line, i32 character,
line_index = 0;
}
i32 size = buffer_size(buffer);
u32 size = buffer_size(buffer);
i32 this_start = buffer->line_starts[line_index];
i32 max_character = (size-this_start) + 1;
u32 this_start = buffer->line_starts[line_index];
u32 max_character = (size-this_start) + 1;
if (line_index+1 < buffer->line_count){
i32 next_start = buffer->line_starts[line_index+1];
u32 next_start = buffer->line_starts[line_index+1];
max_character = (next_start-this_start);
}
i32 adjusted_pos = 0;
u32 adjusted_pos = 0;
if (character > 0){
if (reversed){
if (character > max_character){
@ -1331,8 +1332,8 @@ struct Buffer_Cursor_Seek_Params{
Buffer_Seek seek;
System_Functions *system;
Render_Font *font;
i32 *wrap_line_index;
i32 *character_starts;
u32 *wrap_line_index;
u32 *character_starts;
b32 virtual_white;
b32 return_hint;
Full_Cursor *cursor_out;
@ -1345,9 +1346,9 @@ struct Buffer_Cursor_Seek_State{
Gap_Buffer_Stream stream;
b32 still_looping;
i32 i;
i32 size;
i32 wrap_unit_end;
u32 i;
u32 size;
u32 wrap_unit_end;
b32 first_of_the_line;
b32 xy_seek;
@ -1371,7 +1372,7 @@ struct Buffer_Cursor_Seek_State{
#define DrReturn(n) { *S_ptr = S; S_ptr->__pc__ = -1; return(n); }
internal Buffer_Layout_Stop
buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params params, f32 line_shift, b32 do_wrap, i32 wrap_unit_end){
buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params params, f32 line_shift, b32 do_wrap, u32 wrap_unit_end){
Buffer_Cursor_Seek_State S = *S_ptr;
Buffer_Layout_Stop S_stop;
@ -1385,11 +1386,11 @@ 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 = (i32)buffer_size(params.buffer);
S.size = (u32)buffer_size(params.buffer);
// Get cursor hint
{
i32 line_index = 0;
u32 line_index = 0;
switch (params.seek.type){
case buffer_seek_pos:
{
@ -1400,25 +1401,25 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
case buffer_seek_character_pos:
{
i32 line_count = params.buffer->line_count;
i32 max_character = params.character_starts[line_count] - 1;
params.seek.pos = clamp_i32(0, (i32)params.seek.pos, max_character);
u32 line_count = params.buffer->line_count;
u32 max_character = params.character_starts[line_count] - 1;
params.seek.pos = clamp_u32(0, (u32)params.seek.pos, max_character);
i32 *char_starts = params.character_starts;
u32 *char_starts = params.character_starts;
i32 pos = (i32)params.seek.pos;
u32 pos = (u32)params.seek.pos;
line_index = buffer_get_line_index_from_character_pos(char_starts, pos, 0, line_count);
}break;
case buffer_seek_line_char:
{
line_index = params.seek.line - 1;
line_index = (u32)params.seek.line - 1;
line_index = clamp_bottom(0, line_index);
}break;
case buffer_seek_unwrapped_xy:
{
line_index = (i32)(params.seek.y / S.font_height);
line_index = (u32)(params.seek.y / S.font_height);
line_index = clamp_bottom(0, line_index);
}break;
@ -1430,7 +1431,7 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
default: InvalidCodePath;
}
i32 safe_line_index = line_index;
u32 safe_line_index = line_index;
if (line_index >= params.buffer->line_count){
safe_line_index = params.buffer->line_count-1;
}
@ -1820,8 +1821,8 @@ struct Buffer_Render_Params{
struct Buffer_Render_State{
Gap_Buffer_Stream stream;
b32 still_looping;
i32 i;
i32 size;
u32 i;
u32 size;
f32 shift_x;
f32 shift_y;
@ -1831,9 +1832,9 @@ struct Buffer_Render_State{
Render_Item_Write write;
f32 byte_advance;
i32 line;
i32 wrap_line;
i32 wrap_unit_end;
u32 line;
u32 wrap_line;
u32 wrap_unit_end;
b32 skipping_whitespace;
b32 first_of_the_line;

View File

@ -15,8 +15,8 @@
struct Buffer_Model_Step{
u32 type;
u32 value;
i32 i;
i32 byte_length;
u32 i;
u32 byte_length;
};
struct Buffer_Model_Behavior{

View File

@ -21,7 +21,7 @@ enum Edit_Pos_Set_Type{
struct File_Edit_Positions{
GUI_Scroll_Vars scroll;
Full_Cursor cursor;
i32 mark;
u32 mark;
f32 preferred_x;
i32 scroll_i;
i32 last_set_type;
@ -54,7 +54,7 @@ edit_pos_set_scroll(File_Edit_Positions *edit_pos, GUI_Scroll_Vars scroll){
//
struct Text_Effect{
i32 start, end;
u32 start, end;
u32 color;
f32 seconds_down, seconds_max;
};
@ -109,20 +109,20 @@ global_const Editing_File_Settings null_editing_file_settings = {0};
struct Editing_File_State{
Gap_Buffer buffer;
i32 *wrap_line_index;
i32 wrap_max;
u32 *wrap_line_index;
u32 wrap_max;
i32 *character_starts;
i32 character_start_max;
u32 *character_starts;
u32 character_start_max;
f32 *line_indents;
i32 line_indent_max;
u32 line_indent_max;
i32 wrap_line_count;
u32 wrap_line_count;
i32 *wrap_positions;
i32 wrap_position_count;
i32 wrap_position_max;
u32 *wrap_positions;
u32 wrap_position_count;
u32 wrap_position_max;
Undo_Data undo;

View File

@ -46,7 +46,7 @@ FILE_TRACK_LINK File_Track_Result
expand_track_system_listeners(File_Track_System *system, Partition *scratch, void *mem, umem size);
FILE_TRACK_LINK File_Track_Result
get_change_event(File_Track_System *system, Partition *scratch, u8 *buffer, umem max, umem *size);
get_change_event(File_Track_System *system, Partition *scratch, u8 *buffer, umem max);
FILE_TRACK_LINK File_Track_Result
shut_down_track_system(File_Track_System *system, Partition *scratch);

View File

@ -402,11 +402,11 @@ view_compute_cursor(System_Functions *system, View *view, Buffer_Seek seek, b32
Buffer_Cursor_Seek_State state = {0};
Buffer_Layout_Stop stop = {0};
i32 size = buffer_size(params.buffer);
u32 size = buffer_size(params.buffer);
f32 line_shift = 0.f;
i32 wrap_unit_end = 0;
i32 wrap_array_index = 0;
u32 wrap_unit_end = 0;
u32 wrap_array_index = 0;
b32 do_wrap = false;
b32 first_wrap_determination = true;
@ -849,14 +849,14 @@ enum{
internal i32
file_grow_starts_as_needed(General_Memory *general, Gap_Buffer *buffer, i32 additional_lines){
b32 result = GROW_NOT_NEEDED;
i32 max = buffer->line_max;
i32 count = buffer->line_count;
i32 target_lines = count + additional_lines;
u32 max = buffer->line_max;
u32 count = buffer->line_count;
u32 target_lines = count + additional_lines;
if (target_lines > max || max == 0){
max = l_round_up_u32(target_lines + max, KB(1));
i32 *new_lines = (i32*)general_memory_reallocate(general, buffer->line_starts, sizeof(i32)*count, sizeof(i32)*max);
u32 *new_lines = (u32*)general_memory_reallocate(general, buffer->line_starts, sizeof(u32)*count, sizeof(u32)*max);
if (new_lines){
result = GROW_SUCCESS;
@ -896,20 +896,20 @@ file_update_cursor_positions(System_Functions *system, Models *models, Editing_F
internal void
file_measure_starts(General_Memory *general, Gap_Buffer *buffer){
if (!buffer->line_starts){
i32 max = buffer->line_max = KB(1);
buffer->line_starts = (i32*)general_memory_allocate(general, max*sizeof(i32));
u32 max = buffer->line_max = KB(1);
buffer->line_starts = (u32*)general_memory_allocate(general, max*sizeof(u32));
TentativeAssert(buffer->line_starts != 0);
// TODO(allen): when unable to allocate?
}
Buffer_Measure_Starts state = {0};
while (buffer_measure_starts(&state, buffer)){
i32 count = state.count;
i32 max = buffer->line_max;
u32 count = state.count;
u32 max = buffer->line_max;
max = ((max + 1) << 1);
{
i32 *new_lines = (i32*)general_memory_reallocate(general, buffer->line_starts, sizeof(i32)*count, sizeof(i32)*max);
u32 *new_lines = (u32*)general_memory_reallocate(general, buffer->line_starts, sizeof(u32)*count, sizeof(u32)*max);
// TODO(allen): when unable to grow?
TentativeAssert(new_lines);
@ -921,16 +921,16 @@ 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.
internal void
file_allocate_metadata_as_needed(General_Memory *general, Gap_Buffer *buffer, void **mem, i32 *mem_max_count, i32 count, i32 item_size){
file_allocate_metadata_as_needed(General_Memory *general, Gap_Buffer *buffer, void **mem, u32 *mem_max_count, u32 count, u32 item_size){
if (*mem == 0){
i32 max = ((count+1)*2);
u32 max = ((count+1)*2);
max = (max+(0x3FF))&(~(0x3FF));
*mem = general_memory_allocate(general, max*item_size);
*mem_max_count = max;
}
else if (*mem_max_count < count){
i32 old_max = *mem_max_count;
i32 max = ((count+1)*2);
u32 old_max = *mem_max_count;
u32 max = ((count+1)*2);
max = (max+(0x3FF))&(~(0x3FF));
void *new_mem = general_memory_reallocate(general, *mem, item_size*old_max, item_size*max);
@ -989,16 +989,16 @@ struct Code_Wrap_State{
b32 in_pp_body;
Code_Wrap_X plane_wrap_x;
i32 *line_starts;
i32 line_index;
i32 next_line_start;
u32 *line_starts;
u32 line_index;
u32 next_line_start;
f32 x;
b32 consume_newline;
Gap_Buffer_Stream stream;
i32 size;
i32 i;
u32 size;
u32 i;
Render_Font *font;
f32 tab_indent_amount;
@ -1052,8 +1052,8 @@ wrap_state_set_top(Code_Wrap_State *state, f32 line_shift){
}
struct Code_Wrap_Step{
i32 position_start;
i32 position_end;
u32 position_start;
u32 position_end;
f32 start_x;
f32 final_x;
@ -1062,9 +1062,9 @@ struct Code_Wrap_Step{
};
internal Code_Wrap_Step
wrap_state_consume_token(System_Functions *system, Render_Font *font, Code_Wrap_State *state, i32 fixed_end_point){
wrap_state_consume_token(System_Functions *system, Render_Font *font, Code_Wrap_State *state, u32 fixed_end_point){
Code_Wrap_Step result = {0};
i32 i = state->i;
u32 i = state->i;
result.position_start = i;
@ -1102,9 +1102,9 @@ wrap_state_consume_token(System_Functions *system, Render_Font *font, Code_Wrap_
state->next_line_start = state->line_starts[state->line_index + 1];
}
i32 line_start = state->line_starts[state->line_index];
u32 line_start = state->line_starts[state->line_index];
b32 still_looping = 0;
i32 end = state->token_ptr->start + state->token_ptr->size;
u32 end = state->token_ptr->start + state->token_ptr->size;
if (fixed_end_point >= 0 && end > fixed_end_point){
end = fixed_end_point;
@ -1391,7 +1391,7 @@ struct Wrap_Current_Shift{
};
internal Wrap_Current_Shift
get_current_shift(Code_Wrap_State *wrap_state, i32 next_line_start){
get_current_shift(Code_Wrap_State *wrap_state, u32 next_line_start){
Wrap_Current_Shift result = {0};
result.shift = wrap_state->wrap_x.paren_nesting[wrap_state->wrap_x.paren_safe_top];
@ -1531,7 +1531,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
Gap_Buffer_Stream stream = {0};
u32 word_stage = 0;
i32 i = stop.pos;
u32 i = stop.pos;
f32 x = stop.x;
f32 self_x = 0;
if (buffer_stringify_loop(&stream, params.buffer, i, size)){
@ -1589,7 +1589,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
if (use_tokens){
Code_Wrap_State original_wrap_state = wrap_state;
i32 next_line_start = buffer_size(params.buffer);
u32 next_line_start = buffer_size(params.buffer);
if (stop.line_index+1 < params.buffer->line_count){
next_line_start = params.buffer->line_starts[stop.line_index+1];
}
@ -1626,11 +1626,11 @@ 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;
i = clamp_bottom(wrap_state.i, i);
end_i = clamp_top(end_i, wrap_state.next_line_start);
i = clamp_bottom((u32)wrap_state.i, i);
end_i = clamp_top(end_i, (u32)wrap_state.next_line_start);
f32 x = wrap_state.x;
@ -1734,7 +1734,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
next_token_is_on_line = true;
}
i32 next_wrap_position = step.position_end;
u32 next_wrap_position = (u32)step.position_end;
f32 wrap_x = step.final_x;
if (wrap_state.token_ptr->start > step.position_start && next_wrap_position < wrap_state.token_ptr->start && next_token_is_on_line){
next_wrap_position = wrap_state.token_ptr->start;
@ -1826,7 +1826,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
}
}
i32 wrap_position = potential_marks[best_i].wrap_position;
u32 wrap_position = potential_marks[best_i].wrap_position;
f32 line_shift = potential_marks[best_i].line_shift;
b32 adjust_top_to_this = potential_marks[best_i].adjust_top_to_this;
wrap_indent_marks[real_count].wrap_position = wrap_position;
@ -1924,6 +1924,7 @@ 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){
General_Memory *general = &models->mem.general;
Partition *part = &models->mem.part;
Open_File_Hook_Function *hook_open_file = models->hook_open_file;
Application_Links *app_links = &models->app_links;
@ -1939,7 +1940,9 @@ file_create_from_string(System_Functions *system, Models *models, Editing_File *
buffer_init_provide_page(&init, data, page_size);
}
b32 init_success = buffer_end_init(&init);
u32 scratch_size = (u32)partition_remaining(part);
Assert(scratch_size > 0);
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){
@ -2278,7 +2281,7 @@ file_first_lex_serial(Mem_Options *mem, Editing_File *file){
}
internal b32
file_relex_parallel(System_Functions *system, Mem_Options *mem, Editing_File *file, i32 start_i, i32 end_i, i32 shift_amount){
file_relex_parallel(System_Functions *system, Mem_Options *mem, Editing_File *file, u32 start_i, u32 end_i, i32 shift_amount){
General_Memory *general = &mem->general;
Partition *part = &mem->part;
@ -3429,7 +3432,7 @@ view_replace_range(System_Functions *system, Models *models, View *view,
}
inline void
view_post_paste_effect(View *view, f32 seconds, i32 start, i32 size, i32 color){
view_post_paste_effect(View *view, f32 seconds, u32 start, u32 size, u32 color){
Editing_File *file = view->file_data.file;
file->state.paste_effect.start = start;
@ -5967,7 +5970,7 @@ draw_file_loaded(System_Functions *system, View *view, i32_Rect rect, b32 is_act
f32 line_shift = 0.f;
b32 do_wrap = false;
i32 wrap_unit_end = 0;
u32 wrap_unit_end = 0;
b32 first_wrap_determination = true;
u32 wrap_array_index = 0;
@ -6007,7 +6010,7 @@ draw_file_loaded(System_Functions *system, View *view, i32_Rect rect, b32 is_act
}while(stop.status != BLStatus_Finished);
}
i32 cursor_begin = 0, cursor_end = 0;
u32 cursor_begin = 0, cursor_end = 0;
u32 cursor_color = 0, at_cursor_color = 0;
if (view->file_data.show_temp_highlight){
cursor_begin = (u32)view->file_data.temp_highlight.pos;
@ -6035,12 +6038,12 @@ draw_file_loaded(System_Functions *system, View *view, i32_Rect rect, b32 is_act
u32 mark_color = style->main.mark_color;
Buffer_Render_Item *item = items;
Buffer_Render_Item *item_end = item + count;
i32 prev_ind = max_i32;
u32 prev_ind = max_u32;
u32 highlight_color = 0;
u32 highlight_this_color = 0;
for (; item < item_end; ++item){
i32 ind = item->index;
u32 ind = item->index;
highlight_this_color = 0;
if (tokens_use && ind != prev_ind){
Cpp_Token current_token = token_array.tokens[token_i-1];
@ -6100,7 +6103,9 @@ draw_file_loaded(System_Functions *system, View *view, i32_Rect rect, b32 is_act
u32 fade_color = 0xFFFF00FF;
f32 fade_amount = 0.f;
if (file->state.paste_effect.seconds_down > 0.f && file->state.paste_effect.start <= ind && ind < file->state.paste_effect.end){
if (file->state.paste_effect.seconds_down > 0.f &&
file->state.paste_effect.start <= ind &&
ind < file->state.paste_effect.end){
fade_color = file->state.paste_effect.color;
fade_amount = file->state.paste_effect.seconds_down;
fade_amount /= file->state.paste_effect.seconds_max;

View File

@ -1,59 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 03.03.2017
*
* Font data type definitions.
*
*/
// TOP
#if !defined(FCODER_FONT_DATA_H)
#define FCODER_FONT_DATA_H
#define ITEM_PER_FONT_PAGE 256
struct Glyph_Bounds{
f32 x0, x1;
f32 y0, y1;
f32 xoff, yoff;
f32 xoff2, yoff2;
};
global_const Glyph_Bounds null_glyph_bounds = {0};
struct Glyph_Page{
u32 page_number;
f32 advance[ITEM_PER_FONT_PAGE];
Glyph_Bounds glyphs[ITEM_PER_FONT_PAGE];
u32 tex;
i32 tex_width, tex_height;
};
#define FONT_PAGE_EMPTY ((Glyph_Page*)0)
#define FONT_PAGE_DELETED ((Glyph_Page*)(1))
#define FONT_PAGE_MAX 0x1100
struct Render_Font{
Glyph_Page **pages;
u32 page_count, page_max;
f32 byte_advance;
f32 byte_sub_advances[3];
i32 height, ascent, descent, line_skip, advance;
u32 filename_len;
u32 name_len;
char filename[256];
char name[256];
};
struct Glyph_Data{
Glyph_Bounds bounds;
u32 tex;
i32 tex_width, tex_height;
};
#endif
// BOTTOM

View File

@ -1,76 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 11.03.2017
*
* Font system interface.
*
*/
// TOP
#if !defined(FCODER_FONT_INTERFACE_H)
#define FCODER_FONT_INTERFACE_H
typedef u32 Font_ID;
struct Render_Font;
struct Glyph_Page;
#define Sys_Font_Get_Count_Sig(name_) u32 (name_)(void)
typedef Sys_Font_Get_Count_Sig(Font_Get_Count_Function);
#define Sys_Font_Get_IDs_By_Index_Sig(name_) b32 (name_)(u32 first_index, u32 index_count, u32 *id_out)
typedef Sys_Font_Get_IDs_By_Index_Sig(Font_Get_IDs_By_Index_Function);
#define Sys_Font_Get_Name_By_Index_Sig(name_) u32 (name_)(u32 font_index, char *str_out, u32 str_out_cap)
typedef Sys_Font_Get_Name_By_Index_Sig(Font_Get_Name_By_Index_Function);
#define Sys_Font_Get_Name_By_ID_Sig(name_) u32 (name_)(u32 font_id, char *str_out, u32 str_out_cap)
typedef Sys_Font_Get_Name_By_ID_Sig(Font_Get_Name_By_ID_Function);
#define Sys_Font_Get_Render_Data_By_ID_Sig(name_) Render_Font* (name_)(u32 font_id)
typedef Sys_Font_Get_Render_Data_By_ID_Sig(Font_Get_Render_Data_By_ID_Function);
#define Sys_Font_Load_Page_Sig(name_) void (name_)(Render_Font *font, Glyph_Page *page, u32 page_number)
typedef Sys_Font_Load_Page_Sig(Font_Load_Page_Function);
#define Sys_Font_Allocate_Sig(name_) void* (name_)(i32 size)
typedef Sys_Font_Allocate_Sig(Font_Allocate_Function);
#define Sys_Font_Free_Sig(name_) void (name_)(void *ptr)
typedef Sys_Font_Free_Sig(Font_Free_Function);
struct Font_Functions{
Font_Get_Count_Function *get_count;
Font_Get_IDs_By_Index_Function *get_ids_by_index;
Font_Get_Name_By_Index_Function *get_name_by_index;
Font_Get_Name_By_ID_Function *get_name_by_id;
Font_Get_Render_Data_By_ID_Function *get_render_data_by_id;
Font_Load_Page_Function *load_page;
Font_Allocate_Function *allocate;
Font_Free_Function *free;
};
internal f32 font_get_byte_advance(Render_Font *font);
internal f32*font_get_byte_sub_advances(Render_Font *font);
internal i32 font_get_height(Render_Font *font);
internal i32 font_get_ascent(Render_Font *font);
internal i32 font_get_descent(Render_Font *font);
internal i32 font_get_line_skip(Render_Font *font);
internal i32 font_get_advance(Render_Font *font);
internal b32 font_can_render(struct System_Functions *system, Render_Font *font, u32 codepoint);
internal f32 font_get_glyph_advance(struct System_Functions *system, Render_Font *font, u32 codepoint);
struct Glyph_Data;
internal Glyph_Data font_get_glyph(System_Functions *system, Render_Font *font, u32 codepoint);
internal Glyph_Page *font_get_or_make_page(struct System_Functions *system, Render_Font *font, u32 page_number);
#endif
// BOTTOM

View File

@ -1,23 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 13.03.2017
*
* Font system interface to the OS layer.
*
*/
// TOP
#if !defined(FCODER_FONT_INTERFACE_TO_OS_H)
#define FCODER_FONT_INTERFACE_TO_OS_H
#define Sys_Font_Init_Sig(name_) void (name_)(Font_Functions *font, void *memory, umem memory_size, u32 font_size, b32 use_hinting)
internal Sys_Font_Init_Sig(system_font_init);
#endif
// BOTTOM

View File

@ -1,493 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 10.03.2017
*
* Where I save crappy old font stuff.
*
*/
// TOP
#include "font/4coder_font_data.h"
struct Font_Table_Entry{
u32 hash;
String name;
Font_ID font_id;
};
struct Font_Info{
Render_Font *font;
String filename;
String name;
i32 pt_size;
};
struct Font_Slot{
Font_Slot *next, *prev;
Font_ID font_id;
u8 padding[6];
};
global_const Font_Slot null_font_slot = {0};
#define Font_Load_Sig(name)\
i32 name(Render_Font *font_out, char *filename, char *fontname, i32 pt_size, i32 tab_width, b32 store_texture)
typedef Font_Load_Sig(Font_Load);
#define Font_Load_Page_Sig(name)\
i32 name(Render_Font *font, Glyph_Page *page, char *filename, i32 pt_size, i32 tab_width)
typedef Font_Load_Page_Sig(Font_Load_Page);
#define Release_Font_Sig(name) void name(Render_Font *font)
typedef Release_Font_Sig(Release_Font);
struct Font_Set{
Font_Info *info;
Font_Table_Entry *entries;
u32 count, max;
void *font_block;
Font_Slot free_slots;
Font_Slot used_slots;
Font_Load *font_load;
Font_Load_Page *font_load_page;
Release_Font *release_font;
b8 *font_used_flags;
Font_ID used_this_frame;
Font_ID live_max;
};
inline Font_Info*
get_font_info(Font_Set *set, Font_ID font_id){
Font_Info *result = set->info + font_id - 1;
return(result);
}
internal void
font_set_begin_render(Font_Set *font_set){
font_set->used_this_frame = 0;
memset(font_set->font_used_flags, 0, font_set->max);
}
inline u32
font_hash(String name){
u32 x = 5381;
char *p = name.str;
for (i32 i = 0; i < name.size; ++i, ++p){
x = ((x << 5) + x) ^ (*p);
}
return(x);
}
inline void
font__insert(Font_Slot *pos, Font_Slot *slot){
Font_Slot *nex;
nex = pos->next;
slot->next = nex;
slot->prev = pos;
nex->prev = slot;
pos->next = slot;
}
inline void
font__remove(Font_Slot *slot){
Font_Slot *n, *p;
n = slot->next;
p = slot->prev;
p->next = n;
n->prev = p;
}
internal void
font_set_init(Font_Set *set, Partition *partition, i32 max, Font_ID live_max){
partition_align(partition, 8);
set->info = push_array(partition, Font_Info, max);
partition_align(partition, 8);
set->entries = push_array(partition, Font_Table_Entry, max);
set->count = 0;
set->max = max;
partition_align(partition, 8);
set->font_block = push_block(partition, live_max*(sizeof(Render_Font) + sizeof(Font_Slot)));
set->free_slots = null_font_slot;
set->used_slots = null_font_slot;
dll_init_sentinel(&set->free_slots);
dll_init_sentinel(&set->used_slots);
char *ptr = (char*)set->font_block;
for (i32 i = 0; i < live_max; ++i){
dll_insert(&set->free_slots, (Font_Slot*)ptr);
ptr += sizeof(Font_Slot) + sizeof(Render_Font);
}
set->font_used_flags = push_array(partition, b8, max);
set->live_max = live_max;
}
internal b32
font_set_can_add(Font_Set *set){
b32 result = 0;
if (set->count*8 < set->max*7) result = 1;
return(result);
}
internal void
font_set_add_hash(Font_Set *set, String name, Font_ID font_id){
Font_Table_Entry entry;
entry.hash = font_hash(name);
entry.name = name;
entry.font_id = font_id;
u32 i = entry.hash % set->max;
u32 j = i - 1;
if (i <= 1) j += set->max;
for (; i != j; ++i){
if (i == set->max) i = 0;
if (set->entries[i].font_id == 0){
set->entries[i] = entry;
break;
}
}
Assert(i != j);
}
inline b32
font_set_can_load(Font_Set *set){
b32 result = (set->free_slots.next != &set->free_slots);
return(result);
}
internal void
font_set_load(Font_Set *set, Font_ID font_id){
Font_Info *info = get_font_info(set, font_id);
Font_Slot *slot = set->free_slots.next;
Assert(slot != &set->free_slots);
font__remove(slot);
font__insert(&set->used_slots, slot);
Render_Font *font = (Render_Font*)(slot + 1);
set->font_load(font, info->filename.str, info->name.str, info->pt_size, 4, true);
info->font = font;
slot->font_id = font_id;
}
internal void
font_set_evict_lru(Font_Set *set){
Font_Slot *slot = set->used_slots.prev;
Assert(slot != &set->used_slots);
Font_ID font_id = slot->font_id;
Font_Info *info = get_font_info(set, font_id);
Assert(((Font_Slot*)info->font) - 1 == slot);
set->release_font(info->font);
info->font = 0;
slot->font_id = 0;
font__remove(slot);
font__insert(&set->free_slots, slot);
}
internal void
font_set_use(Font_Set *set, Font_ID font_id){
b8 already_used = set->font_used_flags[font_id-1];
if (!already_used){
if (set->used_this_frame < set->live_max){
++set->used_this_frame;
set->font_used_flags[font_id-1] = 1;
already_used = 1;
}
}
if (already_used){
// TODO(allen): optimize if you don't mind!!!!
Font_Info *info = get_font_info(set, font_id);
Font_Slot *slot;
if (info->font == 0){
if (!font_set_can_load(set)){
font_set_evict_lru(set);
}
font_set_load(set, font_id);
}
slot = ((Font_Slot*)info->font) - 1;
font__remove(slot);
font__insert(&set->used_slots, slot);
}
}
internal b32
font_set_add(Font_Set *set, String filename, String name, i32 pt_size){
b32 result = false;
if (font_set_can_add(set)){
Render_Font dummy_font = {0};
Font_ID font_id = (i16)(++set->count);
Font_Info *info = get_font_info(set, font_id);
info->filename = filename;
info->name = name;
info->pt_size = pt_size;
set->font_load(&dummy_font, info->filename.str, info->name.str, info->pt_size, 4, false);
font_set_add_hash(set, name, font_id);
if (font_set_can_load(set)){
font_set_load(set, font_id);
}
result = true;
}
return(result);
}
internal b32
font_set_find_pos(Font_Set *set, String name, u32 *position){
u32 hash = font_hash(name);
u32 i = hash % set->max;
u32 j = i - 1;
if (j <= 1){
j += set->max;
}
b32 result = 0;
for (; i != j; ++i){
if (i == set->max){
i = 0;
}
Font_Table_Entry *entry = set->entries + i;
if (entry->hash == hash){
if (match_ss(name, entry->name)){
result = 1;
*position = i;
break;
}
}
}
return(result);
}
internal b32
font_set_get_name(Font_Set *set, Font_ID font_id, String *name){
Font_Info *info = get_font_info(set, font_id);
b32 result = copy_checked_ss(name, info->name);
return(result);
}
internal b32
font_set_extract(Font_Set *set, String name, Font_ID *font_id){
u32 position;
b32 result = font_set_find_pos(set, name, &position);
if (result){
*font_id = set->entries[position].font_id;
}
return(result);
}
//////////////////////////////////
internal b32
get_codepoint_can_render(Render_Font *font, u32 codepoint){
b32 exists = false;
if (codepoint < 0x10FFFF){
exists = true;
}
return(exists);
}
struct Codepoint_Indexes{
b32 exists;
u32 page_number;
u32 glyph_index;
};
internal Codepoint_Indexes
get_codepoint_page_number(Render_Font *font, u32 codepoint){
Codepoint_Indexes result = {0};
u32 page_number = (codepoint >> 8);
if (page_number <= 0x10FF){
result.exists = true;
result.page_number = page_number;
result.glyph_index = (codepoint & 0x000000FF);
}
return(result);
}
#define MAX_PAGE_COUNT (u32)(0x1100)
#define GLYPH_PAGE_EMPTY ((Glyph_Page*)(0))
#define GLYPH_PAGE_DELETED ((Glyph_Page*)(max_u64))
#define IS_REAL_FONT_PAGE(p) (((p) != GLYPH_PAGE_EMPTY) && ((p) != GLYPH_PAGE_DELETED))
internal Glyph_Page**
font_lookup_page(Render_Font *font, u32 page_number, b32 find_empty_slot){
Glyph_Page **result = 0;
if (font->page_max > 0){
u32 first_index = page_number % font->page_max;
u32 range_count = 0;
u32 ranges[4];
if (first_index == 0){
ranges[0] = 0;
ranges[1] = font->page_max;
range_count = 2;
}
else{
ranges[0] = first_index;
ranges[1] = font->page_max;
ranges[2] = 0;
ranges[3] = first_index;
range_count = 4;
}
if (find_empty_slot){
for(u32 j = 0; j < range_count; j += 2){
u32 start = ranges[j];
u32 stop = ranges[j+1];
for (u32 i = start; i < stop; ++i){
Glyph_Page *ptr = font->pages[i];
if (ptr == GLYPH_PAGE_EMPTY || ptr == GLYPH_PAGE_DELETED){
result = &font->pages[i];
goto break2;
}
if (ptr->page_number == page_number){
goto break2;
}
}
}
}
else{
for(u32 j = 0; j < range_count; j += 2){
u32 start = ranges[j];
u32 stop = ranges[j+1];
for (u32 i = start; i < stop; ++i){
Glyph_Page *ptr = font->pages[i];
if (ptr == GLYPH_PAGE_EMPTY){
goto break2;
}
if (ptr != GLYPH_PAGE_DELETED){
if (ptr->page_number == page_number){
result = &font->pages[i];
goto break2;
}
}
}
}
}
break2:;
}
return(result);
}
internal Glyph_Page*
font_get_or_make_page(Render_Font *font, u32 page_number){
Glyph_Page *page = 0;
if (page_number <= 0x10FF){
Glyph_Page **page_ptr = font_lookup_page(font, page_number, false);
page = 0;
if (page_ptr != 0){
page = *page_ptr;
}
if (page == 0){
u32 new_count = 1;
if (font->page_max < MAX_PAGE_COUNT && (font->page_count+new_count)*3 < font->page_max*2){
u32 new_page_max = (font->page_count+new_count)*3;
new_page_max = clamp_top(new_page_max, MAX_PAGE_COUNT);
Glyph_Page **new_pages = (Glyph_Page**)ALLOCATE(new_page_max * sizeof(Glyph_Page*));
u32 old_page_max = font->page_max;
Glyph_Page **pages = font->pages;
for (u32 i = 0; i < old_page_max; ++i){
Glyph_Page *current_page = pages[i];
if (current_page != GLYPH_PAGE_EMPTY && current_page != GLYPH_PAGE_DELETED){
Glyph_Page **dest = font_lookup_page(font, current_page->page_number, true);
Assert(dest != 0);
*dest = current_page;
}
}
FREE(font->pages);
font->pages = new_pages;
font->page_max = new_page_max;
}
Glyph_Page *new_page = (Glyph_Page*)ALLOCATE(sizeof(Glyph_Page));
Glyph_Page **dest = font_lookup_page(font, page_number, true);
*dest = new_page;
++font->page_count;
//set->font_load_page(font, new_page, );
}
}
return(page);
}
internal void
get_codepoint_memory(Render_Font *font, u32 codepoint, Glyph_Bounds **bounds_mem_out, f32 **advance_mem_out){
Glyph_Bounds *bounds = 0;
f32 *advance = 0;
if (get_codepoint_can_render(font, codepoint)){
Codepoint_Indexes indexes = get_codepoint_page_number(font, codepoint);
Glyph_Page *page = font_get_or_make_page(font, indexes.page_number);
bounds = &page->glyphs[indexes.glyph_index];
advance = &page->advance[indexes.glyph_index];
}
*bounds_mem_out = bounds;
*advance_mem_out = advance;
}
internal b32
get_codepoint_glyph_data(Render_Font *font, u32 codepoint, Glyph_Data *data_out){
b32 success = false;
if (get_codepoint_can_render(font, codepoint)){
Codepoint_Indexes indexes = get_codepoint_page_number(font, codepoint);
Glyph_Page *page = font_get_or_make_page(font, indexes.page_number);
data_out->bounds = page->glyphs[indexes.glyph_index];
data_out->tex = page->tex;
data_out->tex_width = page->tex_width;
data_out->tex_height = page->tex_height;
success = true;
}
return(success);
}
internal f32
get_codepoint_advance(Render_Font *font, u32 codepoint){
f32 advance = (f32)font->advance;
if (get_codepoint_can_render(font, codepoint)){
Codepoint_Indexes indexes = get_codepoint_page_number(font, codepoint);
Glyph_Page *page = font_get_or_make_page(font, indexes.page_number);
advance = page->advance[indexes.glyph_index];
}
return(advance);
}
internal b32
set_codepoint_advance(Render_Font *font, u32 codepoint, f32 value){
b32 success = false;
if (get_codepoint_can_render(font, codepoint)){
Codepoint_Indexes indexes = get_codepoint_page_number(font, codepoint);
Glyph_Page *page = font_get_or_make_page(font, indexes.page_number);
page->advance[indexes.glyph_index] = value;
success = true;
}
return(success);
}
// BOTTOM

View File

@ -1,198 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 11.03.2017
*
* Implements some basic getters for fonts set up to make the font type opaque.
*
*/
// TOP
#include "4ed_font_data.h"
internal f32
font_get_byte_advance(Render_Font *font){
return(font->byte_advance);
}
internal f32*
font_get_byte_sub_advances(Render_Font *font){
return(font->byte_sub_advances);
}
internal i32
font_get_height(Render_Font *font){
return(font->height);
}
internal i32
font_get_ascent(Render_Font *font){
return(font->ascent);
}
internal i32
font_get_descent(Render_Font *font){
return(font->descent);
}
internal i32
font_get_line_skip(Render_Font *font){
return(font->line_skip);
}
internal i32
font_get_advance(Render_Font *font){
return(font->advance);
}
internal b32
font_can_render(System_Functions *system, Render_Font *font, u32 codepoint){
b32 result = false;
u32 page_number = (codepoint >> 8);
u32 glyph_index = codepoint & 0xFF;
Glyph_Page *page = font_get_or_make_page(system, font, page_number);
if (page != 0 && page->advance[glyph_index] > 0.f){
result = true;
}
return(result);
}
internal f32
font_get_glyph_advance(System_Functions *system, Render_Font *font, u32 codepoint){
f32 result = 0.f;
u32 page_number = (codepoint >> 8);
u32 glyph_index = codepoint & 0xFF;
Glyph_Page *page = font_get_or_make_page(system, font, page_number);
if (page != 0 && page->advance[glyph_index] > 0.f){
result = page->advance[glyph_index];
}
return(result);
}
internal Glyph_Data
font_get_glyph(System_Functions *system, Render_Font *font, u32 codepoint){
Glyph_Data result = {0};
u32 page_number = (codepoint >> 8);
u32 glyph_index = codepoint & 0xFF;
Glyph_Page *page = font_get_or_make_page(system, font, page_number);
if (page != 0 && page->advance[glyph_index] > 0.f){
result.bounds = page->glyphs[glyph_index];
result.tex = page->tex;
result.tex_width = page->tex_width;
result.tex_height = page->tex_height;
}
return(result);
}
internal Glyph_Page**
font_page_lookup(Render_Font *font, u32 page_number, b32 get_empty_slot){
Glyph_Page **result = 0;
if (font->page_max > 0){
u32 first_index = page_number % font->page_max;
u32 range_count = 0;
u32 ranges[4];
if (first_index == 0){
ranges[0] = 0;
ranges[1] = font->page_max;
range_count = 2;
}
else{
ranges[0] = first_index;
ranges[1] = font->page_max;
ranges[2] = 0;
ranges[3] = first_index;
range_count = 4;
}
Glyph_Page **pages = font->pages;
if (get_empty_slot){
for (u32 j = 0; j < range_count; j += 2){
u32 stop = ranges[j+1];
for (u32 i = ranges[j]; i < stop; ++i){
if (pages[i] == FONT_PAGE_EMPTY || pages[i] == FONT_PAGE_DELETED){
result = &pages[i];
goto break2;
}
if (pages[i]->page_number == page_number){
goto break2;
}
}
}
}
else{
for (u32 j = 0; j < range_count; j += 2){
u32 stop = ranges[j+1];
for (u32 i = ranges[j]; i < stop; ++i){
if (pages[i] == FONT_PAGE_EMPTY){
goto break2;
}
if (pages[i] != FONT_PAGE_DELETED && pages[i]->page_number == page_number){
result = &pages[i];
goto break2;
}
}
}
}
break2:;
}
return(result);
}
internal Glyph_Page*
font_get_or_make_page(System_Functions *system, Render_Font *font, u32 page_number){
Glyph_Page *result = 0;
if (page_number <= 0x10FF){
Glyph_Page **page_get_result = font_page_lookup(font, page_number, false);
if (page_get_result == 0){
b32 has_space = true;
u32 new_page_count = 1;
u32 new_max = (font->page_count+new_page_count)*3;
if (font->page_max < FONT_PAGE_MAX && new_max > font->page_max*2){
Glyph_Page **pages = (Glyph_Page**)system->font.allocate(sizeof(Glyph_Page*)*new_max);
has_space = false;
if (pages != 0){
memset(pages, 0, sizeof(*pages)*new_max);
u32 old_max = font->page_max;
for (u32 i = 0; i < old_max; ++i){
Glyph_Page *this_page = pages[i];
if (this_page != FONT_PAGE_EMPTY && this_page != FONT_PAGE_DELETED){
u32 this_page_number = this_page->page_number;
Glyph_Page **dest = font_page_lookup(font, this_page_number, true);
Assert(dest != 0);
*dest = this_page;
}
}
system->font.free(font->pages);
font->pages = pages;
font->page_max = new_max;
has_space = true;
}
}
if (has_space){
Glyph_Page *new_page = (Glyph_Page*)system->font.allocate(sizeof(Glyph_Page));
if (new_page != 0){
Glyph_Page **dest = font_page_lookup(font, page_number, true);
Assert(dest != 0);
*dest = new_page;
font->page_count += new_page_count;
result = new_page;
system->font.load_page(font, new_page, page_number);
}
}
}
else{
result = *page_get_result;
}
}
return(result);
}
// BOTTOM

View File

@ -12,7 +12,7 @@
#if !defined(FCODER_SYSTEM_INTERFACE_H)
#define FCODER_SYSTEM_INTERFACE_H
#include "4ed_font_interface.h"
#include "font/4coder_font_interface.h"
// types
struct Plat_Handle{
@ -57,7 +57,7 @@ typedef Sys_Add_Listener_Sig(System_Add_Listener);
#define Sys_Remove_Listener_Sig(name) b32 name(char *filename)
typedef Sys_Remove_Listener_Sig(System_Remove_Listener);
#define Sys_Get_File_Change_Sig(name) i32 name(char *buffer, umem max, b32 *mem_too_small, umem *required_size)
#define Sys_Get_File_Change_Sig(name) i32 name(char *buffer, i32 max, b32 *mem_too_small, i32 *required_size)
typedef Sys_Get_File_Change_Sig(System_Get_File_Change);
// time
@ -212,7 +212,7 @@ typedef Sys_Memory_Set_Protection_Sig(System_Memory_Set_Protection);
#define Sys_Memory_Free_Sig(name) void name(void *ptr, umem size)
typedef Sys_Memory_Free_Sig(System_Memory_Free);
#define Sys_File_Exists_Sig(name) b32 name(char *filename, u32 len)
#define Sys_File_Exists_Sig(name) b32 name(char *filename, i32 len)
typedef Sys_File_Exists_Sig(System_File_Exists);
#define Sys_Directory_CD_Sig(name) bool32 name(char *dir, i32 *len, i32 cap, char *rel_path, i32 rel_len)

View File

@ -12,7 +12,7 @@
#if !defined(FCODER_SYSTEM_SHARED_CPP)
#define FCODER_SYSTEM_SHARED_CPP
#include "4ed_font_data.h"
#include "font/4coder_font_data.h"
//
// Standard implementation of file system stuff based on the file track layer.
@ -21,14 +21,14 @@
internal void
init_shared_vars(){
umem scratch_size = KB(128);
void *scratch_memory = system_memory_allocate(scratch_size);
void *scratch_memory = system_get_memory(scratch_size);
shared_vars.scratch = make_part(scratch_memory, scratch_size);
shared_vars.track_table_size = KB(16);
shared_vars.track_table = system_memory_allocate(shared_vars.track_table_size);
shared_vars.track_table = system_get_memory(shared_vars.track_table_size);
shared_vars.track_node_size = KB(16);
void *track_nodes = system_memory_allocate(shared_vars.track_node_size);
void *track_nodes = system_get_memory(shared_vars.track_node_size);
i32 track_result = init_track_system(&shared_vars.track, &shared_vars.scratch, shared_vars.track_table, shared_vars.track_table_size, track_nodes, shared_vars.track_node_size);
@ -45,10 +45,9 @@ handle_track_out_of_memory(i32 val){
case FileTrack_OutOfTableMemory:
{
u32 new_table_size = shared_vars.track_table_size*2;
u32 old_table_size = shared_vars.track_table_size;
void *new_table = system_memory_allocate(new_table_size);
void *new_table = system_get_memory(new_table_size);
move_track_system(&shared_vars.track, &shared_vars.scratch, new_table, new_table_size);
system_memory_free(shared_vars.track_table, old_table_size);
system_free_memory(shared_vars.track_table);
shared_vars.track_table_size = new_table_size;
shared_vars.track_table = new_table;
}break;
@ -56,7 +55,7 @@ handle_track_out_of_memory(i32 val){
case FileTrack_OutOfListenerMemory:
{
shared_vars.track_node_size *= 2;
void *node_expansion = system_memory_allocate(shared_vars.track_node_size);
void *node_expansion = system_get_memory(shared_vars.track_node_size);
expand_track_system_listeners(&shared_vars.track, &shared_vars.scratch, node_expansion, shared_vars.track_node_size);
}break;
@ -68,13 +67,13 @@ handle_track_out_of_memory(i32 val){
internal
Sys_Add_Listener_Sig(system_add_listener){
b32 result = false;
b32 result = 0;
for (;;){
File_Track_Result track_result = add_listener(&shared_vars.track, &shared_vars.scratch, (u8*)filename);
i32 track_result = add_listener(&shared_vars.track, &shared_vars.scratch, filename);
if (handle_track_out_of_memory(track_result)){
if (track_result == FileTrack_Good){
result = true;
result = 1;
}
break;
}
@ -85,10 +84,10 @@ Sys_Add_Listener_Sig(system_add_listener){
internal
Sys_Remove_Listener_Sig(system_remove_listener){
b32 result = false;
File_Track_Result track_result = remove_listener(&shared_vars.track, &shared_vars.scratch, (u8*)filename);
i32 result = 0;
i32 track_result = remove_listener(&shared_vars.track, &shared_vars.scratch, filename);
if (track_result == FileTrack_Good){
result = true;
result = 1;
}
return(result);
}
@ -97,8 +96,8 @@ internal
Sys_Get_File_Change_Sig(system_get_file_change){
b32 result = false;
umem size = 0;
File_Track_Result get_result = get_change_event(&shared_vars.track, &shared_vars.scratch, (u8*)buffer, max, &size);
i32 size = 0;
i32 get_result = get_change_event(&shared_vars.track, &shared_vars.scratch, buffer, max, &size);
*required_size = size;
*mem_too_small = false;
@ -128,14 +127,14 @@ sysshared_load_file(char *filename){
result.got_file = 1;
if (size > 0){
result.size = size;
result.data = (char*)system_memory_allocate(size+1);
result.data = (char*)system_get_memory(size+1);
if (!result.data){
result = null_file_data;
}
else{
if (!system_load_file(handle, result.data, size)){
system_memory_free(result.data, size+1);
system_free_memory(result.data);
result = null_file_data;
}
}
@ -158,9 +157,11 @@ usable_ascii(char c){
internal void
sysshared_filter_real_files(char **files, i32 *file_count){
i32 end = *file_count;
i32 i = 0, j = 0;
for (; i < end; ++i){
i32 i, j;
i32 end;
end = *file_count;
for (i = 0, j = 0; i < end; ++i){
if (system_file_can_be_made(files[i])){
files[j] = files[i];
++j;
@ -171,20 +172,20 @@ sysshared_filter_real_files(char **files, i32 *file_count){
internal Partition
sysshared_scratch_partition(i32 size){
void *data = system_memory_allocate(size);
void *data = system_get_memory(size);
Partition part = make_part(data, size);
return(part);
}
// TODO(allen): attempt to grow in place by just acquiring next vpages?!
internal void
sysshared_partition_grow(Partition *part, umem new_size){
sysshared_partition_grow(Partition *part, i32 new_size){
void *data = 0;
if (new_size > part->max){
void *data = system_memory_allocate(new_size);
// TODO(allen): attempt to grow in place by just acquiring next vpages?!
data = system_get_memory(new_size);
memcpy(data, part->base, part->pos);
system_memory_free(part->base, part->max);
system_free_memory(part->base);
part->base = (char*)data;
part->max = new_size;
}
}

View File

@ -886,7 +886,7 @@ static Argument_Breakdown
parameter_parse(Partition *part, char *data, Cpp_Token *args_start_token, Cpp_Token *args_end_token){
int32_t arg_index = 0;
Cpp_Token *arg_token = args_start_token + 1;
int32_t param_string_start = arg_token->start;
uint32_t param_string_start = arg_token->start;
int32_t arg_count = 1;
arg_token = args_start_token;

View File

@ -23,7 +23,7 @@ TYPE: 'build-target'
#include <string.h>
static float
get_line_y(Application_Links *app, View_Summary *view, int32_t line){
get_line_y(Application_Links *app, View_Summary *view, size_t line){
Full_Cursor cursor = {0};
view_compute_cursor(app, view, seek_line_char(line, 1), &cursor);
float y = cursor.wrapped_y;
@ -43,9 +43,9 @@ CUSTOM_COMMAND_SIG(kill_rect){
int32_t line_count = (int32_t)(rect.y1 - rect.y0 + 1);
for (int32_t line_i = line_count; line_i >= 0; --line_i){
int32_t line = rect.y0 + line_i;
int32_t start = 0;
int32_t end = 0;
size_t line = rect.y0 + line_i;
size_t start = 0;
size_t end = 0;
bool32 success = true;
Full_Cursor cursor = {0};
@ -71,7 +71,7 @@ CUSTOM_COMMAND_SIG(kill_rect){
}
static void
pad_buffer_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t line, char padchar, int32_t target){
pad_buffer_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, size_t line, char padchar, size_t target){
Partial_Cursor start = {0};
Partial_Cursor end = {0};
@ -83,7 +83,7 @@ pad_buffer_line(Application_Links *app, Partition *part, Buffer_Summary *buffer,
if (buffer_compute_cursor(app, buffer, seek_end, &end)){
if (end.character-1 < target){
Temp_Memory temp = begin_temp_memory(part);
int32_t size = target - (end.character-1);
size_t size = target - (end.character-1);
char *str = push_array(part, char, size);
memset(str, ' ', size);
buffer_replace_range(app, buffer, end.pos, end.pos, str, size);
@ -137,10 +137,10 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
Buffer_Rect rect = get_rect(&view);
int32_t start_line = view.cursor.line;
int32_t pos = view.cursor.character-1;
size_t start_line = view.cursor.line;
size_t pos = view.cursor.character-1;
for (int32_t i = rect.line0; i <= rect.line1; ++i){
for (size_t i = rect.line0; i <= rect.line1; ++i){
pad_buffer_line(app, &global_part, &buffer, i, ' ', pos);
}
@ -158,7 +158,7 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
Buffer_Edit *edits = edit;
for (int32_t i = 0; i <= line_count; ++i){
int32_t line = i + rect.line0;
size_t line = i + rect.line0;
Partial_Cursor cursor = {0};
Buffer_Seek seek = seek_line_char(line, pos+1);
@ -188,7 +188,7 @@ CUSTOM_COMMAND_SIG(multi_line_edit){
Buffer_Edit *edits = edit;
for (int32_t i = 0; i <= line_count; ++i){
int32_t line = i + rect.line0;
size_t line = i + rect.line0;
Partial_Cursor cursor = {0};
Buffer_Seek seek = seek_line_char(line, pos+1);
@ -227,11 +227,11 @@ enum{
};
static bool32
find_scope_top(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
find_scope_top(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
int32_t position = 0;
size_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index;
@ -287,11 +287,11 @@ find_scope_top(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos
}
static bool32
find_scope_bottom(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
find_scope_bottom(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
int32_t position = 0;
size_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index+1;
@ -348,11 +348,11 @@ find_scope_bottom(Application_Links *app, Buffer_Summary *buffer, int32_t start_
}
static bool32
find_next_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
find_next_scope(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
int32_t position = 0;
size_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index+1;
@ -428,11 +428,11 @@ find_next_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_po
}
static bool32
find_prev_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, uint32_t flags, int32_t *end_pos_out){
find_prev_scope(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, uint32_t flags, size_t *end_pos_out){
Cpp_Get_Token_Result get_result = {0};
bool32 success = 0;
int32_t position = 0;
size_t position = 0;
if (buffer_get_token_index(app, buffer, start_pos, &get_result)){
int32_t token_index = get_result.token_index-1;
@ -507,7 +507,7 @@ find_prev_scope(Application_Links *app, Buffer_Summary *buffer, int32_t start_po
}
static void
view_set_to_region(Application_Links *app, View_Summary *view, int32_t major_pos, int32_t minor_pos, float normalized_threshold){
view_set_to_region(Application_Links *app, View_Summary *view, size_t major_pos, size_t minor_pos, float normalized_threshold){
Range range = make_range(major_pos, minor_pos);
bool32 bottom_major = false;
if (major_pos == range.max){
@ -562,8 +562,8 @@ CUSTOM_COMMAND_SIG(highlight_surrounding_scope){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_scope_top(app, &buffer, start_pos, FindScope_Parent, &top)){
view_set_cursor(app, &view, seek_pos(top), true);
if (find_scope_bottom(app, &buffer, start_pos, FindScope_Parent | FindScope_EndOfToken, &bottom)){
@ -582,8 +582,8 @@ CUSTOM_COMMAND_SIG(highlight_first_child_scope){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_next_scope(app, &buffer, start_pos, 0, &top)){
if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){
view_set_cursor(app, &view, seek_pos(top), true);
@ -598,8 +598,8 @@ CUSTOM_COMMAND_SIG(highlight_next_sibling_scope){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_next_scope(app, &buffer, start_pos, FindScope_NextSibling, &top)){
if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){
view_set_cursor(app, &view, seek_pos(top), true);
@ -614,8 +614,8 @@ CUSTOM_COMMAND_SIG(highlight_prev_sibling_scope){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_prev_scope(app, &buffer, start_pos, FindScope_NextSibling, &top)){
if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){
view_set_cursor(app, &view, seek_pos(top), true);
@ -630,8 +630,8 @@ CUSTOM_COMMAND_SIG(highlight_next_scope_absolute){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_next_scope(app, &buffer, start_pos, 0, &top)){
if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){
view_set_cursor(app, &view, seek_pos(top), true);
@ -646,8 +646,8 @@ CUSTOM_COMMAND_SIG(highlight_prev_scope_absolute){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t start_pos = view.cursor.pos;
int32_t top = 0, bottom = 0;
size_t start_pos = view.cursor.pos;
size_t top = 0, bottom = 0;
if (find_prev_scope(app, &buffer, start_pos, 0, &top)){
if (find_scope_bottom(app, &buffer, top, FindScope_EndOfToken, &bottom)){
view_set_cursor(app, &view, seek_pos(top), true);
@ -697,11 +697,11 @@ CUSTOM_COMMAND_SIG(place_in_scope){
--max_adjustment;
}
int32_t min_pos = range.min + min_adjustment;
int32_t max_pos = range.max + max_adjustment;
size_t min_pos = range.min + min_adjustment;
size_t max_pos = range.max + max_adjustment;
int32_t cursor_pos = min_pos;
int32_t mark_pos = max_pos;
size_t cursor_pos = min_pos;
size_t mark_pos = max_pos;
if (view.cursor.pos > view.mark.pos){
cursor_pos = max_pos;
@ -735,11 +735,11 @@ CUSTOM_COMMAND_SIG(delete_current_scope){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t top = view.cursor.pos;
int32_t bottom = view.mark.pos;
size_t top = view.cursor.pos;
size_t bottom = view.mark.pos;
if (top > bottom){
Swap(int32_t, top, bottom);
Swap(size_t, top, bottom);
}
if (buffer_get_char(app, &buffer, top) == '{' && buffer_get_char(app, &buffer, bottom-1) == '}'){
@ -948,10 +948,10 @@ parse_statement_down(Application_Links *app, Statement_Parser *parser, Cpp_Token
}
static bool32
find_whole_statement_down(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t *start_out, int32_t *end_out){
find_whole_statement_down(Application_Links *app, Buffer_Summary *buffer, size_t pos, size_t *start_out, size_t *end_out){
bool32 result = false;
int32_t start = pos;
int32_t end = start;
size_t start = pos;
size_t end = start;
Cpp_Get_Token_Result get_result = {0};
@ -990,11 +990,11 @@ CUSTOM_COMMAND_SIG(scope_absorb_down){
View_Summary view = get_active_view(app, access);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
int32_t top = view.cursor.pos;
int32_t bottom = view.mark.pos;
size_t top = view.cursor.pos;
size_t bottom = view.mark.pos;
if (top > bottom){
Swap(int32_t, top, bottom);
Swap(size_t, top, bottom);
}
Partition *part = &global_part;
@ -1123,9 +1123,9 @@ CUSTOM_COMMAND_SIG(rename_parameter){
String replace_string = with.string;
Buffer_Edit *edits = (Buffer_Edit*)partition_current(part);
uint32_t remaining = (uint32_t)partition_remaining(part);
uint32_t edit_size = sizeof(Buffer_Edit);
uint32_t edit_max = remaining/edit_size;
size_t remaining = partition_remaining(part);
size_t edit_size = sizeof(Buffer_Edit);
uint32_t edit_max = (uint32_t)(remaining/edit_size);
uint32_t edit_count = 0;
if (edit_max >= 1){
@ -1149,7 +1149,7 @@ CUSTOM_COMMAND_SIG(rename_parameter){
switch (token_ptr->type){
case CPP_TOKEN_IDENTIFIER:
{
if (token_ptr->size == old_lexeme.size){
if (token_ptr->size == (uint32_t)old_lexeme.size){
char other_lexeme_base[128];
String other_lexeme = make_fixed_width_string(other_lexeme_base);
other_lexeme.size = old_lexeme.size;

View File

@ -15,7 +15,7 @@ TYPE: 'drop-in-command-pack'
#include "4coder_helper/4coder_streaming.h"
static bool32
get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, int32_t *numeric_start, int32_t *numeric_end){
get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, size_t *numeric_start, size_t *numeric_end){
bool32 result = false;
char current = buffer_get_char(app, buffer, start_pos);
@ -25,10 +25,10 @@ get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, int
int32_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
int32_t pos = start_pos;
size_t pos = start_pos;
int32_t pos1 = 0;
int32_t pos2 = 0;
size_t pos1 = 0;
size_t pos2 = 0;
if (init_stream_chunk(&stream, app, buffer, start_pos, chunk, chunk_size)){
@ -72,15 +72,15 @@ get_numeric_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, int
}
struct Miblo_Number_Info{
int32_t start, end;
size_t start, end;
int32_t x;
};
static bool32
get_numeric_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Miblo_Number_Info *info){
get_numeric_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t pos, Miblo_Number_Info *info){
bool32 result = false;
int32_t numeric_start = 0, numeric_end = 0;
size_t numeric_start = 0, numeric_end = 0;
if (get_numeric_string_at_cursor(app, buffer, pos, &numeric_start, &numeric_end)){
int32_t string_length = (int32_t)(numeric_end - numeric_start);
char numeric_string[1024];
@ -133,7 +133,7 @@ CUSTOM_COMMAND_SIG(miblo_decrement_basic){
// (h+:)?m?m:ss
static bool32
get_timestamp_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, int32_t *timestamp_start, int32_t *timestamp_end){
get_timestamp_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t start_pos, size_t *timestamp_start, size_t *timestamp_end){
bool32 result = false;
char current = buffer_get_char(app, buffer, start_pos);
@ -143,10 +143,10 @@ get_timestamp_string_at_cursor(Application_Links *app, Buffer_Summary *buffer, i
int32_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0};
int32_t pos = start_pos;
size_t pos = start_pos;
int32_t pos1 = 0;
int32_t pos2 = 0;
size_t pos1 = 0;
size_t pos2 = 0;
if (init_stream_chunk(&stream, app, buffer, start_pos, chunk, chunk_size)){
@ -272,15 +272,15 @@ timestamp_to_str(String *dest, Miblo_Timestamp t){
}
struct Miblo_Timestamp_Info{
int32_t start, end;
size_t start, end;
Miblo_Timestamp time;
};
static bool32
get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Miblo_Timestamp_Info *info){
get_timestamp_at_cursor(Application_Links *app, Buffer_Summary *buffer, size_t pos, Miblo_Timestamp_Info *info){
bool32 result = false;
int32_t timestamp_start = 0, timestamp_end = 0;
size_t timestamp_start = 0, timestamp_end = 0;
if (get_timestamp_string_at_cursor(app, buffer, pos, &timestamp_start, &timestamp_end)){
int32_t string_length = (int32_t)(timestamp_end - timestamp_start);
char timestamp_string[1024];

View File

@ -72,9 +72,10 @@
//////////////////////////////
#include "4ed_file_track.h"
#include "4ed_font_interface_to_os.h"
#include "4ed_system_shared.h"
#include "win32_4ed_file_track.cpp"
//
// Win32_Vars structs
//
@ -1147,35 +1148,31 @@ Sys_Get_Binary_Path_Sig(system_get_binary_path){
internal
Sys_File_Exists_Sig(system_file_exists){
b32 result = false;
char full_filename_space[1024];
String full_filename;
HANDLE file;
b32 result = 0;
Partition *scratch = &shared_vars.scratch;
Temp_Memory temp = begin_temp_memory(scratch);
u32 filename_16_max = (len+1)*2;
u16 *filename_16 = push_array(scratch, u16, filename_16_max);
b32 convert_error = false;
u32 filename_16_len = (u32)utf8_to_utf16_minimal_checking(filename_16, filename_16_max, (u8*)filename, len, &convert_error);
if (!convert_error){
filename_16[filename_16_len] = 0;
if (len < sizeof(full_filename_space)){
full_filename = make_fixed_width_string(full_filename_space);
copy_ss(&full_filename, make_string(filename, len));
terminate_with_null(&full_filename);
file = CreateFile(full_filename.str, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
HANDLE file = CreateFile((LPWSTR)filename_16, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (file != INVALID_HANDLE_VALUE){
CloseHandle(file);
result = true;
result = 1;
}
}
end_temp_memory(temp);
return(result);
}
internal
Sys_Directory_CD_Sig(system_directory_cd){
String directory = make_string_cap(dir, *len, cap);
b32 result = false;
b32 result = 0;
i32 old_size;
char rel_path_space[1024];
@ -1185,7 +1182,7 @@ Sys_Directory_CD_Sig(system_directory_cd){
if (rel_path[0] != 0){
if (rel_path[0] == '.' && rel_path[1] == 0){
result = true;
result = 1;
}
else if (rel_path[0] == '.' && rel_path[1] == '.' && rel_path[2] == 0){
result = remove_last_folder(&directory);
@ -1196,8 +1193,8 @@ Sys_Directory_CD_Sig(system_directory_cd){
old_size = directory.size;
append_partial_sc(&directory, rel_path);
append_s_char(&directory, '\\');
if (Win32DirectoryExists((u8*)directory.str)){
result = true;
if (Win32DirectoryExists(directory.str)){
result = 1;
}
else{
directory.size = old_size;
@ -1302,57 +1299,10 @@ Win32ReadClipboardContents(){
// Command Line Exectuion
//
internal b32
win32_create_process_utf8(char *cmd, char *command_line, char *path, STARTUPINFO *startup, PROCESS_INFORMATION *info){
b32 result = false;
LPWSTR env_variables = 0;
Partition *scratch = &shared_vars.scratch;
Temp_Memory temp = begin_temp_memory(scratch);
u32 cmd_len = 0;
for (;cmd[cmd_len];++cmd_len);
u32 command_line_len = 0;
for (;command_line[command_line_len];++command_line_len);
u32 path_len = 0;
for (;path[path_len];++path_len);
u32 cmd_16_max = (cmd_len+1)*2;
u32 command_line_16_max = (command_line_len+1)*2;
u32 path_16_max = (path_len+1)*2;
u16 *cmd_16 = push_array(scratch, u16, cmd_16_max);
u16 *command_line_16 = push_array(scratch, u16, command_line_16_max);
u16 *path_16 = push_array(scratch, u16, path_16_max);
b32 convert_error = false;
u32 cmd_16_len = (u32)utf8_to_utf16_minimal_checking(cmd_16, cmd_16_max - 1, (u8*)cmd, cmd_len, &convert_error);
if (!convert_error){
u32 command_line_16_len = (u32)utf8_to_utf16_minimal_checking(command_line_16, command_line_16_max - 1, (u8*)command_line, command_line_len, &convert_error);
if (!convert_error){
u32 path_16_len = (u32)utf8_to_utf16_minimal_checking(path_16, path_16_max - 1, (u8*)path, path_len, &convert_error);
if (!convert_error){
cmd_16[cmd_16_len] = 0;
command_line_16[command_line_16_len] = 0;
path_16[path_16_len] = 0;
result = CreateProcess((LPWSTR)cmd_16, (LPWSTR)command_line_16, 0, 0, TRUE, 0, env_variables, (LPWSTR)path_16, startup, info);
}
}
}
end_temp_memory(temp);
return(result);
}
internal
Sys_CLI_Call_Sig(system_cli_call){
char cmd[] = "c:\\windows\\system32\\cmd.exe";
char *env_variables = 0;
char command_line[2048];
String s = make_fixed_width_string(command_line);
@ -1382,7 +1332,10 @@ Sys_CLI_Call_Sig(system_cli_call){
PROCESS_INFORMATION info = {};
Assert(sizeof(Plat_Handle) >= sizeof(HANDLE));
if (win32_create_process_utf8(cmd, command_line, path, &startup, &info)){
if (CreateProcess(cmd, command_line,
0, 0, TRUE, 0,
env_variables, path,
&startup, &info)){
success = 1;
CloseHandle(info.hThread);
*(HANDLE*)&cli_out->proc = info.hProcess;
@ -2177,7 +2130,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
memory_vars.user_memory = VirtualAlloc(base, memory_vars.target_memory_size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
win32vars.target.max = MB(1);
win32vars.target.push_buffer = (char*)system_memory_allocate(win32vars.target.max);
win32vars.target.push_buffer = (char*)system_get_memory(win32vars.target.max);
if (memory_vars.vars_memory == 0 || memory_vars.target_memory == 0 || memory_vars.user_memory == 0 || win32vars.target.push_buffer == 0){
exit(1);
@ -2204,16 +2157,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
// Read Command Line
//
DWORD cd_required = (GetCurrentDirectory(0, 0)*4) + 1;
u16 *current_directory_16 = (u16*)system_memory_allocate(cd_required*4);
DWORD written_16 = GetCurrentDirectory(cd_required, (LPWSTR)current_directory_16);
DWORD required = (GetCurrentDirectory(0, 0)*4) + 1;
char *current_directory_mem = (char*)system_get_memory(required);
DWORD written = GetCurrentDirectory(required, current_directory_mem);
u8 *current_directory_mem = (u8*)(current_directory_16 + cd_required);
b32 convert_error = false;
u32 current_directory_len = (u32)utf16_to_utf8_minimal_checking(current_directory_mem, cd_required*2, current_directory_16, written_16, &convert_error);
String current_directory = make_string_cap(current_directory_mem, current_directory_len, cd_required*2);
String current_directory = make_string_cap(current_directory_mem, written, required);
terminate_with_null(&current_directory);
replace_char(&current_directory, '\\', '/');
@ -2251,7 +2199,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
if (win32vars.custom_api.get_alpha_4coder_version == 0 ||
win32vars.custom_api.get_alpha_4coder_version(MAJOR, MINOR, PATCH) == 0){
MessageBox(0, L"Error: The application and custom version numbers don't match.\n", L"Error", 0);
MessageBox(0,"Error: The application and custom version numbers don't match.\n", "Error",0);
exit(1);
}
win32vars.custom_api.get_bindings = (Get_Binding_Data_Function*)
@ -2259,7 +2207,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
}
if (win32vars.custom_api.get_bindings == 0){
MessageBox(0, L"Error: The custom dll is missing.\n", L"Error", 0);
MessageBox(0,"Error: The custom dll is missing.\n", "Error",0);
exit(1);
}
@ -2275,8 +2223,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
window_class.style = CS_HREDRAW|CS_VREDRAW;
window_class.lpfnWndProc = (WNDPROC)(Win32Callback);
window_class.hInstance = hInstance;
window_class.lpszClassName = L"4coder-win32-wndclass";
window_class.hIcon = LoadIcon(hInstance, L"main");
window_class.lpszClassName = "4coder-win32-wndclass";
window_class.hIcon = LoadIcon(hInstance, "main");
if (!RegisterClass(&window_class)){
exit(1);
@ -2297,7 +2245,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
// TODO(allen): non-fatal diagnostics
}
#define WINDOW_NAME L"4coder-window: " L_VERSION
#define WINDOW_NAME "4coder-window: " VERSION
i32 window_x = CW_USEDEFAULT;
i32 window_y = CW_USEDEFAULT;
@ -2386,7 +2334,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
win32vars.app.init(&win32vars.system, &win32vars.target, &memory_vars, win32vars.clipboard_contents, current_directory, win32vars.custom_api);
system_memory_free(current_directory_16, 0);
system_free_memory(current_directory.str);
b32 keep_playing = 1;
win32vars.first = 1;
@ -2626,10 +2574,10 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
return(0);
}
#include "4ed_font_static_functions.cpp"
#include "font/4coder_font_static_functions.cpp"
#include "win32_4ed_fonts.cpp"
#include "win32_4ed_file_track.cpp"
//#include "win32_4ed_file_track.cpp"
#if 0
// NOTE(allen): In case I want to switch back to a console

View File

@ -295,7 +295,7 @@ expand_track_system_listeners(File_Track_System *system, Partition *scratch, voi
}
FILE_TRACK_LINK File_Track_Result
get_change_event(File_Track_System *system, Partition *scratch, u8 *buffer, umem max, umem *size){
get_change_event(File_Track_System *system, Partition *scratch, u8 *buffer, i32 max, umem *size){
File_Track_Result result = FileTrack_NoMoreEvents;
Win32_File_Track_Vars *vars = to_vars(system);
@ -341,7 +341,7 @@ get_change_event(File_Track_System *system, Partition *scratch, u8 *buffer, umem
i32 req_size = dir_len + 1 + len;
if (req_size < max){
u16 *buffer_16 = push_array(scratch, u16, req_size+1);
i32 pos = GetFinalPathNameByHandle(listener.dir, (LPWSTR)buffer_16, (DWORD)max, FILE_NAME_NORMALIZED);
i32 pos = GetFinalPathNameByHandle(listener.dir, (LPWSTR)buffer_16, max, FILE_NAME_NORMALIZED);
b32 convert_error = false;
umem buffer_size = utf16_to_utf8_minimal_checking(buffer, max-1, buffer_16, pos, &convert_error);

View File

@ -10,9 +10,9 @@
// TOP
#include "4ed_system_shared.h"
#include "4ed_font_interface.h"
#include "4ed_font_interface_to_os.h"
#include "4ed_font_data.h"
#include "font/4coder_font_interface.h"
#include "font/4coder_font_interface_to_os.h"
#include "font/4coder_font_data.h"
struct Win32_Fonts{
Partition part;