removed open, and open_background from the dact system
parent
d224d8cd7b
commit
bc15f0ed3c
109
4ed.cpp
109
4ed.cpp
|
@ -801,13 +801,9 @@ COMMAND_DECL(interactive_new){
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMAND_DECL(interactive_open){
|
COMMAND_DECL(interactive_open){
|
||||||
|
|
||||||
USE_MODELS(models);
|
USE_MODELS(models);
|
||||||
USE_PANEL(panel);
|
|
||||||
USE_VIEW(view);
|
USE_VIEW(view);
|
||||||
|
|
||||||
Delay *delay = &models->delay1;
|
|
||||||
|
|
||||||
char *filename = 0;
|
char *filename = 0;
|
||||||
int filename_len = 0;
|
int filename_len = 0;
|
||||||
int do_in_background = 0;
|
int do_in_background = 0;
|
||||||
|
@ -830,16 +826,10 @@ COMMAND_DECL(interactive_open){
|
||||||
if (filename){
|
if (filename){
|
||||||
String string = make_string(filename, filename_len);
|
String string = make_string(filename, filename_len);
|
||||||
if (do_in_background){
|
if (do_in_background){
|
||||||
delayed_open_background(delay, string);
|
view_open_file(system, models, 0, string);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// TODO(allen): Change the behavior of all delayed_open/background
|
view_open_file(system, models, view, string);
|
||||||
// calls so that they still allocate the buffer right away. This way
|
|
||||||
// it's still possible to get at the buffer if so wished in the API.
|
|
||||||
// The switch for this view doesn't need to happen until the file is ready.
|
|
||||||
//
|
|
||||||
// Alternatively... fuck all delayed actions. Please make them go away.
|
|
||||||
delayed_open(delay, string, panel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -848,54 +838,6 @@ COMMAND_DECL(interactive_open){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
|
||||||
view_file_in_panel(Command_Data *cmd, Panel *panel, Editing_File *file){
|
|
||||||
Models *models = cmd->models;
|
|
||||||
|
|
||||||
Partition old_part;
|
|
||||||
Temp_Memory temp;
|
|
||||||
View *old_view;
|
|
||||||
Partition *part;
|
|
||||||
|
|
||||||
old_view = cmd->view;
|
|
||||||
old_part = cmd->part;
|
|
||||||
|
|
||||||
cmd->view = panel->view;
|
|
||||||
part = &models->mem.part;
|
|
||||||
temp = begin_temp_memory(part);
|
|
||||||
cmd->part = partition_sub_part(part, Kbytes(16));
|
|
||||||
|
|
||||||
View *view = panel->view;
|
|
||||||
view_set_file(view, file, models);
|
|
||||||
view_show_file(view);
|
|
||||||
|
|
||||||
cmd->part = old_part;
|
|
||||||
end_temp_memory(temp);
|
|
||||||
cmd->view = old_view;
|
|
||||||
|
|
||||||
panel->view->map = get_map(models, file->settings.base_map_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void
|
|
||||||
init_normal_file(System_Functions *system, Models *models, Editing_File *file,
|
|
||||||
char *buffer, i32 size){
|
|
||||||
|
|
||||||
General_Memory *general = &models->mem.general;
|
|
||||||
|
|
||||||
String val = make_string(buffer, size);
|
|
||||||
file_create_from_string(system, models, file, file->name.source_path.str, val);
|
|
||||||
|
|
||||||
if (file->settings.tokens_exist){
|
|
||||||
file_first_lex_parallel(system, general, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (View_Iter iter = file_view_iter_init(&models->layout, file, 0);
|
|
||||||
file_view_iter_good(iter);
|
|
||||||
iter = file_view_iter_next(iter)){
|
|
||||||
view_measure_wraps(general, iter.view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(allen): Improvements to reopen
|
// TODO(allen): Improvements to reopen
|
||||||
// - Preserve existing token stack
|
// - Preserve existing token stack
|
||||||
// - Keep current version open and do some sort of diff to keep
|
// - Keep current version open and do some sort of diff to keep
|
||||||
|
@ -1601,10 +1543,8 @@ COMMAND_DECL(set_settings){
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMAND_DECL(command_line){
|
COMMAND_DECL(command_line){
|
||||||
|
|
||||||
USE_VARS(vars);
|
USE_VARS(vars);
|
||||||
USE_MODELS(models);
|
USE_MODELS(models);
|
||||||
USE_PANEL(panel);
|
|
||||||
USE_VIEW(view);
|
USE_VIEW(view);
|
||||||
|
|
||||||
Partition *part = &models->mem.part;
|
Partition *part = &models->mem.part;
|
||||||
|
@ -1784,7 +1724,7 @@ COMMAND_DECL(command_line){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bind_to_new_view){
|
if (bind_to_new_view){
|
||||||
view_file_in_panel(command, panel, file);
|
view_set_file(view, file, models);
|
||||||
}
|
}
|
||||||
|
|
||||||
proc = procs + vars->cli_processes.count++;
|
proc = procs + vars->cli_processes.count++;
|
||||||
|
@ -3878,26 +3818,26 @@ App_Step_Sig(app_step){
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 i;
|
i32 i;
|
||||||
String file_name;
|
String filename;
|
||||||
Panel *panel = models->layout.used_sentinel.next;
|
Panel *panel = models->layout.used_sentinel.next;
|
||||||
for (i = 0;
|
for (i = 0;
|
||||||
i < models->settings.init_files_count;
|
i < models->settings.init_files_count;
|
||||||
++i, panel = panel->next){
|
++i, panel = panel->next){
|
||||||
file_name = make_string_slowly(models->settings.init_files[i]);
|
filename = make_string_slowly(models->settings.init_files[i]);
|
||||||
|
|
||||||
if (i < models->layout.panel_count){
|
if (i < models->layout.panel_count){
|
||||||
delayed_open(&models->delay1, file_name, panel);
|
view_open_file(system, models, panel->view, filename);
|
||||||
if (i == 0){
|
if (i == 0){
|
||||||
delayed_set_line(&models->delay1, panel, models->settings.initial_line);
|
delayed_set_line(&models->delay1, panel, models->settings.initial_line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
delayed_open_background(&models->delay1, file_name);
|
view_open_file(system, models, 0, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < models->layout.panel_count){
|
if (i < models->layout.panel_count){
|
||||||
view_file_in_panel(cmd, panel, models->message_buffer);
|
view_set_file(panel->view, models->message_buffer, models);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4361,7 +4301,6 @@ App_Step_Sig(app_step){
|
||||||
Working_Set *working_set = &models->working_set;
|
Working_Set *working_set = &models->working_set;
|
||||||
Mem_Options *mem = &models->mem;
|
Mem_Options *mem = &models->mem;
|
||||||
General_Memory *general = &mem->general;
|
General_Memory *general = &mem->general;
|
||||||
Partition *part = &mem->part;
|
|
||||||
|
|
||||||
i32 count = models->delay1.count;
|
i32 count = models->delay1.count;
|
||||||
models->delay1.count = 0;
|
models->delay1.count = 0;
|
||||||
|
@ -4383,41 +4322,13 @@ App_Step_Sig(app_step){
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
#if 0
|
||||||
case DACT_OPEN:
|
case DACT_OPEN:
|
||||||
case DACT_OPEN_BACKGROUND:
|
case DACT_OPEN_BACKGROUND:
|
||||||
{
|
{
|
||||||
String filename = string;
|
|
||||||
Editing_File *file = working_set_contains(system, working_set, filename);
|
|
||||||
|
|
||||||
if (file == 0){
|
|
||||||
File_Loading loading = system->file_load_begin(filename.str);
|
|
||||||
|
|
||||||
if (loading.exists){
|
|
||||||
Temp_Memory temp = begin_temp_memory(part);
|
|
||||||
char *buffer = push_array(part, char, loading.size);
|
|
||||||
|
|
||||||
if (system->file_load_end(loading, buffer)){
|
|
||||||
file = working_set_alloc_always(working_set, general);
|
|
||||||
if (file){
|
|
||||||
file_init_strings(file);
|
|
||||||
file_set_name(working_set, file, filename.str);
|
|
||||||
working_set_add(system, working_set, file, general);
|
|
||||||
|
|
||||||
init_normal_file(system, models, file,
|
|
||||||
buffer, loading.size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end_temp_memory(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file){
|
|
||||||
if (act->type == DACT_OPEN){
|
|
||||||
view_file_in_panel(cmd, panel, file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}break;
|
}break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case DACT_SET_LINE:
|
case DACT_SET_LINE:
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
enum Action_Type{
|
enum Action_Type{
|
||||||
DACT_OPEN,
|
|
||||||
DACT_OPEN_BACKGROUND,
|
|
||||||
DACT_SET_LINE,
|
DACT_SET_LINE,
|
||||||
DACT_SWITCH,
|
DACT_SWITCH,
|
||||||
DACT_TRY_KILL,
|
DACT_TRY_KILL,
|
||||||
|
@ -124,8 +122,6 @@ delayed_action_repush(Delay *delay, Delayed_Action *act){
|
||||||
return(new_act);
|
return(new_act);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define delayed_open(delay, ...) delayed_action_(delay, DACT_OPEN, ##__VA_ARGS__)
|
|
||||||
#define delayed_open_background(delay, ...) delayed_action_(delay, DACT_OPEN_BACKGROUND, ##__VA_ARGS__)
|
|
||||||
#define delayed_set_line(delay, ...) delayed_action_(delay, DACT_SET_LINE, ##__VA_ARGS__)
|
#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_switch(delay, ...) delayed_action_(delay, DACT_SWITCH, ##__VA_ARGS__)
|
||||||
#define delayed_try_kill(delay, ...) delayed_action_(delay, DACT_TRY_KILL, ##__VA_ARGS__)
|
#define delayed_try_kill(delay, ...) delayed_action_(delay, DACT_TRY_KILL, ##__VA_ARGS__)
|
||||||
|
|
|
@ -3072,6 +3072,65 @@ view_new_file(System_Functions *system, Models *models,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
init_normal_file(System_Functions *system, Models *models, Editing_File *file,
|
||||||
|
char *buffer, i32 size){
|
||||||
|
|
||||||
|
General_Memory *general = &models->mem.general;
|
||||||
|
|
||||||
|
String val = make_string(buffer, size);
|
||||||
|
file_create_from_string(system, models, file, file->name.source_path.str, val);
|
||||||
|
|
||||||
|
if (file->settings.tokens_exist){
|
||||||
|
file_first_lex_parallel(system, general, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (View_Iter iter = file_view_iter_init(&models->layout, file, 0);
|
||||||
|
file_view_iter_good(iter);
|
||||||
|
iter = file_view_iter_next(iter)){
|
||||||
|
view_measure_wraps(general, iter.view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
view_open_file(System_Functions *system, Models *models,
|
||||||
|
View *view, String filename){
|
||||||
|
Working_Set *working_set = &models->working_set;
|
||||||
|
General_Memory *general = &models->mem.general;
|
||||||
|
Partition *part = &models->mem.part;
|
||||||
|
|
||||||
|
Editing_File *file = working_set_contains(system, working_set, filename);
|
||||||
|
|
||||||
|
if (file == 0){
|
||||||
|
File_Loading loading = system->file_load_begin(filename.str);
|
||||||
|
|
||||||
|
if (loading.exists){
|
||||||
|
Temp_Memory temp = begin_temp_memory(part);
|
||||||
|
char *buffer = push_array(part, char, loading.size);
|
||||||
|
|
||||||
|
if (system->file_load_end(loading, buffer)){
|
||||||
|
file = working_set_alloc_always(working_set, general);
|
||||||
|
if (file){
|
||||||
|
file_init_strings(file);
|
||||||
|
file_set_name(working_set, file, filename.str);
|
||||||
|
working_set_add(system, working_set, file, general);
|
||||||
|
|
||||||
|
init_normal_file(system, models, file,
|
||||||
|
buffer, loading.size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end_temp_memory(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file){
|
||||||
|
if (view){
|
||||||
|
view_set_file(view, file, models);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
interactive_view_complete(System_Functions *system, View *view, String dest, i32 user_action){
|
interactive_view_complete(System_Functions *system, View *view, String dest, i32 user_action){
|
||||||
Models *models = view->persistent.models;
|
Models *models = view->persistent.models;
|
||||||
|
@ -3080,7 +3139,7 @@ interactive_view_complete(System_Functions *system, View *view, String dest, i32
|
||||||
|
|
||||||
switch (view->action){
|
switch (view->action){
|
||||||
case IAct_Open:
|
case IAct_Open:
|
||||||
delayed_open(&models->delay1, dest, panel);
|
view_open_file(system, models, view, dest);
|
||||||
delayed_touch_file(&models->delay1, old_file);
|
delayed_touch_file(&models->delay1, old_file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -146,8 +146,10 @@ char* generate_keycode_enum(){
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
char daction_enum_name[] = "Action_Type";
|
char daction_enum_name[] = "Action_Type";
|
||||||
char *daction_enum[] = {
|
char *daction_enum[] = {
|
||||||
|
#if 0
|
||||||
"OPEN",
|
"OPEN",
|
||||||
"OPEN_BACKGROUND",
|
"OPEN_BACKGROUND",
|
||||||
|
#endif
|
||||||
"SET_LINE",
|
"SET_LINE",
|
||||||
#if 0
|
#if 0
|
||||||
"SAVE_AS",
|
"SAVE_AS",
|
||||||
|
|
Loading…
Reference in New Issue