misc bug fixes and cleanups, added function lister, and scope navigator

master
Allen Webster 2017-01-13 22:01:35 -05:00
parent e37cce743a
commit f6a1c50d14
24 changed files with 1509 additions and 907 deletions

View File

@ -176,20 +176,6 @@ HOOK_SIG(my_view_adjust){
return(0);
}
// NOTE(allen|a4.0.12): This is for testing it may be removed and replaced with a better test for the buffer_get_font when you eventally read this and wonder what it's about.
CUSTOM_COMMAND_SIG(write_name_of_font){
View_Summary view = get_active_view(app, AccessOpen);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
char font_name[256];
int32_t font_max = 256;
int32_t font_len = buffer_get_font(app, &buffer, font_name, font_max);
if (font_len != 0){
write_string(app, &view, &buffer, make_string(font_name, font_len));
}
}
CUSTOM_COMMAND_SIG(newline_or_goto_position){
View_Summary view = get_active_view(app, AccessProtected);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
@ -538,8 +524,6 @@ default_keys(Bind_Helper *context){
bind(context, '\n', MDFR_SHIFT, newline_or_goto_position);
bind(context, ' ', MDFR_SHIFT, write_character);
bind(context, ';', MDFR_ALT, write_name_of_font);
end_map(context);
}

View File

@ -284,14 +284,13 @@ typedef struct Stream_Tokens{
} Stream_Tokens;
static bool32
init_stream_tokens(Stream_Tokens *stream, Application_Links *app, Buffer_Summary *buffer,
int32_t pos, Cpp_Token *data, int32_t count){
init_stream_tokens(Stream_Tokens *stream, Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Token *data, int32_t count){
bool32 result = 0;
refresh_buffer(app, buffer);
int32_t token_count = buffer_token_count(app, buffer);
if (pos >= 0 && pos < token_count && count > 0){
if (buffer->tokens_are_ready && pos >= 0 && pos < token_count && count > 0){
stream->app = app;
stream->buffer = buffer;
stream->base_tokens = data;
@ -317,7 +316,10 @@ static void
end_temp_stream_token(Stream_Tokens *stream, Stream_Tokens temp){
if (stream->start != temp.start || stream->end != temp.end){
Application_Links *app = stream->app;
buffer_read_tokens(app, stream->buffer, stream->start, stream->end, stream->base_tokens);
buffer_read_tokens(app, temp.buffer, temp.start, temp.end, temp.base_tokens);
stream->tokens = stream->base_tokens - temp.start;
stream->start = temp.start;
stream->end = temp.end;
}
}
@ -633,6 +635,50 @@ 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){
Partial_Cursor partial_cursor;
int32_t result = buffer->size;
if (line <= buffer->line_count){
buffer_compute_cursor(app, buffer, seek_line_char(line, 65536), &partial_cursor);
result = partial_cursor.pos;
}
return(result);
}
static bool32
buffer_line_is_blank(Application_Links *app, Buffer_Summary *buffer, int32_t line){
Partial_Cursor start, end;
bool32 result = 0;
if (line <= buffer->line_count){
buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &start);
buffer_compute_cursor(app, buffer, seek_line_char(line, 65536), &end);
static const int32_t chunk_size = 1024;
char chunk[chunk_size];
Stream_Chunk stream = {0};
int32_t i = start.pos;
stream.max_end = end.pos;
result = true;
if (init_stream_chunk(&stream, app, buffer, i, chunk, chunk_size)){
bool32 still_looping = false;
do{
for (;i < stream.end; ++i){
char c = stream.data[i];
if (!(c == ' ' || c == '\t' || c == '\r' || c == '\v' || c == '\n')){
result = false;
goto double_break;
}
}
still_looping = forward_stream_chunk(&stream);
}while(still_looping);
}
double_break:;
}
return(result);
}
static int32_t
buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
Partial_Cursor partial_cursor;
@ -641,8 +687,7 @@ buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, int32_t po
}
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){
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);
Cpp_Get_Token_Result get_token = cpp_get_token(tokens, line_start);
@ -1697,8 +1742,7 @@ buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int
--pos;
if (pos > 0){
stream.min_start = an_pos+1;
if (init_stream_chunk(&stream, app, buffer,
pos, data_chunk, sizeof(data_chunk))){
if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){
char c = 0, pc = stream.data[pos];
@ -1985,8 +2029,6 @@ CUSTOM_COMMAND_SIG(open_long_braces_break){
long_braces(app, text, size);
}
// TODO(allen): have this thing check if it is on
// a blank line and insert newlines as needed.
CUSTOM_COMMAND_SIG(if0_off){
char text1[] = "\n#if 0";
int32_t size1 = sizeof(text1) - 1;
@ -2018,7 +2060,7 @@ CUSTOM_COMMAND_SIG(if0_off){
edits[1].start = range.max;
edits[1].end = range.max;
buffer_batch_edit(app,&buffer, base, global_part.pos, edits, ArrayCount(edits), BatchEdit_Normal);
buffer_batch_edit(app, &buffer, base, global_part.pos, edits, ArrayCount(edits), BatchEdit_Normal);
view = get_view(app, view.view_id, AccessAll);
if (view.cursor.pos > view.mark.pos){
@ -2624,9 +2666,7 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
Search_Range *ranges = set.ranges;
String search_name = make_lit_string("*search*");
Buffer_Summary search_buffer = get_buffer_by_name(app, search_name.str, search_name.size,
AccessAll);
Buffer_Summary search_buffer = get_buffer_by_name(app, search_name.str, search_name.size, AccessAll);
if (!search_buffer.exists){
search_buffer = create_buffer(app, search_name.str, search_name.size, BufferCreate_AlwaysNew);
buffer_set_setting(app, &search_buffer, BufferSetting_Unimportant, true);
@ -2694,8 +2734,7 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
char *spare = push_array(part, char, str_len);
if (spare == 0){
buffer_replace_range(app, &search_buffer,
size, size, str, part_size);
buffer_replace_range(app, &search_buffer, size, size, str, part_size);
size += part_size;
end_temp_memory(temp);
@ -2717,6 +2756,7 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part
append_s_char(&out_line, ' ');
append_ss(&out_line, line_str);
append_s_char(&out_line, '\n');
Assert(out_line.size == str_len);
end_temp_memory(line_temp);
}
@ -2831,8 +2871,7 @@ CUSTOM_COMMAND_SIG(word_complete){
char space[1024];
Stream_Chunk chunk = {0};
if (init_stream_chunk(&chunk, app, &buffer,
cursor_pos, space, sizeof(space))){
if (init_stream_chunk(&chunk, app, &buffer, cursor_pos, space, sizeof(space))){
int32_t still_looping = true;
do{
for (; cursor_pos >= chunk.start; --cursor_pos){
@ -3691,7 +3730,7 @@ process_config_file(Application_Links *app){
end_temp_memory(temp);
}
else{
print_message(app, literal("Did not find config.4coder, using default settings"));
print_message(app, literal("Did not find config.4coder, using default settings\n"));
}
}

View File

@ -89,8 +89,8 @@ inline Tail_Temp_Partition
begin_tail_part(Partition *data, int32_t size){
Tail_Temp_Partition result = {0};
if (data->pos + size <= data->max){
result.handle = data;
result.old_max = data->max;
result.handle = data;
result.old_max = data->max;
data->max -= size;
result.part = make_part(data->base + data->max, size);
}
@ -218,7 +218,7 @@ general_memory_open(General_Memory *general, void *memory, int32_t size){
insert_bubble2(&general->free_sentinel, first);
}
#ifdef Assert
#if defined(Assert)
static int32_t
general_memory_check(General_Memory *general){
Bubble *sentinel = &general->sentinel;
@ -310,5 +310,10 @@ general_memory_reallocate_nocopy(General_Memory *general, void *old, int32_t siz
return(result);
}
#define reset_temp_memory end_temp_memory
#define gen_struct(g, T) (T*)general_memory_allocate(g, sizeof(T), 0)
#define gen_array(g, T, size) (T*)general_memory_allocate(g, sizeof(T)*(size))
#define gen_block(g, size) general_memory_open(g, size, 0)
#endif

View File

@ -252,7 +252,7 @@ ENUM(uint32_t, Access_Flag){
only return objects that have no protection flags set.) */
AccessOpen = 0x0,
/* DOC(AccessProtected is set on buffers and views that are "read only" such as
the output from an app->exec_system_command call such as *build*. This is to prevent
the output from an app->exec_system_command call into *build*. This is to prevent
the user from accidentally editing output that they might prefer to keep in tact.) */
AccessProtected = 0x1,
/* DOC(AccessHidden is set on any view that is not currently showing it's file, for
@ -484,8 +484,7 @@ STRUCT GUI_Scroll_Vars{
int32_t prev_target_x;
};
/* DOC(The Buffer_Seek_Type is is used in a Buffer_Seek to identify which
coordinates are suppose to be used for the seek.)
/* DOC(The Buffer_Seek_Type is is used in a Buffer_Seek to identify which coordinates are suppose to be used for the seek.)
DOC_SEE(Buffer_Seek)
DOC_SEE(4coder_Buffer_Positioning_System)
*/
@ -542,11 +541,9 @@ STRUCT Full_Cursor{
int32_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;
/* 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.) */
/* 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;
/* 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.) */
/* 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;
/* DOC(This field contains the x position measured with unwrapped lines.) */
float unwrapped_x;
@ -558,10 +555,7 @@ STRUCT Full_Cursor{
float wrapped_y;
};
/* DOC(Partial_Cursor describes the position of a cursor in all of
the coordinate systems that a invariant to the View. In other words
the coordinate systems available here can be used on a buffer that is
not currently associated with a View.)
/* DOC(Partial_Cursor describes the position of a cursor in all of the coordinate systems that a invariant to the View. In other words the coordinate systems available here can be used on a buffer that is not currently associated with a View.)
DOC_SEE(4coder_Buffer_Positioning_System) */
STRUCT Partial_Cursor{
/* DOC(This field contains the cursor's position in absolute byte index positioning.) */
@ -573,9 +567,7 @@ STRUCT Partial_Cursor{
int32_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.) */
/* 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;
@ -637,15 +629,9 @@ STRUCT Buffer_Summary{
DOC_SEE(Access_Flag)
DOC_SEE(Full_Cursor) */
STRUCT View_Summary{
/* DOC(
This field indicates whether the View_Summary describes a view that is open in 4coder.
When this field is false the summary is referred to as a "null summary".
) */
/* DOC( This field indicates whether the View_Summary describes a view that is open in 4coder. When this field is false the summary is referred to as a "null summary". ) */
bool32 exists;
/* DOC(
If this is not a null summary, this field is the id of the associated view.
If this is a null summary then view_id is 0.
) */
/* DOC(If this is not a null summary, this field is the id of the associated view. If this is a null summary then view_id is 0. ) */
int32_t view_id;
/* DOC(If this is not a null summary, then this is the id of the buffer this view currently sees.) */
int32_t buffer_id;
@ -660,20 +646,14 @@ STRUCT View_Summary{
float preferred_x;
/* DOC(If this is not a null summary, this specifies the height of a line rendered in the view.) */
float line_height;
/*
DOC(If this is not a null summary, this indicates that the view is set to render with unwrapped lines.)
*/
/* DOC(If this is not a null summary, this indicates that the view is set to render with unwrapped lines.) */
bool32 unwrapped_lines;
/* DOC(If this is not a null summary, this indicates that the view is set to highlight white space.) */
bool32 show_whitespace;
/*
DOC(If this is not a null summary, this describes the screen position in which this view's is displayed.)
*/
/* DOC(If this is not a null summary, this describes the screen position in which this view's is displayed.) */
i32_Rect view_region;
/*
DOC(If this is not a null summary, this describes the screen position in which this view's buffer is displayed. This is different from view_region, because it does not include any fixed height GUI at the top of the view.)
*/
/* DOC(If this is not a null summary, this describes the screen position in which this view's buffer is displayed. This is different from view_region, because it does not include any fixed height GUI at the top of the view.) */
i32_Rect file_region;
/* DOC(If this is not a null summary, this describes the scrolling position inside the view.) */
GUI_Scroll_Vars scroll_vars;

View File

@ -160,15 +160,9 @@ API_EXPORT FCPP_LINK Cpp_Get_Token_Result
cpp_get_token(Cpp_Token_Array array, int32_t pos)/*
DOC_PARAM(array, The array of tokens from which to get a token.)
DOC_PARAM(pos, The position, measured in bytes, to get the token for.)
DOC_RETURN(A Cpp_Get_Token_Result struct is returned containing the index
of a token and a flag indicating whether the pos is contained in the token
or in whitespace after the token.)
DOC_RETURN(A Cpp_Get_Token_Result struct is returned containing the index of a token and a flag indicating whether the pos is contained in the token or in whitespace after the token.)
DOC(This call performs a binary search over all of the tokens looking
for the token that contains the specified position. If the position
is in whitespace between the tokens, the returned token index is the
index of the token immediately before the provided position. The returned
index can be -1 if the position is before the first token.)
DOC(This call finds the token that contains a particular position, or if the position is in between tokens it finds the index of the token to the left of the position. The returned index can be -1 if the position is before the first token.)
DOC_SEE(Cpp_Get_Token_Result)
*/{
@ -966,37 +960,17 @@ DOC_PARAM(chunk, The first or next chunk of the file being lexed.)
DOC_PARAM(size, The number of bytes in the chunk including the null terminator if the chunk ends in a null terminator. If the chunk ends in a null terminator the system will interpret it as the end of the file.)
DOC_PARAM(full_size, If the final chunk is not null terminated this parameter should specify the length of the file in bytes. To rely on an eventual null terminator use HAS_NULL_TERM for this parameter.)
DOC_PARAM(token_array_out, The token array structure that will receive the tokens output by the lexer.)
DOC_PARAM(max_tokens_out, The maximum number of tokens to be output to the token array. To rely on the
max built into the token array pass NO_OUT_LIMIT here.)
DOC_PARAM(max_tokens_out, The maximum number of tokens to be output to the token array. To rely on the max built into the token array pass NO_OUT_LIMIT here.)
DOC(This call is the primary interface of the lexing system. It is quite general so it can be used in a lot of different ways. I will explain the general rules first, and then give some examples of common ways it might be used.
First a lexing state, Cpp_Lex_Data, must be initialized. The file to lex must be read into N contiguous chunks
of memory. An output Cpp_Token_Array must be allocated and initialized with the appropriate count and max_count
values. Then each chunk of the file must be passed to cpp_lex_step in order using the same lexing state for each call.
Every time a call to cpp_lex_step returns LexResult_NeedChunk, the next call to cpp_lex_step should use the
next chunk. If the return is some other value, the lexer hasn't finished with the current chunk and it sopped for some
other reason, so the same chunk should be used again in the next call.
First a lexing state, Cpp_Lex_Data, must be initialized. The file to lex must be read into N contiguous chunks of memory. An output Cpp_Token_Array must be allocated and initialized with the appropriate count and max_count values. Then each chunk of the file must be passed to cpp_lex_step in order using the same lexing state for each call. Every time a call to cpp_lex_step returns LexResult_NeedChunk, the next call to cpp_lex_step should use the next chunk. If the return is some other value, the lexer hasn't finished with the current chunk and it sopped for some other reason, so the same chunk should be used again in the next call.
If the file chunks contain a null terminator the lexer will return LexResult_Finished when it finds this character.
At this point calling the lexer again with the same state will result in an error. If you do not have a null
terminated chunk to end the file, you may instead pass the exact size in bytes of the entire file to the full_size
parameter and it will automatically handle the termination of the lexing state when it has read that many bytes.
If a full_size is specified and the system terminates for having seen that many bytes, it will return
LexResult_Finished. If a full_size is specified and a null character is read before the total number of bytes have
been read the system will still terminate as usual and return LexResult_Finished.
If the file chunks contain a null terminator the lexer will return LexResult_Finished when it finds this character. At this point calling the lexer again with the same state will result in an error. If you do not have a null terminated chunk to end the file, you may instead pass the exact size in bytes of the entire file to the full_size parameter and it will automatically handle the termination of the lexing state when it has read that many bytes. If a full_size is specified and the system terminates for having seen that many bytes, it will return LexResult_Finished. If a full_size is specified and a null character is read before the total number of bytes have been read the system will still terminate as usual and return LexResult_Finished.
If the system has filled the entire output array it will return LexResult_NeedTokenMemory. When this happens if you
want to continue lexing the file you can grow the token array, or switch to a new output array and then call
cpp_lex_step again with the chunk that was being lexed and the new output. You can also specify a max_tokens_out
which is limits how many new tokens will be added to the token array. Even if token_array_out still had more space
to hold tokens, if the max_tokens_out limit is hit, the lexer will stop and return LexResult_HitTokenLimit. If this
happens there is still space left in the token array, so you can resume simply by calling cpp_lex_step again with
the same chunk and the same output array. Also note that, unlike the chunks which must only be replaced when the
system says it needs a chunk. You may switch to or modify the output array in between calls as much as you like.
If the system has filled the entire output array it will return LexResult_NeedTokenMemory. When this happens if you want to continue lexing the file you can grow the token array, or switch to a new output array and then call cpp_lex_step again with the chunk that was being lexed and the new output. You can also specify a max_tokens_out which is limits how many new tokens will be added to the token array. Even if token_array_out still had more space to hold tokens, if the max_tokens_out limit is hit, the lexer will stop and return LexResult_HitTokenLimit. If this happens there is still space left in the token array, so you can resume simply by calling cpp_lex_step again with the same chunk and the same output array. Also note that, unlike the chunks which must only be replaced when the system says it needs a chunk. You may switch to or modify the output array in between calls as much as you like.
The most basic use of this system is to get it all done in one big chunk and try to allocate a nearly "infinite" output
array so that it will not run out of memory. This way you can get the entire job done in one call and then just assert
to make sure it returns LexResult_Finished to you:
The most basic use of this system is to get it all done in one big chunk and try to allocate a nearly "infinite" output array so that it will not run out of memory. This way you can get the entire job done in one call and then just assert to make sure it returns LexResult_Finished to you:
CODE_EXAMPLE(
Cpp_Token_Array lex_file(char *file_name){

View File

@ -19,91 +19,91 @@
/* DOC(A Cpp_Token_Type classifies a token to make parsing easier. Some types are not actually output by the lexer, but exist because parsers will also make use of token types in their own output.) */
ENUM(uint32_t, Cpp_Token_Type){
CPP_TOKEN_JUNK = 0,
CPP_TOKEN_JUNK = 0,
CPP_TOKEN_COMMENT = 1,
CPP_PP_INCLUDE = 2,
CPP_PP_DEFINE = 3,
CPP_PP_UNDEF = 4,
CPP_PP_IF = 5,
CPP_PP_IFDEF = 6,
CPP_PP_IFNDEF = 7,
CPP_PP_ELSE = 8,
CPP_PP_ELIF = 9,
CPP_PP_ENDIF = 10,
CPP_PP_ERROR = 11,
CPP_PP_IMPORT = 12,
CPP_PP_USING = 13,
CPP_PP_LINE = 14,
CPP_PP_PRAGMA = 15,
CPP_PP_STRINGIFY = 16,
CPP_PP_CONCAT = 17,
CPP_PP_UNKNOWN = 18,
CPP_PP_INCLUDE = 2,
CPP_PP_DEFINE = 3,
CPP_PP_UNDEF = 4,
CPP_PP_IF = 5,
CPP_PP_IFDEF = 6,
CPP_PP_IFNDEF = 7,
CPP_PP_ELSE = 8,
CPP_PP_ELIF = 9,
CPP_PP_ENDIF = 10,
CPP_PP_ERROR = 11,
CPP_PP_IMPORT = 12,
CPP_PP_USING = 13,
CPP_PP_LINE = 14,
CPP_PP_PRAGMA = 15,
CPP_PP_STRINGIFY = 16,
CPP_PP_CONCAT = 17,
CPP_PP_UNKNOWN = 18,
CPP_PP_DEFINED = 19,
CPP_PP_INCLUDE_FILE = 20,
CPP_PP_ERROR_MESSAGE = 21,
CPP_TOKEN_KEY_TYPE = 22,
CPP_TOKEN_KEY_MODIFIER = 23,
CPP_TOKEN_KEY_QUALIFIER = 24,
CPP_TOKEN_KEY_TYPE = 22,
CPP_TOKEN_KEY_MODIFIER = 23,
CPP_TOKEN_KEY_QUALIFIER = 24,
/* DOC(This type is not stored in token output from the lexer.) */
CPP_TOKEN_KEY_OPERATOR = 25,
CPP_TOKEN_KEY_CONTROL_FLOW = 26,
CPP_TOKEN_KEY_OPERATOR = 25,
CPP_TOKEN_KEY_CONTROL_FLOW = 26,
CPP_TOKEN_KEY_CAST = 27,
CPP_TOKEN_KEY_TYPE_DECLARATION = 28,
CPP_TOKEN_KEY_ACCESS = 29,
CPP_TOKEN_KEY_LINKAGE = 30,
CPP_TOKEN_KEY_OTHER = 31,
CPP_TOKEN_KEY_TYPE_DECLARATION = 28,
CPP_TOKEN_KEY_ACCESS = 29,
CPP_TOKEN_KEY_LINKAGE = 30,
CPP_TOKEN_KEY_OTHER = 31,
CPP_TOKEN_IDENTIFIER = 32,
CPP_TOKEN_INTEGER_CONSTANT = 33,
CPP_TOKEN_CHARACTER_CONSTANT = 34,
CPP_TOKEN_FLOATING_CONSTANT = 35,
CPP_TOKEN_STRING_CONSTANT = 36,
CPP_TOKEN_BOOLEAN_CONSTANT = 37,
CPP_TOKEN_IDENTIFIER = 32,
CPP_TOKEN_INTEGER_CONSTANT = 33,
CPP_TOKEN_CHARACTER_CONSTANT = 34,
CPP_TOKEN_FLOATING_CONSTANT = 35,
CPP_TOKEN_STRING_CONSTANT = 36,
CPP_TOKEN_BOOLEAN_CONSTANT = 37,
CPP_TOKEN_STATIC_ASSERT = 38,
CPP_TOKEN_BRACKET_OPEN = 39,
CPP_TOKEN_BRACKET_CLOSE = 40,
CPP_TOKEN_PARENTHESE_OPEN = 41,
CPP_TOKEN_PARENTHESE_CLOSE = 42,
CPP_TOKEN_BRACE_OPEN = 43,
CPP_TOKEN_BRACE_CLOSE = 44,
CPP_TOKEN_BRACKET_OPEN = 39,
CPP_TOKEN_BRACKET_CLOSE = 40,
CPP_TOKEN_PARENTHESE_OPEN = 41,
CPP_TOKEN_PARENTHESE_CLOSE = 42,
CPP_TOKEN_BRACE_OPEN = 43,
CPP_TOKEN_BRACE_CLOSE = 44,
CPP_TOKEN_SEMICOLON = 45,
CPP_TOKEN_ELLIPSIS = 46,
/* DOC(This is an 'ambiguous' token type because it requires
parsing to determine the full nature of the token.) */
CPP_TOKEN_STAR = 47,
CPP_TOKEN_STAR = 47,
/* DOC(This is an 'ambiguous' token type because it requires
parsing to determine the full nature of the token.) */
CPP_TOKEN_AMPERSAND = 48,
CPP_TOKEN_AMPERSAND = 48,
/* DOC(This is an 'ambiguous' token type because it requires
parsing to determine the full nature of the token.) */
CPP_TOKEN_TILDE = 49,
CPP_TOKEN_TILDE = 49,
/* DOC(This is an 'ambiguous' token type because it requires
parsing to determine the full nature of the token.) */
CPP_TOKEN_PLUS = 50,
CPP_TOKEN_PLUS = 50,
/* DOC(This is an 'ambiguous' token type because it requires
parsing to determine the full nature of the token.) */
CPP_TOKEN_MINUS = 51,
CPP_TOKEN_MINUS = 51,
/* DOC(This is an 'ambiguous' token type because it requires
parsing to determine the full nature of the token.) */
CPP_TOKEN_INCREMENT = 52,
CPP_TOKEN_INCREMENT = 52,
/* DOC(This is an 'ambiguous' token type because it requires
parsing to determine the full nature of the token.) */
CPP_TOKEN_DECREMENT = 53,
CPP_TOKEN_DECREMENT = 53,
// NOTE(allen): Precedence 1, LtoR
CPP_TOKEN_SCOPE = 54,
CPP_TOKEN_SCOPE = 54,
// NOTE(allen): Precedence 2, LtoR
/* DOC(This type is for parser use, it is not output by the lexer.) */
@ -117,8 +117,8 @@ ENUM(uint32_t, Cpp_Token_Type){
CPP_TOKEN_CALL = 59,
/* DOC(This type is for parser use, it is not output by the lexer.) */
CPP_TOKEN_INDEX = 60,
CPP_TOKEN_DOT = 61,
CPP_TOKEN_ARROW = 62,
CPP_TOKEN_DOT = 61,
CPP_TOKEN_ARROW = 62,
// NOTE(allen): Precedence 3, RtoL
/* DOC(This token is for parser use, it is not output by the lexer.) */
@ -129,7 +129,7 @@ ENUM(uint32_t, Cpp_Token_Type){
CPP_TOKEN_POSITIVE = 65,
/* DOC(This token is for parser use, it is not output by the lexer.) */
CPP_TOKEN_NEGAITVE = 66,
CPP_TOKEN_NOT = 67,
CPP_TOKEN_NOT = 67,
/* DOC(This type is for parser use, it is not output by the lexer.) */
CPP_TOKEN_BIT_NOT = 68,
@ -156,15 +156,15 @@ ENUM(uint32_t, Cpp_Token_Type){
CPP_TOKEN_DELETE_ARRAY = 81,
// NOTE(allen): Precedence 4, LtoR
CPP_TOKEN_PTRDOT = 82,
CPP_TOKEN_PTRARROW = 83,
CPP_TOKEN_PTRDOT = 82,
CPP_TOKEN_PTRARROW = 83,
// NOTE(allen): Precedence 5, LtoR
/* DOC(This type is for parser use, it is not output by the lexer.) */
CPP_TOKEN_MUL = 84,
CPP_TOKEN_DIV = 85,
CPP_TOKEN_MOD = 86,
CPP_TOKEN_MUL = 84,
CPP_TOKEN_DIV = 85,
CPP_TOKEN_MOD = 86,
// NOTE(allen): Precedence 6, LtoR
@ -175,14 +175,14 @@ ENUM(uint32_t, Cpp_Token_Type){
CPP_TOKEN_SUB = 88,
// NOTE(allen): Precedence 7, LtoR
CPP_TOKEN_LSHIFT = 89,
CPP_TOKEN_RSHIFT = 90,
CPP_TOKEN_LSHIFT = 89,
CPP_TOKEN_RSHIFT = 90,
// NOTE(allen): Precedence 8, LtoR
CPP_TOKEN_LESS = 91,
CPP_TOKEN_GRTR = 92,
CPP_TOKEN_GRTREQ = 93,
CPP_TOKEN_LESSEQ = 94,
CPP_TOKEN_LESS = 91,
CPP_TOKEN_GRTR = 92,
CPP_TOKEN_GRTREQ = 93,
CPP_TOKEN_LESSEQ = 94,
// NOTE(allen): Precedence 9, LtoR
CPP_TOKEN_EQEQ = 95,
@ -191,38 +191,38 @@ ENUM(uint32_t, Cpp_Token_Type){
// NOTE(allen): Precedence 10, LtoR
/* DOC(This type is for parser use, it is not output by the lexer.) */
CPP_TOKEN_BIT_AND = 97,
CPP_TOKEN_BIT_AND = 97,
// NOTE(allen): Precedence 11, LtoR
CPP_TOKEN_BIT_XOR = 98,
CPP_TOKEN_BIT_XOR = 98,
// NOTE(allen): Precedence 12, LtoR
CPP_TOKEN_BIT_OR = 99,
CPP_TOKEN_BIT_OR = 99,
// NOTE(allen): Precedence 13, LtoR
CPP_TOKEN_AND = 100,
CPP_TOKEN_AND = 100,
// NOTE(allen): Precedence 14, LtoR
CPP_TOKEN_OR = 101,
CPP_TOKEN_OR = 101,
// NOTE(allen): Precedence 15, RtoL
CPP_TOKEN_TERNARY_QMARK = 102,
CPP_TOKEN_COLON = 103,
CPP_TOKEN_COLON = 103,
CPP_TOKEN_THROW = 104,
CPP_TOKEN_EQ = 105,
CPP_TOKEN_ADDEQ = 106,
CPP_TOKEN_SUBEQ = 107,
CPP_TOKEN_MULEQ = 108,
CPP_TOKEN_DIVEQ = 109,
CPP_TOKEN_MODEQ = 110,
CPP_TOKEN_LSHIFTEQ = 111,
CPP_TOKEN_RSHIFTEQ = 112,
CPP_TOKEN_ANDEQ = 113,
CPP_TOKEN_OREQ = 114,
CPP_TOKEN_XOREQ = 115,
CPP_TOKEN_EQ = 105,
CPP_TOKEN_ADDEQ = 106,
CPP_TOKEN_SUBEQ = 107,
CPP_TOKEN_MULEQ = 108,
CPP_TOKEN_DIVEQ = 109,
CPP_TOKEN_MODEQ = 110,
CPP_TOKEN_LSHIFTEQ = 111,
CPP_TOKEN_RSHIFTEQ = 112,
CPP_TOKEN_ANDEQ = 113,
CPP_TOKEN_OREQ = 114,
CPP_TOKEN_XOREQ = 115,
// NOTE(allen): Precedence 16, LtoR
CPP_TOKEN_COMMA = 116,
CPP_TOKEN_COMMA = 116,
/* DOC(This type is for parser use, it is not output by the lexer.) */
CPP_TOKEN_EOF = 117,
@ -230,16 +230,13 @@ ENUM(uint32_t, Cpp_Token_Type){
CPP_TOKEN_TYPE_COUNT = 118
};
/* DOC(Cpp_Token represents a single lexed token.
It is the primary output of the lexing system.)
/* DOC(Cpp_Token represents a single lexed token. It is the primary output of the lexing system.)
DOC_SEE(Cpp_Token_Flag) */
STRUCT Cpp_Token{
/* DOC(The type field indicates the type of the token.
All tokens have a type no matter the circumstances.) */
Cpp_Token_Type type;
STRUCT Cpp_Token{
/* DOC(The type field indicates the type of the token. All tokens have a type no matter the circumstances.) */
Cpp_Token_Type type;
/* DOC(The start field indicates the index of the first character
of this token's lexeme.) */
/* DOC(The start field indicates the index of the first character of this token's lexeme.) */
int32_t start;
/* DOC(The size field indicates the number of bytes in this token's lexeme.) */
@ -255,14 +252,13 @@ DOC_SEE(Cpp_Token_Flag) */
/* DOC(The Cpp_Token_Flags are used to mark up tokens with additional information.) */
ENUM(uint16_t, Cpp_Token_Flag){
/* DOC(Indicates that the token is a preprocessor directive.) */
CPP_TFLAG_PP_DIRECTIVE = 0x1,
CPP_TFLAG_PP_DIRECTIVE = 0x1,
/* DOC(Indicates that the token is on the line of a preprocessor directive.) */
CPP_TFLAG_PP_BODY = 0x2,
CPP_TFLAG_PP_BODY = 0x2,
/* DOC(Indicates that the token spans across multiple lines. This can show up
on line comments and string literals with back slash line continuation. ) */
CPP_TFLAG_MULTILINE = 0x4,
/* DOC(Indicates that the token spans across multiple lines. This can show up on line comments and string literals with back slash line continuation. ) */
CPP_TFLAG_MULTILINE = 0x4,
/* DOC(Indicates that the token is some kind of operator or punctuation like braces.) */
CPP_TFLAG_IS_OPERATOR = 0x8,
@ -271,19 +267,15 @@ ENUM(uint16_t, Cpp_Token_Flag){
CPP_TFLAG_IS_KEYWORD = 0x10
};
/* DOC(Cpp_Token_Array is used to bundle together the common elements
of a growing array of Cpp_Tokens. To initialize it the tokens field should
point to a block of memory with a size equal to max_count*sizeof(Cpp_Token)
and the count should be initialized to zero.) */
STRUCT Cpp_Token_Array{
/* DOC(Cpp_Token_Array is used to bundle together the common elements of a growing array of Cpp_Tokens. To initialize it the tokens field should point to a block of memory with a size equal to max_count*sizeof(Cpp_Token) and the count should be initialized to zero.) */
STRUCT Cpp_Token_Array{
/* DOC(The tokens field points to the memory used to store the array of tokens.) */
Cpp_Token *tokens;
Cpp_Token *tokens;
/* DOC(The count field counts how many tokens in the array are currently used.) */
int32_t count;
/* DOC(The max_count field specifies the maximum size the count field may grow to before
the tokens array is out of space.) */
/* DOC(The max_count field specifies the maximum size the count field may grow to before the tokens array is out of space.) */
int32_t max_count;
};
@ -291,32 +283,26 @@ static Cpp_Token_Array null_cpp_token_array = {0};
/* DOC(Cpp_Get_Token_Result is the return result of the cpp_get_token call.)
DOC_SEE(cpp_get_token) */
STRUCT Cpp_Get_Token_Result{
/* DOC(The token_index field indicates which token answers the query. To get the token from
the source array CODE_EXAMPLE(array.tokens[result.token_index])) */
int32_t token_index;
STRUCT Cpp_Get_Token_Result{
/* DOC(The token_index field indicates which token answers the query. To get the token from the source array CODE_EXAMPLE(array.tokens[result.token_index])) */
int32_t token_index;
/* DOC(The in_whitespace field is true when the query position was actually in whitespace
after the result token.) */
int32_t in_whitespace;
/* DOC(The in_whitespace field is true when the query position was actually in whitespace after the result token.) */
int32_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.) */
/* 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;
/* DOC(If the token_index refers to an actual token, this is the start+size value of the token.
Otherwise this is zero.) */
/* 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;
};
/* DOC(Cpp_Relex_Range is the return result of the cpp_get_relex_range call.)
DOC_SEE(cpp_get_relex_range) */
STRUCT Cpp_Relex_Range{
STRUCT Cpp_Relex_Range{
/* DOC(The index of the first token in the unedited array that needs to be relexed.) */
int32_t start_token_index;
/* DOC(The index of the first token in the unedited array after the edited range
that may not need to be relexed. Sometimes a relex operation has to lex past this
position to find a token that is not effected by the edit.) */
/* DOC(The index of the first token in the unedited array after the edited range that may not need to be relexed. Sometimes a relex operation has to lex past this position to find a token that is not effected by the edit.) */
int32_t end_token_index;
};
@ -328,14 +314,12 @@ struct Cpp_Lex_FSM{
};
static Cpp_Lex_FSM null_lex_fsm = {0};
/* DOC(Cpp_Lex_Data represents the state of the lexer so that the system may be resumable
and the user can manage the lexer state and decide when to resume lexing with it. To create
a new lexer state call cpp_lex_data_init.
/* DOC(Cpp_Lex_Data represents the state of the lexer so that the system may be resumable and the user can manage the lexer state and decide when to resume lexing with it. To create a new lexer state call cpp_lex_data_init.
The internals of the lex state should not be treated as a part of the public API.)
DOC_SEE(cpp_lex_data_init)
HIDE_MEMBERS() */
STRUCT Cpp_Lex_Data{
STRUCT Cpp_Lex_Data{
char tb[32];
int32_t tb_pos;
int32_t token_start;
@ -359,23 +343,20 @@ ENUM(int32_t, Cpp_Lex_Result){
/* DOC(This indicates that the system got to the end of the file and will not accept more input.) */
LexResult_Finished = 0,
/* DOC(This indicates that the system got to the end of an input chunk and is ready to receive the
next input chunk.) */
/* DOC(This indicates that the system got to the end of an input chunk and is ready to receive the next input chunk.) */
LexResult_NeedChunk = 1,
/* DOC(This indicates that the output array ran out of space to store tokens and needs to be
replaced or expanded before continuing.) */
/* DOC(This indicates that the output array ran out of space to store tokens and needs to be replaced or expanded before continuing.) */
LexResult_NeedTokenMemory = 2,
/* DOC(This indicates that the maximum number of output tokens as specified by the user was hit.) */
LexResult_HitTokenLimit = 3,
};
/* DOC(Cpp_Relex_Data represents the state of the relexer so that the system may be resumable.
To create a new relex state call cpp_relex_init.)
/* DOC(Cpp_Relex_Data represents the state of the relexer so that the system may be resumable. To create a new relex state call cpp_relex_init.)
DOC_SEE(cpp_relex_init)
HIDE_MEMBERS()*/
STRUCT Cpp_Relex_Data{
STRUCT Cpp_Relex_Data{
Cpp_Lex_Data lex;
Cpp_Token end_token;
@ -451,7 +432,7 @@ ENUM_INTERNAL(uint8_t, Cpp_Lex_State){
};
ENUM_INTERNAL(uint8_t, Cpp_Lex_Int_State){
LSINT_default,
LSINT_default,
LSINT_u,
LSINT_l,
LSINT_L,

35
4ed.cpp
View File

@ -272,7 +272,7 @@ panel_make_empty(System_Functions *system, App_Vars *vars, Panel *panel){
View_And_ID new_view;
Assert(panel->view == 0);
new_view = live_set_alloc_view(system, &vars->live_set, panel, models);
new_view = live_set_alloc_view(&vars->live_set, panel, models);
view_set_file(new_view.view, models->scratch_buffer, models);
new_view.view->map = get_map(models, mapid_file);
@ -507,7 +507,7 @@ case_change_range(System_Functions *system, Mem_Options *mem, View *view, Editin
system->cancel_job(BACKGROUND_THREADS, file->state.lex_job);
}
file_update_history_before_edit(system, mem, file, step, 0, hist_normal);
file_update_history_before_edit(mem, file, step, 0, hist_normal);
u8 *data = (u8*)file->state.buffer.data;
for (i32 i = range.start; i < range.end; ++i){
@ -516,8 +516,9 @@ case_change_range(System_Functions *system, Mem_Options *mem, View *view, Editin
}
}
if (file->state.token_array.tokens)
if (file->state.token_array.tokens){
file_relex_parallel(system, mem, file, range.start, range.end, 0);
}
}
}
@ -596,7 +597,7 @@ COMMAND_DECL(close_panel){
i32 active;
if (models->layout.panel_count > 1){
live_set_free_view(system, command->live_set, view);
live_set_free_view(command->live_set, view);
panel->view = 0;
div = layout_get_divider(&models->layout, panel->parent);
@ -1309,7 +1310,11 @@ app_setup_memory(System_Functions *system, Application_Memory *memory){
*vars = app_vars_zero();
vars->models.mem.part = _partition;
#if defined(USE_DEBUG_MEMORY)
general_memory_open(system, &vars->models.mem.general, memory->target_memory, memory->target_memory_size);
#else
general_memory_open(&vars->models.mem.general, memory->target_memory, memory->target_memory_size);
#endif
return(vars);
}
@ -1661,7 +1666,7 @@ App_Init_Sig(app_init){
}
// NOTE(allen): file setup
working_set_init(system, &models->working_set, partition, &vars->models.mem.general);
working_set_init(&models->working_set, partition, &vars->models.mem.general);
models->working_set.default_display_width = DEFAULT_DISPLAY_WIDTH;
models->working_set.default_minimum_base_display_width = DEFAULT_MINIMUM_BASE_DISPLAY_WIDTH;
@ -1673,7 +1678,7 @@ App_Init_Sig(app_init){
// TODO(allen): more robust allocation solution for the clipboard
if (clipboard.str){
String *dest = working_set_next_clipboard_string(system, &models->mem.general, &models->working_set, clipboard.size);
String *dest = working_set_next_clipboard_string(&models->mem.general, &models->working_set, clipboard.size);
copy_ss(dest, make_string((char*)clipboard.str, clipboard.size));
}
@ -1710,12 +1715,19 @@ App_Init_Sig(app_init){
};
for (i32 i = 0; i < ArrayCount(init_files); ++i){
Editing_File *file = working_set_alloc_always(system, &models->working_set, general);
buffer_bind_name(system, general, &models->working_set, file, init_files[i].name);
Editing_File *file = working_set_alloc_always(&models->working_set, general);
buffer_bind_name(general, &models->working_set, file, init_files[i].name);
switch (init_files[i].type){
case 0: init_normal_file(system, models, file, 0, 0); break;
case 1: init_read_only_file(system, models, file); break;
case 0:
{
init_normal_file(system, models, file, 0, 0);
}break;
case 1:
{
init_read_only_file(system, models, file);
}break;
}
file->settings.never_kill = 1;
@ -1811,8 +1823,7 @@ App_Step_Sig(app_step){
String clipboard = input->clipboard;
if (clipboard.str){
String *dest =
working_set_next_clipboard_string(system, &models->mem.general, &models->working_set, clipboard.size);
String *dest =working_set_next_clipboard_string(&models->mem.general, &models->working_set, clipboard.size);
dest->size = eol_convert_in(dest->str, clipboard.str, clipboard.size);
}

55
4ed.h
View File

@ -27,11 +27,12 @@ struct Application_Memory{
#define KEY_INPUT_BUFFER_DSIZE (KEY_INPUT_BUFFER_SIZE << 1)
struct Key_Input_Data{
Key_Event_Data press[KEY_INPUT_BUFFER_SIZE];
Key_Event_Data hold[KEY_INPUT_BUFFER_SIZE];
i32 press_count;
Key_Event_Data press[KEY_INPUT_BUFFER_SIZE];
Key_Event_Data hold[KEY_INPUT_BUFFER_SIZE];
i32 press_count;
i32 hold_count;
// TODO(allen): determine if we still need this.
char modifiers[MDFR_INDEX_COUNT];
};
static Key_Input_Data null_key_input_data = {0};
@ -74,39 +75,39 @@ typedef struct Plat_Settings{
} Plat_Settings;
#define App_Read_Command_Line_Sig(name) \
i32 name(System_Functions *system, \
Application_Memory *memory, \
String current_directory, \
Plat_Settings *plat_settings, \
char ***files, i32 **file_count, \
Command_Line_Parameters clparams)
i32 name(System_Functions *system, \
Application_Memory *memory, \
String current_directory, \
Plat_Settings *plat_settings, \
char ***files, i32 **file_count, \
Command_Line_Parameters clparams)
typedef App_Read_Command_Line_Sig(App_Read_Command_Line);
#define App_Init_Sig(name) void \
name(System_Functions *system, \
Render_Target *target, \
Application_Memory *memory, \
String clipboard, \
String current_directory, \
Custom_API api)
Render_Target *target, \
Application_Memory *memory, \
String clipboard, \
String current_directory, \
Custom_API api)
typedef App_Init_Sig(App_Init);
enum Application_Mouse_Cursor{
APP_MOUSE_CURSOR_DEFAULT,
APP_MOUSE_CURSOR_ARROW,
APP_MOUSE_CURSOR_IBEAM,
APP_MOUSE_CURSOR_LEFTRIGHT,
APP_MOUSE_CURSOR_UPDOWN,
// never below this
APP_MOUSE_CURSOR_COUNT
APP_MOUSE_CURSOR_DEFAULT,
APP_MOUSE_CURSOR_ARROW,
APP_MOUSE_CURSOR_IBEAM,
APP_MOUSE_CURSOR_LEFTRIGHT,
APP_MOUSE_CURSOR_UPDOWN,
// never below this
APP_MOUSE_CURSOR_COUNT
};
struct Application_Step_Result{
Application_Mouse_Cursor mouse_cursor_type;
Application_Mouse_Cursor mouse_cursor_type;
b32 lctrl_lalt_is_altgr;
b32 trying_to_kill;
b32 perform_kill;
@ -123,11 +124,11 @@ struct Application_Step_Input{
#define App_Step_Sig(name) void \
name(System_Functions *system, \
Render_Target *target, \
Application_Memory *memory, \
Application_Step_Input *input, \
Application_Step_Result *result, \
Command_Line_Parameters params)
Render_Target *target, \
Application_Memory *memory, \
Application_Step_Input *input, \
Application_Step_Result *result, \
Command_Line_Parameters params)
typedef App_Step_Sig(App_Step);

View File

@ -248,7 +248,7 @@ DOC_SEE(Command_Line_Interface_Flag)
}
}
else if (buffer.name){
file = working_set_alloc_always(system, working_set, general);
file = working_set_alloc_always(working_set, general);
if (file == 0){
append_ss(&feedback_str, make_lit_string("ERROR: unable to allocate a new buffer\n"));
do_feedback_message(system, models, feedback_str);
@ -256,7 +256,7 @@ DOC_SEE(Command_Line_Interface_Flag)
goto done;
}
String name = make_string_terminated(part, buffer.name, buffer.name_len);
buffer_bind_name(system, general, working_set, file, name);
buffer_bind_name(general, working_set, file, name);
init_read_only_file(system, models, file);
}
@ -367,7 +367,7 @@ DOC_SEE(The_4coder_Clipboard)
General_Memory *general = &models->mem.general;
Working_Set *working = &models->working_set;
String *dest = working_set_next_clipboard_string(system, general, working, len);
String *dest = working_set_next_clipboard_string(general, working, len);
copy_ss(dest, make_string(str, len));
system->post_clipboard(*dest);
}
@ -689,8 +689,7 @@ DOC_SEE(Buffer_Batch_Edit_Type)
char *inv_str = (char*)part->base + part->pos;
int32_t inv_str_max = part->max - part->pos;
Edit_Spec spec =
file_compute_edit(system, mem, file, edits, str, str_len, inverse_edits, inv_str, inv_str_max, edit_count, type);
Edit_Spec spec = file_compute_edit(mem, file, edits, str, str_len, inverse_edits, inv_str, inv_str_max, edit_count, type);
file_do_batch_edit(system, models, file, spec, hist_normal, type);
@ -714,7 +713,7 @@ DOC_RETURN(returns non-zero on success)
Command_Data *cmd = (Command_Data*)app->cmd_context;
Editing_File *file = imp_get_file(cmd, buffer);
bool32 result = 0;
if (file){
result = 1;
switch (setting){
@ -764,10 +763,10 @@ DOC_SEE(Buffer_Setting_ID)
else{
if (value){
if (!file->settings.virtual_white){
file_first_lex_parallel(system, &models->mem, file);
file_first_lex_parallel(system, &models->mem, file);
}
else{
file_first_lex_serial(system, &models->mem, file);
file_first_lex_serial(&models->mem, file);
}
}
}
@ -787,7 +786,7 @@ DOC_SEE(Buffer_Setting_ID)
if (new_value != file->settings.display_width){
i16 font_id = file->settings.font_id;
Render_Font *font = get_font_info(models->font_set, font_id)->font;
file_set_display_width_and_fix_cursor(system, models, file, new_value, (f32)font->height, font->advance_data);
file_set_display_width_and_fix_cursor(models, file, new_value, (f32)font->height, font->advance_data);
}
}break;
@ -800,7 +799,7 @@ DOC_SEE(Buffer_Setting_ID)
if (new_value != file->settings.minimum_base_display_width){
i16 font_id = file->settings.font_id;
Render_Font *font = get_font_info(models->font_set, font_id)->font;
file_set_minimum_base_display_width_and_fix_cursor(system, models, file, new_value, (f32)font->height, font->advance_data);
file_set_minimum_base_display_width_and_fix_cursor(models, file, new_value, (f32)font->height, font->advance_data);
}
}break;
@ -865,11 +864,11 @@ DOC_SEE(Buffer_Setting_ID)
if (value){
if (!file->settings.virtual_white){
if (!file->settings.tokens_exist){
file_first_lex_serial(system, &models->mem, file);
file_first_lex_serial(&models->mem, file);
}
if (!file->state.still_lexing){
file->settings.virtual_white = 1;
full_remeasure = 1;
file->settings.virtual_white = 1;
full_remeasure = 1;
}
else{
result = 0;
@ -887,9 +886,9 @@ DOC_SEE(Buffer_Setting_ID)
i16 font_id = file->settings.font_id;
Render_Font *font = get_font_info(models->font_set, font_id)->font;
file_allocate_character_starts_as_needed(system, &models->mem.general, file);
file_allocate_character_starts_as_needed(&models->mem.general, file);
buffer_measure_character_starts(&file->state.buffer, file->state.character_starts, 0, file->settings.virtual_white);
file_measure_wraps(system, models, file, (f32)font->height, font->advance_data);
file_measure_wraps(models, file, (f32)font->height, font->advance_data);
file_update_cursor_positions(models, file);
}
}break;
@ -954,10 +953,8 @@ Buffer_Get_Token_Index(Application_Links *app, Buffer_Summary *buffer, int32_t p
DOC_PARAM(buffer, The buffer from which to get a token.)
DOC_PARAM(pos, The position in the buffer in absolute coordinates.)
DOC_PARAM(get_result, The output struct specifying which token contains pos.)
DOC_RETURN(Returns non-zero on success. This call can fail if the buffer doesn't exist,
or if the buffer doesn't have tokens ready.)
DOC(This call finds the token that contains a particular position, or if the position is in between
tokens it finds the index of the token to the left of the position.)
DOC_RETURN(Returns non-zero on success. This call can fail if the buffer doesn't exist, or if the buffer doesn't have tokens ready.)
DOC(This call finds the token that contains a particular position, or if the position is in between tokens it finds the index of the token to the left of the position. The returned index can be -1 if the position is before the first token.)
DOC_SEE(Cpp_Get_Token_Result)
DOC_SEE(cpp_get_token)
*/{
@ -993,7 +990,7 @@ DOC_SEE(Buffer_Create_Flag)
*/{
bool32 result = 0;
if (data){
data->flags = flags;
data->flags = flags;
result = 1;
}
return(result);
@ -1014,14 +1011,14 @@ DOC_SEE(end_buffer_creation)
*/{
bool32 result = 0;
if (data){
String fname = make_fixed_width_string(data->fname_space);
copy_ss(&fname, make_string(filename, filename_len));
data->fname_len = filename_len;
String fname = make_fixed_width_string(data->fname_space);
copy_ss(&fname, make_string(filename, filename_len));
data->fname_len = filename_len;
result = 1;
}
return(result);
}
API_EXPORT Buffer_Summary
End_Buffer_Creation(Application_Links *app, Buffer_Creation_Data *data)
/*
@ -1041,14 +1038,14 @@ DOC_SEE(begin_buffer_creation)
Buffer_Summary result = {0};
if (data && data->fname_len > 0){
String fname = make_string(data->fname_space, data->fname_len);
Editing_File *file = 0;
b32 do_new_file = 0;
Plat_Handle handle = {0};
Temp_Memory temp = begin_temp_memory(part);
String fname = make_string(data->fname_space, data->fname_len);
Editing_File *file = 0;
b32 do_new_file = 0;
Plat_Handle handle = {0};
Temp_Memory temp = begin_temp_memory(part);
Editing_File_Canon_Name canon = {0};
if (get_canon_name(system, &canon, fname)){
file = working_set_canon_contains(working_set, canon.name);
@ -1083,17 +1080,17 @@ DOC_SEE(begin_buffer_creation)
char *buffer = push_array(part, char, size);
if (buffer == 0){
buffer = (char*)general_memory_allocate(system, general, size);
buffer = (char*)general_memory_allocate(general, size);
Assert(buffer != 0);
in_general_mem = 1;
}
if (system->load_file(handle, buffer, size)){
system->load_close(handle);
file = working_set_alloc_always(system, working_set, general);
file = working_set_alloc_always(working_set, general);
if (file){
buffer_bind_file(system, general, working_set, file, canon.name);
buffer_bind_name(system, general, working_set, file, fname);
buffer_bind_name(general, working_set, file, fname);
init_normal_file(system, models, file, buffer, size);
fill_buffer_summary(&result, file, cmd);
}
@ -1103,13 +1100,13 @@ DOC_SEE(begin_buffer_creation)
}
if (in_general_mem){
general_memory_free(system, general, buffer);
general_memory_free(general, buffer);
}
}
else if (!(flags & BufferCreate_NeverNew)){
file = working_set_alloc_always(system, working_set, general);
file = working_set_alloc_always(working_set, general);
if (file){
buffer_bind_name(system, general, working_set, file, fname);
buffer_bind_name(general, working_set, file, fname);
init_normal_file(system, models, file, 0, 0);
fill_buffer_summary(&result, file, cmd);
}
@ -1120,7 +1117,7 @@ DOC_SEE(begin_buffer_creation)
}
end_temp_memory(temp);
}
}
return(result);
}
@ -1142,15 +1139,15 @@ DOC_RETURN(This call returns non-zero on success.)
Editing_File *file = imp_get_file(cmd, buffer);
if (file){
if (file_get_sync(file) != DirtyState_UpToDate){
result = 1;
Partition *part = &models->mem.part;
Temp_Memory temp = begin_temp_memory(part);
String name = make_string_terminated(part, filename, filename_len);
result = 1;
Partition *part = &models->mem.part;
Temp_Memory temp = begin_temp_memory(part);
String name = make_string_terminated(part, filename, filename_len);
save_file_to_name(system, models, file, name.str);
end_temp_memory(temp);
}
}
}
return(result);
}
@ -1414,7 +1411,6 @@ in the system, the call will fail.)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
System_Functions *system = cmd->system;
Models *models = cmd->models;
View *vptr = imp_get_view(cmd, view);
@ -1430,7 +1426,7 @@ in the system, the call will fail.)
i32 which_child;
i32 active;
live_set_free_view(system, models->live_set, vptr);
live_set_free_view(models->live_set, vptr);
panel->view = 0;
div = layout_get_divider(&models->layout, panel->parent);
@ -2022,7 +2018,7 @@ DOC(This call changes 4coder's default font to one of the built in fonts.)
if (font_set_extract(set, font_name, &font_id)){
if (apply_to_all_files){
global_set_font(cmd->system, cmd->models, font_id);
global_set_font(cmd->models, font_id);
}
else{
global_font->font_id = font_id;
@ -2039,7 +2035,6 @@ DOC_PARAM(len, The len parameter specifies the length of the name string.)
DOC(This call sets the display font of a particular buffer.)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
System_Functions *system = cmd->system;
Models *models = cmd->models;
Editing_File *file = imp_get_file(cmd, buffer);
@ -2049,7 +2044,7 @@ DOC(This call sets the display font of a particular buffer.)
i16 font_id = 0;
if (font_set_extract(set, font_name, &font_id)){
file_set_font(system, models, file, font_id);
file_set_font(models, file, font_id);
}
}
}
@ -2067,7 +2062,7 @@ DOC_RETURN(returns non-zero on success)
Models *models = cmd->models;
Editing_File *file = imp_get_file(cmd, buffer);
bool32 result = 0;
bool32 result = 0;
if (file){
Font_Set *set = models->font_set;
String name = make_string_cap(name_out, 0, name_max);

View File

@ -25,7 +25,13 @@
#include "4ed_rendering.h"
#include "4ed.h"
#include "4ed_mem.h"
# include "4coder_mem.h"
//#define USE_DEBUG_MEMORY
#if defined(USE_DEBUG_MEMORY)
# include "4ed_debug_mem.h"
#endif
#define FCPP_FORBID_MALLOC
#include "4cpp_lexer.h"

78
4ed_debug_mem.h Normal file
View File

@ -0,0 +1,78 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 01.14.2017
*
*
*
*/
// TOP
#ifndef FED_DEBUG_MEM_H
#define FED_DEBUG_MEM_H
// NOTE(allen): revent any future instantiation of 4coder_mem.h
#define FCODER_MEM_H
#if !defined(OS_PAGE_SIZE)
#define OS_PAGE_SIZE 4096
#endif
struct Debug_GM{
System_Functions *system;
};
static void
debug_gm_open(System_Functions *system, Debug_GM *general, void *memory, i32 size){
general->system = system;
}
static void*
debug_gm_allocate(Debug_GM *general, int32_t size){
System_Functions *system = general->system;
persist u32 round_val = OS_PAGE_SIZE-1;
size = (size + round_val) & (~round_val);
void *result = system->memory_allocate(0, size + OS_PAGE_SIZE);
system->memory_set_protection(0, (u8*)result + size, OS_PAGE_SIZE, 0);
return(result);
}
static void
debug_gm_free(Debug_GM *general, void *memory){
System_Functions *system = general->system;
system->memory_free(0, memory, 0);
}
static void*
debug_gm_reallocate(Debug_GM *general, void *old, int32_t old_size, int32_t size){
void *result = debug_gm_allocate(general, size);
memcpy(result, old, old_size);
debug_gm_free(general, old);
return(result);
}
inline void*
debug_gm_reallocate_nocopy(Debug_GM *general, void *old, int32_t size){
debug_gm_free(general, old);
void *result = debug_gm_allocate(general, size);
return(result);
}
// Redefine the normal general memory names to go to these debug names.
#define General_Memory Debug_GM
struct Debug_Mem_Options{
Partition part;
General_Memory general;
};
#define Mem_Options Debug_Mem_Options
#define general_memory_open(sys,gen,mem,siz) debug_gm_open(sys,gen,mem,siz)
#define general_memory_allocate(gen,siz) debug_gm_allocate(gen,siz)
#define general_memory_free(gen,siz) debug_gm_free(gen,siz)
#define general_memory_reallocate(gen,old,old_size,new_size) debug_gm_reallocate(gen,old,old_size,new_size)
#define general_memory_reallocate_nocopy(gen,old,new_size) debug_gm_reallocate_nocopy(gen,old,new_size)
#endif
// BOTTOM

File diff suppressed because it is too large Load Diff

View File

@ -174,8 +174,7 @@ font_set_use(Partition *partition, Font_Set *set, i16 font_id){
}
internal b32
font_set_add(Partition *partition, Font_Set *set,
String filename, String name, i32 pt_size){
font_set_add(Partition *partition, Font_Set *set, String filename, String name, i32 pt_size){
b32 result = 0;
if (font_set_can_add(set)){
Render_Font dummy_font = {0};
@ -184,10 +183,7 @@ font_set_add(Partition *partition, Font_Set *set,
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);
set->font_load(&dummy_font, info->filename.str, info->name.str, info->pt_size, 4, false);
info->height = dummy_font.height;
info->advance = dummy_font.advance;

107
4ed_mem.h
View File

@ -1,107 +0,0 @@
#ifndef FED_MEM_H
#define FED_MEM_H
#include "4coder_mem.h"
//#define MEMORY_DEBUG
static void
general_memory_open(System_Functions *system, General_Memory *general, void *memory, int32_t size){
#if defined(MEMORY_DEBUG)
general_memory_open(general, memory, size);
#else
general_memory_open(general, memory, size);
#endif
}
#if defined(Assert) && !defined(MEMORY_DEBUG)
static int32_t
general_memory_check(System_Functions *system, General_Memory *general){
Bubble *sentinel = &general->sentinel;
for (Bubble *bubble = sentinel->next;
bubble != sentinel;
bubble = bubble->next){
Assert(bubble);
Bubble *next = bubble->next;
Assert(bubble == next->prev);
if (next != sentinel && bubble->prev != sentinel){
Assert(bubble->next > bubble);
Assert(bubble > bubble->prev);
char *end_ptr = (char*)(bubble + 1) + bubble->size;
char *next_ptr = (char*)next;
(void)(end_ptr);
(void)(next_ptr);
Assert(end_ptr == next_ptr);
}
}
return(1);
}
#else
static int32_t
general_memory_check(System_Functions *system, General_Memory *general){return(1);}
#endif
#define OS_PAGE_SIZE 4096
static void*
general_memory_allocate(System_Functions *system, General_Memory *general, int32_t size){
#if defined(MEMORY_DEBUG)
{
persist u32 round_val = OS_PAGE_SIZE-1;
size = (size + round_val) & (~round_val);
void *result = system->memory_allocate(0, size + OS_PAGE_SIZE);
system->memory_set_protection(0, (u8*)result + size, OS_PAGE_SIZE, 0);
return(result);
}
#else
return general_memory_allocate(general, size);
#endif
}
static void
general_memory_free(System_Functions *system, General_Memory *general, void *memory){
#if defined(MEMORY_DEBUG)
{
system->memory_free(0, memory, 0);
}
#else
return general_memory_free(general, memory);
#endif
}
static void*
general_memory_reallocate(System_Functions *system, General_Memory *general, void *old, int32_t old_size, int32_t size){
#if defined(MEMORY_DEBUG)
{
void *result = general_memory_allocate(system, general, size);
memcpy(result, old, old_size);
general_memory_free(system, general, old);
return(result);
}
#else
return general_memory_reallocate(general, old, old_size, size);
#endif
}
inline void*
general_memory_reallocate_nocopy(System_Functions *system, General_Memory *general, void *old, int32_t size){
#if defined(MEMORY_DEBUG)
{
general_memory_free(system, general, old);
return general_memory_allocate(system, general, size);
}
#else
return general_memory_reallocate_nocopy(general, old, size);
#endif
}
#define reset_temp_memory end_temp_memory
#define gen_struct(s, g, T) (T*)general_memory_allocate(s, g, sizeof(T), 0)
#define gen_array(s, g, T, size) (T*)general_memory_allocate(s, g, sizeof(T)*(size))
#define gen_block(s, g, size) general_memory_open(s, g, size, 0)
#endif

View File

@ -33,7 +33,7 @@ begin_render_section(Render_Target *target, System_Functions *system){
memset(font_set->font_used_flags, 0, font_set->max);
target->size = 0;
target->clip_top = -1;
i32_Rect clip;
clip.x0 = 0;
clip.y0 = 0;
@ -112,12 +112,11 @@ draw_margin(Render_Target *target, i32_Rect outer, i32 width, u32 color){
inline internal i32
font_predict_size(i32 pt_size){
return pt_size*pt_size*128;
return pt_size*pt_size*128;
}
internal void
font_draw_glyph_mono(Render_Target *target, i16 font_id,
u8 character, f32 x, f32 y, f32 advance, u32 color){
font_draw_glyph_mono(Render_Target *target, i16 font_id, u8 character, f32 x, f32 y, f32 advance, u32 color){
Render_Piece_Combined piece;
piece.header.type = piece_type_mono_glyph;
piece.glyph.pos.x = x;
@ -137,8 +136,7 @@ font_draw_glyph_mono(Render_Target *target, i16 font_id,
}
internal void
font_draw_glyph(Render_Target *target, i16 font_id,
u8 character, f32 x, f32 y, u32 color){
font_draw_glyph(Render_Target *target, i16 font_id, u8 character, f32 x, f32 y, u32 color){
Render_Piece_Combined piece;
piece.header.type = piece_type_glyph;
piece.glyph.pos.x = x;

Binary file not shown.

View File

@ -134,12 +134,12 @@ sysshared_load_file(char *filename){
result.data = (char*)system_get_memory(size+1);
if (!result.data){
result = file_data_zero();
result = null_file_data;
}
else{
if (!system_load_file(handle, result.data, size)){
system_free_memory(result.data);
result = file_data_zero();
result = null_file_data;
}
}
}
@ -366,8 +366,7 @@ private_draw_rectangle_outline(Render_Target *target, f32_Rect rect, u32 color){
}
inline void
private_draw_gradient(Render_Target *target, f32_Rect rect,
Vec4 color_left, Vec4 color_right){
private_draw_gradient(Render_Target *target, f32_Rect rect, Vec4 color_left, Vec4 color_right){
Vec4 cl = color_left;
Vec4 cr = color_right;
@ -429,12 +428,8 @@ get_exact_render_quad(Glyph_Data *b, i32 pw, i32 ph, float xpos, float ypos){
}
inline void
private_draw_glyph(Render_Target *target, Render_Font *font,
u8 character, f32 x, f32 y, u32 color){
Render_Quad q = get_render_quad(
font->glyphs + character,
font->tex_width, font->tex_height, x, y
);
private_draw_glyph(Render_Target *target, Render_Font *font, u8 character, f32 x, f32 y, u32 color){
Render_Quad q = get_render_quad(font->glyphs + character, font->tex_width, font->tex_height, x, y);
draw_set_color(target, color);
draw_bind_texture(target, font->tex);
@ -494,59 +489,50 @@ launch_rendering(Render_Target *target){
switch (type){
case piece_type_rectangle:
{
Render_Piece_Rectangle *rectangle =
ExtractStruct(Render_Piece_Rectangle);
Render_Piece_Rectangle *rectangle = ExtractStruct(Render_Piece_Rectangle);
private_draw_rectangle(target, rectangle->rect, rectangle->color);
}break;
case piece_type_outline:
{
Render_Piece_Rectangle *rectangle =
ExtractStruct(Render_Piece_Rectangle);
Render_Piece_Rectangle *rectangle = ExtractStruct(Render_Piece_Rectangle);
private_draw_rectangle_outline(target, rectangle->rect, rectangle->color);
}break;
case piece_type_gradient:
{
Render_Piece_Gradient *gradient =
ExtractStruct(Render_Piece_Gradient);
private_draw_gradient(target, gradient->rect,
unpack_color4(gradient->left_color),
unpack_color4(gradient->right_color));
Render_Piece_Gradient *gradient = ExtractStruct(Render_Piece_Gradient);
private_draw_gradient(target, gradient->rect, unpack_color4(gradient->left_color), unpack_color4(gradient->right_color));
}break;
case piece_type_glyph:
{
Render_Piece_Glyph *glyph =
ExtractStruct(Render_Piece_Glyph);
Render_Piece_Glyph *glyph = ExtractStruct(Render_Piece_Glyph);
Render_Font *font = get_font_info(&target->font_set, glyph->font_id)->font;
if (font)
private_draw_glyph(target, font, glyph->character,
glyph->pos.x, glyph->pos.y, glyph->color);
if (font){
private_draw_glyph(target, font, glyph->character, glyph->pos.x, glyph->pos.y, glyph->color);
}
}break;
case piece_type_mono_glyph:
{
Render_Piece_Glyph *glyph =
ExtractStruct(Render_Piece_Glyph);
Render_Piece_Glyph *glyph = ExtractStruct(Render_Piece_Glyph);
Render_Font *font = get_font_info(&target->font_set, glyph->font_id)->font;
if (font)
private_draw_glyph_mono(target, font, glyph->character,
glyph->pos.x, glyph->pos.y, glyph->color);
if (font){
private_draw_glyph_mono(target, font, glyph->character, glyph->pos.x, glyph->pos.y, glyph->color);
}
}break;
case piece_type_mono_glyph_advance:
{
Render_Piece_Glyph_Advance *glyph =
ExtractStruct(Render_Piece_Glyph_Advance);
Render_Piece_Glyph_Advance *glyph = ExtractStruct(Render_Piece_Glyph_Advance);
Render_Font *font = get_font_info(&target->font_set, glyph->font_id)->font;
if (font)
private_draw_glyph_mono(target, font, glyph->character,
glyph->pos.x, glyph->pos.y,
glyph->advance, glyph->color);
if (font){
private_draw_glyph_mono(target, font, glyph->character, glyph->pos.x, glyph->pos.y, glyph->advance, glyph->color);
}
}break;
case piece_type_change_clip:

View File

@ -19,11 +19,7 @@ struct File_Data{
u32 size;
b32 got_file;
};
inline File_Data
file_data_zero(){
File_Data result = {0};
return(result);
}
globalvar File_Data null_file_data = {0};
#define Sys_Get_Memory_Sig(name) void* name(i32 size, i32 line_number, char *file_name)
#define Sys_Free_Memory_Sig(name) void name(void *block)

View File

@ -116,7 +116,7 @@ working_set_alloc(Working_Set *working_set){
}
internal Editing_File*
working_set_alloc_always(System_Functions *system, Working_Set *working_set, General_Memory *general){
working_set_alloc_always(Working_Set *working_set, General_Memory *general){
Editing_File *result = 0;
Editing_File *new_chunk;
i32 full_new_count = working_set->file_max;
@ -126,7 +126,7 @@ working_set_alloc_always(System_Functions *system, Working_Set *working_set, Gen
else new_count = (i16)full_new_count;
if (working_set->file_count == working_set->file_max &&working_set->array_count < working_set->array_max){
new_chunk = gen_array(system, general, Editing_File, new_count);
new_chunk = gen_array(general, Editing_File, new_count);
working_set_extend_memory(working_set, new_chunk, new_count);
}
result = working_set_alloc(working_set);
@ -185,7 +185,7 @@ working_set_get_active_file(Working_Set *working_set, i32 id){
}
internal void
working_set_init(System_Functions *system, Working_Set *working_set, Partition *partition, General_Memory *general){
working_set_init(Working_Set *working_set, Partition *partition, General_Memory *general){
i16 init_count = 16;
i16 array_init_count = 256;
@ -211,7 +211,7 @@ working_set_init(System_Functions *system, Working_Set *working_set, Partition *
i32 item_size = sizeof(File_Name_Entry);
i32 table_size = working_set->file_max;
i32 mem_size = table_required_mem_size(table_size, item_size);
void *mem = general_memory_allocate(system, general, mem_size);
void *mem = general_memory_allocate(general, mem_size);
memset(mem, 0, mem_size);
table_init_memory(&working_set->canon_table, mem, table_size, item_size);
}
@ -221,23 +221,23 @@ working_set_init(System_Functions *system, Working_Set *working_set, Partition *
i32 item_size = sizeof(File_Name_Entry);
i32 table_size = working_set->file_max;
i32 mem_size = table_required_mem_size(table_size, item_size);
void *mem = general_memory_allocate(system, general, mem_size);
void *mem = general_memory_allocate(general, mem_size);
memset(mem, 0, mem_size);
table_init_memory(&working_set->name_table, mem, table_size, item_size);
}
}
inline void
working_set__grow_if_needed(System_Functions *system, Table *table, General_Memory *general, void *arg, Hash_Function *hash_func, Compare_Function *comp_func){
working_set__grow_if_needed(Table *table, General_Memory *general, void *arg, Hash_Function *hash_func, Compare_Function *comp_func){
if (table_at_capacity(table)){
Table btable = {0};
i32 new_max = table->max * 2;
i32 mem_size = table_required_mem_size(new_max, table->item_size);
void *mem = general_memory_allocate(system, general, mem_size);
void *mem = general_memory_allocate(general, mem_size);
table_init_memory(&btable, mem, new_max, table->item_size);
table_clear(&btable);
table_rehash(table, &btable, 0, hash_func, comp_func);
general_memory_free(system, general, table->hash_array);
general_memory_free(general, table->hash_array);
*table = btable;
}
}
@ -256,8 +256,8 @@ working_set_contains_basic(Working_Set *working_set, Table *table, String name){
}
internal b32
working_set_add_basic(System_Functions *system, General_Memory *general, Working_Set *working_set, Table *table, Editing_File *file, String name){
working_set__grow_if_needed(system, table, general, 0, tbl_string_hash, tbl_string_compare);
working_set_add_basic(General_Memory *general, Working_Set *working_set, Table *table, Editing_File *file, String name){
working_set__grow_if_needed(table, general, 0, tbl_string_hash, tbl_string_compare);
File_Name_Entry entry;
entry.name = name;
@ -279,9 +279,8 @@ working_set_canon_contains(Working_Set *working_set, String name){
}
internal b32
working_set_canon_add(System_Functions *system, General_Memory *general, Working_Set *working_set,
Editing_File *file, String name){
b32 result = working_set_add_basic(system, general,working_set, &working_set->canon_table, file, name);
working_set_canon_add(General_Memory *general, Working_Set *working_set, Editing_File *file, String name){
b32 result = working_set_add_basic(general,working_set, &working_set->canon_table, file, name);
return(result);
}
@ -298,9 +297,8 @@ working_set_name_contains(Working_Set *working_set, String name){
}
internal b32
working_set_name_add(System_Functions *system, General_Memory *general, Working_Set *working_set,
Editing_File *file, String name){
b32 result = working_set_add_basic(system, general, working_set, &working_set->name_table, file, name);
working_set_name_add(General_Memory *general, Working_Set *working_set, Editing_File *file, String name){
b32 result = working_set_add_basic(general, working_set, &working_set->name_table, file, name);
return(result);
}
@ -435,8 +433,8 @@ buffer_bind_file(System_Functions *system, General_Memory *general, Working_Set
file->canon.name = make_fixed_width_string(file->canon.name_);
copy_ss(&file->canon.name, canon_filename);
terminate_with_null(&file->canon.name);
system->add_listener(file->canon.name_);
b32 result = working_set_canon_add(system, general, working_set, file, file->canon.name);
system->add_listener(file->canon.name.str);
b32 result = working_set_canon_add(general, working_set, file, file->canon.name);
Assert(result); AllowLocal(result);
}
@ -453,7 +451,7 @@ buffer_unbind_file(System_Functions *system, Working_Set *working_set, Editing_F
}
internal void
buffer_bind_name(System_Functions *system, General_Memory *general, Working_Set *working_set, Editing_File *file, String filename){
buffer_bind_name(General_Memory *general, Working_Set *working_set, Editing_File *file, String filename){
Assert(file->name.live_name.size == 0 &&
file->name.source_path.size == 0 &&
file->name.extension.size == 0);
@ -467,7 +465,7 @@ buffer_bind_name(System_Functions *system, General_Memory *general, Working_Set
copy_ss(&file->name.source_path, new_name.source_path);
copy_ss(&file->name.extension, new_name.extension);
b32 result = working_set_name_add(system, general, working_set, file, file->name.live_name);
b32 result = working_set_name_add(general, working_set, file, file->name.live_name);
Assert(result); AllowLocal(result);
}

View File

@ -133,7 +133,7 @@ struct Application_Links;
#define InterlockedCompareExchange(dest, ex, comp) __sync_val_compare_and_swap((dest), (comp), (ex))
#include "filetrack/4tech_file_track_linux.c"
#include "system_shared.h"
#include "4ed_system_shared.h"
//
// Linux structs / enums
@ -1338,7 +1338,7 @@ INTERNAL_Sys_Get_Thread_States_Sig(internal_get_thread_states){
// Linux rendering/font system functions
//
#include "system_shared.cpp"
#include "4ed_system_shared.cpp"
#include "linux_font.cpp"
internal f32

14
pens_arena.cpp Normal file
View File

@ -0,0 +1,14 @@
/*
Build target for the 'pens' project.
By Allen Webster
Created 09.01.2017 (dd.mm.yyyy)
*/
// TOP
struct Arena{
};
// BOTTOM

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,34 @@
extensions=".c.cpp.h.hpp.bat.sh";
fkey_command_win[1] = {"build.bat", "*compilation*", true};
fkey_command_win[2] = {"..\\misc\\run.bat", "*run*"};
fkey_command_win[3] = {"site\\build.bat", "*compilation*", true};
fkey_command_win[4] = {"file\\run_tests.bat", "*tests*", true};
fkey_command_win[5] = {0, 0};
fkey_command_win[2] = {"site\\build.bat", "*compilation*", true};
fkey_command_win[3] = {"file\\run_tests.bat", "*tests*", true};
fkey_command_win[4] = {0, 0};
fkey_command_win[5] = {"..\\misc\\run.bat", "*run*"};
fkey_command_win[6] = {0, 0};
fkey_command_win[7] = {0, 0};
fkey_command_win[8] = {"package.bat", "*package*"};
fkey_command_win[8] = {0, 0};
fkey_command_win[9] = {0, 0};
fkey_command_win[10] = {0, 0};
fkey_command_win[11] = {0, 0};
fkey_command_win[12] = {0, 0};
fkey_command_win[8] = {"package.bat", "*package*"};
fkey_command_win[13] = {0, 0};
fkey_command_win[14] = {0, 0};
fkey_command_win[15] = {0, 0};
fkey_command_win[16] = {0, 0};
fkey_command_linux[1] = {"./build.sh", "*compilation*", true};
fkey_command_linux[2] = {"../build/4ed", "*run*"};
fkey_command_linux[3] = {"site/build.sh", "*compilation*", true};
fkey_command_linux[2] = {"site/build.sh", "*compilation*", true};
fkey_command_linux[3] = {0, 0};
fkey_command_linux[4] = {0, 0};
fkey_command_linux[5] = {0, 0};
fkey_command_linux[5] = {"../build/4ed", "*run*"};
fkey_command_linux[6] = {0, 0};
fkey_command_linux[7] = {0, 0};
fkey_command_linux[8] = {"./package.sh", "*package*"};
fkey_command_linux[8] = {0, 0};
fkey_command_linux[9] = {0, 0};
fkey_command_linux[10] = {0, 0};
fkey_command_linux[11] = {0, 0};
fkey_command_linux[12] = {0, 0};
fkey_command_linux[12] = {"./package.sh", "*package*"};
fkey_command_linux[13] = {0, 0};
fkey_command_linux[14] = {0, 0};
fkey_command_linux[15] = {0, 0};

View File

@ -69,7 +69,7 @@ struct Application_Links;
#define GL_TEXTURE_MAX_LEVEL 0x813D
#include "filetrack/4tech_file_track_win32.c"
#include "system_shared.h"
#include "4ed_system_shared.h"
#define SUPPORT_DPI 1
#define USE_FT_FONTS 1
@ -111,7 +111,7 @@ struct Control_Keys{
b8 l_alt;
b8 r_alt;
};
static Control_Keys null_control_keys;
static Control_Keys null_control_keys = {0};
struct Win32_Input_Chunk_Transient{
Key_Input_Data key_data;
@ -1221,7 +1221,7 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){
return(close_me);
}
#include "system_shared.cpp"
#include "4ed_system_shared.cpp"
#if USE_FT_FONTS
# include "win32_ft_font.cpp"
@ -1486,10 +1486,8 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
case VK_MENU:case VK_LMENU:case VK_RMENU:
case VK_SHIFT:case VK_LSHIFT:case VK_RSHIFT:
{
Control_Keys *controls = 0;
b8 *control_keys = 0;
controls = &win32vars.input_chunk.pers.controls;
control_keys = win32vars.input_chunk.pers.control_keys;
Control_Keys *controls = &win32vars.input_chunk.pers.controls;
b8 *control_keys = win32vars.input_chunk.pers.control_keys;
b8 down = ((lParam & Bit_31)?(0):(1));
b8 is_right = ((lParam & Bit_24)?(1):(0));
@ -1722,7 +1720,7 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
win32vars.input_chunk.pers.mouse_l = 0;
win32vars.input_chunk.pers.mouse_r = 0;
for (int32_t i = 0; i < MDFR_INDEX_COUNT; ++i){
for (i32 i = 0; i < MDFR_INDEX_COUNT; ++i){
win32vars.input_chunk.pers.control_keys[i] = 0;
}
win32vars.input_chunk.pers.controls = null_control_keys;
@ -2091,7 +2089,7 @@ WinMain(HINSTANCE hInstance,
PFD_MAIN_PLANE,
0,
0, 0, 0 };
// TODO(allen): get an upgraded context to see if that fixes the nvidia card issues.
{
i32 pixel_format;
pixel_format = ChoosePixelFormat(hdc, &pfd);