merging whitespace by handle cuz yay
This commit is contained in:
commit
f8e39d9957
|
@ -63,6 +63,8 @@ ENUM(uint64_t, Command_ID){
|
|||
cmdid_interactive_new,
|
||||
/* DOC(cmdid_interactive_open begins an interactive dialogue to open a file into a buffer.) */
|
||||
cmdid_interactive_open,
|
||||
/* DOC(cmdid_interactive_open_or_new begins an interactive dialogue to open a file into a buffer, if the name specified does not match any existing buffer, a new buffer is created instead.) */
|
||||
cmdid_interactive_open_or_new,
|
||||
/* DOC(cmdid_save_as does not currently work and is likely to be removed rather that fixed.) */
|
||||
cmdid_save_as,
|
||||
/* DOC(cmdid_interactive_switch_buffer begins an interactive dialogue to choose an open buffer to swap into the active view.) */
|
||||
|
@ -187,14 +189,14 @@ ENUM(int32_t, View_Setting_ID){
|
|||
/* DOC(ViewSetting_Null is not a valid setting, it is reserved to detect errors.) */
|
||||
ViewSetting_Null,
|
||||
|
||||
/* DOC(The ViewSetting_ShowWhitespace setting determines whether the view highlights
|
||||
whitespace in a file. Whenever the view switches to a new buffer this setting is turned off.) */
|
||||
/* DOC(The ViewSetting_ShowWhitespace setting determines whether the view highlights whitespace in a file. Whenever the view switches to a new buffer this setting is turned off.) */
|
||||
ViewSetting_ShowWhitespace,
|
||||
|
||||
/* DOC(The ViewSetting_ShowScrollbar setting determines whether a scroll bar is
|
||||
attached to a view in it's scrollable section.) */
|
||||
/* DOC(The ViewSetting_ShowScrollbar setting determines whether a scroll bar is attached to a view in it's scrollable section.) */
|
||||
ViewSetting_ShowScrollbar,
|
||||
|
||||
/* DOC(The ViewSetting_ShowFileBar settings determines whether to show the file bar.) */
|
||||
ViewSetting_ShowFileBar,
|
||||
};
|
||||
|
||||
/* DOC(A Buffer_Create_Flag field specifies how a buffer should be created.) */
|
||||
|
@ -230,18 +232,13 @@ ENUM(uint32_t, Buffer_Kill_Flag){
|
|||
|
||||
/* DOC(An Access_Flag field specifies what sort of permission you grant to an access call. An access call is usually one the returns a summary struct. If a 4coder object has a particular protection flag set and the corresponding bit is not set in the access field, that 4coder object is hidden. On the other hand if a protection flag is set in the access parameter and the object does not have that protection flag, the object is still returned from the access call.) */
|
||||
ENUM(uint32_t, Access_Flag){
|
||||
/* DOC(AccessOpen does not include any bits, it indicates that the access should
|
||||
only return objects that have no protection flags set.) */
|
||||
/* DOC(AccessOpen does not include any bits, it indicates that the access should 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 into *build*. This is to prevent
|
||||
the user from accidentally editing output that they might prefer to keep in tact.) */
|
||||
/* DOC(AccessProtected is set on buffers and views that are "read only" such as the output from an 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
|
||||
instance because it is navigating the file system to open a file.) */
|
||||
/* DOC(AccessHidden is set on any view that is not currently showing it's file, for instance because it is navigating the file system to open a file.) */
|
||||
AccessHidden = 0x2,
|
||||
/* DOC(AccessAll is a catchall access for cases where an access call should always
|
||||
return an object no matter what it's protection flags are.) */
|
||||
/* DOC(AccessAll is a catchall access for cases where an access call should always return an object no matter what it's protection flags are.) */
|
||||
AccessAll = 0xFF
|
||||
};
|
||||
|
||||
|
@ -565,13 +562,11 @@ STRUCT Buffer_Edit{
|
|||
DOC_SEE(Access_Flag)
|
||||
DOC_SEE(Dirty_State) */
|
||||
STRUCT Buffer_Summary{
|
||||
/* DOC(This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder.
|
||||
When this field is false the summary is referred to as a "null summary".) */
|
||||
/* DOC(This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder. When this field is false the summary is referred to as a "null summary".) */
|
||||
bool32 exists;
|
||||
/* DOC(If this is not a null summary, this field indicates whether the buffer has finished loading.) */
|
||||
bool32 ready;
|
||||
/* DOC(If this is not a null summary this field is the id of the associated buffer.
|
||||
If this is a null summary then buffer_id is 0.) */
|
||||
/* DOC(If this is not a null summary this field is the id of the associated buffer. If this is a null summary then buffer_id is 0.) */
|
||||
int32_t buffer_id;
|
||||
/*DOC(If this is not a null summary, this field contains flags describing the protection status of the buffer.)*/
|
||||
Access_Flag lock_flags;
|
||||
|
@ -596,10 +591,7 @@ STRUCT Buffer_Summary{
|
|||
|
||||
/* DOC(If this is not a null summary, this field indicates whether the buffer is set to lex tokens.) */
|
||||
bool32 is_lexed;
|
||||
/* DOC(If this is not a null summary, this field indicates whether the buffer has up to date tokens available.
|
||||
If this field is false, it may simply mean the tokens are still being generated in a background task and will
|
||||
be available later. If that is the case, is_lexed will be true to indicate that the buffer is trying to get
|
||||
it's tokens up to date.) */
|
||||
/* DOC(If this is not a null summary, this field indicates whether the buffer has up to date tokens available. If this field is false, it may simply mean the tokens are still being generated in a background task and will be available later. If that is the case, is_lexed will be true to indicate that the buffer is trying to get it's tokens up to date.) */
|
||||
bool32 tokens_are_ready;
|
||||
/* DOC(If this is not a null summary, this field specifies the id of the command map for this buffer.) */
|
||||
int32_t map_id;
|
||||
|
|
|
@ -473,15 +473,25 @@ CUSTOM_COMMAND_SIG(open_panel_hsplit){
|
|||
//
|
||||
|
||||
CUSTOM_COMMAND_SIG(show_scrollbar){
|
||||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
View_Summary view = get_active_view(app, AccessAll);
|
||||
view_set_setting(app, &view, ViewSetting_ShowScrollbar, true);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(hide_scrollbar){
|
||||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
View_Summary view = get_active_view(app, AccessAll);
|
||||
view_set_setting(app, &view, ViewSetting_ShowScrollbar, false);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(show_file_bar){
|
||||
View_Summary view = get_active_view(app, AccessAll);
|
||||
view_set_setting(app, &view, ViewSetting_ShowFileBar, true);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(hide_file_bar){
|
||||
View_Summary view = get_active_view(app, AccessAll);
|
||||
view_set_setting(app, &view, ViewSetting_ShowFileBar, false);
|
||||
}
|
||||
|
||||
//toggle_fullscreen can be used as a command
|
||||
|
||||
CUSTOM_COMMAND_SIG(toggle_line_wrap){
|
||||
|
@ -565,7 +575,7 @@ CUSTOM_COMMAND_SIG(search);
|
|||
CUSTOM_COMMAND_SIG(reverse_search);
|
||||
|
||||
static void
|
||||
isearch(Application_Links *app, int32_t start_reversed){
|
||||
isearch(Application_Links *app, int32_t start_reversed, String query_init){
|
||||
uint32_t access = AccessProtected;
|
||||
|
||||
View_Summary view = get_active_view(app, access);
|
||||
|
@ -576,98 +586,123 @@ isearch(Application_Links *app, int32_t start_reversed){
|
|||
Query_Bar bar = {0};
|
||||
if (start_query_bar(app, &bar, 0) == 0) return;
|
||||
|
||||
int32_t reverse = start_reversed;
|
||||
int32_t pos = view.cursor.pos;
|
||||
bool32 reverse = start_reversed;
|
||||
int32_t first_pos = view.cursor.pos;
|
||||
|
||||
int32_t pos = first_pos;
|
||||
if (query_init.size != 0){
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
int32_t start_pos = pos;
|
||||
int32_t first_pos = pos;
|
||||
Range match = make_range(pos, pos);
|
||||
|
||||
char bar_string_space[256];
|
||||
bar.string = make_fixed_width_string(bar_string_space);
|
||||
copy_ss(&bar.string, query_init);
|
||||
|
||||
String isearch_str = make_lit_string("I-Search: ");
|
||||
String rsearch_str = make_lit_string("Reverse-I-Search: ");
|
||||
|
||||
bool32 first_step = true;
|
||||
|
||||
User_Input in = {0};
|
||||
for (;;){
|
||||
view_set_highlight(app, &view, match.start, match.end, true);
|
||||
|
||||
// NOTE(allen): Change the bar's prompt to match the current direction.
|
||||
if (reverse) bar.prompt = rsearch_str;
|
||||
else bar.prompt = isearch_str;
|
||||
|
||||
in = get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
|
||||
if (in.abort) break;
|
||||
|
||||
// NOTE(allen): If we're getting mouse events here it's a 4coder bug, because we
|
||||
// only asked to intercept key events.
|
||||
Assert(in.type == UserInputKey);
|
||||
|
||||
char character = to_writable_char(in.key.character);
|
||||
int32_t made_change = 0;
|
||||
if (in.key.keycode == '\n' || in.key.keycode == '\t'){
|
||||
break;
|
||||
if (reverse){
|
||||
bar.prompt = rsearch_str;
|
||||
}
|
||||
else if (character && key_is_unmodified(&in.key)){
|
||||
append_s_char(&bar.string, character);
|
||||
made_change = 1;
|
||||
else{
|
||||
bar.prompt = isearch_str;
|
||||
}
|
||||
else if (in.key.keycode == key_back){
|
||||
if (bar.string.size > 0){
|
||||
--bar.string.size;
|
||||
made_change = 1;
|
||||
|
||||
bool32 step_forward = false;
|
||||
bool32 step_backward = false;
|
||||
bool32 backspace = false;
|
||||
|
||||
if (!first_step){
|
||||
in = get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
|
||||
if (in.abort) break;
|
||||
|
||||
// NOTE(allen): If we're getting mouse events here it's a 4coder bug, because we only asked to intercept key events.
|
||||
Assert(in.type == UserInputKey);
|
||||
|
||||
char character = to_writable_char(in.key.character);
|
||||
bool32 made_change = false;
|
||||
if (in.key.keycode == '\n' || in.key.keycode == '\t'){
|
||||
break;
|
||||
}
|
||||
else if (character && key_is_unmodified(&in.key)){
|
||||
append_s_char(&bar.string, character);
|
||||
made_change = true;
|
||||
}
|
||||
else if (in.key.keycode == key_back){
|
||||
if (bar.string.size > 0){
|
||||
--bar.string.size;
|
||||
made_change = true;
|
||||
}
|
||||
backspace = true;
|
||||
}
|
||||
|
||||
if ((in.command.command == search) || in.key.keycode == key_page_down || in.key.keycode == key_down){
|
||||
step_forward = true;
|
||||
}
|
||||
|
||||
if ((in.command.command == reverse_search) || in.key.keycode == key_page_up || in.key.keycode == key_up){
|
||||
step_backward = true;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t step_forward = 0;
|
||||
int32_t step_backward = 0;
|
||||
|
||||
if ((in.command.command == search) ||
|
||||
in.key.keycode == key_page_down || in.key.keycode == key_down) step_forward = 1;
|
||||
if ((in.command.command == reverse_search) ||
|
||||
in.key.keycode == key_page_up || in.key.keycode == key_up) step_backward = 1;
|
||||
else{
|
||||
if (bar.string.size != 0){
|
||||
step_backward = true;
|
||||
}
|
||||
first_step = false;
|
||||
}
|
||||
|
||||
start_pos = pos;
|
||||
if (step_forward && reverse){
|
||||
start_pos = match.start + 1;
|
||||
pos = start_pos;
|
||||
reverse = 0;
|
||||
step_forward = 0;
|
||||
reverse = false;
|
||||
step_forward = false;
|
||||
}
|
||||
if (step_backward && !reverse){
|
||||
start_pos = match.start - 1;
|
||||
pos = start_pos;
|
||||
reverse = 1;
|
||||
step_backward = 0;
|
||||
reverse = true;
|
||||
step_backward = false;
|
||||
}
|
||||
|
||||
if (in.key.keycode != key_back){
|
||||
int32_t new_pos;
|
||||
if (!backspace){
|
||||
if (reverse){
|
||||
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0,
|
||||
bar.string.str, bar.string.size, &new_pos);
|
||||
int32_t new_pos = 0;
|
||||
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0, bar.string.str, bar.string.size, &new_pos);
|
||||
if (new_pos >= 0){
|
||||
if (step_backward){
|
||||
pos = new_pos;
|
||||
start_pos = new_pos;
|
||||
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0,
|
||||
bar.string.str, bar.string.size, &new_pos);
|
||||
if (new_pos < 0) new_pos = start_pos;
|
||||
buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0, bar.string.str, bar.string.size, &new_pos);
|
||||
if (new_pos < 0){
|
||||
new_pos = start_pos;
|
||||
}
|
||||
}
|
||||
match.start = new_pos;
|
||||
match.end = match.start + bar.string.size;
|
||||
}
|
||||
}
|
||||
else{
|
||||
buffer_seek_string_insensitive_forward(app, &buffer, start_pos + 1, 0,
|
||||
bar.string.str, bar.string.size, &new_pos);
|
||||
int32_t new_pos = 0;
|
||||
buffer_seek_string_insensitive_forward(app, &buffer, start_pos + 1, 0, bar.string.str, bar.string.size, &new_pos);
|
||||
if (new_pos < buffer.size){
|
||||
if (step_forward){
|
||||
pos = new_pos;
|
||||
start_pos = new_pos;
|
||||
buffer_seek_string_insensitive_forward(app, &buffer, start_pos + 1, 0,
|
||||
bar.string.str, bar.string.size, &new_pos);
|
||||
if (new_pos >= buffer.size) new_pos = start_pos;
|
||||
buffer_seek_string_insensitive_forward(app, &buffer, start_pos + 1, 0, bar.string.str, bar.string.size, &new_pos);
|
||||
if (new_pos >= buffer.size){
|
||||
new_pos = start_pos;
|
||||
}
|
||||
}
|
||||
match.start = new_pos;
|
||||
match.end = match.start + bar.string.size;
|
||||
|
@ -680,6 +715,7 @@ isearch(Application_Links *app, int32_t start_reversed){
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
view_set_highlight(app, &view, 0, 0, false);
|
||||
if (in.abort){
|
||||
view_set_cursor(app, &view, seek_pos(first_pos), true);
|
||||
|
@ -690,11 +726,31 @@ isearch(Application_Links *app, int32_t start_reversed){
|
|||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(search){
|
||||
isearch(app, false);
|
||||
String query = {0};
|
||||
isearch(app, false, query);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(reverse_search){
|
||||
isearch(app, true);
|
||||
String query = {0};
|
||||
isearch(app, true, query);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(search_identifier){
|
||||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
|
||||
|
||||
char space[256];
|
||||
String query = read_identifier_at_pos(app, &buffer, view.cursor.pos, space, sizeof(space), 0);
|
||||
isearch(app, false, query);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(reverse_search_identifier){
|
||||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
|
||||
|
||||
char space[256];
|
||||
String query = read_identifier_at_pos(app, &buffer, view.cursor.pos, space, sizeof(space), 0);
|
||||
isearch(app, true, query);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(replace_in_range){
|
||||
|
@ -735,6 +791,36 @@ CUSTOM_COMMAND_SIG(replace_in_range){
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
query_replace(Application_Links *app, View_Summary *view, Buffer_Summary *buffer, int32_t pos, String r, String w){
|
||||
int32_t new_pos = 0;
|
||||
buffer_seek_string_forward(app, buffer, pos, 0, r.str, r.size, &new_pos);
|
||||
|
||||
User_Input in = {0};
|
||||
while (new_pos < buffer->size){
|
||||
Range match = make_range(new_pos, new_pos + r.size);
|
||||
view_set_highlight(app, view, match.min, match.max, 1);
|
||||
|
||||
in = get_user_input(app, EventOnAnyKey, EventOnButton);
|
||||
if (in.abort || in.key.keycode == key_esc || !key_is_unmodified(&in.key)) break;
|
||||
|
||||
if (in.key.character == 'y' || in.key.character == 'Y' || in.key.character == '\n' || in.key.character == '\t'){
|
||||
buffer_replace_range(app, buffer, match.min, match.max, w.str, w.size);
|
||||
pos = match.start + w.size;
|
||||
}
|
||||
else{
|
||||
pos = match.max;
|
||||
}
|
||||
|
||||
buffer_seek_string_forward(app, buffer, pos, 0, r.str, r.size, &new_pos);
|
||||
}
|
||||
|
||||
view_set_highlight(app, view, 0, 0, 0);
|
||||
if (in.abort) return;
|
||||
|
||||
view_set_cursor(app, view, seek_pos(pos), true);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(query_replace){
|
||||
Query_Bar replace;
|
||||
char replace_space[1024];
|
||||
|
@ -751,55 +837,57 @@ CUSTOM_COMMAND_SIG(query_replace){
|
|||
|
||||
if (!query_user_string(app, &with)) return;
|
||||
|
||||
String r, w;
|
||||
r = replace.string;
|
||||
w = with.string;
|
||||
String r = replace.string;
|
||||
String w = with.string;
|
||||
|
||||
View_Summary view = get_active_view(app, AccessOpen);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
|
||||
int32_t pos = view.cursor.pos;
|
||||
|
||||
Query_Bar bar;
|
||||
Buffer_Summary buffer;
|
||||
View_Summary view;
|
||||
int32_t pos, new_pos;
|
||||
|
||||
bar.prompt = make_lit_string("Replace? (y)es, (n)ext, (esc)\n");
|
||||
bar.string = null_string;
|
||||
|
||||
start_query_bar(app, &bar, 0);
|
||||
|
||||
uint32_t access = AccessOpen;
|
||||
view = get_active_view(app, access);
|
||||
buffer = get_buffer(app, view.buffer_id, access);
|
||||
|
||||
pos = view.cursor.pos;
|
||||
buffer_seek_string_forward(app, &buffer, pos, 0, r.str, r.size, &new_pos);
|
||||
|
||||
User_Input in = {0};
|
||||
while (new_pos < buffer.size){
|
||||
Range match = make_range(new_pos, new_pos + r.size);
|
||||
view_set_highlight(app, &view, match.min, match.max, 1);
|
||||
|
||||
in = get_user_input(app, EventOnAnyKey, EventOnButton);
|
||||
if (in.abort || in.key.keycode == key_esc || !key_is_unmodified(&in.key)) break;
|
||||
|
||||
if (in.key.character == 'y' ||
|
||||
in.key.character == 'Y' ||
|
||||
in.key.character == '\n' ||
|
||||
in.key.character == '\t'){
|
||||
buffer_replace_range(app, &buffer, match.min, match.max, w.str, w.size);
|
||||
pos = match.start + w.size;
|
||||
}
|
||||
else{
|
||||
pos = match.max;
|
||||
}
|
||||
|
||||
buffer_seek_string_forward(app, &buffer, pos, 0, r.str, r.size, &new_pos);
|
||||
}
|
||||
|
||||
view_set_highlight(app, &view, 0, 0, 0);
|
||||
if (in.abort) return;
|
||||
|
||||
view_set_cursor(app, &view, seek_pos(pos), 1);
|
||||
query_replace(app, &view, &buffer, pos, r, w);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(query_replace_identifier){
|
||||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
|
||||
|
||||
Range range = {0};
|
||||
char space[256];
|
||||
String query = read_identifier_at_pos(app, &buffer, view.cursor.pos, space, sizeof(space), &range);
|
||||
|
||||
if (query.size != 0){
|
||||
Query_Bar replace;
|
||||
replace.prompt = make_lit_string("Replace: ");
|
||||
replace.string = query;
|
||||
if (start_query_bar(app, &replace, 0) == 0) return;
|
||||
|
||||
Query_Bar with;
|
||||
char with_space[1024];
|
||||
with.prompt = make_lit_string("With: ");
|
||||
with.string = make_fixed_width_string(with_space);
|
||||
|
||||
if (!query_user_string(app, &with)) return;
|
||||
|
||||
String r = replace.string;
|
||||
String w = with.string;
|
||||
|
||||
View_Summary view = get_active_view(app, AccessOpen);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen);
|
||||
int32_t pos = range.start;
|
||||
|
||||
Query_Bar bar;
|
||||
bar.prompt = make_lit_string("Replace? (y)es, (n)ext, (esc)\n");
|
||||
bar.string = null_string;
|
||||
start_query_bar(app, &bar, 0);
|
||||
|
||||
query_replace(app, &view, &buffer, pos, r, w);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// File Handling Commands
|
||||
|
@ -835,6 +923,10 @@ CUSTOM_COMMAND_SIG(interactive_open){
|
|||
exec_command(app, cmdid_interactive_open);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(interactive_open_or_new){
|
||||
exec_command(app, cmdid_interactive_open_or_new);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(save_as){
|
||||
exec_command(app, cmdid_save_as);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ default_keys(Bind_Helper *context){
|
|||
bind(context, '<', MDFR_CTRL, change_active_panel_backwards);
|
||||
|
||||
bind(context, 'n', MDFR_CTRL, interactive_new);
|
||||
bind(context, 'o', MDFR_CTRL, interactive_open);
|
||||
bind(context, 'o', MDFR_CTRL, interactive_open_or_new);
|
||||
bind(context, 'o', MDFR_ALT, open_in_other);
|
||||
bind(context, 'k', MDFR_CTRL, interactive_kill_buffer);
|
||||
bind(context, 'i', MDFR_CTRL, interactive_switch_buffer);
|
||||
|
@ -177,8 +177,10 @@ default_keys(Bind_Helper *context){
|
|||
bind(context, 'm', MDFR_CTRL, cursor_mark_swap);
|
||||
bind(context, 'O', MDFR_CTRL, reopen);
|
||||
bind(context, 'q', MDFR_CTRL, query_replace);
|
||||
bind(context, 'Q', MDFR_CTRL, query_replace_identifier);
|
||||
bind(context, 'r', MDFR_CTRL, reverse_search);
|
||||
bind(context, 's', MDFR_CTRL, save);
|
||||
bind(context, 't', MDFR_CTRL, search_identifier);
|
||||
bind(context, 'T', MDFR_CTRL, list_all_locations_of_identifier);
|
||||
bind(context, 'u', MDFR_CTRL, to_uppercase);
|
||||
bind(context, 'v', MDFR_CTRL, paste_and_indent);
|
||||
|
@ -194,7 +196,7 @@ default_keys(Bind_Helper *context){
|
|||
bind(context, '?', MDFR_CTRL, toggle_show_whitespace);
|
||||
bind(context, '~', MDFR_CTRL, clean_all_lines);
|
||||
bind(context, '\n', MDFR_NONE, newline_or_goto_position);
|
||||
bind(context, '\n', MDFR_SHIFT, newline_or_goto_position);
|
||||
bind(context, '\n', MDFR_SHIFT, newline_or_goto_position_same_panel);
|
||||
bind(context, ' ', MDFR_SHIFT, write_character);
|
||||
|
||||
end_map(context);
|
||||
|
|
|
@ -36,6 +36,12 @@ static General_Memory global_general;
|
|||
// Jump Buffer Locking
|
||||
//
|
||||
|
||||
#if !defined(AUTO_CENTER_AFTER_JUMPS)
|
||||
static bool32 auto_center_after_jumps = true;
|
||||
#else
|
||||
static bool32 auto_center_after_jumps = AUTO_CENTER_AFTER_JUMPS;
|
||||
#endif
|
||||
|
||||
static char locked_buffer_space[256];
|
||||
static String locked_buffer = make_fixed_width_string(locked_buffer_space);
|
||||
|
||||
|
@ -361,9 +367,9 @@ read_config_line(Cpp_Token_Array array, int32_t *i_ptr){
|
|||
if (i < array.count){
|
||||
Cpp_Token token = read_config_token(array, &i);
|
||||
|
||||
bool32 subscript_success = 1;
|
||||
bool32 subscript_success = true;
|
||||
if (token.type == CPP_TOKEN_BRACKET_OPEN){
|
||||
subscript_success = 0;
|
||||
subscript_success = false;
|
||||
++i;
|
||||
if (i < array.count){
|
||||
config_line.subscript_token = read_config_token(array, &i);
|
||||
|
@ -375,7 +381,7 @@ read_config_line(Cpp_Token_Array array, int32_t *i_ptr){
|
|||
++i;
|
||||
if (i < array.count){
|
||||
token = read_config_token(array, &i);
|
||||
subscript_success = 1;
|
||||
subscript_success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -390,9 +396,9 @@ read_config_line(Cpp_Token_Array array, int32_t *i_ptr){
|
|||
if (i < array.count){
|
||||
Cpp_Token val_token = read_config_token(array, &i);
|
||||
|
||||
bool32 array_success = 1;
|
||||
bool32 array_success = true;
|
||||
if (val_token.type == CPP_TOKEN_BRACE_OPEN){
|
||||
array_success = 0;
|
||||
array_success = false;
|
||||
++i;
|
||||
if (i < array.count){
|
||||
config_line.val_array_start = i;
|
||||
|
@ -405,13 +411,13 @@ read_config_line(Cpp_Token_Array array, int32_t *i_ptr){
|
|||
}
|
||||
if (array_token.type == CPP_TOKEN_BRACE_CLOSE){
|
||||
config_line.val_array_end = i;
|
||||
array_success = 1;
|
||||
array_success = true;
|
||||
break;
|
||||
}
|
||||
else{
|
||||
if (array_token.type == CPP_TOKEN_COMMA){
|
||||
if (!expecting_array_item){
|
||||
expecting_array_item = 1;
|
||||
expecting_array_item = true;
|
||||
}
|
||||
else{
|
||||
break;
|
||||
|
@ -419,7 +425,7 @@ read_config_line(Cpp_Token_Array array, int32_t *i_ptr){
|
|||
}
|
||||
else{
|
||||
if (expecting_array_item){
|
||||
expecting_array_item = 0;
|
||||
expecting_array_item = false;
|
||||
++config_line.val_array_count;
|
||||
}
|
||||
}
|
||||
|
@ -621,6 +627,8 @@ static String user_name = make_fixed_width_string(user_name_space);
|
|||
|
||||
static Extension_List treat_as_code_exts = {0};
|
||||
|
||||
static bool32 automatically_load_project = false;
|
||||
|
||||
static bool32
|
||||
get_current_name(char **name_out, int32_t *len_out){
|
||||
bool32 result = false;
|
||||
|
@ -748,6 +756,8 @@ process_config_file(Application_Links *app){
|
|||
set_extensions(&treat_as_code_exts, str);
|
||||
}
|
||||
}
|
||||
|
||||
config_bool_var(item, "automatically_load_project", 0, &automatically_load_project);
|
||||
}
|
||||
}
|
||||
adjust_all_buffer_wrap_widths(app, new_wrap_width, new_min_base_width);
|
||||
|
@ -780,8 +790,11 @@ init_memory(Application_Links *app){
|
|||
general_memory_open(&global_general, general_mem, general_size);
|
||||
}
|
||||
|
||||
static bool32 default_use_scrollbars = false;
|
||||
static bool32 default_use_file_bars = true;
|
||||
|
||||
static void
|
||||
default_4coder_initialize(Application_Links *app){
|
||||
default_4coder_initialize(Application_Links *app, bool32 use_scrollbars, bool32 use_file_bars){
|
||||
init_memory(app);
|
||||
process_config_file(app);
|
||||
|
||||
|
@ -790,28 +803,48 @@ default_4coder_initialize(Application_Links *app){
|
|||
|
||||
change_theme(app, theme.str, theme.size);
|
||||
change_font(app, font.str, font.size, 1);
|
||||
|
||||
default_use_scrollbars = use_scrollbars;
|
||||
default_use_file_bars = use_file_bars;
|
||||
}
|
||||
|
||||
static void
|
||||
default_4coder_initialize(Application_Links *app){
|
||||
default_4coder_initialize(app, false, true);
|
||||
}
|
||||
|
||||
static void
|
||||
default_4coder_side_by_side_panels(Application_Links *app){
|
||||
exec_command(app, open_panel_vsplit);
|
||||
exec_command(app, hide_scrollbar);
|
||||
exec_command(app, change_active_panel);
|
||||
exec_command(app, hide_scrollbar);
|
||||
open_panel_vsplit(app);
|
||||
if (!default_use_scrollbars){
|
||||
hide_scrollbar(app);
|
||||
}
|
||||
if (!default_use_file_bars){
|
||||
hide_file_bar(app);
|
||||
}
|
||||
change_active_panel(app);
|
||||
if (!default_use_scrollbars){
|
||||
hide_scrollbar(app);
|
||||
}
|
||||
if (!default_use_file_bars){
|
||||
hide_file_bar(app);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
default_4coder_one_panel(Application_Links *app){
|
||||
exec_command(app, hide_scrollbar);
|
||||
if (!default_use_scrollbars){
|
||||
hide_scrollbar(app);
|
||||
}
|
||||
if (!default_use_file_bars){
|
||||
hide_file_bar(app);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
default_4coder_full_width_bottom_side_by_side_panels(Application_Links *app){
|
||||
open_special_note_view(app);
|
||||
exec_command(app, open_panel_vsplit);
|
||||
exec_command(app, hide_scrollbar);
|
||||
exec_command(app, change_active_panel);
|
||||
exec_command(app, hide_scrollbar);
|
||||
default_4coder_side_by_side_panels(app);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,11 +11,16 @@ TYPE: 'internal-for-default-system'
|
|||
|
||||
#include "4coder_default_framework.h"
|
||||
#include "4coder_helper/4coder_bind_helper.h"
|
||||
#include "4coder_project_commands.cpp"
|
||||
|
||||
HOOK_SIG(default_start){
|
||||
default_4coder_initialize(app);
|
||||
default_4coder_side_by_side_panels(app);
|
||||
|
||||
if (automatically_load_project){
|
||||
load_project(app);
|
||||
}
|
||||
|
||||
// no meaning for return
|
||||
return(0);
|
||||
}
|
||||
|
@ -70,12 +75,11 @@ OPEN_FILE_HOOK_SIG(default_file_settings){
|
|||
// NOTE(allen|a4.0.8): The get_parameter_buffer was eliminated
|
||||
// and instead the buffer is passed as an explicit parameter through
|
||||
// the function call. That is where buffer_id comes from here.
|
||||
uint32_t access = AccessAll;
|
||||
Buffer_Summary buffer = get_buffer(app, buffer_id, access);
|
||||
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
|
||||
Assert(buffer.exists);
|
||||
|
||||
int32_t treat_as_code = false;
|
||||
int32_t wrap_lines = true;
|
||||
bool32 treat_as_code = false;
|
||||
bool32 wrap_lines = true;
|
||||
|
||||
int32_t extension_count = 0;
|
||||
char **extension_list = get_current_code_extensions(&extension_count);
|
||||
|
@ -97,9 +101,11 @@ OPEN_FILE_HOOK_SIG(default_file_settings){
|
|||
wrap_lines = false;
|
||||
}
|
||||
|
||||
int32_t map_id = (treat_as_code)?((int32_t)default_code_map):((int32_t)mapid_file);
|
||||
|
||||
buffer_set_setting(app, &buffer, BufferSetting_WrapPosition, default_wrap_width);
|
||||
buffer_set_setting(app, &buffer, BufferSetting_MinimumBaseWrapPosition, default_min_base_width);
|
||||
buffer_set_setting(app, &buffer, BufferSetting_MapID, (treat_as_code)?((int32_t)default_code_map):((int32_t)mapid_file));
|
||||
buffer_set_setting(app, &buffer, BufferSetting_MapID, map_id);
|
||||
|
||||
if (treat_as_code && enable_code_wrapping && buffer.size < (1 << 18)){
|
||||
// NOTE(allen|a4.0.12): There is a little bit of grossness going on here.
|
||||
|
|
|
@ -49,11 +49,10 @@ buffer_boundary_seek(Application_Links *app, Buffer_Summary *buffer, int32_t sta
|
|||
}
|
||||
|
||||
static void
|
||||
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);
|
||||
basic_seek(Application_Links *app, bool32 seek_forward, uint32_t flags){
|
||||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
|
||||
int32_t pos = buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_forward, flags);
|
||||
view_set_cursor(app, &view, seek_pos(pos), true);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,45 +31,27 @@ TYPE: 'drop-in-command-pack'
|
|||
// Declaration list
|
||||
//
|
||||
|
||||
static void
|
||||
list_all_functions(Application_Links *app, Partition *part, Buffer_Summary *buffer){
|
||||
String search_name = make_lit_string("*decls*");
|
||||
Buffer_Summary decls_buffer = get_buffer_by_name(app, search_name.str, search_name.size, AccessAll);
|
||||
if (!decls_buffer.exists){
|
||||
decls_buffer = create_buffer(app, search_name.str, search_name.size, BufferCreate_AlwaysNew);
|
||||
buffer_set_setting(app, &decls_buffer, BufferSetting_Unimportant, true);
|
||||
buffer_set_setting(app, &decls_buffer, BufferSetting_ReadOnly, true);
|
||||
buffer_set_setting(app, &decls_buffer, BufferSetting_WrapLine, false);
|
||||
}
|
||||
else{
|
||||
buffer_replace_range(app, &decls_buffer, 0, decls_buffer.size, 0, 0);
|
||||
}
|
||||
|
||||
Temp_Memory temp = begin_temp_memory(part);
|
||||
|
||||
struct Function_Positions{
|
||||
int32_t sig_start_index;
|
||||
int32_t sig_end_index;
|
||||
int32_t open_paren_pos;
|
||||
};
|
||||
|
||||
Function_Positions *positions_array = push_array(part, Function_Positions, (4<<10)/sizeof(Function_Positions));
|
||||
int32_t positions_count = 0;
|
||||
|
||||
Partition extra_memory_ = partition_sub_part(part, (4<<10));
|
||||
Partition *extra_memory = &extra_memory_;
|
||||
char *str = (char*)partition_current(part);
|
||||
int32_t part_size = 0;
|
||||
int32_t size = 0;
|
||||
struct Function_Positions{
|
||||
int32_t sig_start_index;
|
||||
int32_t sig_end_index;
|
||||
int32_t open_paren_pos;
|
||||
};
|
||||
|
||||
struct Get_Positions_Results{
|
||||
int32_t positions_count;
|
||||
int32_t next_token_index;
|
||||
bool32 still_looping;
|
||||
};
|
||||
|
||||
static Get_Positions_Results
|
||||
get_function_positions(Application_Links *app, Buffer_Summary *buffer, int32_t token_index, Function_Positions *positions_array, int32_t positions_max){
|
||||
Get_Positions_Results result = {0};
|
||||
|
||||
static const int32_t token_chunk_size = 512;
|
||||
Cpp_Token token_chunk[token_chunk_size];
|
||||
Stream_Tokens token_stream = {0};
|
||||
|
||||
if (init_stream_tokens(&token_stream, app, buffer, 0, token_chunk, token_chunk_size)){
|
||||
Stream_Tokens start_position_stream_temp = begin_temp_stream_token(&token_stream);
|
||||
|
||||
int32_t token_index = 0;
|
||||
if (init_stream_tokens(&token_stream, app, buffer, token_index, token_chunk, token_chunk_size)){
|
||||
int32_t nest_level = 0;
|
||||
int32_t paren_nest_level = 0;
|
||||
|
||||
|
@ -80,7 +62,14 @@ list_all_functions(Application_Links *app, Partition *part, Buffer_Summary *buff
|
|||
bool32 still_looping = false;
|
||||
|
||||
// Look for the next token at global scope that might need to be printed.
|
||||
mode1: do{
|
||||
mode1:
|
||||
Assert(nest_level == 0);
|
||||
Assert(paren_nest_level == 0);
|
||||
first_paren_index = 0;
|
||||
first_paren_position = 0;
|
||||
last_paren_index = 0;
|
||||
|
||||
do{
|
||||
for (; token_index < token_stream.end; ++token_index){
|
||||
Cpp_Token *token = &token_stream.tokens[token_index];
|
||||
|
||||
|
@ -168,76 +157,110 @@ list_all_functions(Application_Links *app, Partition *part, Buffer_Summary *buff
|
|||
positions.sig_start_index = signature_start_index;
|
||||
positions.sig_end_index = last_paren_index;
|
||||
positions.open_paren_pos = first_paren_position;
|
||||
positions_array[positions_count++] = positions;
|
||||
positions_array[result.positions_count++] = positions;
|
||||
}
|
||||
|
||||
end_temp_stream_token(&token_stream, backward_stream_temp);
|
||||
if (result.positions_count >= positions_max){
|
||||
result.next_token_index = token_index;
|
||||
result.still_looping = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
goto mode1;
|
||||
}
|
||||
|
||||
end:;
|
||||
end_temp_stream_token(&token_stream, start_position_stream_temp);
|
||||
// Print the results
|
||||
String buffer_name = make_string(buffer->buffer_name, buffer->buffer_name_len);
|
||||
for (int32_t i = 0; i < positions_count; ++i){
|
||||
Function_Positions *positions = &positions_array[i];
|
||||
Temp_Memory extra_temp = begin_temp_memory(extra_memory);
|
||||
|
||||
int32_t local_index = positions->sig_start_index;
|
||||
int32_t end_index = positions->sig_end_index;
|
||||
int32_t open_paren_pos = positions->open_paren_pos;
|
||||
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
static void
|
||||
print_positions(Application_Links *app, Buffer_Summary *buffer, Function_Positions *positions_array, int32_t positions_count, Buffer_Summary *output_buffer, Partition *part){
|
||||
|
||||
Temp_Memory temp = begin_temp_memory(part);
|
||||
|
||||
Partition extra_memory_ = partition_sub_part(part, (4<<10));
|
||||
Partition *extra_memory = &extra_memory_;
|
||||
|
||||
char *str_ptr = (char*)partition_current(part);
|
||||
int32_t part_size = 0;
|
||||
|
||||
String buffer_name = make_string(buffer->buffer_name, buffer->buffer_name_len);
|
||||
int32_t size = output_buffer->size;
|
||||
|
||||
for (int32_t i = 0; i < positions_count; ++i){
|
||||
Function_Positions *positions = &positions_array[i];
|
||||
Temp_Memory extra_temp = begin_temp_memory(extra_memory);
|
||||
|
||||
int32_t local_index = positions->sig_start_index;
|
||||
int32_t end_index = positions->sig_end_index;
|
||||
int32_t open_paren_pos = positions->open_paren_pos;
|
||||
|
||||
Assert(end_index > local_index);
|
||||
|
||||
static const int32_t sig_chunk_size = 64;
|
||||
Cpp_Token sig_chunk[sig_chunk_size];
|
||||
Stream_Tokens sig_stream = {0};
|
||||
if (init_stream_tokens(&sig_stream, app, buffer, local_index, sig_chunk, sig_chunk_size)){
|
||||
bool32 still_looping = false;
|
||||
do{
|
||||
for (; local_index < token_stream.end; ++local_index){
|
||||
Cpp_Token *token = &token_stream.tokens[local_index];
|
||||
if (!(token->flags & CPP_TFLAG_PP_BODY)){
|
||||
if (token->type != CPP_TOKEN_COMMENT){
|
||||
bool32 delete_space_before = false;
|
||||
bool32 space_after = false;
|
||||
for (; local_index < sig_stream.end; ++local_index){
|
||||
Cpp_Token *token = &sig_stream.tokens[local_index];
|
||||
if (!(token->flags & CPP_TFLAG_PP_BODY) && token->type != CPP_TOKEN_COMMENT){
|
||||
bool32 delete_space_before = false;
|
||||
bool32 space_after = false;
|
||||
|
||||
switch (token->type){
|
||||
case CPP_TOKEN_PARENTHESE_OPEN:
|
||||
case CPP_TOKEN_PARENTHESE_CLOSE:
|
||||
{
|
||||
delete_space_before = true;
|
||||
}break;
|
||||
|
||||
switch (token->type){
|
||||
case CPP_TOKEN_COMMA:
|
||||
case CPP_TOKEN_PARENTHESE_OPEN:
|
||||
case CPP_TOKEN_PARENTHESE_CLOSE:
|
||||
{
|
||||
delete_space_before = true;
|
||||
}break;
|
||||
}
|
||||
|
||||
switch (token->type){
|
||||
case CPP_TOKEN_IDENTIFIER:
|
||||
case CPP_TOKEN_COMMA:
|
||||
case CPP_TOKEN_STAR:
|
||||
{
|
||||
space_after = true;
|
||||
}break;
|
||||
}
|
||||
if (token->flags & CPP_TFLAG_IS_KEYWORD){
|
||||
case CPP_TOKEN_IDENTIFIER:
|
||||
case CPP_TOKEN_STAR:
|
||||
{
|
||||
space_after = true;
|
||||
}break;
|
||||
|
||||
case CPP_TOKEN_COMMA:
|
||||
{
|
||||
delete_space_before = true;
|
||||
space_after = true;
|
||||
}break;
|
||||
}
|
||||
|
||||
if (token->flags & CPP_TFLAG_IS_KEYWORD){
|
||||
space_after = true;
|
||||
}
|
||||
|
||||
if (delete_space_before){
|
||||
int32_t pos = extra_memory->pos - 1;
|
||||
char *base = ((char*)(extra_memory->base));
|
||||
if (pos >= 0 && base[pos] == ' '){
|
||||
extra_memory->pos = pos;
|
||||
}
|
||||
|
||||
if (delete_space_before){
|
||||
int32_t pos = extra_memory->pos - 1;
|
||||
char *base = ((char*)(extra_memory->base));
|
||||
if (pos >= 0 && base[pos] == ' '){
|
||||
extra_memory->pos = pos;
|
||||
}
|
||||
}
|
||||
|
||||
char *token_str = push_array(extra_memory, char, token->size + space_after);
|
||||
|
||||
}
|
||||
|
||||
char *token_str = push_array(extra_memory, char, token->size + space_after);
|
||||
if (token_str != 0){
|
||||
buffer_read_range(app, buffer, token->start, token->start + token->size, token_str);
|
||||
if (space_after){
|
||||
token_str[token->size] = ' ';
|
||||
}
|
||||
}
|
||||
else{
|
||||
goto finish_print;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (local_index == end_index){
|
||||
goto finish_print;
|
||||
}
|
||||
}
|
||||
still_looping = forward_stream_tokens(&token_stream);
|
||||
still_looping = forward_stream_tokens(&sig_stream);
|
||||
}while(still_looping);
|
||||
|
||||
finish_print:;
|
||||
|
@ -252,7 +275,7 @@ list_all_functions(Application_Links *app, Partition *part, Buffer_Summary *buff
|
|||
|
||||
char *out_space = push_array(part, char, append_len);
|
||||
if (out_space == 0){
|
||||
buffer_replace_range(app, &decls_buffer, size, size, str, part_size);
|
||||
buffer_replace_range(app, output_buffer, size, size, str_ptr, part_size);
|
||||
size += part_size;
|
||||
|
||||
end_temp_memory(temp);
|
||||
|
@ -272,19 +295,53 @@ list_all_functions(Application_Links *app, Partition *part, Buffer_Summary *buff
|
|||
append(&out, sig);
|
||||
append(&out, '\n');
|
||||
}
|
||||
|
||||
end_temp_memory(extra_temp);
|
||||
}
|
||||
|
||||
buffer_replace_range(app, &decls_buffer, size, size, str, part_size);
|
||||
|
||||
View_Summary view = get_active_view(app, AccessAll);
|
||||
view_set_buffer(app, &view, decls_buffer.buffer_id, 0);
|
||||
|
||||
lock_jump_buffer(search_name.str, search_name.size);
|
||||
|
||||
end_temp_memory(temp);
|
||||
end_temp_memory(extra_temp);
|
||||
}
|
||||
|
||||
buffer_replace_range(app, output_buffer, size, size, str_ptr, part_size);
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
|
||||
static void
|
||||
list_all_functions(Application_Links *app, Partition *part, Buffer_Summary *buffer){
|
||||
String search_name = make_lit_string("*decls*");
|
||||
Buffer_Summary decls_buffer = get_buffer_by_name(app, search_name.str, search_name.size, AccessAll);
|
||||
if (!decls_buffer.exists){
|
||||
decls_buffer = create_buffer(app, search_name.str, search_name.size, BufferCreate_AlwaysNew);
|
||||
buffer_set_setting(app, &decls_buffer, BufferSetting_Unimportant, true);
|
||||
buffer_set_setting(app, &decls_buffer, BufferSetting_ReadOnly, true);
|
||||
buffer_set_setting(app, &decls_buffer, BufferSetting_WrapLine, false);
|
||||
}
|
||||
else{
|
||||
buffer_replace_range(app, &decls_buffer, 0, decls_buffer.size, 0, 0);
|
||||
}
|
||||
|
||||
Temp_Memory temp = begin_temp_memory(part);
|
||||
|
||||
int32_t positions_max = (4<<10)/sizeof(Function_Positions);
|
||||
Function_Positions *positions_array = push_array(part, Function_Positions, positions_max);
|
||||
|
||||
int32_t token_index = 0;
|
||||
bool32 still_looping = false;
|
||||
do{
|
||||
Get_Positions_Results get_positions_results = get_function_positions(app, buffer, token_index, positions_array, positions_max);
|
||||
|
||||
int32_t positions_count = get_positions_results.positions_count;
|
||||
token_index = get_positions_results.next_token_index;
|
||||
still_looping = get_positions_results.still_looping;
|
||||
|
||||
print_positions(app, buffer, positions_array, positions_count, &decls_buffer, part);
|
||||
}while(still_looping);
|
||||
|
||||
View_Summary view = get_active_view(app, AccessAll);
|
||||
view_set_buffer(app, &view, decls_buffer.buffer_id, 0);
|
||||
|
||||
lock_jump_buffer(search_name.str, search_name.size);
|
||||
|
||||
end_temp_memory(temp);
|
||||
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(list_all_functions_current_buffer){
|
||||
|
|
|
@ -22,29 +22,6 @@ exec_command(Application_Links *app, Generic_Command cmd){
|
|||
}
|
||||
}
|
||||
|
||||
static View_Summary
|
||||
get_first_view_with_buffer(Application_Links *app, int32_t buffer_id){
|
||||
View_Summary result = {};
|
||||
View_Summary test = {};
|
||||
|
||||
if (buffer_id != 0){
|
||||
uint32_t access = AccessAll;
|
||||
for(test = get_view_first(app, access);
|
||||
test.exists;
|
||||
get_view_next(app, &test, access)){
|
||||
|
||||
Buffer_Summary buffer = get_buffer(app, test.buffer_id, access);
|
||||
|
||||
if(buffer.buffer_id == buffer_id){
|
||||
result = test;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
key_is_unmodified(Key_Event_Data *key){
|
||||
char *mods = key->modifiers;
|
||||
|
@ -69,10 +46,9 @@ to_writable_char(Key_Code long_character){
|
|||
return(character);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
static bool32
|
||||
query_user_general(Application_Links *app, Query_Bar *bar, bool32 force_number){
|
||||
User_Input in;
|
||||
int32_t success = 1;
|
||||
bool32 success = true;
|
||||
|
||||
// NOTE(allen|a3.4.4): It will not cause an *error* if we continue on after failing to.
|
||||
// start a query bar, but it will be unusual behavior from the point of view of the
|
||||
|
@ -86,12 +62,12 @@ query_user_general(Application_Links *app, Query_Bar *bar, bool32 force_number){
|
|||
// types specified in the flags. The first set of flags are inputs you'd like to intercept
|
||||
// that you don't want to abort on. The second set are inputs that you'd like to cause
|
||||
// the command to abort. If an event satisfies both flags, it is treated as an abort.
|
||||
in = get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
|
||||
User_Input in = get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
|
||||
|
||||
// NOTE(allen|a3.4.4): The responsible thing to do on abort is to end the command
|
||||
// without waiting on get_user_input again.
|
||||
if (in.abort){
|
||||
success = 0;
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -276,13 +252,38 @@ get_line_x_rect(View_Summary *view){
|
|||
return(rect);
|
||||
}
|
||||
|
||||
static View_Summary
|
||||
get_first_view_with_buffer(Application_Links *app, int32_t buffer_id){
|
||||
View_Summary result = {0};
|
||||
View_Summary test = {0};
|
||||
|
||||
if (buffer_id != 0){
|
||||
uint32_t access = AccessAll;
|
||||
for(test = get_view_first(app, access);
|
||||
test.exists;
|
||||
get_view_next(app, &test, access)){
|
||||
|
||||
Buffer_Summary buffer = get_buffer(app, test.buffer_id, access);
|
||||
|
||||
if(buffer.buffer_id == buffer_id){
|
||||
result = test;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
static bool32
|
||||
open_file(Application_Links *app, Buffer_Summary *buffer_out, char *filename, int32_t filename_len, bool32 background, bool32 never_new){
|
||||
bool32 result = false;
|
||||
Buffer_Summary buffer = get_buffer_by_name(app, filename, filename_len, AccessProtected|AccessHidden);
|
||||
|
||||
if (buffer.exists){
|
||||
if (buffer_out) *buffer_out = buffer;
|
||||
if (buffer_out){
|
||||
*buffer_out = buffer;
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
else{
|
||||
|
@ -295,7 +296,9 @@ open_file(Application_Links *app, Buffer_Summary *buffer_out, char *filename, in
|
|||
}
|
||||
buffer = create_buffer(app, filename, filename_len, flags);
|
||||
if (buffer.exists){
|
||||
if (buffer_out) *buffer_out = buffer;
|
||||
if (buffer_out){
|
||||
*buffer_out = buffer;
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
@ -303,15 +306,15 @@ open_file(Application_Links *app, Buffer_Summary *buffer_out, char *filename, in
|
|||
return(result);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
view_open_file(Application_Links *app, View_Summary *view, char *filename, int32_t filename_len, int32_t never_new){
|
||||
int32_t result = 0;
|
||||
static bool32
|
||||
view_open_file(Application_Links *app, View_Summary *view, char *filename, int32_t filename_len, bool32 never_new){
|
||||
bool32 result = false;
|
||||
|
||||
if (view){
|
||||
if (view != 0){
|
||||
Buffer_Summary buffer = {0};
|
||||
if (open_file(app, &buffer, filename, filename_len, false, never_new)){
|
||||
view_set_buffer(app, view, buffer.buffer_id, 0);
|
||||
result = 1;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,15 +20,27 @@ struct Name_Based_Jump_Location{
|
|||
|
||||
static void
|
||||
jump_to_location(Application_Links *app, View_Summary *view, Name_Based_Jump_Location *l){
|
||||
Buffer_Summary buffer = {0};
|
||||
if (open_file(app, &buffer, l->file.str, l->file.size, false, true)){
|
||||
View_Summary target_view = get_first_view_with_buffer(app, buffer.buffer_id);
|
||||
if (!target_view.exists){
|
||||
view_set_buffer(app, view, buffer.buffer_id, 0);
|
||||
target_view = *view;
|
||||
}
|
||||
view_set_cursor(app, &target_view, seek_line_char(l->line, l->column), true);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
jump_to_location_always_use_view(Application_Links *app, View_Summary *view, Name_Based_Jump_Location *l){
|
||||
if (view_open_file(app, view, l->file.str, l->file.size, true)){
|
||||
view_set_cursor(app, view, seek_line_char(l->line, l->column), true);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t
|
||||
static bool32
|
||||
ms_style_verify(String line, int32_t paren_pos){
|
||||
int32_t result = false;
|
||||
|
||||
String line_part = substr_tail(line, paren_pos);
|
||||
if (match_part_sc(line_part, ") : ")){
|
||||
result = true;
|
||||
|
@ -36,7 +48,6 @@ ms_style_verify(String line, int32_t paren_pos){
|
|||
else if (match_part_sc(line_part, "): ")){
|
||||
result = true;
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -170,18 +170,13 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int3
|
|||
int32_t chunk_size = sizeof(chunk);
|
||||
Stream_Chunk stream = {0};
|
||||
|
||||
int32_t no_hard;
|
||||
int32_t prev_endline;
|
||||
int32_t still_looping;
|
||||
char at_pos;
|
||||
|
||||
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){
|
||||
// step 1: find the first non-whitespace character
|
||||
// ahead of the current position.
|
||||
still_looping = true;
|
||||
bool32 still_looping = true;
|
||||
do{
|
||||
for (; pos < stream.end; ++pos){
|
||||
at_pos = stream.data[pos];
|
||||
char at_pos = stream.data[pos];
|
||||
if (!char_is_whitespace(at_pos)){
|
||||
goto double_break_1;
|
||||
}
|
||||
|
@ -195,11 +190,11 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int3
|
|||
// the prev_endline value. if another '\n' is found
|
||||
// with non-whitespace then the previous line was
|
||||
// all whitespace.
|
||||
no_hard = false;
|
||||
prev_endline = -1;
|
||||
bool32 no_hard = false;
|
||||
int32_t prev_endline = -1;
|
||||
while(still_looping){
|
||||
for (; pos < stream.end; ++pos){
|
||||
at_pos = stream.data[pos];
|
||||
char at_pos = stream.data[pos];
|
||||
if (at_pos == '\n'){
|
||||
if (no_hard){
|
||||
goto double_break_2;
|
||||
|
@ -232,10 +227,9 @@ buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int
|
|||
char data_chunk[1024];
|
||||
Stream_Chunk stream = {0};
|
||||
|
||||
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))){
|
||||
|
||||
bool32 still_looping = 1;
|
||||
bool32 still_looping = true;
|
||||
do{
|
||||
for (; pos < stream.end; ++pos){
|
||||
if (!char_is_whitespace(stream.data[pos])){
|
||||
|
@ -246,7 +240,7 @@ buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int
|
|||
}while(still_looping);
|
||||
double_break1:;
|
||||
|
||||
still_looping = 1;
|
||||
still_looping = true;
|
||||
do{
|
||||
for (; pos < stream.end; ++pos){
|
||||
if (char_is_whitespace(stream.data[pos])){
|
||||
|
@ -311,13 +305,12 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i
|
|||
char data_chunk[1024];
|
||||
Stream_Chunk stream = {0};
|
||||
|
||||
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))){
|
||||
|
||||
bool32 still_looping = 1;
|
||||
bool32 still_looping = true;
|
||||
do{
|
||||
for (; pos < stream.end; ++pos){
|
||||
if (char_is_alpha_numeric_true(stream.data[pos])){
|
||||
if (char_is_alpha_numeric_true_utf8(stream.data[pos])){
|
||||
goto double_break1;
|
||||
}
|
||||
}
|
||||
|
@ -325,10 +318,10 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i
|
|||
}while(still_looping);
|
||||
double_break1:;
|
||||
|
||||
still_looping = 1;
|
||||
still_looping = true;
|
||||
do{
|
||||
for (; pos < stream.end; ++pos){
|
||||
if (!char_is_alpha_numeric_true(stream.data[pos])){
|
||||
if (!char_is_alpha_numeric_true_utf8(stream.data[pos])){
|
||||
goto double_break2;
|
||||
}
|
||||
}
|
||||
|
@ -347,13 +340,11 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in
|
|||
|
||||
--pos;
|
||||
if (pos > 0){
|
||||
if (init_stream_chunk(&stream, app, buffer,
|
||||
pos, data_chunk, sizeof(data_chunk))){
|
||||
|
||||
bool32 still_looping = 1;
|
||||
if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){
|
||||
bool32 still_looping = true;
|
||||
do{
|
||||
for (; pos >= stream.start; --pos){
|
||||
if (char_is_alpha_numeric_true(stream.data[pos])){
|
||||
if (char_is_alpha_numeric_true_utf8(stream.data[pos])){
|
||||
goto double_break1;
|
||||
}
|
||||
}
|
||||
|
@ -361,10 +352,82 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in
|
|||
}while(still_looping);
|
||||
double_break1:;
|
||||
|
||||
still_looping = 1;
|
||||
still_looping = true;
|
||||
do{
|
||||
for (; pos >= stream.start; --pos){
|
||||
if (!char_is_alpha_numeric_true(stream.data[pos])){
|
||||
if (!char_is_alpha_numeric_true_utf8(stream.data[pos])){
|
||||
++pos;
|
||||
goto double_break2;
|
||||
}
|
||||
}
|
||||
still_looping = backward_stream_chunk(&stream);
|
||||
}while(still_looping);
|
||||
double_break2:;
|
||||
}
|
||||
}
|
||||
else{
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
return(pos);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
buffer_seek_alphanumeric_or_underscore_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
|
||||
char data_chunk[1024];
|
||||
Stream_Chunk stream = {0};
|
||||
|
||||
if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){
|
||||
bool32 still_looping = true;
|
||||
do{
|
||||
for (; pos < stream.end; ++pos){
|
||||
if (char_is_alpha_numeric_utf8(stream.data[pos])){
|
||||
goto double_break1;
|
||||
}
|
||||
}
|
||||
still_looping = forward_stream_chunk(&stream);
|
||||
}while(still_looping);
|
||||
double_break1:;
|
||||
|
||||
still_looping = true;
|
||||
do{
|
||||
for (; pos < stream.end; ++pos){
|
||||
if (!char_is_alpha_numeric_utf8(stream.data[pos])){
|
||||
goto double_break2;
|
||||
}
|
||||
}
|
||||
still_looping = forward_stream_chunk(&stream);
|
||||
}while(still_looping);
|
||||
double_break2:;
|
||||
}
|
||||
|
||||
return(pos);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
buffer_seek_alphanumeric_or_underscore_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
|
||||
char data_chunk[1024];
|
||||
Stream_Chunk stream = {0};
|
||||
|
||||
--pos;
|
||||
if (pos > 0){
|
||||
if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){
|
||||
|
||||
bool32 still_looping = true;
|
||||
do{
|
||||
for (; pos >= stream.start; --pos){
|
||||
if (char_is_alpha_numeric_utf8(stream.data[pos])){
|
||||
goto double_break1;
|
||||
}
|
||||
}
|
||||
still_looping = backward_stream_chunk(&stream);
|
||||
}while(still_looping);
|
||||
double_break1:;
|
||||
|
||||
still_looping = true;
|
||||
do{
|
||||
for (; pos >= stream.start; --pos){
|
||||
if (!char_is_alpha_numeric_utf8(stream.data[pos])){
|
||||
++pos;
|
||||
goto double_break2;
|
||||
}
|
||||
|
@ -389,20 +452,18 @@ buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, in
|
|||
++pos;
|
||||
if (pos < an_pos){
|
||||
stream.max_end = an_pos;
|
||||
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];
|
||||
uint8_t c = 0;
|
||||
++pos;
|
||||
|
||||
bool32 still_looping = 1;
|
||||
do{
|
||||
for (; pos < stream.end; ++pos){
|
||||
c = stream.data[pos];
|
||||
if (char_is_upper(c) && char_is_lower(pc)){
|
||||
if (char_is_upper(c)){
|
||||
goto double_break1;
|
||||
}
|
||||
pc = c;
|
||||
}
|
||||
still_looping = forward_stream_chunk(&stream);
|
||||
}while(still_looping);
|
||||
|
@ -426,16 +487,15 @@ buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int
|
|||
stream.min_start = an_pos+1;
|
||||
if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){
|
||||
|
||||
char c = 0, pc = stream.data[pos];
|
||||
char c = 0;
|
||||
|
||||
bool32 still_looping = 1;
|
||||
do{
|
||||
for (; pos >= stream.start; --pos){
|
||||
c = stream.data[pos];
|
||||
if (char_is_upper(c) && char_is_lower(pc)){
|
||||
if (char_is_upper(c)){
|
||||
goto double_break1;
|
||||
}
|
||||
pc = c;
|
||||
}
|
||||
still_looping = backward_stream_chunk(&stream);
|
||||
}while(still_looping);
|
||||
|
@ -986,6 +1046,31 @@ get_first_token_at_line(Application_Links *app, Buffer_Summary *buffer, Cpp_Toke
|
|||
return(result);
|
||||
}
|
||||
|
||||
static String
|
||||
read_identifier_at_pos(Application_Links *app, Buffer_Summary *buffer, int32_t pos, char *space, int32_t max, Range *range_out){
|
||||
String query = {0};
|
||||
|
||||
int32_t start = buffer_seek_alphanumeric_or_underscore_left(app, buffer, pos);
|
||||
int32_t end = buffer_seek_alphanumeric_or_underscore_right(app, buffer, start);
|
||||
|
||||
if (!(start <= pos && pos < end)){
|
||||
end = buffer_seek_alphanumeric_or_underscore_right(app, buffer, pos);
|
||||
start = buffer_seek_alphanumeric_or_underscore_left(app, buffer, end);
|
||||
}
|
||||
|
||||
if (start <= pos && pos < end){
|
||||
int32_t size = end - start;
|
||||
if (size <= max){
|
||||
if (range_out != 0){
|
||||
*range_out = make_range(start, end);
|
||||
}
|
||||
buffer_read_range(app, buffer, start, end, space);
|
||||
query = make_string_cap(space, size, max);
|
||||
}
|
||||
}
|
||||
|
||||
return(query);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -23,26 +23,43 @@ CUSTOM_COMMAND_SIG(goto_jump_at_cursor){
|
|||
|
||||
Name_Based_Jump_Location location = {0};
|
||||
if (parse_jump_from_buffer_line(app, &global_part, view.buffer_id, view.cursor.line, false, &location)){
|
||||
|
||||
exec_command(app, change_active_panel);
|
||||
change_active_panel(app);
|
||||
view = get_active_view(app, AccessAll);
|
||||
jump_to_location(app, &view, &location);
|
||||
if (auto_center_after_jumps){
|
||||
center_view(app);
|
||||
}
|
||||
}
|
||||
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(goto_jump_at_cursor_same_panel){
|
||||
Temp_Memory temp = begin_temp_memory(&global_part);
|
||||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
|
||||
Name_Based_Jump_Location location = {0};
|
||||
if (parse_jump_from_buffer_line(app, &global_part, view.buffer_id, view.cursor.line, false, &location)){
|
||||
view = get_active_view(app, AccessAll);
|
||||
jump_to_location(app, &view, &location);
|
||||
if (auto_center_after_jumps){
|
||||
center_view(app);
|
||||
}
|
||||
}
|
||||
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
|
||||
//
|
||||
// Error Jumping
|
||||
//
|
||||
|
||||
static int32_t
|
||||
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){
|
||||
|
||||
Assert(direction == 1 || direction == -1);
|
||||
|
||||
int32_t result = false;
|
||||
bool32 result = false;
|
||||
int32_t line = first_line;
|
||||
String line_str = {0};
|
||||
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
|
||||
|
@ -144,23 +161,22 @@ advance_cursor_in_jump_view(Application_Links *app, Partition *part, View_Summar
|
|||
return(result);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
seek_jump(Application_Links *app, Partition *part, int32_t skip_repeats, int32_t skip_sub_errors, int32_t direction){
|
||||
int32_t result = 0;
|
||||
static bool32
|
||||
seek_jump(Application_Links *app, Partition *part, bool32 skip_repeats, bool32 skip_sub_errors, int32_t direction){
|
||||
bool32 result = false;
|
||||
|
||||
View_Summary view = get_view_for_locked_jump_buffer(app);
|
||||
if (view.exists){
|
||||
|
||||
Name_Based_Jump_Location location = {0};
|
||||
if (advance_cursor_in_jump_view(app, &global_part, &view, skip_repeats, skip_sub_errors, direction, &location)){
|
||||
View_Summary active_view = get_active_view(app, AccessAll);
|
||||
if (active_view.view_id == view.view_id){
|
||||
exec_command(app, change_active_panel);
|
||||
change_active_panel(app);
|
||||
active_view = get_active_view(app, AccessAll);
|
||||
}
|
||||
|
||||
jump_to_location(app, &active_view, &location);
|
||||
result = 1;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,29 +185,29 @@ seek_jump(Application_Links *app, Partition *part, int32_t skip_repeats, int32_t
|
|||
|
||||
|
||||
CUSTOM_COMMAND_SIG(goto_next_jump){
|
||||
int32_t skip_repeats = true;
|
||||
int32_t skip_sub_errors = true;
|
||||
bool32 skip_repeats = true;
|
||||
bool32 skip_sub_errors = true;
|
||||
int32_t dir = 1;
|
||||
seek_jump(app, &global_part, skip_repeats, skip_sub_errors, dir);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(goto_prev_jump){
|
||||
int32_t skip_repeats = true;
|
||||
int32_t skip_sub_errors = true;
|
||||
bool32 skip_repeats = true;
|
||||
bool32 skip_sub_errors = true;
|
||||
int32_t dir = -1;
|
||||
seek_jump(app, &global_part, skip_repeats, skip_sub_errors, dir);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(goto_next_jump_no_skips){
|
||||
int32_t skip_repeats = false;
|
||||
int32_t skip_sub_errors = true;
|
||||
bool32 skip_repeats = false;
|
||||
bool32 skip_sub_errors = true;
|
||||
int32_t dir = 1;
|
||||
seek_jump(app, &global_part, skip_repeats, skip_sub_errors, dir);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(goto_prev_jump_no_skips){
|
||||
int32_t skip_repeats = false;
|
||||
int32_t skip_sub_errors = true;
|
||||
bool32 skip_repeats = false;
|
||||
bool32 skip_sub_errors = true;
|
||||
int32_t dir = -1;
|
||||
seek_jump(app, &global_part, skip_repeats, skip_sub_errors, dir);
|
||||
}
|
||||
|
@ -216,11 +232,24 @@ CUSTOM_COMMAND_SIG(newline_or_goto_position){
|
|||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
|
||||
|
||||
if (buffer.lock_flags & AccessProtected){
|
||||
exec_command(app, goto_jump_at_cursor);
|
||||
goto_jump_at_cursor(app);
|
||||
lock_jump_buffer(buffer);
|
||||
}
|
||||
else{
|
||||
exec_command(app, write_character);
|
||||
write_character(app);
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(newline_or_goto_position_same_panel){
|
||||
View_Summary view = get_active_view(app, AccessProtected);
|
||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected);
|
||||
|
||||
if (buffer.lock_flags & AccessProtected){
|
||||
goto_jump_at_cursor_same_panel(app);
|
||||
lock_jump_buffer(buffer);
|
||||
}
|
||||
else{
|
||||
write_character(app);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -290,8 +290,14 @@ static i32_4tech
|
|||
general_memory_check(General_Memory *general){}
|
||||
#endif
|
||||
|
||||
#if !defined(PRFL_FUNC_GROUP)
|
||||
#define PRFL_FUNC_GROUP()
|
||||
#endif
|
||||
|
||||
static void*
|
||||
general_memory_allocate(General_Memory *general, i32_4tech size){
|
||||
PRFL_FUNC_GROUP();
|
||||
|
||||
void *result = 0;
|
||||
if (size < BUBBLE_MIN_SIZE) size = BUBBLE_MIN_SIZE;
|
||||
for (Bubble *bubble = general->free_sentinel.next2;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
4coder_string.h - Version 1.0.66
|
||||
4coder_string.h - Version 1.0.72
|
||||
no warranty implied; use at your own risk
|
||||
|
||||
This software is in the public domain. Where that dedication is not
|
||||
|
@ -70,16 +70,24 @@ static String null_string = {0};
|
|||
|
||||
FSTRING_INLINE b32_4tech char_is_slash(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_upper(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_upper_utf8(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_lower(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_lower_utf8(u8_4tech c);
|
||||
FSTRING_INLINE char char_to_upper(char c);
|
||||
FSTRING_INLINE char char_to_lower(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_whitespace(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_alpha_numeric(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_alpha_numeric_utf8(u8_4tech c);
|
||||
FSTRING_INLINE b32_4tech char_is_alpha_numeric_true(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_alpha_numeric_true_utf8(u8_4tech c);
|
||||
FSTRING_INLINE b32_4tech char_is_alpha(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_alpha_utf8(u8_4tech c);
|
||||
FSTRING_INLINE b32_4tech char_is_alpha_true(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_alpha_true_utf8(u8_4tech c);
|
||||
FSTRING_INLINE b32_4tech char_is_hex(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_hex_utf8(u8_4tech c);
|
||||
FSTRING_INLINE b32_4tech char_is_numeric(char c);
|
||||
FSTRING_INLINE b32_4tech char_is_numeric_utf8(u8_4tech c);
|
||||
FSTRING_INLINE String make_string_cap(void *str, i32_4tech size, i32_4tech mem_size);
|
||||
FSTRING_INLINE String make_string(void *str, i32_4tech size);
|
||||
#ifndef make_lit_string
|
||||
|
@ -300,6 +308,14 @@ char_is_upper(char c)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_upper_utf8(char c)
|
||||
{
|
||||
return (c >= 'A' && c <= 'Z' || c >= 128);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_lower(char c)
|
||||
|
@ -308,6 +324,14 @@ char_is_lower(char c)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_lower_utf8(u8_4tech c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z' || c >= 128);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE char
|
||||
char_to_upper(char c)
|
||||
|
@ -340,6 +364,14 @@ char_is_alpha_numeric(char c)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_numeric_utf8(u8_4tech c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || c >= 128);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_numeric_true(char c)
|
||||
|
@ -348,6 +380,14 @@ char_is_alpha_numeric_true(char c)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_numeric_true_utf8(u8_4tech c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c >= 128);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_alpha(char c)
|
||||
|
@ -356,6 +396,14 @@ char_is_alpha(char c)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_utf8(u8_4tech c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c >= 128);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_true(char c)
|
||||
|
@ -364,6 +412,14 @@ char_is_alpha_true(char c)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_true_utf8(u8_4tech c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= 128);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_hex(char c)
|
||||
|
@ -372,6 +428,14 @@ char_is_hex(char c)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_hex_utf8(u8_4tech c)
|
||||
{
|
||||
return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f' || c >= 128);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_numeric(char c)
|
||||
|
@ -380,6 +444,14 @@ char_is_numeric(char c)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(FSTRING_GUARD)
|
||||
FSTRING_INLINE b32_4tech
|
||||
char_is_numeric_utf8(u8_4tech c)
|
||||
{
|
||||
return (c >= '0' && c <= '9' || c >= 128);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// String Making Functions
|
||||
|
|
|
@ -154,12 +154,26 @@ open_all_files_with_extension(Application_Links *app, Partition *scratch_part, c
|
|||
}
|
||||
|
||||
// NOTE(allen|a4.0.14): open_all_code and close_all_code now use the extensions set in the loaded project. If there is no project loaded the extensions ".cpp.hpp.c.h.cc" are used.
|
||||
static void
|
||||
open_all_code(Application_Links *app, String dir){
|
||||
int32_t extension_count = 0;
|
||||
char **extension_list = get_current_project_extensions(&extension_count);
|
||||
open_all_files_with_extension_internal(app, dir, extension_list, extension_count, false);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(open_all_code){
|
||||
int32_t extension_count = 0;
|
||||
char **extension_list = get_current_project_extensions(&extension_count);
|
||||
open_all_files_with_extension(app, &global_part, extension_list, extension_count, false);
|
||||
}
|
||||
|
||||
static void
|
||||
open_all_code_recursive(Application_Links *app, String dir){
|
||||
int32_t extension_count = 0;
|
||||
char **extension_list = get_current_project_extensions(&extension_count);
|
||||
open_all_files_with_extension_internal(app, dir, extension_list, extension_count, true);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(open_all_code_recursive){
|
||||
int32_t extension_count = 0;
|
||||
char **extension_list = get_current_project_extensions(&extension_count);
|
||||
|
@ -172,6 +186,195 @@ CUSTOM_COMMAND_SIG(close_all_code){
|
|||
close_all_files_with_extension(app, &global_part, extension_list, extension_count);
|
||||
}
|
||||
|
||||
static void
|
||||
load_project_from_file(Application_Links *app, Partition *part, FILE *file, String project_dir){
|
||||
Temp_Memory temp = begin_temp_memory(part);
|
||||
|
||||
char *mem = 0;
|
||||
int32_t size = 0;
|
||||
bool32 file_read_success = file_handle_dump(part, file, &mem, &size);
|
||||
if (file_read_success){
|
||||
Cpp_Token_Array array;
|
||||
array.count = 0;
|
||||
array.max_count = (1 << 20)/sizeof(Cpp_Token);
|
||||
array.tokens = push_array(&global_part, Cpp_Token, array.max_count);
|
||||
|
||||
Cpp_Lex_Data S = cpp_lex_data_init();
|
||||
Cpp_Lex_Result result = cpp_lex_step(&S, mem, size+1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
|
||||
|
||||
if (result == LexResult_Finished){
|
||||
// Clear out current project
|
||||
if (current_project.close_all_code_when_this_project_closes){
|
||||
exec_command(app, close_all_code);
|
||||
}
|
||||
current_project = null_project;
|
||||
|
||||
// Set new project directory
|
||||
{
|
||||
current_project.dir = current_project.dir_space;
|
||||
String str = make_fixed_width_string(current_project.dir_space);
|
||||
copy(&str, project_dir);
|
||||
terminate_with_null(&str);
|
||||
current_project.dir_len = str.size;
|
||||
}
|
||||
|
||||
// Read the settings from project.4coder
|
||||
for (int32_t i = 0; i < array.count; ++i){
|
||||
Config_Line config_line = read_config_line(array, &i);
|
||||
if (config_line.read_success){
|
||||
Config_Item item = get_config_item(config_line, mem, array);
|
||||
|
||||
{
|
||||
char str_space[512];
|
||||
String str = make_fixed_width_string(str_space);
|
||||
if (config_string_var(item, "extensions", 0, &str)){
|
||||
if (str.size < sizeof(current_project.extension_list.extension_space)){
|
||||
set_extensions(¤t_project.extension_list, str);
|
||||
print_message(app, str.str, str.size);
|
||||
print_message(app, "\n", 1);
|
||||
}
|
||||
else{
|
||||
print_message(app, literal("STRING TOO LONG!\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
bool32 open_recursively = false;
|
||||
if (config_bool_var(item, "open_recursively", 0, &open_recursively)){
|
||||
current_project.open_recursively = open_recursively;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
#define FKEY_COMMAND "fkey_command_win"
|
||||
#elif defined(__linux__)
|
||||
#define FKEY_COMMAND "fkey_command_linux"
|
||||
#else
|
||||
#error no project configuration names for this platform
|
||||
#endif
|
||||
|
||||
int32_t index = 0;
|
||||
Config_Array_Reader array_reader = {0};
|
||||
if (config_array_var(item, FKEY_COMMAND, &index, &array_reader)){
|
||||
if (index >= 1 && index <= 16){
|
||||
Config_Item array_item = {0};
|
||||
int32_t item_index = 0;
|
||||
|
||||
char space[256];
|
||||
String msg = make_fixed_width_string(space);
|
||||
append(&msg, FKEY_COMMAND"[");
|
||||
append_int_to_str(&msg, index);
|
||||
append(&msg, "] = {");
|
||||
|
||||
for (config_array_next_item(&array_reader, &array_item);
|
||||
config_array_good(&array_reader);
|
||||
config_array_next_item(&array_reader, &array_item)){
|
||||
|
||||
if (item_index >= 4){
|
||||
break;
|
||||
}
|
||||
|
||||
append(&msg, "[");
|
||||
append_int_to_str(&msg, item_index);
|
||||
append(&msg, "] = ");
|
||||
|
||||
bool32 read_string = false;
|
||||
bool32 read_bool = false;
|
||||
|
||||
char *dest_str = 0;
|
||||
int32_t dest_str_size = 0;
|
||||
|
||||
bool32 *dest_bool = 0;
|
||||
|
||||
switch (item_index){
|
||||
case 0:
|
||||
{
|
||||
dest_str = current_project.fkey_commands[index-1].command;
|
||||
dest_str_size = sizeof(current_project.fkey_commands[index-1].command);
|
||||
read_string = true;
|
||||
}break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
dest_str = current_project.fkey_commands[index-1].out;
|
||||
dest_str_size = sizeof(current_project.fkey_commands[index-1].out);
|
||||
read_string = true;
|
||||
}break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
dest_bool = ¤t_project.fkey_commands[index-1].use_build_panel;
|
||||
read_bool = true;
|
||||
}break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
dest_bool = ¤t_project.fkey_commands[index-1].save_dirty_buffers;
|
||||
read_bool = true;
|
||||
}break;
|
||||
}
|
||||
|
||||
if (read_string){
|
||||
if (config_int_var(array_item, 0, 0, 0)){
|
||||
append(&msg, "NULL, ");
|
||||
dest_str[0] = 0;
|
||||
}
|
||||
|
||||
char str_space[512];
|
||||
String str = make_fixed_width_string(str_space);
|
||||
if (config_string_var(array_item, 0, 0, &str)){
|
||||
if (str.size < dest_str_size){
|
||||
interpret_escaped_string(dest_str, str);
|
||||
append(&msg, dest_str);
|
||||
append(&msg, ", ");
|
||||
}
|
||||
else{
|
||||
append(&msg, "STRING TOO LONG!, ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (read_bool){
|
||||
if (config_bool_var(array_item, 0, 0, dest_bool)){
|
||||
if (*dest_bool){
|
||||
append(&msg, "true, ");
|
||||
}
|
||||
else{
|
||||
append(&msg, "false, ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item_index++;
|
||||
}
|
||||
|
||||
append(&msg, "}\n");
|
||||
print_message(app, msg.str, msg.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (current_project.close_all_files_when_project_opens){
|
||||
close_all_files_with_extension(app, &global_part, 0, 0);
|
||||
}
|
||||
|
||||
// Open all project files
|
||||
if (current_project.open_recursively){
|
||||
open_all_code_recursive(app, project_dir);
|
||||
}
|
||||
else{
|
||||
open_all_code(app, project_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(load_project){
|
||||
Partition *part = &global_part;
|
||||
|
||||
|
@ -183,204 +386,33 @@ CUSTOM_COMMAND_SIG(load_project){
|
|||
}
|
||||
|
||||
if (project_name.size != 0){
|
||||
int32_t original_size = project_name.size;
|
||||
append_sc(&project_name, "project.4coder");
|
||||
terminate_with_null(&project_name);
|
||||
|
||||
FILE *file = fopen(project_name.str, "rb");
|
||||
if (file){
|
||||
project_name.size = original_size;
|
||||
bool32 load_failed = false;
|
||||
for(;;){
|
||||
int32_t original_size = project_name.size;
|
||||
append_sc(&project_name, "project.4coder");
|
||||
terminate_with_null(&project_name);
|
||||
|
||||
Temp_Memory temp = begin_temp_memory(part);
|
||||
|
||||
char *mem = 0;
|
||||
int32_t size = 0;
|
||||
bool32 file_read_success = file_handle_dump(part, file, &mem, &size);
|
||||
if (file_read_success){
|
||||
FILE *file = fopen(project_name.str, "rb");
|
||||
if (file){
|
||||
project_name.size = original_size;
|
||||
terminate_with_null(&project_name);
|
||||
load_project_from_file(app, part, file, project_name);
|
||||
fclose(file);
|
||||
break;
|
||||
}
|
||||
else{
|
||||
project_name.size = original_size;
|
||||
remove_last_folder(&project_name);
|
||||
|
||||
Cpp_Token_Array array;
|
||||
array.count = 0;
|
||||
array.max_count = (1 << 20)/sizeof(Cpp_Token);
|
||||
array.tokens = push_array(&global_part, Cpp_Token, array.max_count);
|
||||
|
||||
Cpp_Lex_Data S = cpp_lex_data_init();
|
||||
Cpp_Lex_Result result = cpp_lex_step(&S, mem, size+1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
|
||||
|
||||
if (result == LexResult_Finished){
|
||||
// Clear out current project
|
||||
if (current_project.close_all_code_when_this_project_closes){
|
||||
exec_command(app, close_all_code);
|
||||
}
|
||||
current_project = null_project;
|
||||
|
||||
// Set new project directory
|
||||
{
|
||||
current_project.dir = current_project.dir_space;
|
||||
String str = make_fixed_width_string(current_project.dir_space);
|
||||
copy(&str, project_name);
|
||||
terminate_with_null(&str);
|
||||
current_project.dir_len = str.size;
|
||||
}
|
||||
|
||||
// Read the settings from project.4coder
|
||||
for (int32_t i = 0; i < array.count; ++i){
|
||||
Config_Line config_line = read_config_line(array, &i);
|
||||
if (config_line.read_success){
|
||||
Config_Item item = get_config_item(config_line, mem, array);
|
||||
|
||||
{
|
||||
char str_space[512];
|
||||
String str = make_fixed_width_string(str_space);
|
||||
if (config_string_var(item, "extensions", 0, &str)){
|
||||
if (str.size < sizeof(current_project.extension_list.extension_space)){
|
||||
set_extensions(¤t_project.extension_list, str);
|
||||
print_message(app, str.str, str.size);
|
||||
print_message(app, "\n", 1);
|
||||
}
|
||||
else{
|
||||
print_message(app, literal("STRING TOO LONG!\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
bool32 open_recursively = false;
|
||||
if (config_bool_var(item, "open_recursively", 0, &open_recursively)){
|
||||
current_project.open_recursively = open_recursively;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
#define FKEY_COMMAND "fkey_command_win"
|
||||
#elif defined(__linux__)
|
||||
#define FKEY_COMMAND "fkey_command_linux"
|
||||
#else
|
||||
#error no project configuration names for this platform
|
||||
#endif
|
||||
|
||||
int32_t index = 0;
|
||||
Config_Array_Reader array_reader = {0};
|
||||
if (config_array_var(item, FKEY_COMMAND, &index, &array_reader)){
|
||||
if (index >= 1 && index <= 16){
|
||||
Config_Item array_item = {0};
|
||||
int32_t item_index = 0;
|
||||
|
||||
char space[256];
|
||||
String msg = make_fixed_width_string(space);
|
||||
append(&msg, FKEY_COMMAND"[");
|
||||
append_int_to_str(&msg, index);
|
||||
append(&msg, "] = {");
|
||||
|
||||
for (config_array_next_item(&array_reader, &array_item);
|
||||
config_array_good(&array_reader);
|
||||
config_array_next_item(&array_reader, &array_item)){
|
||||
|
||||
if (item_index >= 4){
|
||||
break;
|
||||
}
|
||||
|
||||
append(&msg, "[");
|
||||
append_int_to_str(&msg, item_index);
|
||||
append(&msg, "] = ");
|
||||
|
||||
bool32 read_string = false;
|
||||
bool32 read_bool = false;
|
||||
|
||||
char *dest_str = 0;
|
||||
int32_t dest_str_size = 0;
|
||||
|
||||
bool32 *dest_bool = 0;
|
||||
|
||||
switch (item_index){
|
||||
case 0:
|
||||
{
|
||||
dest_str = current_project.fkey_commands[index-1].command;
|
||||
dest_str_size = sizeof(current_project.fkey_commands[index-1].command);
|
||||
read_string = true;
|
||||
}break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
dest_str = current_project.fkey_commands[index-1].out;
|
||||
dest_str_size = sizeof(current_project.fkey_commands[index-1].out);
|
||||
read_string = true;
|
||||
}break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
dest_bool = ¤t_project.fkey_commands[index-1].use_build_panel;
|
||||
read_bool = true;
|
||||
}break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
dest_bool = ¤t_project.fkey_commands[index-1].save_dirty_buffers;
|
||||
read_bool = true;
|
||||
}break;
|
||||
}
|
||||
|
||||
if (read_string){
|
||||
if (config_int_var(array_item, 0, 0, 0)){
|
||||
append(&msg, "NULL, ");
|
||||
dest_str[0] = 0;
|
||||
}
|
||||
|
||||
char str_space[512];
|
||||
String str = make_fixed_width_string(str_space);
|
||||
if (config_string_var(array_item, 0, 0, &str)){
|
||||
if (str.size < dest_str_size){
|
||||
interpret_escaped_string(dest_str, str);
|
||||
append(&msg, dest_str);
|
||||
append(&msg, ", ");
|
||||
}
|
||||
else{
|
||||
append(&msg, "STRING TOO LONG!, ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (read_bool){
|
||||
if (config_bool_var(array_item, 0, 0, dest_bool)){
|
||||
if (*dest_bool){
|
||||
append(&msg, "true, ");
|
||||
}
|
||||
else{
|
||||
append(&msg, "false, ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item_index++;
|
||||
}
|
||||
|
||||
append(&msg, "}\n");
|
||||
print_message(app, msg.str, msg.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (current_project.close_all_files_when_project_opens){
|
||||
close_all_files_with_extension(app, &global_part, 0, 0);
|
||||
}
|
||||
|
||||
// Open all project files
|
||||
if (current_project.open_recursively){
|
||||
exec_command(app, open_all_code_recursive);
|
||||
}
|
||||
else{
|
||||
exec_command(app, open_all_code);
|
||||
}
|
||||
if (project_name.size >= original_size){
|
||||
load_failed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
else{
|
||||
|
||||
if (load_failed){
|
||||
char message_space[512];
|
||||
String message = make_fixed_width_string(message_space);
|
||||
append_sc(&message, "Did not find project.4coder. ");
|
||||
|
@ -391,6 +423,7 @@ CUSTOM_COMMAND_SIG(load_project){
|
|||
else{
|
||||
append_sc(&message, "Continuing without a project");
|
||||
}
|
||||
append_s_char(&message, '\n');
|
||||
print_message(app, message.str, message.size);
|
||||
}
|
||||
}
|
||||
|
@ -456,8 +489,22 @@ exec_project_fkey_command(Application_Links *app, int32_t command_ind){
|
|||
CUSTOM_COMMAND_SIG(project_fkey_command){
|
||||
User_Input input = get_command_input(app);
|
||||
if (input.type == UserInputKey){
|
||||
bool32 got_ind = false;
|
||||
int32_t ind = 0;
|
||||
if (input.key.keycode >= key_f1 && input.key.keycode <= key_f16){
|
||||
int32_t ind = (input.key.keycode - key_f1);
|
||||
ind = (input.key.keycode - key_f1);
|
||||
got_ind = true;
|
||||
}
|
||||
else if (input.key.character_no_caps_lock >= '1' && input.key.character_no_caps_lock >= '9'){
|
||||
ind = (input.key.character_no_caps_lock - '1');
|
||||
got_ind = true;
|
||||
}
|
||||
else if (input.key.character_no_caps_lock == '0'){
|
||||
ind = 9;
|
||||
got_ind = true;
|
||||
}
|
||||
|
||||
if (got_ind){
|
||||
exec_project_fkey_command(app, ind);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,8 +148,7 @@ search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *
|
|||
if (new_size < space->max + len){
|
||||
new_size = space->max + len;
|
||||
}
|
||||
space->space = (char*)general_memory_reallocate(
|
||||
general, space->space, space->new_pos, new_size);
|
||||
space->space = (char*)general_memory_reallocate(general, space->space, space->new_pos, new_size);
|
||||
ostring = strspace_append(space, str, len);
|
||||
}
|
||||
|
||||
|
@ -183,8 +182,8 @@ buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, in
|
|||
int32_t still_looping = true;
|
||||
do{
|
||||
for (; pos < chunk.end; ++pos){
|
||||
char at_pos = chunk.data[pos];
|
||||
if (!char_is_alpha_numeric(at_pos)) goto double_break;
|
||||
uint8_t at_pos = (uint8_t)chunk.data[pos];
|
||||
if (!char_is_alpha_numeric_utf8(at_pos)) goto double_break;
|
||||
}
|
||||
still_looping = forward_stream_chunk(&chunk);
|
||||
}while(still_looping);
|
||||
|
@ -222,21 +221,21 @@ match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Ma
|
|||
char first = word.str[0];
|
||||
|
||||
char prev = ' ';
|
||||
if (char_is_alpha_numeric(first)){
|
||||
if (char_is_alpha_numeric_utf8(first)){
|
||||
prev = buffer_get_char(app, &result.buffer, result.start - 1);
|
||||
}
|
||||
|
||||
if (!char_is_alpha_numeric(prev)){
|
||||
if (!char_is_alpha_numeric_utf8(prev)){
|
||||
result.end = result.start + word.size;
|
||||
if (result.end <= end_pos){
|
||||
char last = word.str[word.size-1];
|
||||
|
||||
char next = ' ';
|
||||
if (char_is_alpha_numeric(last)){
|
||||
if (char_is_alpha_numeric_utf8(last)){
|
||||
next = buffer_get_char(app, &result.buffer, result.end);
|
||||
}
|
||||
|
||||
if (!char_is_alpha_numeric(next)){
|
||||
if (!char_is_alpha_numeric_utf8(next)){
|
||||
result.found_match = true;
|
||||
found_match = FindResult_FoundMatch;
|
||||
}
|
||||
|
@ -250,7 +249,7 @@ match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Ma
|
|||
case SearchFlag_MatchWordPrefix:
|
||||
{
|
||||
char prev = buffer_get_char(app, &result.buffer, result.start - 1);
|
||||
if (!char_is_alpha_numeric(prev)){
|
||||
if (!char_is_alpha_numeric_utf8(prev)){
|
||||
result.end =
|
||||
buffer_seek_alpha_numeric_end(
|
||||
app, &result.buffer, result.start);
|
||||
|
@ -685,14 +684,14 @@ list_all_locations_of_identifier_parameters(Application_Links *app, bool32 subst
|
|||
bool32 success = buffer_get_token_index(app, &buffer, view.cursor.pos, &get_result);
|
||||
|
||||
if (success && !get_result.in_whitespace){
|
||||
char space[128];
|
||||
char space[256];
|
||||
int32_t size = get_result.token_end - get_result.token_start;
|
||||
|
||||
if (size > 0 && size <= sizeof(space)){
|
||||
success = buffer_read_range(app, &buffer, get_result.token_start, get_result.token_end, space);
|
||||
if (success){
|
||||
String str = make_string(space, size);
|
||||
exec_command(app, change_active_panel);
|
||||
change_active_panel(app);
|
||||
|
||||
uint32_t flags = 0;
|
||||
if (substrings){
|
||||
|
@ -770,7 +769,7 @@ CUSTOM_COMMAND_SIG(word_complete){
|
|||
do{
|
||||
for (; cursor_pos >= chunk.start; --cursor_pos){
|
||||
char c = chunk.data[cursor_pos];
|
||||
if (char_is_alpha(c)){
|
||||
if (char_is_alpha_utf8(c)){
|
||||
word_start = cursor_pos;
|
||||
}
|
||||
else if (!char_is_numeric(c)){
|
||||
|
|
|
@ -1,198 +0,0 @@
|
|||
/*
|
||||
4coder_windows_bindings.cpp - Supplies bindings very similar to the bindings in modern style editors like notepad.
|
||||
|
||||
TYPE: 'build-target'
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
#if !defined(FCODER_WINDOWS_BINDINGS_CPP)
|
||||
#define FCODER_WINDOWS_BINDINGS_CPP
|
||||
|
||||
#include "4coder_default_include.cpp"
|
||||
|
||||
void
|
||||
default_keys(Bind_Helper *context){
|
||||
begin_map(context, mapid_global);
|
||||
|
||||
bind(context, 't', MDFR_CTRL, open_panel_vsplit);
|
||||
bind(context, 'T', MDFR_CTRL, open_panel_hsplit);
|
||||
bind(context, 'w', MDFR_CTRL, close_panel);
|
||||
bind(context, '\t', MDFR_CTRL, change_active_panel);
|
||||
bind(context, '\t', MDFR_CTRL | MDFR_SHIFT, change_active_panel_backwards);
|
||||
|
||||
bind(context, 'n', MDFR_CTRL, interactive_new);
|
||||
bind(context, 'n', MDFR_ALT, new_in_other);
|
||||
bind(context, 'o', MDFR_CTRL, interactive_open);
|
||||
bind(context, 'o', MDFR_ALT, open_in_other);
|
||||
bind(context, 'k', MDFR_CTRL, interactive_kill_buffer);
|
||||
bind(context, 'i', MDFR_CTRL, interactive_switch_buffer);
|
||||
bind(context, 'S', MDFR_CTRL, save_all_dirty_buffers);
|
||||
|
||||
bind(context, 'c', MDFR_ALT, open_color_tweaker);
|
||||
bind(context, 'd', MDFR_ALT, open_debug);
|
||||
|
||||
bind(context, '\\', MDFR_CTRL, change_to_build_panel);
|
||||
bind(context, '|', MDFR_CTRL, close_build_panel);
|
||||
bind(context, key_down, MDFR_ALT, goto_next_error);
|
||||
bind(context, key_up, MDFR_ALT, goto_prev_error);
|
||||
bind(context, key_up, MDFR_ALT | MDFR_SHIFT, goto_first_error);
|
||||
|
||||
bind(context, 'z', MDFR_ALT, execute_any_cli);
|
||||
bind(context, 'Z', MDFR_ALT, execute_previous_cli);
|
||||
bind(context, 'x', MDFR_ALT, execute_arbitrary_command);
|
||||
bind(context, 's', MDFR_ALT, show_scrollbar);
|
||||
bind(context, 'w', MDFR_ALT, hide_scrollbar);
|
||||
|
||||
bind(context, '@', MDFR_ALT, toggle_mouse);
|
||||
bind(context, key_page_up, MDFR_CTRL, toggle_fullscreen);
|
||||
bind(context, 'W', MDFR_CTRL, exit_4coder);
|
||||
bind(context, key_f4, MDFR_ALT, exit_4coder);
|
||||
|
||||
bind(context, key_f1, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f2, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f3, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f4, MDFR_NONE, project_fkey_command);
|
||||
|
||||
bind(context, key_f5, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f6, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f7, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f8, MDFR_NONE, project_fkey_command);
|
||||
|
||||
bind(context, key_f9, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f10, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f11, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f12, MDFR_NONE, project_fkey_command);
|
||||
|
||||
bind(context, key_f13, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f14, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f15, MDFR_NONE, project_fkey_command);
|
||||
bind(context, key_f16, MDFR_NONE, project_fkey_command);
|
||||
|
||||
end_map(context);
|
||||
|
||||
|
||||
begin_map(context, default_code_map);
|
||||
inherit_map(context, mapid_file);
|
||||
|
||||
bind(context, key_right, MDFR_CTRL, seek_alphanumeric_or_camel_right);
|
||||
bind(context, key_left, MDFR_CTRL, seek_alphanumeric_or_camel_left);
|
||||
bind(context, key_right, MDFR_ALT, seek_whitespace_right);
|
||||
bind(context, key_left, MDFR_ALT, seek_whitespace_left);
|
||||
|
||||
bind(context, '\n', MDFR_NONE, write_and_auto_tab);
|
||||
bind(context, '\n', MDFR_SHIFT, write_and_auto_tab);
|
||||
bind(context, '}', MDFR_NONE, write_and_auto_tab);
|
||||
bind(context, ')', MDFR_NONE, write_and_auto_tab);
|
||||
bind(context, ']', MDFR_NONE, write_and_auto_tab);
|
||||
bind(context, ';', MDFR_NONE, write_and_auto_tab);
|
||||
bind(context, '#', MDFR_NONE, write_and_auto_tab);
|
||||
|
||||
bind(context, ' ', MDFR_ALT, word_complete);
|
||||
bind(context, '\t', MDFR_NONE, auto_tab_line_at_cursor);
|
||||
bind(context, '\t', MDFR_SHIFT, auto_tab_range);
|
||||
|
||||
bind(context, 't', MDFR_ALT, write_todo);
|
||||
bind(context, 'y', MDFR_ALT, write_note);
|
||||
bind(context, 'r', MDFR_ALT, write_block);
|
||||
bind(context, '[', MDFR_CTRL, open_long_braces);
|
||||
bind(context, '{', MDFR_CTRL, open_long_braces_semicolon);
|
||||
bind(context, '}', MDFR_CTRL, open_long_braces_break);
|
||||
bind(context, 'i', MDFR_ALT, if0_off);
|
||||
bind(context, '1', MDFR_ALT, open_file_in_quotes);
|
||||
bind(context, '2', MDFR_ALT, open_matching_file_cpp);
|
||||
bind(context, '0', MDFR_CTRL, write_zero_struct);
|
||||
bind(context, 'I', MDFR_CTRL, list_all_functions_current_buffer);
|
||||
|
||||
end_map(context);
|
||||
|
||||
|
||||
begin_map(context, mapid_file);
|
||||
bind_vanilla_keys(context, write_character);
|
||||
|
||||
bind(context, key_mouse_left, MDFR_NONE, click_set_cursor);
|
||||
bind(context, key_mouse_left_release, MDFR_NONE, click_set_mark);
|
||||
bind(context, key_mouse_right, MDFR_NONE, click_set_mark);
|
||||
|
||||
bind(context, key_left, MDFR_NONE, move_left);
|
||||
bind(context, key_right, MDFR_NONE, move_right);
|
||||
bind(context, key_del, MDFR_NONE, delete_char);
|
||||
bind(context, key_del, MDFR_SHIFT, delete_char);
|
||||
bind(context, key_back, MDFR_NONE, backspace_char);
|
||||
bind(context, key_back, MDFR_SHIFT, backspace_char);
|
||||
bind(context, key_up, MDFR_NONE, move_up);
|
||||
bind(context, key_down, MDFR_NONE, move_down);
|
||||
bind(context, key_end, MDFR_NONE, seek_end_of_line);
|
||||
bind(context, key_home, MDFR_NONE, seek_beginning_of_line);
|
||||
bind(context, key_page_up, MDFR_NONE, page_up);
|
||||
bind(context, key_page_down, MDFR_NONE, page_down);
|
||||
|
||||
bind(context, key_right, MDFR_CTRL, seek_alphanumeric_or_camel_right);
|
||||
bind(context, key_left, MDFR_CTRL, seek_alphanumeric_or_camel_left);
|
||||
bind(context, key_right, MDFR_ALT, seek_whitespace_right);
|
||||
bind(context, key_left, MDFR_ALT, seek_whitespace_left);
|
||||
bind(context, key_up, MDFR_CTRL, seek_whitespace_up_end_line);
|
||||
bind(context, key_down, MDFR_CTRL, seek_whitespace_down_end_line);
|
||||
|
||||
bind(context, key_back, MDFR_CTRL, backspace_word);
|
||||
bind(context, key_del, MDFR_CTRL, delete_word);
|
||||
bind(context, key_back, MDFR_ALT, snipe_token_or_word);
|
||||
|
||||
bind(context, ' ', MDFR_CTRL, set_mark);
|
||||
bind(context, 'a', MDFR_CTRL, select_all);
|
||||
bind(context, 'c', MDFR_CTRL, copy);
|
||||
bind(context, 'd', MDFR_CTRL, duplicate_line);
|
||||
bind(context, 'f', MDFR_ALT, list_all_locations);
|
||||
bind(context, 'f', MDFR_CTRL, list_all_substring_locations_case_insensitive);
|
||||
bind(context, 'F', MDFR_CTRL, list_all_locations_of_identifier);
|
||||
bind(context, 'F', MDFR_ALT, list_all_locations_of_identifier_case_insensitive);
|
||||
bind(context, 'e', MDFR_CTRL, center_view);
|
||||
bind(context, 'E', MDFR_CTRL, left_adjust_view);
|
||||
bind(context, 'g', MDFR_CTRL, goto_line);
|
||||
bind(context, 'h', MDFR_CTRL, query_replace);
|
||||
bind(context, 'H', MDFR_CTRL, replace_in_range);
|
||||
bind(context, 'i', MDFR_CTRL, search);
|
||||
bind(context, 'I', MDFR_CTRL, reverse_search);
|
||||
bind(context, 'K', MDFR_CTRL, kill_buffer);
|
||||
bind(context, 'l', MDFR_CTRL, delete_line);
|
||||
bind(context, 'L', MDFR_ALT, toggle_line_wrap);
|
||||
bind(context, 'O', MDFR_CTRL, reopen);
|
||||
bind(context, 's', MDFR_CTRL, save);
|
||||
bind(context, 'S', MDFR_ALT, save_as);
|
||||
bind(context, 'v', MDFR_CTRL, paste_and_indent);
|
||||
bind(context, 'v', MDFR_ALT, toggle_virtual_whitespace);
|
||||
bind(context, 'V', MDFR_CTRL, paste_next_and_indent);
|
||||
bind(context, 'x', MDFR_CTRL, cut);
|
||||
bind(context, 'y', MDFR_CTRL, redo);
|
||||
bind(context, 'z', MDFR_CTRL, undo);
|
||||
|
||||
bind(context, '2', MDFR_CTRL, decrease_line_wrap);
|
||||
bind(context, '3', MDFR_CTRL, increase_line_wrap);
|
||||
|
||||
bind(context, '?', MDFR_CTRL, toggle_show_whitespace);
|
||||
bind(context, '~', MDFR_CTRL, clean_all_lines);
|
||||
bind(context, '\n', MDFR_NONE, newline_or_goto_position);
|
||||
bind(context, '\n', MDFR_SHIFT, newline_or_goto_position);
|
||||
bind(context, ' ', MDFR_SHIFT, write_character);
|
||||
|
||||
end_map(context);
|
||||
}
|
||||
|
||||
#ifndef NO_BINDING
|
||||
extern "C" int32_t
|
||||
get_bindings(void *data, int32_t size){
|
||||
Bind_Helper context_ = begin_bind_helper(data, size);
|
||||
Bind_Helper *context = &context_;
|
||||
|
||||
set_all_default_hooks(context);
|
||||
default_keys(context);
|
||||
|
||||
int32_t result = end_bind_helper(context);
|
||||
return(result);
|
||||
}
|
||||
#endif //NO_BINDING
|
||||
|
||||
#endif
|
||||
|
||||
// BOTTOM
|
||||
|
|
@ -363,7 +363,7 @@ cpp_lex_nonalloc_null_end_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, i32_4tech s
|
|||
S.white_done = 0;
|
||||
for(;;){
|
||||
for (; S.pp_state < LSPP_count && S.pos < end_pos;){
|
||||
c = chunk[S.pos++];
|
||||
c = (u8_4tech)chunk[S.pos++];
|
||||
i32_4tech i = S.pp_state + whitespace_fsm_eq_classes[c];
|
||||
S.pp_state = whitespace_fsm_table[i];
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ uint8_t multiline_state_table[] = {
|
|||
};
|
||||
|
||||
uint16_t main_fsm_eq_classes[] = {
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,
|
||||
};
|
||||
|
||||
const int32_t num_main_fsm_eq_classes = 31;
|
||||
|
@ -68,7 +68,7 @@ uint8_t main_fsm_table[] = {
|
|||
};
|
||||
|
||||
uint16_t pp_include_fsm_eq_classes[] = {
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,
|
||||
};
|
||||
|
||||
const int32_t num_pp_include_fsm_eq_classes = 31;
|
||||
|
@ -108,7 +108,7 @@ uint8_t pp_include_fsm_table[] = {
|
|||
};
|
||||
|
||||
uint16_t pp_macro_fsm_eq_classes[] = {
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,
|
||||
};
|
||||
|
||||
const int32_t num_pp_macro_fsm_eq_classes = 31;
|
||||
|
@ -148,7 +148,7 @@ uint8_t pp_macro_fsm_table[] = {
|
|||
};
|
||||
|
||||
uint16_t pp_identifier_fsm_eq_classes[] = {
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,
|
||||
};
|
||||
|
||||
const int32_t num_pp_identifier_fsm_eq_classes = 31;
|
||||
|
@ -188,7 +188,7 @@ uint8_t pp_identifier_fsm_table[] = {
|
|||
};
|
||||
|
||||
uint16_t pp_body_if_fsm_eq_classes[] = {
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,
|
||||
};
|
||||
|
||||
const int32_t num_pp_body_if_fsm_eq_classes = 31;
|
||||
|
@ -228,7 +228,7 @@ uint8_t pp_body_if_fsm_table[] = {
|
|||
};
|
||||
|
||||
uint16_t pp_body_fsm_eq_classes[] = {
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,
|
||||
};
|
||||
|
||||
const int32_t num_pp_body_fsm_eq_classes = 31;
|
||||
|
@ -268,7 +268,7 @@ uint8_t pp_body_fsm_table[] = {
|
|||
};
|
||||
|
||||
uint16_t pp_number_fsm_eq_classes[] = {
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,
|
||||
};
|
||||
|
||||
const int32_t num_pp_number_fsm_eq_classes = 31;
|
||||
|
@ -320,7 +320,7 @@ uint8_t pp_error_fsm_table[] = {
|
|||
};
|
||||
|
||||
uint16_t pp_junk_fsm_eq_classes[] = {
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,
|
||||
0,40,40,40,40,40,40,40,40,40,80,120,120,120,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,160,200,240,280,320,360,400,440,480,480,520,560,480,600,640,680,720,760,760,760,760,760,760,760,760,760,800,480,840,880,920,480,480,960,960,960,960,960,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,480,1040,480,1080,320,40,960,960,960,960,1120,960,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1160,1000,1000,480,1200,480,480,40,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,960,
|
||||
};
|
||||
|
||||
const int32_t num_pp_junk_fsm_eq_classes = 31;
|
||||
|
|
149
4ed.cpp
149
4ed.cpp
|
@ -275,7 +275,7 @@ panel_make_empty(System_Functions *system, App_Vars *vars, Panel *panel){
|
|||
Assert(panel->view == 0);
|
||||
new_view = live_set_alloc_view(&vars->live_set, panel, models);
|
||||
view_set_file(system, new_view.view, models->scratch_buffer, models);
|
||||
new_view.view->map = get_map(models, mapid_file);
|
||||
new_view.view->map = get_map(models, models->scratch_buffer->settings.base_map_id);
|
||||
|
||||
return(new_view.view);
|
||||
}
|
||||
|
@ -306,16 +306,19 @@ COMMAND_DECL(redo){
|
|||
|
||||
COMMAND_DECL(interactive_new){
|
||||
USE_VIEW(view);
|
||||
|
||||
view_show_interactive(system, view, IAct_New, IInt_Sys_File_List, make_lit_string("New: "));
|
||||
}
|
||||
|
||||
COMMAND_DECL(interactive_open){
|
||||
USE_VIEW(view);
|
||||
|
||||
view_show_interactive(system, view, IAct_Open, IInt_Sys_File_List,make_lit_string("Open: "));
|
||||
}
|
||||
|
||||
COMMAND_DECL(interactive_open_or_new){
|
||||
USE_VIEW(view);
|
||||
view_show_interactive(system, view, IAct_OpenOrNew, IInt_Sys_File_List,make_lit_string("Open: "));
|
||||
}
|
||||
|
||||
// TODO(allen): Improvements to reopen
|
||||
// - Perform a diff
|
||||
// - If the diff is not tremendously big, apply the edits.
|
||||
|
@ -546,12 +549,11 @@ command_caller(Coroutine *coroutine){
|
|||
Generic_Command generic;
|
||||
if (cmd_in->bind.function == command_user_callback){
|
||||
generic.command = cmd_in->bind.custom;
|
||||
models->command_caller(&models->app_links, generic);
|
||||
}
|
||||
else{
|
||||
generic.cmdid = (Command_ID)cmd_in->bind.custom_id;
|
||||
models->command_caller(&models->app_links, generic);
|
||||
}
|
||||
models->command_caller(&models->app_links, generic);
|
||||
}
|
||||
else{
|
||||
cmd_in->bind.function(command->system, command, cmd_in->bind);
|
||||
|
@ -608,6 +610,7 @@ setup_command_table(){
|
|||
|
||||
SET(interactive_new);
|
||||
SET(interactive_open);
|
||||
SET(interactive_open_or_new);
|
||||
SET(interactive_switch_buffer);
|
||||
SET(interactive_kill_buffer);
|
||||
SET(save_as);
|
||||
|
@ -961,7 +964,7 @@ enum Command_Line_Action{
|
|||
CLAct_WindowFullscreen,
|
||||
CLAct_WindowStreamMode,
|
||||
CLAct_FontSize,
|
||||
CLAct_FontStartHinting,
|
||||
CLAct_FontUseHinting,
|
||||
CLAct_Count
|
||||
};
|
||||
|
||||
|
@ -1006,9 +1009,6 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
if (arg[0] == '-'){
|
||||
action = CLAct_Ignore;
|
||||
switch (arg[1]){
|
||||
case 'u': action = CLAct_UserFile; strict = 0; break;
|
||||
case 'U': action = CLAct_UserFile; strict = 1; break;
|
||||
|
||||
case 'd': action = CLAct_CustomDLL; strict = 0; break;
|
||||
case 'D': action = CLAct_CustomDLL; strict = 1; break;
|
||||
|
||||
|
@ -1021,7 +1021,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
case 'S': action = CLAct_WindowStreamMode; break;
|
||||
|
||||
case 'f': action = CLAct_FontSize; break;
|
||||
case 'h': action = CLAct_FontStartHinting; --i; break;
|
||||
case 'h': action = CLAct_FontUseHinting; --i; break;
|
||||
}
|
||||
}
|
||||
else if (arg[0] != 0){
|
||||
|
@ -1032,18 +1032,9 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
}
|
||||
}break;
|
||||
|
||||
case CLAct_UserFile:
|
||||
{
|
||||
settings->user_file_is_strict = strict;
|
||||
if (i < clparams.argc){
|
||||
settings->user_file = clparams.argv[i];
|
||||
}
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
||||
case CLAct_CustomDLL:
|
||||
{
|
||||
plat_settings->custom_dll_is_strict = strict;
|
||||
plat_settings->custom_dll_is_strict = (b8)strict;
|
||||
if (i < clparams.argc){
|
||||
plat_settings->custom_dll = clparams.argv[i];
|
||||
}
|
||||
|
@ -1061,7 +1052,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
case CLAct_WindowSize:
|
||||
{
|
||||
if (i + 1 < clparams.argc){
|
||||
plat_settings->set_window_size = 1;
|
||||
plat_settings->set_window_size = true;
|
||||
plat_settings->window_w = str_to_int_c(clparams.argv[i]);
|
||||
plat_settings->window_h = str_to_int_c(clparams.argv[i+1]);
|
||||
|
||||
|
@ -1073,14 +1064,14 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
case CLAct_WindowMaximize:
|
||||
{
|
||||
--i;
|
||||
plat_settings->maximize_window = 1;
|
||||
plat_settings->maximize_window = true;
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
||||
case CLAct_WindowPosition:
|
||||
{
|
||||
if (i + 1 < clparams.argc){
|
||||
plat_settings->set_window_pos = 1;
|
||||
plat_settings->set_window_pos = true;
|
||||
plat_settings->window_x = str_to_int_c(clparams.argv[i]);
|
||||
plat_settings->window_y = str_to_int_c(clparams.argv[i+1]);
|
||||
|
||||
|
@ -1092,29 +1083,29 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
case CLAct_WindowFullscreen:
|
||||
{
|
||||
--i;
|
||||
plat_settings->fullscreen_window = 1;
|
||||
plat_settings->stream_mode = 1;
|
||||
plat_settings->fullscreen_window = true;
|
||||
plat_settings->stream_mode = true;
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
||||
case CLAct_WindowStreamMode:
|
||||
{
|
||||
--i;
|
||||
plat_settings->stream_mode = 1;
|
||||
plat_settings->stream_mode = true;
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
||||
case CLAct_FontSize:
|
||||
{
|
||||
if (i < clparams.argc){
|
||||
settings->font_size = str_to_int_c(clparams.argv[i]);
|
||||
plat_settings->font_size = str_to_int_c(clparams.argv[i]);
|
||||
}
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
||||
case CLAct_FontStartHinting:
|
||||
case CLAct_FontUseHinting:
|
||||
{
|
||||
plat_settings->use_hinting = 1;
|
||||
plat_settings->use_hinting = true;
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
}
|
||||
|
@ -1151,7 +1142,7 @@ App_Read_Command_Line_Sig(app_read_command_line){
|
|||
App_Settings *settings = &vars->models.settings;
|
||||
|
||||
*settings = null_app_settings;
|
||||
settings->font_size = 16;
|
||||
plat_settings->font_size = 16;
|
||||
|
||||
if (clparams.argc > 1){
|
||||
init_command_line_settings(&vars->models.settings, plat_settings, clparams);
|
||||
|
@ -1179,56 +1170,46 @@ extern "C" SCROLL_RULE_SIG(fallback_scroll_rule){
|
|||
}
|
||||
|
||||
App_Init_Sig(app_init){
|
||||
Partition *partition;
|
||||
Panel *panels, *panel;
|
||||
Panel_Divider *dividers, *div;
|
||||
i32 panel_max_count;
|
||||
i32 divider_max_count;
|
||||
|
||||
App_Vars *vars = (App_Vars*)memory->vars_memory;
|
||||
Models *models = &vars->models;
|
||||
models->keep_playing = 1;
|
||||
models->keep_playing = true;
|
||||
|
||||
app_links_init(system, &models->app_links, memory->user_memory, memory->user_memory_size);
|
||||
|
||||
models->config_api = api;
|
||||
models->app_links.cmd_context = &vars->command_data;
|
||||
|
||||
partition = &models->mem.part;
|
||||
Partition *partition = &models->mem.part;
|
||||
|
||||
{
|
||||
panel_max_count = models->layout.panel_max_count = MAX_VIEWS;
|
||||
divider_max_count = panel_max_count - 1;
|
||||
models->layout.panel_count = 0;
|
||||
|
||||
panels = push_array(partition, Panel, panel_max_count);
|
||||
models->layout.panels = panels;
|
||||
|
||||
dll_init_sentinel(&models->layout.free_sentinel);
|
||||
dll_init_sentinel(&models->layout.used_sentinel);
|
||||
|
||||
panel = panels;
|
||||
for (i32 i = 0; i < panel_max_count; ++i, ++panel){
|
||||
dll_insert(&models->layout.free_sentinel, panel);
|
||||
}
|
||||
|
||||
dividers = push_array(partition, Panel_Divider, divider_max_count);
|
||||
models->layout.dividers = dividers;
|
||||
|
||||
div = dividers;
|
||||
for (i32 i = 0; i < divider_max_count-1; ++i, ++div){
|
||||
div->next = (div + 1);
|
||||
}
|
||||
div->next = 0;
|
||||
models->layout.free_divider = dividers;
|
||||
PRFL_INIT(memory->debug_memory, memory->debug_memory_size);
|
||||
|
||||
i32 panel_max_count = models->layout.panel_max_count = MAX_VIEWS;
|
||||
i32 divider_max_count = panel_max_count - 1;
|
||||
models->layout.panel_count = 0;
|
||||
|
||||
Panel *panels = push_array(partition, Panel, panel_max_count);
|
||||
models->layout.panels = panels;
|
||||
|
||||
dll_init_sentinel(&models->layout.free_sentinel);
|
||||
dll_init_sentinel(&models->layout.used_sentinel);
|
||||
|
||||
Panel *panel = panels;
|
||||
for (i32 i = 0; i < panel_max_count; ++i, ++panel){
|
||||
dll_insert(&models->layout.free_sentinel, panel);
|
||||
}
|
||||
|
||||
Panel_Divider *dividers = push_array(partition, Panel_Divider, divider_max_count);
|
||||
models->layout.dividers = dividers;
|
||||
|
||||
Panel_Divider *div = dividers;
|
||||
for (i32 i = 0; i < divider_max_count-1; ++i, ++div){
|
||||
div->next = (div + 1);
|
||||
}
|
||||
div->next = 0;
|
||||
models->layout.free_divider = dividers;
|
||||
|
||||
|
||||
{
|
||||
View *view = 0;
|
||||
View_Persistent *persistent = 0;
|
||||
i32 i = 0;
|
||||
i32 max = 0;
|
||||
|
||||
models->live_set = &vars->live_set;
|
||||
|
||||
vars->live_set.count = 0;
|
||||
|
@ -1238,12 +1219,12 @@ App_Init_Sig(app_init){
|
|||
|
||||
dll_init_sentinel(&vars->live_set.free_sentinel);
|
||||
|
||||
max = vars->live_set.max;
|
||||
view = vars->live_set.views;
|
||||
for (i = 0; i < max; ++i, ++view){
|
||||
i32 max = vars->live_set.max;
|
||||
View *view = vars->live_set.views;
|
||||
for (i32 i = 0; i < max; ++i, ++view){
|
||||
dll_insert(&vars->live_set.free_sentinel, view);
|
||||
|
||||
persistent = &view->persistent;
|
||||
View_Persistent *persistent = &view->persistent;
|
||||
persistent->id = i;
|
||||
persistent->models = models;
|
||||
}
|
||||
|
@ -1476,7 +1457,7 @@ App_Init_Sig(app_init){
|
|||
struct File_Init{
|
||||
String name;
|
||||
Editing_File **ptr;
|
||||
i32 type;
|
||||
b32 read_only;
|
||||
};
|
||||
|
||||
File_Init init_files[] = {
|
||||
|
@ -1488,16 +1469,11 @@ App_Init_Sig(app_init){
|
|||
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;
|
||||
if (init_files[i].read_only){
|
||||
init_read_only_file(system, models, file);
|
||||
}
|
||||
else{
|
||||
init_normal_file(system, models, file, 0, 0);
|
||||
}
|
||||
|
||||
file->settings.never_kill = true;
|
||||
|
@ -1528,8 +1504,7 @@ App_Init_Sig(app_init){
|
|||
}
|
||||
|
||||
internal i32
|
||||
update_cli_handle_without_file(System_Functions *system, Models *models,
|
||||
CLI_Handles *cli, char *dest, i32 max){
|
||||
update_cli_handle_without_file(System_Functions *system, Models *models, CLI_Handles *cli, char *dest, i32 max){
|
||||
i32 result = 0;
|
||||
u32 amount = 0;
|
||||
|
||||
|
@ -1580,6 +1555,8 @@ update_cli_handle_with_file(System_Functions *system, Models *models, CLI_Handle
|
|||
|
||||
|
||||
App_Step_Sig(app_step){
|
||||
PRFL_BEGIN_FRAME();
|
||||
|
||||
Application_Step_Result app_result = *app_result_;
|
||||
app_result.animating = 0;
|
||||
|
||||
|
@ -2645,6 +2622,8 @@ App_Step_Sig(app_step){
|
|||
*app_result_ = app_result;
|
||||
|
||||
// end-of-app_step
|
||||
|
||||
PRFL_END_FRAME("profile.data");
|
||||
}
|
||||
|
||||
extern "C" App_Get_Functions_Sig(app_get_functions){
|
||||
|
|
22
4ed.h
22
4ed.h
|
@ -21,6 +21,8 @@ struct Application_Memory{
|
|||
i32 target_memory_size;
|
||||
void *user_memory;
|
||||
i32 user_memory_size;
|
||||
void *debug_memory;
|
||||
i32 debug_memory_size;
|
||||
};
|
||||
|
||||
#define KEY_INPUT_BUFFER_SIZE 8
|
||||
|
@ -38,30 +40,32 @@ get_single_key(Key_Input_Data *data, i32 index){
|
|||
return(key);
|
||||
}
|
||||
|
||||
typedef struct Input_Summary{
|
||||
struct Input_Summary{
|
||||
Mouse_State mouse;
|
||||
Key_Input_Data keys;
|
||||
f32 dt;
|
||||
} Input_Summary;
|
||||
};
|
||||
|
||||
typedef struct Command_Line_Parameters{
|
||||
struct Command_Line_Parameters{
|
||||
char **argv;
|
||||
int32_t argc;
|
||||
} Command_Line_Parameters;
|
||||
};
|
||||
|
||||
typedef struct Plat_Settings{
|
||||
struct Plat_Settings{
|
||||
char *custom_dll;
|
||||
b32 custom_dll_is_strict;
|
||||
b32 fullscreen_window;
|
||||
b32 stream_mode;
|
||||
b8 custom_dll_is_strict;
|
||||
b8 fullscreen_window;
|
||||
b8 stream_mode;
|
||||
|
||||
i32 window_w, window_h;
|
||||
i32 window_x, window_y;
|
||||
b8 set_window_pos;
|
||||
b8 set_window_size;
|
||||
b8 maximize_window;
|
||||
|
||||
b8 use_hinting;
|
||||
} Plat_Settings;
|
||||
i32 font_size;
|
||||
};
|
||||
|
||||
#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)
|
||||
|
|
|
@ -606,6 +606,8 @@ range is not within the bounds of the buffer.
|
|||
)
|
||||
DOC_SEE(4coder_Buffer_Positioning_System)
|
||||
*/{
|
||||
PRFL_FUNC_GROUP();
|
||||
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
Editing_File *file = imp_get_file(cmd, buffer);
|
||||
|
||||
|
@ -900,13 +902,7 @@ DOC_SEE(Buffer_Setting_ID)
|
|||
|
||||
case BufferSetting_MapID:
|
||||
{
|
||||
if (value == mapid_global){
|
||||
file->settings.base_map_id = mapid_global;
|
||||
}
|
||||
else if (value == mapid_file){
|
||||
file->settings.base_map_id = mapid_file;
|
||||
}
|
||||
else if (value < mapid_global){
|
||||
if (value < mapid_global){
|
||||
new_mapid = get_map_index(models, value);
|
||||
if (new_mapid < models->user_map_count){
|
||||
file->settings.base_map_id = value;
|
||||
|
@ -915,6 +911,9 @@ DOC_SEE(Buffer_Setting_ID)
|
|||
file->settings.base_map_id = mapid_file;
|
||||
}
|
||||
}
|
||||
else if (value <= mapid_nomap){
|
||||
file->settings.base_map_id = value;
|
||||
}
|
||||
|
||||
for (View_Iter iter = file_view_iter_init(&models->layout, file, 0);
|
||||
file_view_iter_good(iter);
|
||||
|
@ -1117,6 +1116,8 @@ DOC_RETURN(returns a summary of the newly created buffer or of the existing buff
|
|||
|
||||
DOC_SEE(begin_buffer_creation)
|
||||
*/{
|
||||
PRFL_FUNC_GROUP();
|
||||
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
System_Functions *system = cmd->system;
|
||||
Models *models = cmd->models;
|
||||
|
@ -1629,6 +1630,7 @@ DOC_RETURN(returns non-zero on success)
|
|||
switch (setting){
|
||||
case ViewSetting_ShowWhitespace: *value_out = vptr->file_data.show_whitespace; break;
|
||||
case ViewSetting_ShowScrollbar: *value_out = !vptr->hide_scrollbar; break;
|
||||
case ViewSetting_ShowFileBar: *value_out = !vptr->hide_file_bar; break;
|
||||
default: result = 0; break;
|
||||
}
|
||||
}
|
||||
|
@ -1663,6 +1665,11 @@ DOC_SEE(View_Setting_ID)
|
|||
vptr->hide_scrollbar = !value;
|
||||
}break;
|
||||
|
||||
case ViewSetting_ShowFileBar:
|
||||
{
|
||||
vptr->hide_file_bar = !value;
|
||||
}break;
|
||||
|
||||
default:
|
||||
{
|
||||
result = false;
|
||||
|
@ -2070,11 +2077,9 @@ DOC(This call changes 4coder's color pallet to one of the built in themes.)
|
|||
Style_Library *styles = &cmd->models->styles;
|
||||
String theme_name = make_string(name, len);
|
||||
|
||||
i32 i = 0;
|
||||
i32 count = styles->count;
|
||||
Style *s = styles->styles;
|
||||
|
||||
for (i = 0; i < count; ++i, ++s){
|
||||
for (i32 i = 0; i < count; ++i, ++s){
|
||||
if (match_ss(s->name, theme_name)){
|
||||
style_copy(main_style(cmd->models), s);
|
||||
break;
|
||||
|
@ -2087,29 +2092,22 @@ Change_Font(Application_Links *app, char *name, int32_t len, bool32 apply_to_all
|
|||
/*
|
||||
DOC_PARAM(name, The name parameter specifies the name of the font to begin using; it need not be null terminated.)
|
||||
DOC_PARAM(len, The len parameter specifies the length of the name string.)
|
||||
DOC_PARAM(apply_to_all_files, If this is set all open files change to this font. Usually this should be true
|
||||
durring the start hook because several files already exist at that time.)
|
||||
DOC_PARAM(apply_to_all_files, If this is set all open files change to this font. Usually this should be true durring the start hook because several files already exist at that time.)
|
||||
DOC(This call changes 4coder's default font to one of the built in fonts.)
|
||||
*/{
|
||||
|
||||
#if 0
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
Font_Set *set = cmd->models->font_set;
|
||||
Models *models = cmd->models;
|
||||
System_Functions *system = cmd->system;
|
||||
|
||||
Style_Font *global_font = &cmd->models->global_font;
|
||||
String font_name = make_string(name, len);
|
||||
i16 font_id = 0;
|
||||
Font_ID font_id = font_get_id_by_name(system, font_name);
|
||||
|
||||
if (font_set_extract(set, font_name, &font_id)){
|
||||
if (apply_to_all_files){
|
||||
global_set_font(cmd->models, font_id);
|
||||
}
|
||||
else{
|
||||
global_font->font_id = font_id;
|
||||
}
|
||||
if (apply_to_all_files){
|
||||
global_set_font(system, models, font_id);
|
||||
}
|
||||
else{
|
||||
models->global_font_id = font_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
API_EXPORT void
|
||||
|
@ -2121,22 +2119,16 @@ DOC_PARAM(len, The len parameter specifies the length of the name string.)
|
|||
DOC(This call sets the display font of a particular buffer.)
|
||||
*/{
|
||||
|
||||
#if 0
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
Models *models = cmd->models;
|
||||
System_Functions *system = cmd->system;
|
||||
Editing_File *file = imp_get_file(cmd, buffer);
|
||||
|
||||
if (file){
|
||||
Font_Set *set = models->font_set;
|
||||
if (file != 0){
|
||||
String font_name = make_string(name, len);
|
||||
i16 font_id = 0;
|
||||
|
||||
if (font_set_extract(set, font_name, &font_id)){
|
||||
file_set_font(models, file, font_id);
|
||||
}
|
||||
Font_ID font_id = font_get_id_by_name(system, font_name);
|
||||
file_set_font(system, models, file, font_id);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
API_EXPORT bool32
|
||||
|
@ -2146,23 +2138,21 @@ DOC_PARAM(buffer, the buffer from which to get the font name)
|
|||
DOC_PARAM(name_out, a character array in which to write the name of the font)
|
||||
DOC_PARAM(name_max, the capacity of name_out)
|
||||
DOC_RETURN(returns non-zero on success)
|
||||
*/
|
||||
{
|
||||
bool32 result = false;
|
||||
|
||||
#if 0
|
||||
*/{
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
Models *models = cmd->models;
|
||||
System_Functions *system = cmd->system;
|
||||
Editing_File *file = imp_get_file(cmd, buffer);
|
||||
|
||||
if (file){
|
||||
Font_Set *set = models->font_set;
|
||||
bool32 result = false;
|
||||
|
||||
if (file != 0){
|
||||
String name = make_string_cap(name_out, 0, name_max);
|
||||
if (font_set_get_name(set, file->settings.font_id, &name)){
|
||||
result = (name.size > 0);
|
||||
Font_ID font_id = file->settings.font_id;
|
||||
name.size = system->font.get_name_by_id(font_id, name_out, name_max);
|
||||
if (name.size > 0){
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
@ -2172,8 +2162,7 @@ Set_Theme_Colors(Application_Links *app, Theme_Color *colors, int32_t count)
|
|||
/*
|
||||
DOC_PARAM(colors, The colors pointer provides an array of color structs pairing differet style tags to color codes.)
|
||||
DOC_PARAM(count, The count parameter specifies the number of Theme_Color structs in the colors array.)
|
||||
DOC(
|
||||
For each struct in the array, the slot in the main color pallet specified by the struct's tag is set to the color code in the struct. If the tag value is invalid no change is made to the color pallet.)
|
||||
DOC(For each struct in the array, the slot in the main color pallet specified by the struct's tag is set to the color code in the struct. If the tag value is invalid no change is made to the color pallet.)
|
||||
DOC_SEE(Theme_Color)
|
||||
*/{
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
// TOP
|
||||
|
||||
struct App_Settings{
|
||||
char *user_file;
|
||||
b32 user_file_is_strict;
|
||||
|
||||
char *init_files[8];
|
||||
i32 init_files_count;
|
||||
i32 init_files_max;
|
||||
|
@ -20,8 +17,6 @@ struct App_Settings{
|
|||
i32 initial_line;
|
||||
b32 lctrl_lalt_is_altgr;
|
||||
|
||||
i32 font_size;
|
||||
|
||||
char *custom_font_file;
|
||||
char *custom_font_name;
|
||||
i32 custom_font_size;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "4ed_math.h"
|
||||
#include "4ed_system.h"
|
||||
#include "4ed_profile.h"
|
||||
|
||||
//#define USE_DEBUG_MEMORY
|
||||
|
||||
|
|
|
@ -669,6 +669,8 @@ 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, i32 virtual_white){
|
||||
PRFL_FUNC_GROUP();
|
||||
|
||||
assert(mode == 0);
|
||||
|
||||
Gap_Buffer_Stream stream = {0};
|
||||
|
|
|
@ -106,6 +106,11 @@ struct Editing_File_Settings{
|
|||
};
|
||||
global_const Editing_File_Settings null_editing_file_settings = {0};
|
||||
|
||||
struct Editing_Hacks{
|
||||
b32 suppression_mode;
|
||||
b32 needs_wraps_and_fix_cursor;
|
||||
};
|
||||
|
||||
struct Editing_File_State{
|
||||
Gap_Buffer buffer;
|
||||
|
||||
|
@ -140,6 +145,8 @@ struct Editing_File_State{
|
|||
File_Edit_Positions edit_pos_space[16];
|
||||
File_Edit_Positions *edit_poss[16];
|
||||
i32 edit_poss_count;
|
||||
|
||||
Editing_Hacks hacks;
|
||||
};
|
||||
global_const Editing_File_State null_editing_file_state = {0};
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ enum Interactive_Action{
|
|||
IAct_Open,
|
||||
IAct_Save_As,
|
||||
IAct_New,
|
||||
IAct_OpenOrNew,
|
||||
IAct_Switch,
|
||||
IAct_Kill,
|
||||
IAct_Sure_To_Kill,
|
||||
|
@ -212,6 +213,7 @@ struct View{
|
|||
i32 list_i;
|
||||
|
||||
b32 hide_scrollbar;
|
||||
b32 hide_file_bar;
|
||||
|
||||
// interactive stuff
|
||||
Interactive_Interaction interaction;
|
||||
|
@ -897,6 +899,8 @@ file_update_cursor_positions(System_Functions *system, Models *models, Editing_F
|
|||
|
||||
internal void
|
||||
file_measure_starts(General_Memory *general, Gap_Buffer *buffer){
|
||||
PRFL_FUNC_GROUP();
|
||||
|
||||
if (!buffer->line_starts){
|
||||
i32 max = buffer->line_max = KB(1);
|
||||
buffer->line_starts = (i32*)general_memory_allocate(general, max*sizeof(i32));
|
||||
|
@ -1451,6 +1455,8 @@ get_current_shift(Code_Wrap_State *wrap_state, i32 next_line_start){
|
|||
|
||||
internal void
|
||||
file_measure_wraps(System_Functions *system, Models *models, Editing_File *file, Render_Font *font){
|
||||
PRFL_FUNC_GROUP();
|
||||
|
||||
General_Memory *general = &models->mem.general;
|
||||
Partition *part = &models->mem.part;
|
||||
|
||||
|
@ -1507,12 +1513,20 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
|
|||
i32 potential_count = 0;
|
||||
i32 stage = 0;
|
||||
|
||||
PRFL_BEGIN_RESUMABLE(buffer_measure_wrap_y);
|
||||
PRFL_BEGIN_RESUMABLE(NeedWrapDetermination);
|
||||
PRFL_BEGIN_RESUMABLE(NeedLineShift);
|
||||
PRFL_BEGIN_RESUMABLE(LongTokenParsing);
|
||||
|
||||
do{
|
||||
PRFL_START_RESUMABLE(buffer_measure_wrap_y);
|
||||
stop = buffer_measure_wrap_y(&state, params, current_line_shift, do_wrap, wrap_unit_end);
|
||||
PRFL_STOP_RESUMABLE(buffer_measure_wrap_y);
|
||||
|
||||
switch (stop.status){
|
||||
case BLStatus_NeedWrapDetermination:
|
||||
{
|
||||
PRFL_START_RESUMABLE(NeedWrapDetermination);
|
||||
if (use_tokens){
|
||||
if (stage == 0){
|
||||
do_wrap = 0;
|
||||
|
@ -1537,7 +1551,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
|
|||
f32 self_x = 0;
|
||||
i32 wrap_end_result = size;
|
||||
if (buffer_stringify_loop(&stream, params.buffer, i, size)){
|
||||
b32 still_looping = 0;
|
||||
b32 still_looping = false;
|
||||
do{
|
||||
for (; i < stream.end; ++i){
|
||||
{
|
||||
|
@ -1592,11 +1606,13 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
|
|||
do_wrap = 0;
|
||||
}
|
||||
}
|
||||
PRFL_STOP_RESUMABLE(NeedWrapDetermination);
|
||||
}break;
|
||||
|
||||
case BLStatus_NeedWrapLineShift:
|
||||
case BLStatus_NeedLineShift:
|
||||
{
|
||||
PRFL_START_RESUMABLE(NeedLineShift);
|
||||
f32 current_width = width;
|
||||
|
||||
if (use_tokens){
|
||||
|
@ -1634,8 +1650,8 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
|
|||
b32 emit_comment_position = 0;
|
||||
b32 first_word = 1;
|
||||
|
||||
if (wrap_state.token_ptr->type == CPP_TOKEN_COMMENT ||
|
||||
wrap_state.token_ptr->type == CPP_TOKEN_STRING_CONSTANT){
|
||||
if (wrap_state.token_ptr->type == CPP_TOKEN_COMMENT || wrap_state.token_ptr->type == CPP_TOKEN_STRING_CONSTANT){
|
||||
PRFL_START_RESUMABLE(LongTokenParsing);
|
||||
i32 i = wrap_state.token_ptr->start;
|
||||
i32 end_i = i + wrap_state.token_ptr->size;
|
||||
|
||||
|
@ -1665,7 +1681,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
|
|||
potential_wrap.adjust_top_to_this = 0;
|
||||
|
||||
if (buffer_stringify_loop(&stream, params.buffer, i, end_i)){
|
||||
b32 still_looping = 1;
|
||||
b32 still_looping = true;
|
||||
|
||||
while(still_looping){
|
||||
for (; i < stream.end; ++i){
|
||||
|
@ -1677,6 +1693,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
|
|||
for (TRANSLATION_DECL_EMIT_LOOP(J, emits)){
|
||||
TRANSLATION_DECL_GET_STEP(buffer_step, behav, J, emits);
|
||||
if (!codepoint_is_whitespace(buffer_step.value)){
|
||||
i = buffer_step.i;
|
||||
goto doublebreak_stage_vspace;
|
||||
}
|
||||
}
|
||||
|
@ -1755,6 +1772,8 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
|
|||
potential_marks[potential_count] = potential_wrap;
|
||||
++potential_count;
|
||||
}
|
||||
|
||||
PRFL_STOP_RESUMABLE(LongTokenParsing);
|
||||
}
|
||||
|
||||
if (!emit_comment_position){
|
||||
|
@ -1925,10 +1944,17 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
|
|||
|
||||
file->state.line_indents[stop.wrap_line_index] = current_line_shift;
|
||||
file->state.wrap_line_count = stop.wrap_line_index;
|
||||
|
||||
PRFL_STOP_RESUMABLE(NeedLineShift);
|
||||
}break;
|
||||
}
|
||||
}while(stop.status != BLStatus_Finished);
|
||||
|
||||
PRFL_END_RESUMABLE(buffer_measure_wrap_y);
|
||||
PRFL_END_RESUMABLE(NeedWrapDetermination);
|
||||
PRFL_END_RESUMABLE(NeedLineShift);
|
||||
PRFL_END_RESUMABLE(LongTokenParsing);
|
||||
|
||||
++file->state.wrap_line_count;
|
||||
|
||||
file_allocate_wrap_positions_as_needed(general, file, wrap_position_index);
|
||||
|
@ -1936,12 +1962,23 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
|
|||
file->state.wrap_position_count = wrap_position_index;
|
||||
|
||||
end_temp_memory(temp);
|
||||
|
||||
if (file->state.hacks.needs_wraps_and_fix_cursor){
|
||||
file->state.hacks.needs_wraps_and_fix_cursor = false;
|
||||
file_update_cursor_positions(system, models, file);
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
file_measure_wraps_and_fix_cursor(System_Functions *system, Models *models, Editing_File *file, Render_Font *font){
|
||||
file_measure_wraps(system, models, file, font);
|
||||
file_update_cursor_positions(system, models, file);
|
||||
if (file->state.hacks.suppression_mode){
|
||||
file->state.hacks.needs_wraps_and_fix_cursor = true;
|
||||
}
|
||||
else{
|
||||
file->state.hacks.needs_wraps_and_fix_cursor = false;
|
||||
file_measure_wraps(system, models, file, font);
|
||||
file_update_cursor_positions(system, models, file);
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -1962,8 +1999,8 @@ file_set_min_base_width(System_Functions *system, Models *models, Editing_File *
|
|||
|
||||
internal void
|
||||
file_create_from_string(System_Functions *system, Models *models, Editing_File *file, String val, b8 read_only = 0){
|
||||
PRFL_FUNC_GROUP();
|
||||
|
||||
//Font_Set *font_set = models->font_set;
|
||||
General_Memory *general = &models->mem.general;
|
||||
Partition *part = &models->mem.part;
|
||||
Open_File_Hook_Function *hook_open_file = models->hook_open_file;
|
||||
|
@ -1995,12 +2032,15 @@ file_create_from_string(System_Functions *system, Models *models, Editing_File *
|
|||
file->settings.font_id = font_id;
|
||||
Render_Font *font = system->font.get_render_data_by_id(font_id);
|
||||
|
||||
file_measure_starts(general, &file->state.buffer);
|
||||
|
||||
file_allocate_character_starts_as_needed(general, file);
|
||||
buffer_measure_character_starts(system, font, &file->state.buffer, file->state.character_starts, 0, file->settings.virtual_white);
|
||||
|
||||
file_measure_wraps(system, models, file, font);
|
||||
{
|
||||
PRFL_SCOPE_GROUP(measurements);
|
||||
file_measure_starts(general, &file->state.buffer);
|
||||
|
||||
file_allocate_character_starts_as_needed(general, file);
|
||||
buffer_measure_character_starts(system, font, &file->state.buffer, file->state.character_starts, 0, file->settings.virtual_white);
|
||||
|
||||
file_measure_wraps(system, models, file, font);
|
||||
}
|
||||
|
||||
file->settings.read_only = read_only;
|
||||
if (!read_only){
|
||||
|
@ -2032,9 +2072,15 @@ file_create_from_string(System_Functions *system, Models *models, Editing_File *
|
|||
}
|
||||
|
||||
if (hook_open_file){
|
||||
PRFL_SCOPE_GROUP(open_hook);
|
||||
file->state.hacks.suppression_mode = true;
|
||||
hook_open_file(app_links, file->id.id);
|
||||
file->state.hacks.suppression_mode = false;
|
||||
if (file->state.hacks.needs_wraps_and_fix_cursor){
|
||||
file_measure_wraps_and_fix_cursor(system, models, file, font);
|
||||
}
|
||||
}
|
||||
file->settings.is_initialized = 1;
|
||||
file->settings.is_initialized = true;
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -3216,9 +3262,7 @@ file_edit_cursor_fix(System_Functions *system, Models *models, Editing_File *fil
|
|||
scroll.scroll_y = y_position;
|
||||
}
|
||||
|
||||
view_set_cursor_and_scroll(view, new_cursor,
|
||||
1, view->file_data.file->settings.unwrapped_lines,
|
||||
scroll);
|
||||
view_set_cursor_and_scroll(view, new_cursor, 1, view->file_data.file->settings.unwrapped_lines, scroll);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3317,8 +3361,7 @@ file_do_single_edit(System_Functions *system, Models *models, Editing_File *file
|
|||
}
|
||||
|
||||
internal void
|
||||
file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file,
|
||||
Edit_Spec spec, History_Mode history_mode, i32 batch_type){
|
||||
file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file, Edit_Spec spec, History_Mode history_mode, i32 batch_type){
|
||||
|
||||
Mem_Options *mem = &models->mem;
|
||||
General_Memory *general = &mem->general;
|
||||
|
@ -3769,6 +3812,8 @@ make_string_terminated(Partition *part, char *str, i32 len){
|
|||
|
||||
internal void
|
||||
init_normal_file(System_Functions *system, Models *models, Editing_File *file, char *buffer, i32 size){
|
||||
PRFL_FUNC_GROUP();
|
||||
|
||||
String val = make_string(buffer, size);
|
||||
file_create_from_string(system, models, file, val);
|
||||
|
||||
|
@ -3946,9 +3991,7 @@ save_file_by_name(System_Functions *system, Models *models, String name){
|
|||
|
||||
internal void
|
||||
interactive_begin_sure_to_kill(System_Functions *system, View *view, Editing_File *file){
|
||||
view_show_interactive(system, view,
|
||||
IAct_Sure_To_Kill, IInt_Sure_To_Kill,
|
||||
make_lit_string("Are you sure?"));
|
||||
view_show_interactive(system, view, IAct_Sure_To_Kill, IInt_Sure_To_Kill, make_lit_string("Are you sure?"));
|
||||
copy_ss(&view->dest, file->name.live_name);
|
||||
}
|
||||
|
||||
|
@ -4003,14 +4046,16 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32
|
|||
|
||||
switch (view->action){
|
||||
case IAct_Open:
|
||||
view_open_file(system, models, view, dest);
|
||||
view_show_file(view);
|
||||
break;
|
||||
{
|
||||
view_open_file(system, models, view, dest);
|
||||
view_show_file(view);
|
||||
}break;
|
||||
|
||||
case IAct_Save_As:
|
||||
view_interactive_save_as(system, models, view->file_data.file, dest);
|
||||
view_show_file(view);
|
||||
break;
|
||||
{
|
||||
view_interactive_save_as(system, models, view->file_data.file, dest);
|
||||
view_show_file(view);
|
||||
}break;
|
||||
|
||||
case IAct_New:
|
||||
if (dest.size > 0 && !char_is_slash(dest.str[dest.size-1])){
|
||||
|
@ -4022,6 +4067,11 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32
|
|||
}
|
||||
}break;
|
||||
|
||||
case IAct_OpenOrNew:
|
||||
{
|
||||
InvalidCodePath;
|
||||
}break;
|
||||
|
||||
case IAct_Switch:
|
||||
{
|
||||
Editing_File *file = working_set_name_contains(&models->working_set, dest);
|
||||
|
@ -4039,123 +4089,42 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32
|
|||
case IAct_Sure_To_Close:
|
||||
switch (user_action){
|
||||
case 0:
|
||||
models->keep_playing = 0;
|
||||
break;
|
||||
{
|
||||
models->keep_playing = 0;
|
||||
}break;
|
||||
|
||||
case 1:
|
||||
view_show_file(view);
|
||||
break;
|
||||
{
|
||||
view_show_file(view);
|
||||
}break;
|
||||
|
||||
case 2:
|
||||
// TODO(allen): Save all and close.
|
||||
case 2: // TODO(allen): Save all and close.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}break;
|
||||
|
||||
case IAct_Sure_To_Kill:
|
||||
switch (user_action){
|
||||
case 0:
|
||||
kill_file_by_name(system, models, dest);
|
||||
view_show_file(view);
|
||||
break;
|
||||
{
|
||||
kill_file_by_name(system, models, dest);
|
||||
view_show_file(view);
|
||||
}break;
|
||||
|
||||
case 1:
|
||||
view_show_file(view);
|
||||
break;
|
||||
{
|
||||
view_show_file(view);
|
||||
}break;
|
||||
|
||||
case 2:
|
||||
save_file_by_name(system, models, dest);
|
||||
kill_file_by_name(system, models, dest);
|
||||
view_show_file(view);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
{
|
||||
save_file_by_name(system, models, dest);
|
||||
kill_file_by_name(system, models, dest);
|
||||
view_show_file(view);
|
||||
}break;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
internal void
|
||||
update_highlighting(View *view){
|
||||
View *file_view = view->hot_file_view;
|
||||
if (!file_view){
|
||||
view->highlight = {};
|
||||
return;
|
||||
}
|
||||
|
||||
Editing_File *file = file_view->file;
|
||||
if (!file || !file_is_ready(file)){
|
||||
view->highlight = {};
|
||||
return;
|
||||
}
|
||||
|
||||
Models *models = view->persistent.models;
|
||||
|
||||
Style *style = &models->style;
|
||||
i32 pos = view_get_cursor_pos(file_view);
|
||||
char c = buffer_get_char(&file->state.buffer, pos);
|
||||
|
||||
if (c == '\r'){
|
||||
view->highlight.ids[0] =
|
||||
raw_ptr_dif(&style->main.special_character_color, style);
|
||||
}
|
||||
|
||||
else if (file->state.tokens_complete){
|
||||
Cpp_Token_Stack *tokens = &file->state.token_array;
|
||||
Cpp_Get_Token_Result result = cpp_get_token(tokens, pos);
|
||||
Cpp_Token token = tokens->tokens[result.token_index];
|
||||
if (!result.in_whitespace){
|
||||
u32 *color = style_get_color(style, token);
|
||||
view->highlight.ids[0] = raw_ptr_dif(color, style);
|
||||
if (token.type == CPP_TOKEN_JUNK){
|
||||
view->highlight.ids[1] =
|
||||
raw_ptr_dif(&style->main.highlight_junk_color, style);
|
||||
}
|
||||
else if (char_is_whitespace(c)){
|
||||
view->highlight.ids[1] =
|
||||
raw_ptr_dif(&style->main.highlight_white_color, style);
|
||||
}
|
||||
else{
|
||||
view->highlight.ids[1] = 0;
|
||||
}
|
||||
}
|
||||
else{
|
||||
view->highlight.ids[0] = 0;
|
||||
view->highlight.ids[1] =
|
||||
raw_ptr_dif(&style->main.highlight_white_color, style);
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
if (char_is_whitespace(c)){
|
||||
view->highlight.ids[0] = 0;
|
||||
view->highlight.ids[1] =
|
||||
raw_ptr_dif(&style->main.highlight_white_color, style);
|
||||
}
|
||||
else{
|
||||
view->highlight.ids[0] =
|
||||
raw_ptr_dif(&style->main.default_color, style);
|
||||
view->highlight.ids[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_view->show_temp_highlight){
|
||||
view->highlight.ids[2] =
|
||||
raw_ptr_dif(&style->main.highlight_color, style);
|
||||
view->highlight.ids[3] =
|
||||
raw_ptr_dif(&style->main.at_highlight_color, style);
|
||||
}
|
||||
else if (file->state.paste_effect.tick_down > 0){
|
||||
view->highlight.ids[2] =
|
||||
raw_ptr_dif(&style->main.paste_color, style);
|
||||
view->highlight.ids[3] = 0;
|
||||
}
|
||||
else{
|
||||
view->highlight.ids[2] = 0;
|
||||
view->highlight.ids[3] = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
struct File_Bar{
|
||||
f32 pos_x, pos_y;
|
||||
f32 text_shift_x, text_shift_y;
|
||||
|
@ -4207,15 +4176,14 @@ view_reinit_scrolling(View *view){
|
|||
|
||||
internal b32
|
||||
file_step(View *view, i32_Rect region, Input_Summary *user_input, b32 is_active, b32 *consumed_l){
|
||||
i32 is_animating = 0;
|
||||
b32 is_animating = false;
|
||||
Editing_File *file = view->file_data.file;
|
||||
if (file && !file->is_loading){
|
||||
if (file->state.paste_effect.seconds_down > 0.f){
|
||||
file->state.paste_effect.seconds_down -= user_input->dt;
|
||||
is_animating = 1;
|
||||
is_animating = true;
|
||||
}
|
||||
}
|
||||
|
||||
return(is_animating);
|
||||
}
|
||||
|
||||
|
@ -4642,7 +4610,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
|||
|
||||
gui_begin_top_level(target, input);
|
||||
{
|
||||
if (view->showing_ui != VUI_Debug){
|
||||
if (view->showing_ui != VUI_Debug && !view->hide_file_bar){
|
||||
gui_do_top_bar(target);
|
||||
}
|
||||
do_widget(view, target);
|
||||
|
@ -4944,69 +4912,68 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
|||
switch (view->interaction){
|
||||
case IInt_Sys_File_List:
|
||||
{
|
||||
b32 autocomplete_with_enter = 1;
|
||||
b32 activate_directly = 0;
|
||||
b32 autocomplete_with_enter = true;
|
||||
b32 activate_directly = false;
|
||||
|
||||
if (view->action == IAct_Save_As || view->action == IAct_New){
|
||||
autocomplete_with_enter = 0;
|
||||
autocomplete_with_enter = false;
|
||||
}
|
||||
|
||||
String message = null_string;
|
||||
switch (view->action){
|
||||
case IAct_OpenOrNew:
|
||||
case IAct_Open: message = make_lit_string("Open: "); break;
|
||||
case IAct_Save_As: message = make_lit_string("Save As: "); break;
|
||||
case IAct_New: message = make_lit_string("New: "); break;
|
||||
}
|
||||
|
||||
Exhaustive_File_Loop loop;
|
||||
Exhaustive_File_Info file_info;
|
||||
|
||||
GUI_Item_Update update = {0};
|
||||
Hot_Directory *hdir = &models->hot_directory;
|
||||
|
||||
{
|
||||
Single_Line_Input_Step step = {0};
|
||||
Key_Event_Data key = {0};
|
||||
i32 i;
|
||||
b32 do_open_or_new = false;
|
||||
for (i32 i = 0; i < keys.count; ++i){
|
||||
Key_Event_Data key = get_single_key(&keys, i);
|
||||
Single_Line_Input_Step step = app_single_file_input_step(system, &models->working_set, key,
|
||||
&hdir->string, hdir, 1, 0);
|
||||
|
||||
for (i = 0; i < keys.count; ++i){
|
||||
key = get_single_key(&keys, i);
|
||||
step = app_single_file_input_step(system, &models->working_set, key,
|
||||
&hdir->string, hdir, 1, 0);
|
||||
if (step.made_a_change){
|
||||
view->list_i = 0;
|
||||
result.consume_keys = 1;
|
||||
if (step.made_a_change){
|
||||
view->list_i = 0;
|
||||
result.consume_keys = true;
|
||||
}
|
||||
|
||||
if (key.keycode == '\n'){
|
||||
if (!autocomplete_with_enter){
|
||||
activate_directly = true;
|
||||
result.consume_keys = true;
|
||||
}
|
||||
|
||||
if (!autocomplete_with_enter && key.keycode == '\n'){
|
||||
activate_directly = 1;
|
||||
result.consume_keys = 1;
|
||||
else if (view->action == IAct_OpenOrNew){
|
||||
do_open_or_new = true;
|
||||
result.consume_keys = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gui_do_text_field(target, message, hdir->string);
|
||||
|
||||
b32 snap_into_view = 0;
|
||||
b32 snap_into_view = false;
|
||||
scroll_context.id[0] = (u64)(hdir);
|
||||
if (gui_scroll_was_activated(target, scroll_context)){
|
||||
snap_into_view = 1;
|
||||
snap_into_view = true;
|
||||
}
|
||||
gui_begin_scrollable(target, scroll_context, view->gui_scroll,
|
||||
9 * view->line_height, show_scrollbar);
|
||||
gui_begin_scrollable(target, scroll_context, view->gui_scroll, 9 * view->line_height, show_scrollbar);
|
||||
|
||||
id.id[0] = (u64)(hdir) + 1;
|
||||
|
||||
if (gui_begin_list(target, id, view->list_i, 0,
|
||||
snap_into_view, &update)){
|
||||
if (gui_begin_list(target, id, view->list_i, 0, snap_into_view, &update)){
|
||||
// TODO(allen): Allow me to handle key consumption correctly here!
|
||||
gui_standard_list(target, id, &view->gui_scroll, view->scroll_region, &keys, &view->list_i, &update, user_up_key, user_down_key);
|
||||
}
|
||||
|
||||
b32 do_new_directory = false;
|
||||
Exhaustive_File_Loop loop;
|
||||
begin_exhaustive_loop(&loop, hdir);
|
||||
for (i32 i = 0; i < loop.count; ++i){
|
||||
file_info = get_exhaustive_info(system, &models->working_set, &loop, i);
|
||||
Exhaustive_File_Info file_info = get_exhaustive_info(system, &models->working_set, &loop, i);
|
||||
|
||||
if (file_info.name_match){
|
||||
id.id[0] = (u64)(file_info.info);
|
||||
|
@ -5018,22 +4985,32 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
|||
if (gui_do_file_option(target, id, filename, file_info.is_folder, file_info.message)){
|
||||
if (file_info.is_folder){
|
||||
set_last_folder_sc(&hdir->string, file_info.info->filename, '/');
|
||||
do_new_directory = 1;
|
||||
do_new_directory = true;
|
||||
}
|
||||
|
||||
else if (autocomplete_with_enter){
|
||||
complete = 1;
|
||||
complete = true;
|
||||
copy_ss(&comp_dest, loop.full_path);
|
||||
if (view->action == IAct_OpenOrNew){
|
||||
view->action = IAct_Open;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (do_open_or_new){
|
||||
do_open_or_new = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gui_end_list(target);
|
||||
|
||||
if (activate_directly){
|
||||
complete = 1;
|
||||
if (activate_directly || do_open_or_new){
|
||||
complete = true;
|
||||
copy_ss(&comp_dest, hdir->string);
|
||||
if (do_open_or_new){
|
||||
view->action = IAct_New;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_new_directory){
|
||||
|
@ -5502,9 +5479,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
|||
SHOW_GUI_BLANK(0);
|
||||
{
|
||||
Command_Map *map = view_ptr->map;
|
||||
|
||||
#define MAP_LABEL "command map"
|
||||
|
||||
if (map == &models->map_top){
|
||||
SHOW_GUI_STRING(1, h_align, MAP_LABEL, "global");
|
||||
}
|
||||
|
@ -5514,10 +5489,12 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
|||
else if (map == &models->map_ui){
|
||||
SHOW_GUI_STRING(1, h_align, MAP_LABEL, "gui");
|
||||
}
|
||||
else{
|
||||
else if (map == 0){
|
||||
SHOW_GUI_STRING(1, h_align, MAP_LABEL, "nomap");
|
||||
}
|
||||
else if (map >= models->user_maps){
|
||||
i32 map_index = (i32)(view_ptr->map - models->user_maps);
|
||||
i32 map_id = models->map_id_table[map_index];
|
||||
|
||||
SHOW_GUI_STRING(1, h_align, MAP_LABEL, "user");
|
||||
SHOW_GUI_INT(2, h_align, "custom map id", map_id);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,14 @@ struct Render_Font{
|
|||
u32 name_len;
|
||||
char filename[256];
|
||||
char name[256];
|
||||
|
||||
// Hack optimizations
|
||||
struct Page_Cache{
|
||||
u32 page_number;
|
||||
Glyph_Page *page;
|
||||
};
|
||||
|
||||
Page_Cache cache[16];
|
||||
};
|
||||
|
||||
struct Glyph_Data{
|
||||
|
|
|
@ -20,16 +20,16 @@ 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)
|
||||
#define Sys_Font_Get_IDs_By_Index_Sig(name_) b32 (name_)(Font_ID 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)
|
||||
#define Sys_Font_Get_Name_By_ID_Sig(name_) u32 (name_)(Font_ID 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)
|
||||
#define Sys_Font_Get_Render_Data_By_ID_Sig(name_) Render_Font* (name_)(Font_ID 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)
|
||||
|
@ -53,6 +53,8 @@ struct Font_Functions{
|
|||
Font_Free_Function *free;
|
||||
};
|
||||
|
||||
internal u32 font_get_id_by_name(struct System_Functions *system, String name);
|
||||
|
||||
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);
|
||||
|
|
|
@ -11,6 +11,22 @@
|
|||
|
||||
#include "4ed_font_data.h"
|
||||
|
||||
internal u32
|
||||
font_get_id_by_name(System_Functions *system, String name){
|
||||
u32 id = 0;
|
||||
u32 count = system->font.get_count();
|
||||
for (u32 index = 0; index < count; ++index){
|
||||
char str[256];
|
||||
u32 str_len = system->font.get_name_by_index(index, str, sizeof(str));
|
||||
String font_name = make_string(str, str_len);
|
||||
if (match_ss(font_name, name)){
|
||||
system->font.get_ids_by_index(index, 1, &id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(id);
|
||||
}
|
||||
|
||||
internal f32
|
||||
font_get_byte_advance(Render_Font *font){
|
||||
return(font->byte_advance);
|
||||
|
@ -63,7 +79,21 @@ font_get_glyph_advance(System_Functions *system, Render_Font *font, u32 codepoin
|
|||
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);
|
||||
|
||||
Glyph_Page *page = 0;
|
||||
|
||||
// Hack optimizations
|
||||
u32 cache_index = page_number % ArrayCount(font->cache);
|
||||
if (font->cache[cache_index].page_number == page_number){
|
||||
page = font->cache[cache_index].page;
|
||||
}
|
||||
|
||||
if (page == 0){
|
||||
page = font_get_or_make_page(system, font, page_number);
|
||||
font->cache[cache_index].page = page;
|
||||
font->cache[cache_index].page_number = page_number;
|
||||
}
|
||||
|
||||
if (page != 0 && page->advance[glyph_index] > 0.f){
|
||||
result = page->advance[glyph_index];
|
||||
}
|
||||
|
@ -75,7 +105,21 @@ 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);
|
||||
|
||||
Glyph_Page *page = 0;
|
||||
|
||||
// Hack optimizations
|
||||
u32 cache_index = page_number % ArrayCount(font->cache);
|
||||
if (font->cache[cache_index].page_number == page_number){
|
||||
page = font->cache[cache_index].page;
|
||||
}
|
||||
|
||||
if (page == 0){
|
||||
page = font_get_or_make_page(system, font, page_number);
|
||||
font->cache[cache_index].page = page;
|
||||
font->cache[cache_index].page_number = page_number;
|
||||
}
|
||||
|
||||
if (page != 0 && page->advance[glyph_index] > 0.f){
|
||||
result.bounds = page->glyphs[glyph_index];
|
||||
result.tex = page->tex;
|
||||
|
|
|
@ -0,0 +1,217 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 29.03.2017
|
||||
*
|
||||
* Really basic profiling primitives. (not meant to stay for long)
|
||||
*
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
#define FRED_INTERNAL 1
|
||||
|
||||
#include "4tech_defines.h"
|
||||
#include "4ed_profile.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
global f32 frame_target = 58000000.f;
|
||||
|
||||
internal void
|
||||
usage(){
|
||||
fprintf(stderr, "No! Like this, you moron:\n"
|
||||
"\t<PROFILE-EXE> <PROFILE-DATA> [min-time-filter]\n");
|
||||
}
|
||||
|
||||
internal u32
|
||||
parse_frame_count(u8 *ptr, u8 *end){
|
||||
u32 count = 0;
|
||||
|
||||
for (;ptr < end;){
|
||||
u8 *frame_base = *(u8**)ptr;
|
||||
ptr += 8;
|
||||
|
||||
u8 *frame_end = *(u8**)ptr;
|
||||
ptr += 8;
|
||||
|
||||
umem skip_size = frame_end - frame_base;
|
||||
ptr += skip_size;
|
||||
++count;
|
||||
}
|
||||
|
||||
if (ptr != end){
|
||||
count = 0;
|
||||
}
|
||||
|
||||
return(count);
|
||||
}
|
||||
|
||||
struct Parse_Frame_Result{
|
||||
u8 *next_read_ptr;
|
||||
u8 *output_chunk;
|
||||
b32 still_looping;
|
||||
b32 bad_parse;
|
||||
f32 frame_time;
|
||||
};
|
||||
|
||||
internal Parse_Frame_Result
|
||||
parse_frame(u8 *ptr, u8 *end_ptr){
|
||||
Parse_Frame_Result result = {0};
|
||||
|
||||
u8 *frame_base = *(u8**)ptr;
|
||||
ptr += 8;
|
||||
|
||||
u8 *frame_end = *(u8**)ptr;
|
||||
ptr += 8;
|
||||
|
||||
umem frame_size = frame_end - frame_base;
|
||||
u8 *frame_start_ptr = ptr;
|
||||
u8 *frame_end_ptr = ptr + frame_size;
|
||||
|
||||
u8 *out_chunk = (u8*)malloc(frame_size*2);
|
||||
u8 *out_ptr = out_chunk;
|
||||
|
||||
Profile_Group *group = (Profile_Group*)frame_start_ptr;
|
||||
Profile_Group *group_end = (Profile_Group*)frame_end_ptr;
|
||||
|
||||
Profile_Group *stack[64];
|
||||
u32 top = 0;
|
||||
|
||||
stack[top++] = group;
|
||||
|
||||
result.frame_time = group->cycle_count / frame_target;
|
||||
|
||||
for (;group < group_end;){
|
||||
for (u32 i = 1; i < top; ++i){
|
||||
*out_ptr++ = ' ';
|
||||
}
|
||||
|
||||
char *name = group->name;
|
||||
for (u32 i = 0; name[i]; ++i){
|
||||
*out_ptr++ = name[i];
|
||||
}
|
||||
|
||||
*out_ptr++ = ':';
|
||||
*out_ptr++ = ' ';
|
||||
|
||||
char str[64];
|
||||
sprintf(str, "%f", group->cycle_count / frame_target);
|
||||
for (u32 i = 0; str[i]; ++i){
|
||||
*out_ptr++ = str[i];
|
||||
}
|
||||
*out_ptr++ = '\n';
|
||||
|
||||
++group;
|
||||
|
||||
for(;top > 0;){
|
||||
Profile_Group *group_top = stack[top-1];
|
||||
umem end_offset = (u8*)group_top->end - frame_base;
|
||||
u8 *this_group_end_ptr = frame_start_ptr + end_offset;
|
||||
Profile_Group *this_group_end = (Profile_Group*)this_group_end_ptr;
|
||||
|
||||
if (group == this_group_end){
|
||||
--top;
|
||||
}
|
||||
else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
stack[top++] = group;
|
||||
}
|
||||
|
||||
if (top != 1){
|
||||
result.bad_parse = true;
|
||||
}
|
||||
else{
|
||||
*out_ptr++ = 0;
|
||||
result.next_read_ptr = frame_end_ptr;
|
||||
result.output_chunk = out_chunk;
|
||||
if (frame_end_ptr != end_ptr){
|
||||
result.still_looping = true;
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal void
|
||||
print_profile(char *filename, f32 min_filter){
|
||||
FILE *file = fopen(filename, "rb");
|
||||
if (!file){
|
||||
fprintf(stderr, "There ain't no file sittin' around called %s.\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
u32 size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
u8 *buffer = (u8*)malloc(size);
|
||||
|
||||
fread(buffer, 1, size, file);
|
||||
fclose(file);
|
||||
|
||||
u8 *read_ptr = buffer;
|
||||
u8 *end_ptr = buffer + size;
|
||||
|
||||
// Frame Count Parse
|
||||
u32 frame_count = parse_frame_count(read_ptr, end_ptr);
|
||||
|
||||
if (frame_count == 0){
|
||||
fprintf(stderr, "There's some fricken problem. I didn't get a good frame count!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Full Parse
|
||||
u8 **output_chunks = (u8**)malloc(frame_count*sizeof(u8*));
|
||||
u32 chunk_i = 0;
|
||||
|
||||
Parse_Frame_Result result = {0};
|
||||
do{
|
||||
if (chunk_i >= frame_count){
|
||||
fprintf(stderr, "The parse ain't lined up! You're fired!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
result = parse_frame(read_ptr, end_ptr);
|
||||
|
||||
if (result.bad_parse){
|
||||
fprintf(stderr, "You've pickled the data nimwit!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
read_ptr = result.next_read_ptr;
|
||||
if (result.frame_time >= min_filter){
|
||||
output_chunks[chunk_i++] = result.output_chunk;
|
||||
}
|
||||
}while(result.still_looping);
|
||||
|
||||
// Print
|
||||
fprintf(stdout, "Frames: %u (%u)\n", chunk_i, frame_count);
|
||||
for (u32 i = 0; i < chunk_i; ++i){
|
||||
fprintf(stdout, "%s", output_chunks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv){
|
||||
if (argc < 2){
|
||||
usage();
|
||||
}
|
||||
else{
|
||||
f32 min_filter = 0.f;
|
||||
if (argc == 3){
|
||||
min_filter = (f32)atof(argv[2]);
|
||||
}
|
||||
|
||||
print_profile(argv[1], min_filter);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 29.03.2017
|
||||
*
|
||||
* Really basic profiling primitives. (not meant to stay for long)
|
||||
*
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
#if !defined(FRED_PROFILE_H)
|
||||
#define FRED_PROFILE_H
|
||||
|
||||
#if FRED_INTERNAL
|
||||
|
||||
#include <intrin.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct Profile_Group{
|
||||
char name[104];
|
||||
u64 cycle_start;
|
||||
u64 cycle_count;
|
||||
void *end;
|
||||
};
|
||||
|
||||
struct Profile{
|
||||
u8 *buffer;
|
||||
u32 pos, max;
|
||||
|
||||
Profile_Group *stack[64];
|
||||
u32 stack_top;
|
||||
};
|
||||
global Profile global_profile = {0};
|
||||
|
||||
internal Profile_Group*
|
||||
push_group(char *name){
|
||||
Profile_Group *result = 0;
|
||||
if (global_profile.pos + sizeof(Profile_Group) <= global_profile.max){
|
||||
result = (Profile_Group*)(global_profile.buffer + global_profile.pos);
|
||||
global_profile.pos += sizeof(Profile_Group);
|
||||
u32 i = 0;
|
||||
for (; name[i] && i < sizeof(result->name)-1; ++i){
|
||||
result->name[i] = name[i];
|
||||
}
|
||||
result->name[i] = 0;
|
||||
result->cycle_start = __rdtsc();
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal void
|
||||
profile_init(void *mem, u32 max){
|
||||
global_profile.buffer = (u8*)mem;
|
||||
global_profile.max = max;
|
||||
}
|
||||
|
||||
internal void
|
||||
profile_begin_group(char *name){
|
||||
u32 stack_pos = global_profile.stack_top;
|
||||
if (stack_pos < ArrayCount(global_profile.stack)){
|
||||
global_profile.stack[stack_pos] = push_group(name);
|
||||
Assert(global_profile.stack[stack_pos] != 0);
|
||||
++global_profile.stack_top;
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
profile_end_group(){
|
||||
Assert(global_profile.stack_top > 0);
|
||||
u32 stack_pos = --global_profile.stack_top;
|
||||
if (stack_pos < ArrayCount(global_profile.stack)){
|
||||
Profile_Group *group = global_profile.stack[stack_pos];
|
||||
Assert(group != 0);
|
||||
group->cycle_count = __rdtsc() - group->cycle_start;
|
||||
group->end = global_profile.buffer + global_profile.pos;
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
profile_begin_frame(){
|
||||
global_profile.pos = 0;
|
||||
global_profile.stack_top = 0;
|
||||
profile_begin_group("*frame*");
|
||||
}
|
||||
|
||||
internal void
|
||||
profile_end_frame(char *filename){
|
||||
profile_end_group();
|
||||
Assert(global_profile.stack_top == 0);
|
||||
|
||||
FILE *file = fopen(filename, "ab");
|
||||
Assert(file != 0);
|
||||
fwrite(&global_profile.buffer, 8, 1, file);
|
||||
|
||||
Profile_Group *first_group = (Profile_Group*)global_profile.buffer;
|
||||
fwrite(&first_group->end, 8, 1, file);
|
||||
|
||||
fwrite(global_profile.buffer, 1, global_profile.pos, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
internal Profile_Group*
|
||||
profile_begin_resumable(char *name){
|
||||
Profile_Group *result = push_group(name);
|
||||
Assert(result != 0);
|
||||
result->cycle_count = 0;
|
||||
result->end = result + 1;
|
||||
return(result);
|
||||
}
|
||||
|
||||
struct profile_scope{
|
||||
profile_scope(char *name){
|
||||
profile_begin_group(name);
|
||||
}
|
||||
|
||||
~profile_scope(){
|
||||
profile_end_group();
|
||||
}
|
||||
};
|
||||
|
||||
#define PRFL_INIT(m,s) profile_init(m,s)
|
||||
|
||||
#define PRFL_BEGIN_FRAME() profile_begin_frame()
|
||||
#define PRFL_END_FRAME(n) profile_end_frame(n)
|
||||
|
||||
#define PRFL_BEGIN_GROUP(n) profile_begin_group(#n)
|
||||
#define PRFL_END_GROUP() profile_end_group()
|
||||
#define PRFL_SCOPE_GROUP(n) profile_scope SCOPE_##n(#n)
|
||||
|
||||
#define PRFL_FUNC_GROUP() profile_scope SCOPE_FUNC(__FUNCTION__)
|
||||
|
||||
#define PRFL_BEGIN_RESUMABLE(n) Profile_Group *PRFLGRP_##n = profile_begin_resumable(#n)
|
||||
#define PRFL_START_RESUMABLE(n) PRFLGRP_##n->cycle_start = __rdtsc()
|
||||
#define PRFL_STOP_RESUMABLE(n) PRFLGRP_##n->cycle_count += __rdtsc() - PRFLGRP_##n->cycle_start
|
||||
#define PRFL_END_RESUMABLE(n)
|
||||
|
||||
#else
|
||||
|
||||
#define PRFL_INIT(m,s)
|
||||
|
||||
#define PRFL_BEGIN_FRAME()
|
||||
#define PRFL_END_FRAME(n)
|
||||
|
||||
#define PRFL_BEGIN_GROUP(n)
|
||||
#define PRFL_END_GROUP()
|
||||
#define PRFL_SCOPE_GROUP(n)
|
||||
|
||||
#define PRFL_FUNC_GROUP()
|
||||
|
||||
#define PRFL_BEGIN_RESUMABLE(n)
|
||||
#define PRFL_START_RESUMABLE(n)
|
||||
#define PRFL_STOP_RESUMABLE(n)
|
||||
#define PRFL_END_RESUMABLE(n)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
|
@ -3105,7 +3105,7 @@ main(int argc, char **argv)
|
|||
// Font System Init
|
||||
//
|
||||
|
||||
system_font_init(&linuxvars.system.font, 0, 0, 16, true);
|
||||
system_font_init(&linuxvars.system.font, 0, 0, linuxvars.settings.font_size, linuxvars.settings.use_hinting);
|
||||
|
||||
//
|
||||
// Epoll init
|
||||
|
|
|
@ -71,7 +71,7 @@ Sys_Font_Get_Render_Data_By_ID_Sig(system_font_get_render_data_by_id){
|
|||
|
||||
internal
|
||||
Sys_Font_Load_Page_Sig(system_font_load_page){
|
||||
system_set_page(&linuxvars.system, &linux_fonts.part, font, page, page_number, 16, true);
|
||||
system_set_page(&linuxvars.system, &linux_fonts.part, font, page, page_number, linuxvars.settings.font_size, linuxvars.settings.use_hinting);
|
||||
}
|
||||
|
||||
internal
|
||||
|
@ -112,7 +112,7 @@ Sys_Font_Init_Sig(system_font_init){
|
|||
u32 dir_max = KB(32);
|
||||
u8 *directory = push_array(scratch, u8, dir_max);
|
||||
String dir_str = make_string_cap(directory, 0, dir_max);
|
||||
i32 dir_len = system_get_binary_path(&dir_str);
|
||||
u32 dir_len = system_get_binary_path(&dir_str);
|
||||
Assert(dir_len < dir_max);
|
||||
|
||||
{
|
||||
|
|
|
@ -629,7 +629,6 @@ package(char *cdir){
|
|||
copy_file(build_dir, "4ed" EXE, dir, 0, 0);
|
||||
copy_file(build_dir, "4ed_app" DLL, dir, 0, 0);
|
||||
copy_all (pack_data_dir, "*", dir);
|
||||
//copy_file(0, "TODO.txt", dir, 0, 0);
|
||||
copy_file(data_dir, "release-config.4coder", dir, 0, "config.4coder");
|
||||
|
||||
get_4coder_dist_name(&str, true, zip_dir, tier, arch, "zip");
|
||||
|
|
|
@ -114,7 +114,7 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c){
|
|||
default:
|
||||
switch (fsm.state){
|
||||
case LS_default:
|
||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$'){
|
||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$' || c >= 128){
|
||||
fsm.state = LS_identifier;
|
||||
}
|
||||
else if (c >= '1' && c <= '9'){
|
||||
|
@ -192,40 +192,41 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c){
|
|||
break;
|
||||
|
||||
case LS_identifier:
|
||||
if (!((c >= '0' && c <= '9') ||
|
||||
(c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
|
||||
c == '_' || c == '$')){
|
||||
fsm.emit_token = 1;
|
||||
{
|
||||
int is_ident = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$' || c >= 128;
|
||||
if (!is_ident){
|
||||
fsm.emit_token = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LS_pound:
|
||||
switch (c){
|
||||
case '#': fsm.emit_token = 1; break;
|
||||
default: fsm.emit_token = 1; break;
|
||||
}
|
||||
break;
|
||||
{
|
||||
fsm.emit_token = 1;
|
||||
}break;
|
||||
|
||||
case LS_pp:
|
||||
if (c == ' ' || c == '\r' || c == '\v' || c == '\f'){
|
||||
// NOTE(allen): do nothing
|
||||
}
|
||||
else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')){
|
||||
fsm.state = LS_ppdef;
|
||||
}
|
||||
else{
|
||||
fsm.emit_token = 1;
|
||||
}
|
||||
break;
|
||||
{
|
||||
if (c == ' ' || c == '\r' || c == '\v' || c == '\f'){
|
||||
// NOTE(allen): do nothing
|
||||
}
|
||||
else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c >= 128){
|
||||
fsm.state = LS_ppdef;
|
||||
}
|
||||
else{
|
||||
fsm.emit_token = 1;
|
||||
}
|
||||
}break;
|
||||
|
||||
case LS_ppdef:
|
||||
if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))){
|
||||
fsm.emit_token = 1;
|
||||
}
|
||||
break;
|
||||
{
|
||||
int is_ident = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c >= 128;
|
||||
if (!is_ident){
|
||||
fsm.emit_token = 1;
|
||||
}
|
||||
}break;
|
||||
|
||||
case LS_char:
|
||||
case LS_char_multiline:
|
||||
case LS_char: case LS_char_multiline:
|
||||
switch(c){
|
||||
case '\n': case '\'': fsm.emit_token = 1; break;
|
||||
case '\\': fsm.state = LS_char_slashed; break;
|
||||
|
@ -317,22 +318,26 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c){
|
|||
break;
|
||||
|
||||
case LS_hex:
|
||||
if (!(c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F')){
|
||||
fsm.emit_token = 1;
|
||||
}
|
||||
break;
|
||||
{
|
||||
int is_hex = c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F' || c >= 128;
|
||||
if (!is_hex){
|
||||
fsm.emit_token = 1;
|
||||
}
|
||||
}break;
|
||||
|
||||
case LS_dot:
|
||||
if (c >= '0' && c <= '9'){
|
||||
fsm.state = LS_float;
|
||||
}
|
||||
else
|
||||
switch (c){
|
||||
case '.': fsm.state = LS_ellipsis; break;
|
||||
case '*': fsm.emit_token = 1; break;
|
||||
default: fsm.emit_token = 1; break;
|
||||
}
|
||||
break;
|
||||
{
|
||||
if (c >= '0' && c <= '9'){
|
||||
fsm.state = LS_float;
|
||||
}
|
||||
else{
|
||||
switch (c){
|
||||
case '.': fsm.state = LS_ellipsis; break;
|
||||
case '*': fsm.emit_token = 1; break;
|
||||
default: fsm.emit_token = 1; break;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
case LS_ellipsis: fsm.emit_token = 1; break;
|
||||
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
Build target for the 'pens' project.
|
||||
By Allen Webster
|
||||
Created 09.01.2017 (dd.mm.yyyy)
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
struct Arena{
|
||||
|
||||
};
|
||||
|
||||
// BOTTOM
|
||||
|
|
@ -6,6 +6,7 @@ fkey_command_win[2] = {"site\\build.bat", "*compilation*", true , true };
|
|||
fkey_command_win[3] = {"string\\build.bat", "*compilation*", true , true };
|
||||
fkey_command_win[4] = {"echo build: x86 & build.bat /DDEV_BUILD_X86", "*compilation*", true , true };
|
||||
fkey_command_win[5] = {"..\\misc\\run.bat", "*run*", false, false };
|
||||
fkey_command_win[6] = {"run_profile.bat", "*profile*", false, true };
|
||||
fkey_command_win[12] = {"package.bat", "*package*", false, true };
|
||||
|
||||
fkey_command_linux[1] = {"echo build: x64 & ./build.sh", "*compilation*", true , true };
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
@echo off
|
||||
|
||||
SET OPTS=/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /wd4390 /WX
|
||||
SET OPTS=%OPTS% /GR- /EHa- /nologo /FC
|
||||
|
||||
pushd ..\build
|
||||
cl %OPTS% ..\code\4ed_profile.cpp /Zi /Feprofile
|
||||
popd
|
||||
|
||||
pushd ..\data\test
|
||||
..\..\build\profile profile.data 0.4
|
||||
popd
|
|
@ -1,5 +1,5 @@
|
|||
1
|
||||
0
|
||||
69
|
||||
73
|
||||
|
||||
|
||||
|
|
Binary file not shown.
|
@ -63,12 +63,24 @@ char_is_upper(char c)
|
|||
return (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_upper_utf8(char c)
|
||||
/* DOC(If c is an uppercase letter this call returns true.) */{
|
||||
return (c >= 'A' && c <= 'Z' || c >= 128);
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_lower(char c)
|
||||
/* DOC(If c is a lower letter this call returns true.) */{
|
||||
return (c >= 'a' && c <= 'z');
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_lower_utf8(u8_4tech c)
|
||||
/* DOC(If c is a lower letter this call returns true.) */{
|
||||
return (c >= 'a' && c <= 'z' || c >= 128);
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE char
|
||||
char_to_upper(char c)
|
||||
/* DOC(If c is a lowercase letter this call returns the uppercase equivalent, otherwise it returns c.) */{
|
||||
|
@ -93,36 +105,72 @@ char_is_alpha_numeric(char c)
|
|||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_');
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_numeric_utf8(u8_4tech c)
|
||||
/* DOC(This call returns non-zero if c is any alphanumeric character including underscore, or is a part of a UTF8 sequence outside of ASCII.) */{
|
||||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || c >= 128);
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_numeric_true(char c)
|
||||
/* DOC(This call returns non-zero if c is any alphanumeric character no including underscore.) */{
|
||||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_numeric_true_utf8(u8_4tech c)
|
||||
/* DOC(This call returns non-zero if c is any alphanumeric character no including underscore.) */{
|
||||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c >= 128);
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_alpha(char c)
|
||||
/* DOC(This call returns non-zero if c is any alphabetic character including underscore.) */{
|
||||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_');
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_utf8(u8_4tech c)
|
||||
/* DOC(This call returns non-zero if c is any alphabetic character including underscore, or is a part of a UTF8 sequence outside of ASCII.) */{
|
||||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c >= 128);
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_true(char c)
|
||||
/* DOC(This call returns non-zero if c is any alphabetic character.) */{
|
||||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_alpha_true_utf8(u8_4tech c)
|
||||
/* DOC(This call returns non-zero if c is any alphabetic character, or is a part of a UTF8 sequence outside of ASCII.) */{
|
||||
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= 128);
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_hex(char c)
|
||||
/* DOC(This call returns non-zero if c is any valid hexadecimal digit.) */{
|
||||
return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f');
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_hex_utf8(u8_4tech c)
|
||||
/* DOC(This call returns non-zero if c is any valid hexadecimal digit, or is a part of a UTF8 sequence outside of ASCII.) */{
|
||||
return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f' || c >= 128);
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_numeric(char c)
|
||||
/* DOC(This call returns non-zero if c is any valid decimal digit.) */{
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
API_EXPORT_INLINE FSTRING_INLINE b32_4tech
|
||||
char_is_numeric_utf8(u8_4tech c)
|
||||
/* DOC(This call returns non-zero if c is any valid decimal digit, or is a part of a UTF8 sequence outside of ASCII.) */{
|
||||
return (c >= '0' && c <= '9' || c >= 128);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// String Making Functions
|
||||
|
|
|
@ -1100,9 +1100,8 @@ Win32ToggleFullscreen(void){
|
|||
HWND Window = win32vars.window_handle;
|
||||
LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE);
|
||||
if (Style & WS_OVERLAPPEDWINDOW){
|
||||
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
|
||||
if(GetWindowPlacement(Window, &win32vars.GlobalWindowPosition) &&
|
||||
GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
|
||||
MONITORINFO MonitorInfo = {sizeof(MONITORINFO)};
|
||||
if(GetWindowPlacement(Window, &win32vars.GlobalWindowPosition) && GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
|
||||
{
|
||||
SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPos(Window, HWND_TOP,
|
||||
|
@ -1110,16 +1109,14 @@ Win32ToggleFullscreen(void){
|
|||
MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
|
||||
MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
|
||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
win32vars.full_screen = 1;
|
||||
win32vars.full_screen = true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPlacement(Window, &win32vars.GlobalWindowPosition);
|
||||
SetWindowPos(Window, 0, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
win32vars.full_screen = 0;
|
||||
SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
win32vars.full_screen = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1892,6 +1889,24 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
|
|||
Win32Resize(new_width, new_height);
|
||||
}break;
|
||||
|
||||
case WM_DISPLAYCHANGE:
|
||||
{
|
||||
win32vars.got_useful_event = 1;
|
||||
|
||||
LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||
if (!(style & WS_OVERLAPPEDWINDOW)){
|
||||
MONITORINFO monitor_info = {sizeof(MONITORINFO)};
|
||||
if(GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), &monitor_info))
|
||||
{
|
||||
SetWindowPos(hwnd, HWND_TOP,
|
||||
monitor_info.rcMonitor.left, monitor_info.rcMonitor.top,
|
||||
monitor_info.rcMonitor.right - monitor_info.rcMonitor.left,
|
||||
monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top,
|
||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
win32vars.got_useful_event = 1;
|
||||
|
@ -2017,9 +2032,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
|||
memory_vars.target_memory_size = MB(512);
|
||||
memory_vars.target_memory = VirtualAlloc(base, memory_vars.target_memory_size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
|
||||
base = (LPVOID)0;
|
||||
memory_vars.user_memory_size = MB(2);
|
||||
memory_vars.user_memory = VirtualAlloc(base, memory_vars.target_memory_size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
memory_vars.user_memory = system_memory_allocate(memory_vars.user_memory_size);
|
||||
|
||||
memory_vars.debug_memory_size = MB(512);
|
||||
memory_vars.debug_memory = system_memory_allocate(memory_vars.debug_memory_size);
|
||||
|
||||
win32vars.target.max = MB(1);
|
||||
win32vars.target.push_buffer = (char*)system_memory_allocate(win32vars.target.max);
|
||||
|
@ -2182,7 +2199,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
|||
// Font System Init
|
||||
//
|
||||
|
||||
system_font_init(&win32vars.system.font, 0, 0, 16, true);
|
||||
system_font_init(&win32vars.system.font, 0, 0, win32vars.settings.font_size, win32vars.settings.use_hinting);
|
||||
|
||||
//
|
||||
// Misc System Initializations
|
||||
|
|
|
@ -71,7 +71,7 @@ Sys_Font_Get_Render_Data_By_ID_Sig(system_font_get_render_data_by_id){
|
|||
|
||||
internal
|
||||
Sys_Font_Load_Page_Sig(system_font_load_page){
|
||||
system_set_page(&win32vars.system, &win32_fonts.part, font, page, page_number, 16, true);
|
||||
system_set_page(&win32vars.system, &win32_fonts.part, font, page, page_number, win32vars.settings.font_size, win32vars.settings.use_hinting);
|
||||
}
|
||||
|
||||
internal
|
||||
|
@ -112,7 +112,7 @@ Sys_Font_Init_Sig(system_font_init){
|
|||
u32 dir_max = KB(32);
|
||||
u8 *directory = push_array(scratch, u8, dir_max);
|
||||
String dir_str = make_string_cap(directory, 0, dir_max);
|
||||
i32 dir_len = system_get_binary_path(&dir_str);
|
||||
u32 dir_len = system_get_binary_path(&dir_str);
|
||||
Assert(dir_len < dir_max);
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue