Got rename working on Windows
parent
b405737272
commit
edd941b5fd
|
@ -202,6 +202,8 @@ ENUM(uint32_t, Buffer_Create_Flag){
|
|||
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.) */
|
||||
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;
|
||||
};
|
||||
|
||||
/* 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.) */
|
||||
ENUM(uint32_t, Buffer_Kill_Flag){
|
||||
/* DOC(BufferKill_Background is not currently implemented.) */
|
||||
|
|
|
@ -918,12 +918,12 @@ CUSTOM_DOC("Queries the user for two strings, and replaces all occurences of the
|
|||
}
|
||||
|
||||
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;
|
||||
buffer_seek_string_forward(app, buffer, pos, 0, r.str, r.size, &new_pos);
|
||||
|
||||
User_Input in = {0};
|
||||
while (new_pos < buffer->size){
|
||||
for (;new_pos < buffer->size;){
|
||||
Range match = make_range(new_pos, new_pos + r.size);
|
||||
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;
|
||||
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)
|
||||
|
@ -1035,8 +1035,31 @@ CUSTOM_DOC("Saves all buffers marked dirty (showing the '*' indicator).")
|
|||
}
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(delete_file)
|
||||
CUSTOM_DOC("Deletes the file of the current buffer if 4coder has the appropriate access rights.")
|
||||
static void
|
||||
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);
|
||||
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};
|
||||
file_name = make_string(buffer.file_name, buffer.file_name_len);
|
||||
|
||||
String path = path_of_directory(file_name);
|
||||
|
||||
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)
|
||||
append(&cmd, "del ");
|
||||
#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));
|
||||
User_Input in = get_user_input(app, EventOnAnyKey, 0);
|
||||
if (in.key.keycode != 'Y') return;
|
||||
|
||||
exec_system_command(app, 0, buffer_identifier(0), path.str, path.size, cmd.str, cmd.size, 0);
|
||||
|
||||
kill_buffer(app, buffer_identifier(buffer.buffer_id), view.view_id, BufferKill_AlwaysKill);
|
||||
delete_file_base(app, file_name, buffer.buffer_id);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary
|
|||
return(result);
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(IS_WINDOWS)
|
||||
|
||||
// NOTE(allen): Build search rule for windows.
|
||||
static int32_t
|
||||
|
@ -119,7 +119,7 @@ execute_standard_build_search(Application_Links *app, View_Summary *view,
|
|||
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.
|
||||
static int32_t
|
||||
|
|
|
@ -11,6 +11,8 @@ TYPE: 'major-system-include'
|
|||
|
||||
#include "4coder_API/custom.h"
|
||||
|
||||
#include "4coder_os_comp_cracking.h"
|
||||
|
||||
#include "4coder_default_framework.h"
|
||||
#include "4coder_base_commands.cpp"
|
||||
#include "4coder_auto_indent.cpp"
|
||||
|
@ -718,7 +720,10 @@ CUSTOM_DOC("Execute a 'long form' command.")
|
|||
setup_new_project(app);
|
||||
}
|
||||
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{
|
||||
print_message(app, literal("unrecognized command\n"));
|
||||
|
|
|
@ -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_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 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 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)
|
||||
|
@ -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_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 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 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));}
|
||||
|
@ -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_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 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 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));}
|
||||
|
|
|
@ -115,7 +115,7 @@ bind(context, '?', MDFR_CTRL, toggle_show_whitespace);
|
|||
bind(context, '~', MDFR_CTRL, clean_all_lines);
|
||||
bind(context, '\n', MDFR_NONE, newline_or_goto_position);
|
||||
bind(context, '\n', MDFR_SHIFT, newline_or_goto_position_same_panel);
|
||||
bind(context, ' ', MDFR_SHIFT, write_underscore);
|
||||
bind(context, ' ', MDFR_SHIFT, write_character);
|
||||
end_map(context);
|
||||
begin_map(context, default_code_map);
|
||||
inherit_map(context, mapid_file);
|
||||
|
@ -183,6 +183,8 @@ bind(context, 'b', MDFR_CTRL, toggle_filebar);
|
|||
bind(context, '@', MDFR_CTRL, toggle_mouse);
|
||||
bind(context, key_page_up, MDFR_CMND, toggle_fullscreen);
|
||||
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_f2, 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, '\n', MDFR_NONE, newline_or_goto_position);
|
||||
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);
|
||||
begin_map(context, default_code_map);
|
||||
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, 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, 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] = {
|
||||
{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},
|
||||
{"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, 95, 4, "open_panel_hsplit", 17, LINK_PROCS(open_panel_hsplit)},
|
||||
{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, 55305, 4, "toggle_fullscreen", 17, LINK_PROCS(toggle_fullscreen)},
|
||||
{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, 55313, 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, 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, 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] = {
|
||||
{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)},
|
||||
};
|
||||
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},
|
||||
{"default_code_map", 16, "TODO", 4, "mapid_file", 10, fcoder_binds_for_mac_default_default_code_map, 30},
|
||||
};
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
// TOP
|
||||
|
||||
#if !defined(FRED_OS_COMP_CRACKING_H)
|
||||
#define FRED_OS_COMP_CRACKING_H
|
||||
#if !defined(FCODER_OS_COMP_CRACKING_H)
|
||||
#define FCODER_OS_COMP_CRACKING_H
|
||||
|
||||
#if defined(_MSC_VER) /* COMPILER */
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
|||
# error This compiler/platform combo is not supported yet
|
||||
# endif
|
||||
|
||||
# if defined(_M_AMD64) /* Arch */
|
||||
# if defined(_M_AMD64) /* Architecture */
|
||||
# define CALL_CONVENTION
|
||||
# define BUILD_X64
|
||||
# elif defined(_M_IX86)
|
||||
|
@ -53,7 +53,7 @@
|
|||
# endif
|
||||
|
||||
#else
|
||||
#error This compiler is not supported yet
|
||||
# error This compiler is not supported yet
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -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"
|
||||
#elif defined(__linux__)
|
||||
#elif defined(IS_LINUX)
|
||||
# define FKEY_COMMAND "fkey_command_linux"
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
#elif defined(IS_MAC)
|
||||
# define FKEY_COMMAND "fkey_command_mac"
|
||||
#else
|
||||
# error no project configuration names for this platform
|
||||
|
|
|
@ -49,11 +49,11 @@ get_context_on_global_part(void){
|
|||
CUSTOM_COMMAND_SIG(set_bindings_choose)
|
||||
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);
|
||||
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
#elif defined(IS_MAC)
|
||||
|
||||
set_bindings_mac_default(app);
|
||||
|
||||
|
|
5
4ed.cpp
5
4ed.cpp
|
@ -1480,11 +1480,12 @@ App_Step_Sig(app_step){
|
|||
|
||||
for (;system->get_file_change(buffer, buffer_size, &mem_too_small, &size);){
|
||||
Assert(!mem_too_small);
|
||||
Editing_File_Canon_Name canon;
|
||||
Editing_File_Canon_Name canon = {0};
|
||||
if (get_canon_name(system, &canon, make_string(buffer, size))){
|
||||
Editing_File *file = working_set_canon_contains(working_set, canon.name);
|
||||
if (file){
|
||||
if (file != 0){
|
||||
if (file->state.ignore_behind_os == 0){
|
||||
|
||||
file_mark_behind_os(file);
|
||||
}
|
||||
else if (file->state.ignore_behind_os == 1){
|
||||
|
|
|
@ -1314,7 +1314,7 @@ DOC_SEE(Buffer_Create_Flag)
|
|||
if (system->load_file(handle, buffer, size)){
|
||||
system->load_close(handle);
|
||||
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_name(general, working_set, file, fname);
|
||||
init_normal_file(system, models, file, buffer, size);
|
||||
|
@ -1334,6 +1334,10 @@ DOC_SEE(Buffer_Create_Flag)
|
|||
fill_buffer_summary(&result, file, cmd);
|
||||
}
|
||||
|
||||
if (file != 0 && (flags & BufferCreate_JustChangedFile)){
|
||||
file->state.ignore_behind_os = 1;
|
||||
}
|
||||
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
|
||||
|
@ -1341,28 +1345,36 @@ DOC_SEE(Buffer_Create_Flag)
|
|||
}
|
||||
|
||||
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(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(filename_len, The filename_len parameter specifies the length of the filename string.)
|
||||
DOC_PARAM(flags, This parameter is not currently used and should be set to 0 for now.)
|
||||
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(file_name_len, The file_name_len parameter specifies the length of the file_name string.)
|
||||
DOC_PARAM(flags, Specifies special behaviors for the save routine.)
|
||||
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;
|
||||
System_Functions *system = cmd->system;
|
||||
Models *models = cmd->models;
|
||||
bool32 result = 0;
|
||||
bool32 result = false;
|
||||
|
||||
Editing_File *file = imp_get_file(cmd, buffer);
|
||||
if (file){
|
||||
if (file_get_sync(file) != DirtyState_UpToDate){
|
||||
result = 1;
|
||||
if (file != 0){
|
||||
b32 skip_save = false;
|
||||
if (!(flags & BufferSave_IgnoreDirtyFlag)){
|
||||
if (file_get_sync(file) == DirtyState_UpToDate){
|
||||
skip_save = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!skip_save){
|
||||
result = true;
|
||||
|
||||
Partition *part = &models->mem.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);
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#if !defined(FTECH_DEFINES)
|
||||
#define FTECH_DEFINES
|
||||
|
||||
#include "4ed_os_comp_cracking.h"
|
||||
#include "4coder_os_comp_cracking.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -546,7 +546,7 @@ save_file_to_name(System_Functions *system, Models *models, Editing_File *file,
|
|||
result = system->save_file(filename, data, size);
|
||||
|
||||
if (result && using_actual_filename){
|
||||
file->state.ignore_behind_os = true;
|
||||
file->state.ignore_behind_os = 1;
|
||||
}
|
||||
|
||||
file_mark_clean(file);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#if !defined(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 <stdlib.h> // include system for linux (YAY!)
|
||||
|
|
|
@ -1203,7 +1203,7 @@ compile_meta_unit(char *code_directory, char **files, Meta_Keywords *meta_keywor
|
|||
char str_space[512];
|
||||
String name = make_fixed_width_string(str_space);
|
||||
append_sc(&name, code_directory);
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
append_sc(&name, "\\");
|
||||
#else
|
||||
append_sc(&name, "/");
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// TOP
|
||||
|
||||
#define IS_PLAT_LAYER
|
||||
#include "4ed_os_comp_cracking.h"
|
||||
#include "4coder_os_comp_cracking.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "4ed_defines.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// TOP
|
||||
|
||||
#define IS_PLAT_LAYER
|
||||
#include "4ed_os_comp_cracking.h"
|
||||
#include "4coder_os_comp_cracking.h"
|
||||
|
||||
//
|
||||
// Program setup
|
||||
|
|
Loading…
Reference in New Issue