removed kill from the dact system
parent
bc15f0ed3c
commit
37e0b17e7c
30
4ed.cpp
30
4ed.cpp
|
@ -907,8 +907,7 @@ COMMAND_DECL(save){
|
|||
if (file){
|
||||
if (name.str){
|
||||
if (!file->state.is_dummy && file_is_ready(file)){
|
||||
view_save_file(system, &models->mem, &models->working_set,
|
||||
file, 0, name, 1);
|
||||
view_save_file(system, models, file, 0, name, 1);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
@ -929,13 +928,11 @@ COMMAND_DECL(save){
|
|||
if (name.size != 0){
|
||||
if (file){
|
||||
if (!file->state.is_dummy && file_is_ready(file)){
|
||||
view_save_file(system, &models->mem, &models->working_set,
|
||||
file, 0, name, 0);
|
||||
view_save_file(system, models, file, 0, name, 0);
|
||||
}
|
||||
}
|
||||
else{
|
||||
view_save_file(system, &models->mem, &models->working_set,
|
||||
0, 0, name, 0);
|
||||
view_save_file(system, models, 0, 0, name, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -992,7 +989,7 @@ COMMAND_DECL(kill_buffer){
|
|||
if (buffer_id != 0){
|
||||
file = working_set_get_active_file(&models->working_set, buffer_id);
|
||||
if (file){
|
||||
delayed_kill(delay, file);
|
||||
kill_file(system, models, file, string_zero());
|
||||
}
|
||||
}
|
||||
else if (file){
|
||||
|
@ -4382,20 +4379,12 @@ App_Step_Sig(app_step){
|
|||
}
|
||||
}break;
|
||||
|
||||
#if 0
|
||||
case DACT_KILL:
|
||||
{
|
||||
if (!file && string.str){
|
||||
file = working_set_lookup_file(working_set, string);
|
||||
if (!file){
|
||||
file = working_set_contains(system, working_set, string);
|
||||
}
|
||||
}
|
||||
|
||||
if (file && !file->settings.never_kill){
|
||||
working_set_remove(system, working_set, file->name.source_path);
|
||||
kill_file(system, exchange, models, file);
|
||||
}
|
||||
}break;
|
||||
#endif
|
||||
|
||||
case DACT_TRY_KILL:
|
||||
{
|
||||
|
@ -4416,13 +4405,14 @@ App_Step_Sig(app_step){
|
|||
|
||||
if (file && !file->settings.never_kill){
|
||||
if (buffer_needs_save(file)){
|
||||
copy(&view->dest, file->name.live_name);
|
||||
view_show_interactive(system, view, &models->map_ui,
|
||||
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(&view->dest, file->name.live_name);
|
||||
}
|
||||
else{
|
||||
working_set_remove(system, working_set, file->name.source_path);
|
||||
kill_file(system, exchange, models, file);
|
||||
kill_file(system, models, file, string_zero());
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
|
|
@ -2,7 +2,6 @@ enum Action_Type{
|
|||
DACT_SET_LINE,
|
||||
DACT_SWITCH,
|
||||
DACT_TRY_KILL,
|
||||
DACT_KILL,
|
||||
DACT_TOUCH_FILE,
|
||||
DACT_CLOSE,
|
||||
};
|
||||
|
@ -125,6 +124,5 @@ delayed_action_repush(Delay *delay, Delayed_Action *act){
|
|||
#define delayed_set_line(delay, ...) delayed_action_(delay, DACT_SET_LINE, ##__VA_ARGS__)
|
||||
#define delayed_switch(delay, ...) delayed_action_(delay, DACT_SWITCH, ##__VA_ARGS__)
|
||||
#define delayed_try_kill(delay, ...) delayed_action_(delay, DACT_TRY_KILL, ##__VA_ARGS__)
|
||||
#define delayed_kill(delay, ...) delayed_action_(delay, DACT_KILL, ##__VA_ARGS__)
|
||||
#define delayed_touch_file(delay, ...) delayed_action_(delay, DACT_TOUCH_FILE, ##__VA_ARGS__)
|
||||
#define delayed_close(delay, ...) delayed_action_(delay, DACT_CLOSE, ##__VA_ARGS__)
|
||||
|
|
|
@ -3023,8 +3023,11 @@ view_show_file(View *view){
|
|||
}
|
||||
|
||||
internal void
|
||||
view_save_file(System_Functions *system, Mem_Options *mem, Working_Set *working_set,
|
||||
view_save_file(System_Functions *system, Models *models,
|
||||
Editing_File *file, View *view, String filename, b32 save_as){
|
||||
Mem_Options *mem = &models->mem;
|
||||
Working_Set *working_set = &models->working_set;
|
||||
|
||||
if (!file){
|
||||
if (view){
|
||||
file = view->file_data.file;
|
||||
|
@ -3131,6 +3134,41 @@ view_open_file(System_Functions *system, Models *models,
|
|||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
kill_file(System_Functions *system, Models *models,
|
||||
Editing_File *file, String string){
|
||||
Working_Set *working_set = &models->working_set;
|
||||
|
||||
if (!file && string.str){
|
||||
file = working_set_lookup_file(working_set, string);
|
||||
if (!file){
|
||||
file = working_set_contains(system, working_set, string);
|
||||
}
|
||||
}
|
||||
|
||||
if (file && !file->settings.never_kill){
|
||||
working_set_remove(system, working_set, file->name.source_path);
|
||||
file_close(system, &models->mem.general, file);
|
||||
working_set_free_file(&models->working_set, file);
|
||||
|
||||
File_Node *used = &models->working_set.used_sentinel;
|
||||
File_Node *node = used->next;
|
||||
for (View_Iter iter = file_view_iter_init(&models->layout, file, 0);
|
||||
file_view_iter_good(iter);
|
||||
iter = file_view_iter_next(iter)){
|
||||
if (node != used){
|
||||
iter.view->file_data.file = 0;
|
||||
view_set_file(iter.view, (Editing_File*)node, models);
|
||||
node = node->next;
|
||||
}
|
||||
else{
|
||||
iter.view->file_data.file = 0;
|
||||
view_set_file(iter.view, 0, models);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
interactive_view_complete(System_Functions *system, View *view, String dest, i32 user_action){
|
||||
Models *models = view->persistent.models;
|
||||
|
@ -3144,8 +3182,7 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32
|
|||
break;
|
||||
|
||||
case IAct_Save_As:
|
||||
view_save_file(system, &models->mem, &models->working_set,
|
||||
0, view, dest, 1);
|
||||
view_save_file(system, models, 0, view, dest, 1);
|
||||
break;
|
||||
|
||||
case IAct_New:
|
||||
|
@ -3182,16 +3219,15 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32
|
|||
case IAct_Sure_To_Kill:
|
||||
switch (user_action){
|
||||
case 0:
|
||||
delayed_kill(&models->delay1, dest);
|
||||
kill_file(system, models, 0, dest);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
break;
|
||||
|
||||
case 2:
|
||||
view_save_file(system, &models->mem, &models->working_set,
|
||||
0, 0, dest, 0);
|
||||
delayed_kill(&models->delay1, dest);
|
||||
view_save_file(system, models, 0, 0, dest, 0);
|
||||
kill_file(system, models, 0, dest);;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -5271,31 +5307,6 @@ do_render_file_view(System_Functions *system, Exchange *exchange,
|
|||
return(result);
|
||||
}
|
||||
|
||||
internal void
|
||||
kill_file(System_Functions *system, Exchange *exchange, Models *models, Editing_File *file){
|
||||
File_Node *node, *used;
|
||||
|
||||
file_close(system, &models->mem.general, file);
|
||||
working_set_free_file(&models->working_set, file);
|
||||
|
||||
used = &models->working_set.used_sentinel;
|
||||
node = used->next;
|
||||
|
||||
for (View_Iter iter = file_view_iter_init(&models->layout, file, 0);
|
||||
file_view_iter_good(iter);
|
||||
iter = file_view_iter_next(iter)){
|
||||
if (node != used){
|
||||
iter.view->file_data.file = 0;
|
||||
view_set_file(iter.view, (Editing_File*)node, models);
|
||||
node = node->next;
|
||||
}
|
||||
else{
|
||||
iter.view->file_data.file = 0;
|
||||
view_set_file(iter.view, 0, models);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
file_view_free_buffers(View *view){
|
||||
General_Memory *general = &view->persistent.models->mem.general;
|
||||
|
|
|
@ -158,8 +158,11 @@ char *daction_enum[] = {
|
|||
#endif
|
||||
"SWITCH",
|
||||
"TRY_KILL",
|
||||
#if 0
|
||||
"KILL",
|
||||
#endif
|
||||
"TOUCH_FILE",
|
||||
|
||||
"CLOSE",
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue