Got rename working on Windows

This commit is contained in:
Allen Webster 2017-11-21 16:30:40 -05:00
parent b405737272
commit edd941b5fd
17 changed files with 150 additions and 59 deletions

View File

@ -202,6 +202,8 @@ ENUM(uint32_t, Buffer_Create_Flag){
BufferCreate_AlwaysNew = 0x2, BufferCreate_AlwaysNew = 0x2,
/* DOC(When BufferCreate_NeverNew is set it indicates that the buffer should only be created if it is an existing file or if a buffer with the given name is already open.) */ /* DOC(When BufferCreate_NeverNew is set it indicates that the buffer should only be created if it is an existing file or if a buffer with the given name is already open.) */
BufferCreate_NeverNew = 0x4, BufferCreate_NeverNew = 0x4,
/* DOC(When BufferCreate_JustChangedFile is set it indicates that the file to load has just been saved in the same frame and a change notification for the file should be ignored.) */
BufferCreate_JustChangedFile = 0x8,
}; };
@ -213,6 +215,12 @@ STRUCT Buffer_Creation_Data{
int32_t fname_len; int32_t fname_len;
}; };
/* DOC(A Buffer_Save_Flag field specifies buffer saving behavior.) */
ENUM(uint32_t, Buffer_Save_Flag){
/* DOC(BufferSave_IgnoreDirtyFlag tells the save procedure not to check the dirty flag of the buffer. Usually buffers not marked dirty will not be saved, but sometimes it is useful to force it to save anyway. ) */
BufferSave_IgnoreDirtyFlag = 0x1,
};
/* DOC(A Buffer_Kill_Flag field specifies how a buffer should be killed.) */ /* DOC(A Buffer_Kill_Flag field specifies how a buffer should be killed.) */
ENUM(uint32_t, Buffer_Kill_Flag){ ENUM(uint32_t, Buffer_Kill_Flag){
/* DOC(BufferKill_Background is not currently implemented.) */ /* DOC(BufferKill_Background is not currently implemented.) */

View File

@ -918,12 +918,12 @@ CUSTOM_DOC("Queries the user for two strings, and replaces all occurences of the
} }
static void static void
query_replace(Application_Links *app, View_Summary *view, Buffer_Summary *buffer, int32_t pos, String r, String w){ query_replace_base(Application_Links *app, View_Summary *view, Buffer_Summary *buffer, int32_t pos, String r, String w){
int32_t new_pos = 0; int32_t new_pos = 0;
buffer_seek_string_forward(app, buffer, pos, 0, r.str, r.size, &new_pos); buffer_seek_string_forward(app, buffer, pos, 0, r.str, r.size, &new_pos);
User_Input in = {0}; User_Input in = {0};
while (new_pos < buffer->size){ for (;new_pos < buffer->size;){
Range match = make_range(new_pos, new_pos + r.size); Range match = make_range(new_pos, new_pos + r.size);
view_set_highlight(app, view, match.min, match.max, 1); view_set_highlight(app, view, match.min, match.max, 1);
@ -976,7 +976,7 @@ query_replace_parameter(Application_Links *app, String replace_str, int32_t star
bar.string = null_string; bar.string = null_string;
start_query_bar(app, &bar, 0); start_query_bar(app, &bar, 0);
query_replace(app, &view, &buffer, pos, r, w); query_replace_base(app, &view, &buffer, pos, r, w);
} }
CUSTOM_COMMAND_SIG(query_replace) CUSTOM_COMMAND_SIG(query_replace)
@ -1035,8 +1035,31 @@ CUSTOM_DOC("Saves all buffers marked dirty (showing the '*' indicator).")
} }
} }
CUSTOM_COMMAND_SIG(delete_file) static void
CUSTOM_DOC("Deletes the file of the current buffer if 4coder has the appropriate access rights.") delete_file_base(Application_Links *app, String file_name, Buffer_ID buffer_id){
String path = path_of_directory(file_name);
char space[4096];
String cmd = make_fixed_width_string(space);
#if defined(IS_WINDOWS)
append(&cmd, "del ");
#elif defined(IS_LINUX) || defined(IS_MAC)
append(&cmd, "rm ");
#else
# error no delete file command for this platform
#endif
append(&cmd, '"');
append(&cmd, front_of_directory(file_name));
append(&cmd, '"');
exec_system_command(app, 0, buffer_identifier(0), path.str, path.size, cmd.str, cmd.size, 0);
kill_buffer(app, buffer_identifier(buffer_id), 0, BufferKill_AlwaysKill);
}
CUSTOM_COMMAND_SIG(delete_file_query)
CUSTOM_DOC("Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.")
{ {
View_Summary view = get_active_view(app, AccessAll); View_Summary view = get_active_view(app, AccessAll);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessAll); Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessAll);
@ -1045,23 +1068,61 @@ CUSTOM_DOC("Deletes the file of the current buffer if 4coder has the appropriate
String file_name = {0}; String file_name = {0};
file_name = make_string(buffer.file_name, buffer.file_name_len); file_name = make_string(buffer.file_name, buffer.file_name_len);
String path = path_of_directory(file_name);
char space[4096]; char space[4096];
String cmd = make_fixed_width_string(space); Query_Bar bar;
bar.prompt = make_fixed_width_string(space);
append(&bar.prompt, "Delete '");
append(&bar.prompt, file_name);
append(&bar.prompt, "' (Y)es, (n)o");
bar.string = null_string;
if (start_query_bar(app, &bar, 0) == 0) return;
#if defined(_WIN32) User_Input in = get_user_input(app, EventOnAnyKey, 0);
append(&cmd, "del "); if (in.key.keycode != 'Y') return;
#elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
append(&cmd, "rm ");
#else
# error no delete file command for this platform
#endif
append(&cmd, front_of_directory(file_name));
exec_system_command(app, 0, buffer_identifier(0), path.str, path.size, cmd.str, cmd.size, 0); delete_file_base(app, file_name, buffer.buffer_id);
}
kill_buffer(app, buffer_identifier(buffer.buffer_id), view.view_id, BufferKill_AlwaysKill); }
CUSTOM_COMMAND_SIG(rename_file_query)
CUSTOM_DOC("Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.")
{
View_Summary view = get_active_view(app, AccessAll);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessAll);
if (buffer.file_name != 0){
char file_name_space[4096];
String file_name = make_fixed_width_string(file_name_space);
if (copy_checked(&file_name, make_string(buffer.file_name, buffer.file_name_len))){
// Query the user
Query_Bar bar;
char prompt_space[4096];
bar.prompt = make_fixed_width_string(prompt_space);
append(&bar.prompt, "Rename '");
append(&bar.prompt, front_of_directory(file_name));
append(&bar.prompt, "' to: ");
char name_space[4096];
bar.string = make_fixed_width_string(name_space);
if (!query_user_string(app, &bar)) return;
if (bar.string.size == 0) return;
// TODO(allen): There should be a way to say, "detach a buffer's file" and "attach this file to a buffer"
char new_file_name_space[4096];
String new_file_name = make_fixed_width_string(new_file_name_space);
copy(&new_file_name, file_name);
remove_last_folder(&new_file_name);
append(&new_file_name, bar.string);
terminate_with_null(&new_file_name);
if (save_buffer(app, &buffer, new_file_name.str, new_file_name.size, BufferSave_IgnoreDirtyFlag)){
delete_file_base(app, file_name, buffer.buffer_id);
Buffer_Summary new_buffer = create_buffer(app, new_file_name.str, new_file_name.size, BufferCreate_NeverNew|BufferCreate_JustChangedFile);
view_set_buffer(app, &view, new_buffer.buffer_id, 0);
}
}
} }
} }

View File

@ -108,7 +108,7 @@ standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary
return(result); return(result);
} }
#if defined(_WIN32) #if defined(IS_WINDOWS)
// NOTE(allen): Build search rule for windows. // NOTE(allen): Build search rule for windows.
static int32_t static int32_t
@ -119,7 +119,7 @@ execute_standard_build_search(Application_Links *app, View_Summary *view,
return(result); return(result);
} }
#elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) #elif defined(IS_LINUX) || defined(IS_MAC)
// NOTE(allen): Build search rule for linux and mac. // NOTE(allen): Build search rule for linux and mac.
static int32_t static int32_t

View File

@ -11,6 +11,8 @@ TYPE: 'major-system-include'
#include "4coder_API/custom.h" #include "4coder_API/custom.h"
#include "4coder_os_comp_cracking.h"
#include "4coder_default_framework.h" #include "4coder_default_framework.h"
#include "4coder_base_commands.cpp" #include "4coder_base_commands.cpp"
#include "4coder_auto_indent.cpp" #include "4coder_auto_indent.cpp"
@ -718,7 +720,10 @@ CUSTOM_DOC("Execute a 'long form' command.")
setup_new_project(app); setup_new_project(app);
} }
else if (match_ss(bar.string, make_lit_string("delete file"))){ else if (match_ss(bar.string, make_lit_string("delete file"))){
delete_file(app); delete_file_query(app);
}
else if (match_ss(bar.string, make_lit_string("rename file"))){
rename_file_query(app);
} }
else{ else{
print_message(app, literal("unrecognized command\n")); print_message(app, literal("unrecognized command\n"));

View File

@ -29,7 +29,7 @@ struct Application_Links;
#define BUFFER_GET_TOKEN_INDEX_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result) #define BUFFER_GET_TOKEN_INDEX_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result)
#define BUFFER_SEND_END_SIGNAL_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer) #define BUFFER_SEND_END_SIGNAL_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer)
#define CREATE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags) #define CREATE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags)
#define SAVE_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags) #define SAVE_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *file_name, int32_t file_name_len, uint32_t flags)
#define KILL_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags) #define KILL_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags)
#define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app, Access_Flag access) #define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app, Access_Flag access)
#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, Access_Flag access) #define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, Access_Flag access)
@ -462,7 +462,7 @@ static inline bool32 buffer_read_tokens(Application_Links *app, Buffer_Summary *
static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index(app, buffer, pos, get_result));} static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index(app, buffer, pos, get_result));}
static inline bool32 buffer_send_end_signal(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_send_end_signal(app, buffer));} static inline bool32 buffer_send_end_signal(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_send_end_signal(app, buffer));}
static inline Buffer_Summary create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags){return(app->create_buffer(app, filename, filename_len, flags));} static inline Buffer_Summary create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags){return(app->create_buffer(app, filename, filename_len, flags));}
static inline bool32 save_buffer(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags){return(app->save_buffer(app, buffer, filename, filename_len, flags));} static inline bool32 save_buffer(Application_Links *app, Buffer_Summary *buffer, char *file_name, int32_t file_name_len, uint32_t flags){return(app->save_buffer(app, buffer, file_name, file_name_len, flags));}
static inline bool32 kill_buffer(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags){return(app->kill_buffer(app, buffer, view_id, flags));} static inline bool32 kill_buffer(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags){return(app->kill_buffer(app, buffer, view_id, flags));}
static inline View_Summary get_view_first(Application_Links *app, Access_Flag access){return(app->get_view_first(app, access));} static inline View_Summary get_view_first(Application_Links *app, Access_Flag access){return(app->get_view_first(app, access));}
static inline void get_view_next(Application_Links *app, View_Summary *view, Access_Flag access){(app->get_view_next(app, view, access));} static inline void get_view_next(Application_Links *app, View_Summary *view, Access_Flag access){(app->get_view_next(app, view, access));}
@ -547,7 +547,7 @@ static inline bool32 buffer_read_tokens(Application_Links *app, Buffer_Summary *
static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index_(app, buffer, pos, get_result));} static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index_(app, buffer, pos, get_result));}
static inline bool32 buffer_send_end_signal(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_send_end_signal_(app, buffer));} static inline bool32 buffer_send_end_signal(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_send_end_signal_(app, buffer));}
static inline Buffer_Summary create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags){return(app->create_buffer_(app, filename, filename_len, flags));} static inline Buffer_Summary create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags){return(app->create_buffer_(app, filename, filename_len, flags));}
static inline bool32 save_buffer(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags){return(app->save_buffer_(app, buffer, filename, filename_len, flags));} static inline bool32 save_buffer(Application_Links *app, Buffer_Summary *buffer, char *file_name, int32_t file_name_len, uint32_t flags){return(app->save_buffer_(app, buffer, file_name, file_name_len, flags));}
static inline bool32 kill_buffer(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags){return(app->kill_buffer_(app, buffer, view_id, flags));} static inline bool32 kill_buffer(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags){return(app->kill_buffer_(app, buffer, view_id, flags));}
static inline View_Summary get_view_first(Application_Links *app, Access_Flag access){return(app->get_view_first_(app, access));} static inline View_Summary get_view_first(Application_Links *app, Access_Flag access){return(app->get_view_first_(app, access));}
static inline void get_view_next(Application_Links *app, View_Summary *view, Access_Flag access){(app->get_view_next_(app, view, access));} static inline void get_view_next(Application_Links *app, View_Summary *view, Access_Flag access){(app->get_view_next_(app, view, access));}

