file bar hiding, open file that creates new buffer, seek up directories for project.4coder, load project at launch option, WM_DISPLAYCHANGE, alphanumeric word boundaries work with utf8 encoded characters.

This commit is contained in:
Allen Webster 2017-03-27 18:36:42 -04:00
parent bca15da440
commit 49798a25fe
21 changed files with 622 additions and 452 deletions

View File

@ -63,6 +63,8 @@ ENUM(uint64_t, Command_ID){
cmdid_interactive_new, cmdid_interactive_new,
/* DOC(cmdid_interactive_open begins an interactive dialogue to open a file into a buffer.) */ /* DOC(cmdid_interactive_open begins an interactive dialogue to open a file into a buffer.) */
cmdid_interactive_open, 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.) */ /* DOC(cmdid_save_as does not currently work and is likely to be removed rather that fixed.) */
cmdid_save_as, cmdid_save_as,
/* DOC(cmdid_interactive_switch_buffer begins an interactive dialogue to choose an open buffer to swap into the active view.) */ /* 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.) */ /* DOC(ViewSetting_Null is not a valid setting, it is reserved to detect errors.) */
ViewSetting_Null, ViewSetting_Null,
/* DOC(The ViewSetting_ShowWhitespace setting determines whether the view highlights /* 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.) */
whitespace in a file. Whenever the view switches to a new buffer this setting is turned off.) */
ViewSetting_ShowWhitespace, ViewSetting_ShowWhitespace,
/* DOC(The ViewSetting_ShowScrollbar setting determines whether a scroll bar is /* DOC(The ViewSetting_ShowScrollbar setting determines whether a scroll bar is attached to a view in it's scrollable section.) */
attached to a view in it's scrollable section.) */
ViewSetting_ShowScrollbar, 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.) */ /* 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.) */ /* 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){ ENUM(uint32_t, Access_Flag){
/* DOC(AccessOpen does not include any bits, it indicates that the access should /* DOC(AccessOpen does not include any bits, it indicates that the access should only return objects that have no protection flags set.) */
only return objects that have no protection flags set.) */
AccessOpen = 0x0, AccessOpen = 0x0,
/* DOC(AccessProtected is set on buffers and views that are "read only" such as /* 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.) */
the output from an app->exec_system_command call into *build*. This is to prevent
the user from accidentally editing output that they might prefer to keep in tact.) */
AccessProtected = 0x1, AccessProtected = 0x1,
/* DOC(AccessHidden is set on any view that is not currently showing it's file, for /* 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.) */
instance because it is navigating the file system to open a file.) */
AccessHidden = 0x2, AccessHidden = 0x2,
/* DOC(AccessAll is a catchall access for cases where an access call should always /* 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.) */
return an object no matter what it's protection flags are.) */
AccessAll = 0xFF AccessAll = 0xFF
}; };

View File

@ -473,15 +473,25 @@ CUSTOM_COMMAND_SIG(open_panel_hsplit){
// //
CUSTOM_COMMAND_SIG(show_scrollbar){ 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); view_set_setting(app, &view, ViewSetting_ShowScrollbar, true);
} }
CUSTOM_COMMAND_SIG(hide_scrollbar){ 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); 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 //toggle_fullscreen can be used as a command
CUSTOM_COMMAND_SIG(toggle_line_wrap){ CUSTOM_COMMAND_SIG(toggle_line_wrap){
@ -835,6 +845,10 @@ CUSTOM_COMMAND_SIG(interactive_open){
exec_command(app, cmdid_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){ CUSTOM_COMMAND_SIG(save_as){
exec_command(app, cmdid_save_as); exec_command(app, cmdid_save_as);
} }

View File

@ -22,7 +22,7 @@ default_keys(Bind_Helper *context){
bind(context, '<', MDFR_CTRL, change_active_panel_backwards); bind(context, '<', MDFR_CTRL, change_active_panel_backwards);
bind(context, 'n', MDFR_CTRL, interactive_new); 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, 'o', MDFR_ALT, open_in_other);
bind(context, 'k', MDFR_CTRL, interactive_kill_buffer); bind(context, 'k', MDFR_CTRL, interactive_kill_buffer);
bind(context, 'i', MDFR_CTRL, interactive_switch_buffer); bind(context, 'i', MDFR_CTRL, interactive_switch_buffer);

View File

@ -621,6 +621,8 @@ static String user_name = make_fixed_width_string(user_name_space);
static Extension_List treat_as_code_exts = {0}; static Extension_List treat_as_code_exts = {0};
static bool32 automatically_load_project = false;
static bool32 static bool32
get_current_name(char **name_out, int32_t *len_out){ get_current_name(char **name_out, int32_t *len_out){
bool32 result = false; bool32 result = false;
@ -748,6 +750,8 @@ process_config_file(Application_Links *app){
set_extensions(&treat_as_code_exts, str); 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); adjust_all_buffer_wrap_widths(app, new_wrap_width, new_min_base_width);
@ -780,8 +784,11 @@ init_memory(Application_Links *app){
general_memory_open(&global_general, general_mem, general_size); general_memory_open(&global_general, general_mem, general_size);
} }
static bool32 default_use_scrollbars = false;
static bool32 default_use_file_bars = true;
static void static void
default_4coder_initialize(Application_Links *app){ default_4coder_initialize(Application_Links *app, bool32 use_scrollbars, bool32 use_file_bars){
init_memory(app); init_memory(app);
process_config_file(app); process_config_file(app);
@ -790,28 +797,48 @@ default_4coder_initialize(Application_Links *app){
change_theme(app, theme.str, theme.size); change_theme(app, theme.str, theme.size);
change_font(app, font.str, font.size, 1); 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 static void
default_4coder_side_by_side_panels(Application_Links *app){ default_4coder_side_by_side_panels(Application_Links *app){
exec_command(app, open_panel_vsplit); open_panel_vsplit(app);
exec_command(app, hide_scrollbar); if (!default_use_scrollbars){
exec_command(app, change_active_panel); hide_scrollbar(app);
exec_command(app, hide_scrollbar); }
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 static void
default_4coder_one_panel(Application_Links *app){ 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 static void
default_4coder_full_width_bottom_side_by_side_panels(Application_Links *app){ default_4coder_full_width_bottom_side_by_side_panels(Application_Links *app){
open_special_note_view(app); open_special_note_view(app);
exec_command(app, open_panel_vsplit); default_4coder_side_by_side_panels(app);
exec_command(app, hide_scrollbar);
exec_command(app, change_active_panel);
exec_command(app, hide_scrollbar);
} }
#endif #endif

View File

@ -11,11 +11,16 @@ TYPE: 'internal-for-default-system'
#include "4coder_default_framework.h" #include "4coder_default_framework.h"
#include "4coder_helper/4coder_bind_helper.h" #include "4coder_helper/4coder_bind_helper.h"
#include "4coder_project_commands.cpp"
HOOK_SIG(default_start){ HOOK_SIG(default_start){
default_4coder_initialize(app); default_4coder_initialize(app);
default_4coder_side_by_side_panels(app); default_4coder_side_by_side_panels(app);
if (automatically_load_project){
load_project(app);
}
// no meaning for return // no meaning for return
return(0); return(0);
} }

View File

@ -317,7 +317,7 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i
bool32 still_looping = 1; bool32 still_looping = 1;
do{ do{
for (; pos < stream.end; ++pos){ 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; goto double_break1;
} }
} }
@ -328,7 +328,7 @@ buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, i
still_looping = 1; still_looping = 1;
do{ do{
for (; pos < stream.end; ++pos){ 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; goto double_break2;
} }
} }
@ -347,13 +347,12 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in
--pos; --pos;
if (pos > 0){ if (pos > 0){
if (init_stream_chunk(&stream, app, buffer, if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){
pos, data_chunk, sizeof(data_chunk))){
bool32 still_looping = 1; bool32 still_looping = 1;
do{ do{
for (; pos >= stream.start; --pos){ 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; goto double_break1;
} }
} }
@ -364,7 +363,7 @@ buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, in
still_looping = 1; still_looping = 1;
do{ do{
for (; pos >= stream.start; --pos){ 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; ++pos;
goto double_break2; goto double_break2;
} }
@ -389,20 +388,18 @@ buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, in
++pos; ++pos;
if (pos < an_pos){ if (pos < an_pos){
stream.max_end = an_pos; stream.max_end = an_pos;
if (init_stream_chunk(&stream, app, buffer, if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){
pos, data_chunk, sizeof(data_chunk))){
char c = 0, pc = stream.data[pos]; uint8_t c = 0;
++pos; ++pos;
bool32 still_looping = 1; bool32 still_looping = 1;
do{ do{
for (; pos < stream.end; ++pos){ for (; pos < stream.end; ++pos){
c = stream.data[pos]; c = stream.data[pos];
if (char_is_upper(c) && char_is_lower(pc)){ if (char_is_upper(c)){
goto double_break1; goto double_break1;
} }
pc = c;
} }
still_looping = forward_stream_chunk(&stream); still_looping = forward_stream_chunk(&stream);
}while(still_looping); }while(still_looping);
@ -426,16 +423,15 @@ buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int
stream.min_start = an_pos+1; stream.min_start = an_pos+1;
if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){ if (init_stream_chunk(&stream, app, buffer, pos, data_chunk, sizeof(data_chunk))){
char c = 0, pc = stream.data[pos]; char c = 0;
bool32 still_looping = 1; bool32 still_looping = 1;
do{ do{
for (; pos >= stream.start; --pos){ for (; pos >= stream.start; --pos){
c = stream.data[pos]; c = stream.data[pos];
if (char_is_upper(c) && char_is_lower(pc)){ if (char_is_upper(c)){
goto double_break1; goto double_break1;
} }
pc = c;
} }
still_looping = backward_stream_chunk(&stream); still_looping = backward_stream_chunk(&stream);
}while(still_looping); }while(still_looping);

View File

@ -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 no warranty implied; use at your own risk
This software is in the public domain. Where that dedication is not 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_slash(char c);
FSTRING_INLINE b32_4tech char_is_upper(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(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_upper(char c);
FSTRING_INLINE char char_to_lower(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_whitespace(char c);
FSTRING_INLINE b32_4tech char_is_alpha_numeric(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(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(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(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(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(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_cap(void *str, i32_4tech size, i32_4tech mem_size);
FSTRING_INLINE String make_string(void *str, i32_4tech size); FSTRING_INLINE String make_string(void *str, i32_4tech size);
#ifndef make_lit_string #ifndef make_lit_string
@ -300,6 +308,14 @@ char_is_upper(char c)
} }
#endif #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) #if !defined(FSTRING_GUARD)
FSTRING_INLINE b32_4tech FSTRING_INLINE b32_4tech
char_is_lower(char c) char_is_lower(char c)
@ -308,6 +324,14 @@ char_is_lower(char c)
} }
#endif #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) #if !defined(FSTRING_GUARD)
FSTRING_INLINE char FSTRING_INLINE char
char_to_upper(char c) char_to_upper(char c)
@ -340,6 +364,14 @@ char_is_alpha_numeric(char c)
} }
#endif #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) #if !defined(FSTRING_GUARD)
FSTRING_INLINE b32_4tech FSTRING_INLINE b32_4tech
char_is_alpha_numeric_true(char c) char_is_alpha_numeric_true(char c)
@ -348,6 +380,14 @@ char_is_alpha_numeric_true(char c)
} }
#endif #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) #if !defined(FSTRING_GUARD)
FSTRING_INLINE b32_4tech FSTRING_INLINE b32_4tech
char_is_alpha(char c) char_is_alpha(char c)
@ -356,6 +396,14 @@ char_is_alpha(char c)
} }
#endif #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) #if !defined(FSTRING_GUARD)
FSTRING_INLINE b32_4tech FSTRING_INLINE b32_4tech
char_is_alpha_true(char c) char_is_alpha_true(char c)
@ -364,6 +412,14 @@ char_is_alpha_true(char c)
} }
#endif #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) #if !defined(FSTRING_GUARD)
FSTRING_INLINE b32_4tech FSTRING_INLINE b32_4tech
char_is_hex(char c) char_is_hex(char c)
@ -372,6 +428,14 @@ char_is_hex(char c)
} }
#endif #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) #if !defined(FSTRING_GUARD)
FSTRING_INLINE b32_4tech FSTRING_INLINE b32_4tech
char_is_numeric(char c) char_is_numeric(char c)
@ -380,6 +444,14 @@ char_is_numeric(char c)
} }
#endif #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 // String Making Functions

View File

@ -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. // 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){ CUSTOM_COMMAND_SIG(open_all_code){
int32_t extension_count = 0; int32_t extension_count = 0;
char **extension_list = get_current_project_extensions(&extension_count); char **extension_list = get_current_project_extensions(&extension_count);
open_all_files_with_extension(app, &global_part, extension_list, extension_count, false); 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){ CUSTOM_COMMAND_SIG(open_all_code_recursive){
int32_t extension_count = 0; int32_t extension_count = 0;
char **extension_list = get_current_project_extensions(&extension_count); char **extension_list = get_current_project_extensions(&extension_count);
@ -172,34 +186,14 @@ CUSTOM_COMMAND_SIG(close_all_code){
close_all_files_with_extension(app, &global_part, extension_list, extension_count); close_all_files_with_extension(app, &global_part, extension_list, extension_count);
} }
CUSTOM_COMMAND_SIG(load_project){ static void
Partition *part = &global_part; load_project_from_file(Application_Links *app, Partition *part, FILE *file, String project_dir){
char project_file_space[512];
String project_name = make_fixed_width_string(project_file_space);
project_name.size = directory_get_hot(app, project_name.str, project_name.memory_size);
if (project_name.size >= project_name.memory_size){
project_name.size = 0;
}
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;
terminate_with_null(&project_name);
Temp_Memory temp = begin_temp_memory(part); Temp_Memory temp = begin_temp_memory(part);
char *mem = 0; char *mem = 0;
int32_t size = 0; int32_t size = 0;
bool32 file_read_success = file_handle_dump(part, file, &mem, &size); bool32 file_read_success = file_handle_dump(part, file, &mem, &size);
if (file_read_success){ if (file_read_success){
fclose(file);
Cpp_Token_Array array; Cpp_Token_Array array;
array.count = 0; array.count = 0;
array.max_count = (1 << 20)/sizeof(Cpp_Token); array.max_count = (1 << 20)/sizeof(Cpp_Token);
@ -219,7 +213,7 @@ CUSTOM_COMMAND_SIG(load_project){
{ {
current_project.dir = current_project.dir_space; current_project.dir = current_project.dir_space;
String str = make_fixed_width_string(current_project.dir_space); String str = make_fixed_width_string(current_project.dir_space);
copy(&str, project_name); copy(&str, project_dir);
terminate_with_null(&str); terminate_with_null(&str);
current_project.dir_len = str.size; current_project.dir_len = str.size;
} }
@ -370,17 +364,55 @@ CUSTOM_COMMAND_SIG(load_project){
// Open all project files // Open all project files
if (current_project.open_recursively){ if (current_project.open_recursively){
exec_command(app, open_all_code_recursive); open_all_code_recursive(app, project_dir);
} }
else{ else{
exec_command(app, open_all_code); open_all_code(app, project_dir);
} }
} }
} }
end_temp_memory(temp); end_temp_memory(temp);
} }
CUSTOM_COMMAND_SIG(load_project){
Partition *part = &global_part;
char project_file_space[512];
String project_name = make_fixed_width_string(project_file_space);
project_name.size = directory_get_hot(app, project_name.str, project_name.memory_size);
if (project_name.size >= project_name.memory_size){
project_name.size = 0;
}
if (project_name.size != 0){
bool32 load_failed = false;
for(;;){
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;
terminate_with_null(&project_name);
load_project_from_file(app, part, file, project_name);
fclose(file);
break;
}
else{ else{
project_name.size = original_size;
remove_last_folder(&project_name);
if (project_name.size >= original_size){
load_failed = true;
break;
}
}
}
if (load_failed){
char message_space[512]; char message_space[512];
String message = make_fixed_width_string(message_space); String message = make_fixed_width_string(message_space);
append_sc(&message, "Did not find project.4coder. "); append_sc(&message, "Did not find project.4coder. ");
@ -391,6 +423,7 @@ CUSTOM_COMMAND_SIG(load_project){
else{ else{
append_sc(&message, "Continuing without a project"); append_sc(&message, "Continuing without a project");
} }
append_s_char(&message, '\n');
print_message(app, message.str, message.size); 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){ CUSTOM_COMMAND_SIG(project_fkey_command){
User_Input input = get_command_input(app); User_Input input = get_command_input(app);
if (input.type == UserInputKey){ if (input.type == UserInputKey){
bool32 got_ind = false;
int32_t ind = 0;
if (input.key.keycode >= key_f1 && input.key.keycode <= key_f16){ 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); exec_project_fkey_command(app, ind);
} }
} }

View File

@ -148,8 +148,7 @@ search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *
if (new_size < space->max + len){ if (new_size < space->max + len){
new_size = space->max + len; new_size = space->max + len;
} }
space->space = (char*)general_memory_reallocate( space->space = (char*)general_memory_reallocate(general, space->space, space->new_pos, new_size);
general, space->space, space->new_pos, new_size);
ostring = strspace_append(space, str, len); 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; int32_t still_looping = true;
do{ do{
for (; pos < chunk.end; ++pos){ for (; pos < chunk.end; ++pos){
char at_pos = chunk.data[pos]; uint8_t at_pos = (uint8_t)chunk.data[pos];
if (!char_is_alpha_numeric(at_pos)) goto double_break; if (!char_is_alpha_numeric_utf8(at_pos)) goto double_break;
} }
still_looping = forward_stream_chunk(&chunk); still_looping = forward_stream_chunk(&chunk);
}while(still_looping); }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 first = word.str[0];
char prev = ' '; 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); 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; result.end = result.start + word.size;
if (result.end <= end_pos){ if (result.end <= end_pos){
char last = word.str[word.size-1]; char last = word.str[word.size-1];
char next = ' '; char next = ' ';
if (char_is_alpha_numeric(last)){ if (char_is_alpha_numeric_utf8(last)){
next = buffer_get_char(app, &result.buffer, result.end); 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; result.found_match = true;
found_match = FindResult_FoundMatch; found_match = FindResult_FoundMatch;
} }
@ -250,7 +249,7 @@ match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Ma
case SearchFlag_MatchWordPrefix: case SearchFlag_MatchWordPrefix:
{ {
char prev = buffer_get_char(app, &result.buffer, result.start - 1); 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 = result.end =
buffer_seek_alpha_numeric_end( buffer_seek_alpha_numeric_end(
app, &result.buffer, result.start); app, &result.buffer, result.start);
@ -770,7 +769,7 @@ CUSTOM_COMMAND_SIG(word_complete){
do{ do{
for (; cursor_pos >= chunk.start; --cursor_pos){ for (; cursor_pos >= chunk.start; --cursor_pos){
char c = chunk.data[cursor_pos]; char c = chunk.data[cursor_pos];
if (char_is_alpha(c)){ if (char_is_alpha_utf8(c)){
word_start = cursor_pos; word_start = cursor_pos;
} }
else if (!char_is_numeric(c)){ else if (!char_is_numeric(c)){

View File

@ -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; S.white_done = 0;
for(;;){ for(;;){
for (; S.pp_state < LSPP_count && S.pos < end_pos;){ 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]; i32_4tech i = S.pp_state + whitespace_fsm_eq_classes[c];
S.pp_state = whitespace_fsm_table[i]; S.pp_state = whitespace_fsm_table[i];
} }

View File

@ -28,7 +28,7 @@ uint8_t multiline_state_table[] = {
}; };
uint16_t main_fsm_eq_classes[] = { 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; 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[] = { 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; 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[] = { 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; 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[] = { 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; 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[] = { 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; 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[] = { 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; 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[] = { 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; 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[] = { 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; const int32_t num_pp_junk_fsm_eq_classes = 31;

View File

@ -306,16 +306,19 @@ COMMAND_DECL(redo){
COMMAND_DECL(interactive_new){ COMMAND_DECL(interactive_new){
USE_VIEW(view); USE_VIEW(view);
view_show_interactive(system, view, IAct_New, IInt_Sys_File_List, make_lit_string("New: ")); view_show_interactive(system, view, IAct_New, IInt_Sys_File_List, make_lit_string("New: "));
} }
COMMAND_DECL(interactive_open){ COMMAND_DECL(interactive_open){
USE_VIEW(view); USE_VIEW(view);
view_show_interactive(system, view, IAct_Open, IInt_Sys_File_List,make_lit_string("Open: ")); 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 // TODO(allen): Improvements to reopen
// - Perform a diff // - Perform a diff
// - If the diff is not tremendously big, apply the edits. // - If the diff is not tremendously big, apply the edits.
@ -608,6 +611,7 @@ setup_command_table(){
SET(interactive_new); SET(interactive_new);
SET(interactive_open); SET(interactive_open);
SET(interactive_open_or_new);
SET(interactive_switch_buffer); SET(interactive_switch_buffer);
SET(interactive_kill_buffer); SET(interactive_kill_buffer);
SET(save_as); SET(save_as);

View File

@ -1629,6 +1629,7 @@ DOC_RETURN(returns non-zero on success)
switch (setting){ switch (setting){
case ViewSetting_ShowWhitespace: *value_out = vptr->file_data.show_whitespace; break; case ViewSetting_ShowWhitespace: *value_out = vptr->file_data.show_whitespace; break;
case ViewSetting_ShowScrollbar: *value_out = !vptr->hide_scrollbar; break; case ViewSetting_ShowScrollbar: *value_out = !vptr->hide_scrollbar; break;
case ViewSetting_ShowFileBar: *value_out = !vptr->hide_file_bar; break;
default: result = 0; break; default: result = 0; break;
} }
} }
@ -1663,6 +1664,11 @@ DOC_SEE(View_Setting_ID)
vptr->hide_scrollbar = !value; vptr->hide_scrollbar = !value;
}break; }break;
case ViewSetting_ShowFileBar:
{
vptr->hide_file_bar = !value;
}break;
default: default:
{ {
result = false; result = false;

View File

@ -107,6 +107,7 @@ enum Interactive_Action{
IAct_Open, IAct_Open,
IAct_Save_As, IAct_Save_As,
IAct_New, IAct_New,
IAct_OpenOrNew,
IAct_Switch, IAct_Switch,
IAct_Kill, IAct_Kill,
IAct_Sure_To_Kill, IAct_Sure_To_Kill,
@ -212,6 +213,7 @@ struct View{
i32 list_i; i32 list_i;
b32 hide_scrollbar; b32 hide_scrollbar;
b32 hide_file_bar;
// interactive stuff // interactive stuff
Interactive_Interaction interaction; Interactive_Interaction interaction;
@ -1665,7 +1667,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
potential_wrap.adjust_top_to_this = 0; potential_wrap.adjust_top_to_this = 0;
if (buffer_stringify_loop(&stream, params.buffer, i, end_i)){ if (buffer_stringify_loop(&stream, params.buffer, i, end_i)){
b32 still_looping = 1; b32 still_looping = true;
while(still_looping){ while(still_looping){
for (; i < stream.end; ++i){ for (; i < stream.end; ++i){
@ -1677,6 +1679,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
for (TRANSLATION_DECL_EMIT_LOOP(J, emits)){ for (TRANSLATION_DECL_EMIT_LOOP(J, emits)){
TRANSLATION_DECL_GET_STEP(buffer_step, behav, J, emits); TRANSLATION_DECL_GET_STEP(buffer_step, behav, J, emits);
if (!codepoint_is_whitespace(buffer_step.value)){ if (!codepoint_is_whitespace(buffer_step.value)){
i = buffer_step.i;
goto doublebreak_stage_vspace; goto doublebreak_stage_vspace;
} }
} }
@ -3946,9 +3949,7 @@ save_file_by_name(System_Functions *system, Models *models, String name){
internal void internal void
interactive_begin_sure_to_kill(System_Functions *system, View *view, Editing_File *file){ interactive_begin_sure_to_kill(System_Functions *system, View *view, Editing_File *file){
view_show_interactive(system, view, view_show_interactive(system, view, IAct_Sure_To_Kill, IInt_Sure_To_Kill, make_lit_string("Are you sure?"));
IAct_Sure_To_Kill, IInt_Sure_To_Kill,
make_lit_string("Are you sure?"));
copy_ss(&view->dest, file->name.live_name); copy_ss(&view->dest, file->name.live_name);
} }
@ -4003,14 +4004,16 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32
switch (view->action){ switch (view->action){
case IAct_Open: case IAct_Open:
{
view_open_file(system, models, view, dest); view_open_file(system, models, view, dest);
view_show_file(view); view_show_file(view);
break; }break;
case IAct_Save_As: case IAct_Save_As:
{
view_interactive_save_as(system, models, view->file_data.file, dest); view_interactive_save_as(system, models, view->file_data.file, dest);
view_show_file(view); view_show_file(view);
break; }break;
case IAct_New: case IAct_New:
if (dest.size > 0 && !char_is_slash(dest.str[dest.size-1])){ if (dest.size > 0 && !char_is_slash(dest.str[dest.size-1])){
@ -4022,6 +4025,11 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32
} }
}break; }break;
case IAct_OpenOrNew:
{
InvalidCodePath;
}break;
case IAct_Switch: case IAct_Switch:
{ {
Editing_File *file = working_set_name_contains(&models->working_set, dest); Editing_File *file = working_set_name_contains(&models->working_set, dest);
@ -4039,123 +4047,42 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32
case IAct_Sure_To_Close: case IAct_Sure_To_Close:
switch (user_action){ switch (user_action){
case 0: case 0:
{
models->keep_playing = 0; models->keep_playing = 0;
break; }break;
case 1: case 1:
{
view_show_file(view); view_show_file(view);
break; }break;
case 2: case 2: // TODO(allen): Save all and close.
// TODO(allen): Save all and close.
break;
}
break; break;
}break;
case IAct_Sure_To_Kill: case IAct_Sure_To_Kill:
switch (user_action){ switch (user_action){
case 0: case 0:
{
kill_file_by_name(system, models, dest); kill_file_by_name(system, models, dest);
view_show_file(view); view_show_file(view);
break; }break;
case 1: case 1:
{
view_show_file(view); view_show_file(view);
break; }break;
case 2: case 2:
{
save_file_by_name(system, models, dest); save_file_by_name(system, models, dest);
kill_file_by_name(system, models, dest); kill_file_by_name(system, models, dest);
view_show_file(view); view_show_file(view);
break; }break;
} }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{ struct File_Bar{
f32 pos_x, pos_y; f32 pos_x, pos_y;
f32 text_shift_x, text_shift_y; f32 text_shift_x, text_shift_y;
@ -4207,15 +4134,14 @@ view_reinit_scrolling(View *view){
internal b32 internal b32
file_step(View *view, i32_Rect region, Input_Summary *user_input, b32 is_active, b32 *consumed_l){ 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; Editing_File *file = view->file_data.file;
if (file && !file->is_loading){ if (file && !file->is_loading){
if (file->state.paste_effect.seconds_down > 0.f){ if (file->state.paste_effect.seconds_down > 0.f){
file->state.paste_effect.seconds_down -= user_input->dt; file->state.paste_effect.seconds_down -= user_input->dt;
is_animating = 1; is_animating = true;
} }
} }
return(is_animating); return(is_animating);
} }
@ -4642,7 +4568,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
gui_begin_top_level(target, input); 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); gui_do_top_bar(target);
} }
do_widget(view, target); do_widget(view, target);
@ -4944,69 +4870,68 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
switch (view->interaction){ switch (view->interaction){
case IInt_Sys_File_List: case IInt_Sys_File_List:
{ {
b32 autocomplete_with_enter = 1; b32 autocomplete_with_enter = true;
b32 activate_directly = 0; b32 activate_directly = false;
if (view->action == IAct_Save_As || view->action == IAct_New){ if (view->action == IAct_Save_As || view->action == IAct_New){
autocomplete_with_enter = 0; autocomplete_with_enter = false;
} }
String message = null_string; String message = null_string;
switch (view->action){ switch (view->action){
case IAct_OpenOrNew:
case IAct_Open: message = make_lit_string("Open: "); break; case IAct_Open: message = make_lit_string("Open: "); break;
case IAct_Save_As: message = make_lit_string("Save As: "); break; case IAct_Save_As: message = make_lit_string("Save As: "); break;
case IAct_New: message = make_lit_string("New: "); break; case IAct_New: message = make_lit_string("New: "); break;
} }
Exhaustive_File_Loop loop;
Exhaustive_File_Info file_info;
GUI_Item_Update update = {0}; GUI_Item_Update update = {0};
Hot_Directory *hdir = &models->hot_directory; Hot_Directory *hdir = &models->hot_directory;
{ b32 do_open_or_new = false;
Single_Line_Input_Step step = {0}; for (i32 i = 0; i < keys.count; ++i){
Key_Event_Data key = {0}; Key_Event_Data key = get_single_key(&keys, i);
i32 i; Single_Line_Input_Step step = app_single_file_input_step(system, &models->working_set, key,
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); &hdir->string, hdir, 1, 0);
if (step.made_a_change){ if (step.made_a_change){
view->list_i = 0; view->list_i = 0;
result.consume_keys = 1; result.consume_keys = true;
} }
if (!autocomplete_with_enter && key.keycode == '\n'){ if (key.keycode == '\n'){
activate_directly = 1; if (!autocomplete_with_enter){
result.consume_keys = 1; activate_directly = true;
result.consume_keys = true;
}
else if (view->action == IAct_OpenOrNew){
do_open_or_new = true;
result.consume_keys = true;
} }
} }
} }
gui_do_text_field(target, message, hdir->string); gui_do_text_field(target, message, hdir->string);
b32 snap_into_view = 0; b32 snap_into_view = false;
scroll_context.id[0] = (u64)(hdir); scroll_context.id[0] = (u64)(hdir);
if (gui_scroll_was_activated(target, scroll_context)){ 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, gui_begin_scrollable(target, scroll_context, view->gui_scroll, 9 * view->line_height, show_scrollbar);
9 * view->line_height, show_scrollbar);
id.id[0] = (u64)(hdir) + 1; id.id[0] = (u64)(hdir) + 1;
if (gui_begin_list(target, id, view->list_i, 0, if (gui_begin_list(target, id, view->list_i, 0, snap_into_view, &update)){
snap_into_view, &update)){
// TODO(allen): Allow me to handle key consumption correctly here! // 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); 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; b32 do_new_directory = false;
Exhaustive_File_Loop loop;
begin_exhaustive_loop(&loop, hdir); begin_exhaustive_loop(&loop, hdir);
for (i32 i = 0; i < loop.count; ++i){ 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){ if (file_info.name_match){
id.id[0] = (u64)(file_info.info); id.id[0] = (u64)(file_info.info);
@ -5018,22 +4943,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 (gui_do_file_option(target, id, filename, file_info.is_folder, file_info.message)){
if (file_info.is_folder){ if (file_info.is_folder){
set_last_folder_sc(&hdir->string, file_info.info->filename, '/'); set_last_folder_sc(&hdir->string, file_info.info->filename, '/');
do_new_directory = 1; do_new_directory = true;
} }
else if (autocomplete_with_enter){ else if (autocomplete_with_enter){
complete = 1; complete = true;
copy_ss(&comp_dest, loop.full_path); 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); gui_end_list(target);
if (activate_directly){ if (activate_directly || do_open_or_new){
complete = 1; complete = true;
copy_ss(&comp_dest, hdir->string); copy_ss(&comp_dest, hdir->string);
if (do_open_or_new){
view->action = IAct_New;
}
} }
if (do_new_directory){ if (do_new_directory){

View File

@ -112,7 +112,7 @@ Sys_Font_Init_Sig(system_font_init){
u32 dir_max = KB(32); u32 dir_max = KB(32);
u8 *directory = push_array(scratch, u8, dir_max); u8 *directory = push_array(scratch, u8, dir_max);
String dir_str = make_string_cap(directory, 0, 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); Assert(dir_len < dir_max);
{ {

View File

@ -114,7 +114,7 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c){
default: default:
switch (fsm.state){ switch (fsm.state){
case LS_default: 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; fsm.state = LS_identifier;
} }
else if (c >= '1' && c <= '9'){ else if (c >= '1' && c <= '9'){
@ -192,40 +192,41 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c){
break; break;
case LS_identifier: case LS_identifier:
if (!((c >= '0' && c <= '9') || {
(c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || int is_ident = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$' || c >= 128;
c == '_' || c == '$')){ if (!is_ident){
fsm.emit_token = 1; fsm.emit_token = 1;
} }
}
break; break;
case LS_pound: case LS_pound:
switch (c){ {
case '#': fsm.emit_token = 1; break; fsm.emit_token = 1;
default: fsm.emit_token = 1; break; }break;
}
break;
case LS_pp: case LS_pp:
{
if (c == ' ' || c == '\r' || c == '\v' || c == '\f'){ if (c == ' ' || c == '\r' || c == '\v' || c == '\f'){
// NOTE(allen): do nothing // NOTE(allen): do nothing
} }
else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')){ else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c >= 128){
fsm.state = LS_ppdef; fsm.state = LS_ppdef;
} }
else{ else{
fsm.emit_token = 1; fsm.emit_token = 1;
} }
break; }break;
case LS_ppdef: case LS_ppdef:
if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))){ {
int is_ident = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c >= 128;
if (!is_ident){
fsm.emit_token = 1; fsm.emit_token = 1;
} }
break; }break;
case LS_char: case LS_char: case LS_char_multiline:
case LS_char_multiline:
switch(c){ switch(c){
case '\n': case '\'': fsm.emit_token = 1; break; case '\n': case '\'': fsm.emit_token = 1; break;
case '\\': fsm.state = LS_char_slashed; 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; break;
case LS_hex: case LS_hex:
if (!(c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F')){ {
int is_hex = c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F' || c >= 128;
if (!is_hex){
fsm.emit_token = 1; fsm.emit_token = 1;
} }
break; }break;
case LS_dot: case LS_dot:
{
if (c >= '0' && c <= '9'){ if (c >= '0' && c <= '9'){
fsm.state = LS_float; fsm.state = LS_float;
} }
else else{
switch (c){ switch (c){
case '.': fsm.state = LS_ellipsis; break; case '.': fsm.state = LS_ellipsis; break;
case '*': fsm.emit_token = 1; break; case '*': fsm.emit_token = 1; break;
default: fsm.emit_token = 1; break; default: fsm.emit_token = 1; break;
} }
break; }
}break;
case LS_ellipsis: fsm.emit_token = 1; break; case LS_ellipsis: fsm.emit_token = 1; break;

View File

@ -1,5 +1,5 @@
1 1
0 0
69 73

Binary file not shown.

View File

@ -63,12 +63,24 @@ char_is_upper(char c)
return (c >= 'A' && c <= 'Z'); 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 API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_lower(char c) char_is_lower(char c)
/* DOC(If c is a lower letter this call returns true.) */{ /* DOC(If c is a lower letter this call returns true.) */{
return (c >= 'a' && c <= 'z'); 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 API_EXPORT_INLINE FSTRING_INLINE char
char_to_upper(char c) char_to_upper(char c)
/* DOC(If c is a lowercase letter this call returns the uppercase equivalent, otherwise it returns 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 == '_'); 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 API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha_numeric_true(char c) char_is_alpha_numeric_true(char c)
/* DOC(This call returns non-zero if c is any alphanumeric character no including underscore.) */{ /* 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'); 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 API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha(char c) char_is_alpha(char c)
/* DOC(This call returns non-zero if c is any alphabetic character including underscore.) */{ /* DOC(This call returns non-zero if c is any alphabetic character including underscore.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'); 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 API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_alpha_true(char c) char_is_alpha_true(char c)
/* DOC(This call returns non-zero if c is any alphabetic character.) */{ /* DOC(This call returns non-zero if c is any alphabetic character.) */{
return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'); 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 API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_hex(char c) char_is_hex(char c)
/* DOC(This call returns non-zero if c is any valid hexadecimal digit.) */{ /* 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'); 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 API_EXPORT_INLINE FSTRING_INLINE b32_4tech
char_is_numeric(char c) char_is_numeric(char c)
/* DOC(This call returns non-zero if c is any valid decimal digit.) */{ /* DOC(This call returns non-zero if c is any valid decimal digit.) */{
return (c >= '0' && c <= '9'); 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 // String Making Functions

View File

@ -1100,9 +1100,8 @@ Win32ToggleFullscreen(void){
HWND Window = win32vars.window_handle; HWND Window = win32vars.window_handle;
LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE); LONG_PTR Style = GetWindowLongPtr(Window, GWL_STYLE);
if (Style & WS_OVERLAPPEDWINDOW){ if (Style & WS_OVERLAPPEDWINDOW){
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)}; MONITORINFO MonitorInfo = {sizeof(MONITORINFO)};
if(GetWindowPlacement(Window, &win32vars.GlobalWindowPosition) && if(GetWindowPlacement(Window, &win32vars.GlobalWindowPosition) && GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
{ {
SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW); SetWindowLongPtr(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
SetWindowPos(Window, HWND_TOP, SetWindowPos(Window, HWND_TOP,
@ -1110,16 +1109,14 @@ Win32ToggleFullscreen(void){
MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top, MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
SWP_NOOWNERZORDER | SWP_FRAMECHANGED); SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
win32vars.full_screen = 1; win32vars.full_screen = true;
} }
} }
else{ else{
SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW); SetWindowLongPtr(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
SetWindowPlacement(Window, &win32vars.GlobalWindowPosition); SetWindowPlacement(Window, &win32vars.GlobalWindowPosition);
SetWindowPos(Window, 0, 0, 0, 0, 0, SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | win32vars.full_screen = false;
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
win32vars.full_screen = 0;
} }
} }
@ -1892,6 +1889,24 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
Win32Resize(new_width, new_height); Win32Resize(new_width, new_height);
}break; }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: case WM_PAINT:
{ {
win32vars.got_useful_event = 1; win32vars.got_useful_event = 1;

View File

@ -112,7 +112,7 @@ Sys_Font_Init_Sig(system_font_init){
u32 dir_max = KB(32); u32 dir_max = KB(32);
u8 *directory = push_array(scratch, u8, dir_max); u8 *directory = push_array(scratch, u8, dir_max);
String dir_str = make_string_cap(directory, 0, 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); Assert(dir_len < dir_max);
{ {