View File

@ -115,7 +115,7 @@ bind(context, '?', MDFR_CTRL, toggle_show_whitespace);
bind(context, '~', MDFR_CTRL, clean_all_lines); bind(context, '~', MDFR_CTRL, clean_all_lines);
bind(context, '\n', MDFR_NONE, newline_or_goto_position); bind(context, '\n', MDFR_NONE, newline_or_goto_position);
bind(context, '\n', MDFR_SHIFT, newline_or_goto_position_same_panel); bind(context, '\n', MDFR_SHIFT, newline_or_goto_position_same_panel);
bind(context, ' ', MDFR_SHIFT, write_underscore); bind(context, ' ', MDFR_SHIFT, write_character);
end_map(context); end_map(context);
begin_map(context, default_code_map); begin_map(context, default_code_map);
inherit_map(context, mapid_file); inherit_map(context, mapid_file);
@ -183,6 +183,8 @@ bind(context, 'b', MDFR_CTRL, toggle_filebar);
bind(context, '@', MDFR_CTRL, toggle_mouse); bind(context, '@', MDFR_CTRL, toggle_mouse);
bind(context, key_page_up, MDFR_CMND, toggle_fullscreen); bind(context, key_page_up, MDFR_CMND, toggle_fullscreen);
bind(context, 'E', MDFR_CTRL, exit_4coder); bind(context, 'E', MDFR_CTRL, exit_4coder);
bind(context, '+', MDFR_CTRL, increase_face_size);
bind(context, '-', MDFR_CTRL, decrease_face_size);
bind(context, key_f1, MDFR_NONE, project_fkey_command); bind(context, key_f1, MDFR_NONE, project_fkey_command);
bind(context, key_f2, 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_f3, MDFR_NONE, project_fkey_command);
@ -263,7 +265,7 @@ bind(context, '?', MDFR_CMND, toggle_show_whitespace);
bind(context, '~', MDFR_CMND, clean_all_lines); bind(context, '~', MDFR_CMND, clean_all_lines);
bind(context, '\n', MDFR_NONE, newline_or_goto_position); bind(context, '\n', MDFR_NONE, newline_or_goto_position);
bind(context, '\n', MDFR_SHIFT, newline_or_goto_position_same_panel); bind(context, '\n', MDFR_SHIFT, newline_or_goto_position_same_panel);
bind(context, ' ', MDFR_SHIFT, write_underscore); bind(context, ' ', MDFR_SHIFT, write_character);
end_map(context); end_map(context);
begin_map(context, default_code_map); begin_map(context, default_code_map);
inherit_map(context, mapid_file); inherit_map(context, mapid_file);
@ -447,7 +449,7 @@ static Meta_Key_Bind fcoder_binds_for_default_mapid_file[65] = {
{0, 126, 1, "clean_all_lines", 15, LINK_PROCS(clean_all_lines)}, {0, 126, 1, "clean_all_lines", 15, LINK_PROCS(clean_all_lines)},
{0, 10, 0, "newline_or_goto_position", 24, LINK_PROCS(newline_or_goto_position)}, {0, 10, 0, "newline_or_goto_position", 24, LINK_PROCS(newline_or_goto_position)},
{0, 10, 8, "newline_or_goto_position_same_panel", 35, LINK_PROCS(newline_or_goto_position_same_panel)}, {0, 10, 8, "newline_or_goto_position_same_panel", 35, LINK_PROCS(newline_or_goto_position_same_panel)},
{0, 32, 8, "write_underscore", 16, LINK_PROCS(write_underscore)}, {0, 32, 8, "write_character", 15, LINK_PROCS(write_character)},
}; };
static Meta_Key_Bind fcoder_binds_for_default_default_code_map[30] = { static Meta_Key_Bind fcoder_binds_for_default_default_code_map[30] = {
{0, 55300, 1, "seek_alphanumeric_or_camel_right", 32, LINK_PROCS(seek_alphanumeric_or_camel_right)}, {0, 55300, 1, "seek_alphanumeric_or_camel_right", 32, LINK_PROCS(seek_alphanumeric_or_camel_right)},
@ -486,7 +488,7 @@ static Meta_Sub_Map fcoder_submaps_for_default[3] = {
{"mapid_file", 10, "TODO", 4, 0, 0, fcoder_binds_for_default_mapid_file, 65}, {"mapid_file", 10, "TODO", 4, 0, 0, fcoder_binds_for_default_mapid_file, 65},
{"default_code_map", 16, "TODO", 4, "mapid_file", 10, fcoder_binds_for_default_default_code_map, 30}, {"default_code_map", 16, "TODO", 4, "mapid_file", 10, fcoder_binds_for_default_default_code_map, 30},
}; };
static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[46] = { static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[48] = {
{0, 112, 4, "open_panel_vsplit", 17, LINK_PROCS(open_panel_vsplit)}, {0, 112, 4, "open_panel_vsplit", 17, LINK_PROCS(open_panel_vsplit)},
{0, 95, 4, "open_panel_hsplit", 17, LINK_PROCS(open_panel_hsplit)}, {0, 95, 4, "open_panel_hsplit", 17, LINK_PROCS(open_panel_hsplit)},
{0, 80, 4, "close_panel", 11, LINK_PROCS(close_panel)}, {0, 80, 4, "close_panel", 11, LINK_PROCS(close_panel)},
@ -517,6 +519,8 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[46] = {
{0, 64, 1, "toggle_mouse", 12, LINK_PROCS(toggle_mouse)}, {0, 64, 1, "toggle_mouse", 12, LINK_PROCS(toggle_mouse)},
{0, 55305, 4, "toggle_fullscreen", 17, LINK_PROCS(toggle_fullscreen)}, {0, 55305, 4, "toggle_fullscreen", 17, LINK_PROCS(toggle_fullscreen)},
{0, 69, 1, "exit_4coder", 11, LINK_PROCS(exit_4coder)}, {0, 69, 1, "exit_4coder", 11, LINK_PROCS(exit_4coder)},
{0, 43, 1, "increase_face_size", 18, LINK_PROCS(increase_face_size)},
{0, 45, 1, "decrease_face_size", 18, LINK_PROCS(decrease_face_size)},
{0, 55312, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55312, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)},
{0, 55313, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55313, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)},
{0, 55314, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)}, {0, 55314, 0, "project_fkey_command", 20, LINK_PROCS(project_fkey_command)},
@ -597,7 +601,7 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_file[63] = {
{0, 126, 4, "clean_all_lines", 15, LINK_PROCS(clean_all_lines)}, {0, 126, 4, "clean_all_lines", 15, LINK_PROCS(clean_all_lines)},
{0, 10, 0, "newline_or_goto_position", 24, LINK_PROCS(newline_or_goto_position)}, {0, 10, 0, "newline_or_goto_position", 24, LINK_PROCS(newline_or_goto_position)},
{0, 10, 8, "newline_or_goto_position_same_panel", 35, LINK_PROCS(newline_or_goto_position_same_panel)}, {0, 10, 8, "newline_or_goto_position_same_panel", 35, LINK_PROCS(newline_or_goto_position_same_panel)},
{0, 32, 8, "write_underscore", 16, LINK_PROCS(write_underscore)}, {0, 32, 8, "write_character", 15, LINK_PROCS(write_character)},
}; };
static Meta_Key_Bind fcoder_binds_for_mac_default_default_code_map[30] = { static Meta_Key_Bind fcoder_binds_for_mac_default_default_code_map[30] = {
{0, 55300, 4, "seek_alphanumeric_or_camel_right", 32, LINK_PROCS(seek_alphanumeric_or_camel_right)}, {0, 55300, 4, "seek_alphanumeric_or_camel_right", 32, LINK_PROCS(seek_alphanumeric_or_camel_right)},
@ -632,7 +636,7 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_default_code_map[30] = {
{0, 73, 4, "list_all_functions_current_buffer", 33, LINK_PROCS(list_all_functions_current_buffer)}, {0, 73, 4, "list_all_functions_current_buffer", 33, LINK_PROCS(list_all_functions_current_buffer)},
}; };
static Meta_Sub_Map fcoder_submaps_for_mac_default[3] = { static Meta_Sub_Map fcoder_submaps_for_mac_default[3] = {
{"mapid_global", 12, "TODO", 4, 0, 0, fcoder_binds_for_mac_default_mapid_global, 46}, {"mapid_global", 12, "TODO", 4, 0, 0, fcoder_binds_for_mac_default_mapid_global, 48},
{"mapid_file", 10, "TODO", 4, 0, 0, fcoder_binds_for_mac_default_mapid_file, 63}, {"mapid_file", 10, "TODO", 4, 0, 0, fcoder_binds_for_mac_default_mapid_file, 63},
{"default_code_map", 16, "TODO", 4, "mapid_file", 10, fcoder_binds_for_mac_default_default_code_map, 30}, {"default_code_map", 16, "TODO", 4, "mapid_file", 10, fcoder_binds_for_mac_default_default_code_map, 30},
}; };

View File

@ -9,8 +9,8 @@
// TOP // TOP
#if !defined(FRED_OS_COMP_CRACKING_H) #if !defined(FCODER_OS_COMP_CRACKING_H)
#define FRED_OS_COMP_CRACKING_H #define FCODER_OS_COMP_CRACKING_H
#if defined(_MSC_VER) /* COMPILER */ #if defined(_MSC_VER) /* COMPILER */
@ -28,7 +28,7 @@
# error This compiler/platform combo is not supported yet # error This compiler/platform combo is not supported yet
# endif # endif
# if defined(_M_AMD64) /* Arch */ # if defined(_M_AMD64) /* Architecture */
# define CALL_CONVENTION # define CALL_CONVENTION
# define BUILD_X64 # define BUILD_X64
# elif defined(_M_IX86) # elif defined(_M_IX86)
@ -53,7 +53,7 @@
# endif # endif
#else #else
#error This compiler is not supported yet # error This compiler is not supported yet
#endif #endif
#endif #endif

View File

@ -260,11 +260,11 @@ load_project_from_config_data(Application_Links *app, Partition *part, char *con
} }
{ {
#if defined(_WIN32) #if defined(IS_WINDOWS)
# define FKEY_COMMAND "fkey_command_win" # define FKEY_COMMAND "fkey_command_win"
#elif defined(__linux__) #elif defined(IS_LINUX)
# define FKEY_COMMAND "fkey_command_linux" # define FKEY_COMMAND "fkey_command_linux"
#elif defined(__APPLE__) && defined(__MACH__) #elif defined(IS_MAC)
# define FKEY_COMMAND "fkey_command_mac" # define FKEY_COMMAND "fkey_command_mac"
#else #else
# error no project configuration names for this platform # error no project configuration names for this platform

View File

@ -49,11 +49,11 @@ get_context_on_global_part(void){
CUSTOM_COMMAND_SIG(set_bindings_choose) CUSTOM_COMMAND_SIG(set_bindings_choose)
CUSTOM_DOC("Remap keybindings using the 'choose' mapping rule.") CUSTOM_DOC("Remap keybindings using the 'choose' mapping rule.")
{ {
#if defined(_WIN32) || defined(__linux__) #if defined(IS_WINDOWS) || defined(IS_LINUX)
set_bindings_default(app); set_bindings_default(app);
#elif defined(__APPLE__) && defined(__MACH__) #elif defined(IS_MAC)
set_bindings_mac_default(app); set_bindings_mac_default(app);

View File

@ -1480,11 +1480,12 @@ App_Step_Sig(app_step){
for (;system->get_file_change(buffer, buffer_size, &mem_too_small, &size);){ for (;system->get_file_change(buffer, buffer_size, &mem_too_small, &size);){
Assert(!mem_too_small); Assert(!mem_too_small);
Editing_File_Canon_Name canon; Editing_File_Canon_Name canon = {0};
if (get_canon_name(system, &canon, make_string(buffer, size))){ if (get_canon_name(system, &canon, make_string(buffer, size))){
Editing_File *file = working_set_canon_contains(working_set, canon.name); Editing_File *file = working_set_canon_contains(working_set, canon.name);
if (file){ if (file != 0){
if (file->state.ignore_behind_os == 0){ if (file->state.ignore_behind_os == 0){
file_mark_behind_os(file); file_mark_behind_os(file);
} }
else if (file->state.ignore_behind_os == 1){ else if (file->state.ignore_behind_os == 1){

View File

@ -1314,7 +1314,7 @@ DOC_SEE(Buffer_Create_Flag)
if (system->load_file(handle, buffer, size)){ if (system->load_file(handle, buffer, size)){
system->load_close(handle); system->load_close(handle);
file = working_set_alloc_always(working_set, general); file = working_set_alloc_always(working_set, general);
if (file){ if (file != 0){
buffer_bind_file(system, general, working_set, file, canon.name); buffer_bind_file(system, general, working_set, file, canon.name);
buffer_bind_name(general, working_set, file, fname); buffer_bind_name(general, working_set, file, fname);
init_normal_file(system, models, file, buffer, size); init_normal_file(system, models, file, buffer, size);
@ -1334,6 +1334,10 @@ DOC_SEE(Buffer_Create_Flag)
fill_buffer_summary(&result, file, cmd); fill_buffer_summary(&result, file, cmd);
} }
if (file != 0 && (flags & BufferCreate_JustChangedFile)){
file->state.ignore_behind_os = 1;
}
end_temp_memory(temp); end_temp_memory(temp);
} }
@ -1341,28 +1345,36 @@ DOC_SEE(Buffer_Create_Flag)
} }
API_EXPORT bool32 API_EXPORT bool32
Save_Buffer(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags) Save_Buffer(Application_Links *app, Buffer_Summary *buffer, char *file_name, int32_t file_name_len, uint32_t flags)
/* /*
DOC_PARAM(buffer, The buffer parameter specifies the buffer to save to a file.) DOC_PARAM(buffer, The buffer parameter specifies the buffer to save to a file.)
DOC_PARAM(filename, The filename parameter specifies the name of the file to write with the contents of the buffer; it need not be null terminated.) DOC_PARAM(file_name, The file_name parameter specifies the name of the file to write with the contents of the buffer; it need not be null terminated.)
DOC_PARAM(filename_len, The filename_len parameter specifies the length of the filename string.) DOC_PARAM(file_name_len, The file_name_len parameter specifies the length of the file_name string.)
DOC_PARAM(flags, This parameter is not currently used and should be set to 0 for now.) DOC_PARAM(flags, Specifies special behaviors for the save routine.)
DOC_RETURN(This call returns non-zero on success.) DOC_RETURN(This call returns non-zero on success.)
DOC(Often it will make sense to set filename and filename_len to buffer.filename and buffer.filename_len) DOC(Often it will make sense to set file_name and file_name_len to buffer.file_name and buffer.file_name_len)
DOC_SEE(Buffer_Save_Flag)
*/{ */{
Command_Data *cmd = (Command_Data*)app->cmd_context; Command_Data *cmd = (Command_Data*)app->cmd_context;
System_Functions *system = cmd->system; System_Functions *system = cmd->system;
Models *models = cmd->models; Models *models = cmd->models;
bool32 result = 0; bool32 result = false;
Editing_File *file = imp_get_file(cmd, buffer); Editing_File *file = imp_get_file(cmd, buffer);
if (file){ if (file != 0){
if (file_get_sync(file) != DirtyState_UpToDate){ b32 skip_save = false;
result = 1; if (!(flags & BufferSave_IgnoreDirtyFlag)){
if (file_get_sync(file) == DirtyState_UpToDate){
skip_save = true;
}
}
if (!skip_save){
result = true;
Partition *part = &models->mem.part; Partition *part = &models->mem.part;
Temp_Memory temp = begin_temp_memory(part); Temp_Memory temp = begin_temp_memory(part);
String name = make_string_terminated(part, filename, filename_len); String name = make_string_terminated(part, file_name, file_name_len);
save_file_to_name(system, models, file, name.str); save_file_to_name(system, models, file, name.str);
end_temp_memory(temp); end_temp_memory(temp);
} }

View File

@ -12,7 +12,7 @@
#if !defined(FTECH_DEFINES) #if !defined(FTECH_DEFINES)
#define FTECH_DEFINES #define FTECH_DEFINES
#include "4ed_os_comp_cracking.h" #include "4coder_os_comp_cracking.h"
#include <stdint.h> #include <stdint.h>

View File

@ -546,7 +546,7 @@ save_file_to_name(System_Functions *system, Models *models, Editing_File *file,
result = system->save_file(filename, data, size); result = system->save_file(filename, data, size);
if (result && using_actual_filename){ if (result && using_actual_filename){
file->state.ignore_behind_os = true; file->state.ignore_behind_os = 1;
} }
file_mark_clean(file); file_mark_clean(file);

View File

@ -12,7 +12,7 @@
#if !defined(FRED_FILE_MOVING_H) #if !defined(FRED_FILE_MOVING_H)
#define FRED_FILE_MOVING_H #define FRED_FILE_MOVING_H
#include "../4ed_os_comp_cracking.h" #include "../4coder_os_comp_cracking.h"
#include <stdio.h> // include system for windows #include <stdio.h> // include system for windows
#include <stdlib.h> // include system for linux (YAY!) #include <stdlib.h> // include system for linux (YAY!)

View File

@ -1203,7 +1203,7 @@ compile_meta_unit(char *code_directory, char **files, Meta_Keywords *meta_keywor
char str_space[512]; char str_space[512];
String name = make_fixed_width_string(str_space); String name = make_fixed_width_string(str_space);
append_sc(&name, code_directory); append_sc(&name, code_directory);
#ifdef _WIN32 #if defined(_WIN32)
append_sc(&name, "\\"); append_sc(&name, "\\");
#else #else
append_sc(&name, "/"); append_sc(&name, "/");

View File

@ -11,7 +11,7 @@
// TOP // TOP
#define IS_PLAT_LAYER #define IS_PLAT_LAYER
#include "4ed_os_comp_cracking.h" #include "4coder_os_comp_cracking.h"
#include <string.h> #include <string.h>
#include "4ed_defines.h" #include "4ed_defines.h"

View File

@ -10,7 +10,7 @@
// TOP // TOP
#define IS_PLAT_LAYER #define IS_PLAT_LAYER
#include "4ed_os_comp_cracking.h" #include "4coder_os_comp_cracking.h"
// //
// Program setup // Program setup