removed the delayed action system
This commit is contained in:
parent
5275ac5823
commit
17dfa93c34
136
4ed.cpp
136
4ed.cpp
|
@ -906,7 +906,7 @@ COMMAND_DECL(save){
|
||||||
|
|
||||||
if (file){
|
if (file){
|
||||||
if (name.str){
|
if (name.str){
|
||||||
if (!file->state.is_dummy && file_is_ready(file)){
|
if (!file->is_dummy && file_is_ready(file)){
|
||||||
view_save_file(system, models, file, 0, name, 1);
|
view_save_file(system, models, file, 0, name, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -927,7 +927,7 @@ COMMAND_DECL(save){
|
||||||
|
|
||||||
if (name.size != 0){
|
if (name.size != 0){
|
||||||
if (file){
|
if (file){
|
||||||
if (!file->state.is_dummy && file_is_ready(file)){
|
if (!file->is_dummy && file_is_ready(file)){
|
||||||
view_save_file(system, models, file, 0, name, 0);
|
view_save_file(system, models, file, 0, name, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1751,7 +1751,7 @@ globalvar Command_Function command_table[cmdid_count];
|
||||||
internal void
|
internal void
|
||||||
fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *working_set){
|
fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *working_set){
|
||||||
*buffer = buffer_summary_zero();
|
*buffer = buffer_summary_zero();
|
||||||
if (!file->state.is_dummy){
|
if (!file->is_dummy){
|
||||||
buffer->exists = 1;
|
buffer->exists = 1;
|
||||||
buffer->ready = file_is_ready(file);
|
buffer->ready = file_is_ready(file);
|
||||||
|
|
||||||
|
@ -1952,7 +1952,7 @@ extern "C"{
|
||||||
Working_Set *working_set = &cmd->models->working_set;
|
Working_Set *working_set = &cmd->models->working_set;
|
||||||
|
|
||||||
file = working_set_contains(cmd->system, working_set, make_string(filename, len));
|
file = working_set_contains(cmd->system, working_set, make_string(filename, len));
|
||||||
if (file && !file->state.is_dummy){
|
if (file && !file->is_dummy){
|
||||||
fill_buffer_summary(&buffer, file, working_set);
|
fill_buffer_summary(&buffer, file, working_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2241,7 +2241,7 @@ extern "C"{
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
if (view_id >= 0 && view_id < live_set->max){
|
||||||
vptr = live_set->views + view_id;
|
vptr = live_set->views + view_id;
|
||||||
file = vptr->file_data.file;
|
file = vptr->file_data.file;
|
||||||
if (file && !file->state.is_loading){
|
if (file && !file->is_loading){
|
||||||
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
||||||
seek.character = 1;
|
seek.character = 1;
|
||||||
}
|
}
|
||||||
|
@ -2268,7 +2268,7 @@ extern "C"{
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
if (view_id >= 0 && view_id < live_set->max){
|
||||||
vptr = live_set->views + view_id;
|
vptr = live_set->views + view_id;
|
||||||
file = vptr->file_data.file;
|
file = vptr->file_data.file;
|
||||||
if (file && !file->state.is_loading){
|
if (file && !file->is_loading){
|
||||||
result = 1;
|
result = 1;
|
||||||
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
||||||
seek.character = 1;
|
seek.character = 1;
|
||||||
|
@ -3415,17 +3415,6 @@ App_Init_Sig(app_init){
|
||||||
copy(dest, make_string((char*)clipboard.str, clipboard.size));
|
copy(dest, make_string((char*)clipboard.str, clipboard.size));
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(allen): delay setup
|
|
||||||
models->delay1.general = &models->mem.general;
|
|
||||||
models->delay1.max = 16;
|
|
||||||
models->delay1.acts = (Delayed_Action*)general_memory_allocate(
|
|
||||||
&models->mem.general, models->delay1.max*sizeof(Delayed_Action), 0);
|
|
||||||
|
|
||||||
models->delay2.general = &models->mem.general;
|
|
||||||
models->delay2.max = 16;
|
|
||||||
models->delay2.acts = (Delayed_Action*)general_memory_allocate(
|
|
||||||
&models->mem.general, models->delay2.max*sizeof(Delayed_Action), 0);
|
|
||||||
|
|
||||||
// NOTE(allen): style setup
|
// NOTE(allen): style setup
|
||||||
app_hardcode_styles(models);
|
app_hardcode_styles(models);
|
||||||
|
|
||||||
|
@ -3824,10 +3813,16 @@ App_Step_Sig(app_step){
|
||||||
|
|
||||||
if (i < models->layout.panel_count){
|
if (i < models->layout.panel_count){
|
||||||
view_open_file(system, models, panel->view, filename);
|
view_open_file(system, models, panel->view, filename);
|
||||||
|
#if 0
|
||||||
if (i == 0){
|
if (i == 0){
|
||||||
delayed_set_line(&models->delay1, panel, models->settings.initial_line);
|
if (panel->view->file_data.file){
|
||||||
|
// TODO(allen): How to set the cursor of a file on the first frame?
|
||||||
|
view_compute_cursor_from_line_pos(panel->view, models->settings.initial_line, 1);
|
||||||
|
view_move_view_to_cursor(panel->view, &panel->view->recent->scroll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
view_open_file(system, models, 0, filename);
|
view_open_file(system, models, 0, filename);
|
||||||
}
|
}
|
||||||
|
@ -4293,111 +4288,6 @@ App_Step_Sig(app_step){
|
||||||
|
|
||||||
update_command_data(vars, cmd);
|
update_command_data(vars, cmd);
|
||||||
|
|
||||||
// NOTE(allen): process as many delayed actions as possible
|
|
||||||
if (models->delay1.count > 0){
|
|
||||||
Working_Set *working_set = &models->working_set;
|
|
||||||
Mem_Options *mem = &models->mem;
|
|
||||||
General_Memory *general = &mem->general;
|
|
||||||
|
|
||||||
i32 count = models->delay1.count;
|
|
||||||
models->delay1.count = 0;
|
|
||||||
models->delay2.count = 0;
|
|
||||||
|
|
||||||
Delayed_Action *act = models->delay1.acts;
|
|
||||||
for (i32 i = 0; i < count; ++i, ++act){
|
|
||||||
String string = act->string;
|
|
||||||
Panel *panel = act->panel;
|
|
||||||
Editing_File *file = act->file;
|
|
||||||
i32 integer = act->integer;
|
|
||||||
|
|
||||||
// TODO(allen): Paramter checking in each DACT case.
|
|
||||||
switch (act->type){
|
|
||||||
#if 0
|
|
||||||
case DACT_TOUCH_FILE:
|
|
||||||
{
|
|
||||||
|
|
||||||
}break;
|
|
||||||
#endif
|
|
||||||
#if 0
|
|
||||||
case DACT_OPEN:
|
|
||||||
case DACT_OPEN_BACKGROUND:
|
|
||||||
{
|
|
||||||
|
|
||||||
}break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case DACT_SET_LINE:
|
|
||||||
{
|
|
||||||
// TODO(allen): deduplicate
|
|
||||||
if (panel){
|
|
||||||
file = panel->view->file_data.file;
|
|
||||||
}
|
|
||||||
else if (string.str && string.size > 0){
|
|
||||||
file = working_set_lookup_file(working_set, string);
|
|
||||||
}
|
|
||||||
if (file){
|
|
||||||
if (file->state.is_loading){
|
|
||||||
file->preload.start_line = integer;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// TODO(allen): write this case
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}break;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
case DACT_SAVE:
|
|
||||||
case DACT_SAVE_AS:
|
|
||||||
{
|
|
||||||
|
|
||||||
}break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
case DACT_NEW:
|
|
||||||
{
|
|
||||||
|
|
||||||
}break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
case DACT_SWITCH:
|
|
||||||
{
|
|
||||||
|
|
||||||
}break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
case DACT_KILL:
|
|
||||||
{
|
|
||||||
|
|
||||||
}break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
case DACT_TRY_KILL:
|
|
||||||
{
|
|
||||||
|
|
||||||
}break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
case DACT_CLOSE:
|
|
||||||
{
|
|
||||||
|
|
||||||
}break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.str){
|
|
||||||
general_memory_free(general, string.str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Swap(Delay, models->delay1, models->delay2);
|
|
||||||
}
|
|
||||||
|
|
||||||
end_temp_memory(param_stack_temp);
|
end_temp_memory(param_stack_temp);
|
||||||
|
|
||||||
// NOTE(allen): send resize messages to panels that have changed size
|
// NOTE(allen): send resize messages to panels that have changed size
|
||||||
|
|
|
@ -58,8 +58,6 @@ struct Models{
|
||||||
char hot_dir_base_[256];
|
char hot_dir_base_[256];
|
||||||
Hot_Directory hot_directory;
|
Hot_Directory hot_directory;
|
||||||
|
|
||||||
Delay delay1, delay2;
|
|
||||||
|
|
||||||
Panel *prev_mouse_panel;
|
Panel *prev_mouse_panel;
|
||||||
|
|
||||||
Custom_API config_api;
|
Custom_API config_api;
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
#include "4ed_file.cpp"
|
#include "4ed_file.cpp"
|
||||||
#include "4ed_gui.cpp"
|
#include "4ed_gui.cpp"
|
||||||
#include "4ed_layout.cpp"
|
#include "4ed_layout.cpp"
|
||||||
#include "4ed_delay.cpp"
|
|
||||||
#include "4ed_app_models.h"
|
#include "4ed_app_models.h"
|
||||||
#include "4ed_file_view.cpp"
|
#include "4ed_file_view.cpp"
|
||||||
#include "4ed.cpp"
|
#include "4ed.cpp"
|
||||||
|
|
120
4ed_delay.cpp
120
4ed_delay.cpp
|
@ -1,120 +0,0 @@
|
||||||
enum Action_Type{
|
|
||||||
DACT_SET_LINE,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Delayed_Action{
|
|
||||||
Action_Type type;
|
|
||||||
String string;
|
|
||||||
Panel* panel;
|
|
||||||
Editing_File* file;
|
|
||||||
i32 integer;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Delay{
|
|
||||||
General_Memory* general;
|
|
||||||
Delayed_Action* acts;
|
|
||||||
i32 count;
|
|
||||||
i32 max;
|
|
||||||
};
|
|
||||||
|
|
||||||
internal String
|
|
||||||
str_alloc_copy(General_Memory *general, String str){
|
|
||||||
String result;
|
|
||||||
result.memory_size = str.memory_size + 1;
|
|
||||||
result.size = str.size;
|
|
||||||
result.str = (char*)general_memory_allocate(general, result.memory_size, 0);
|
|
||||||
memcpy(result.str, str.str, str.size);
|
|
||||||
result.str[result.size] = 0;
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Delayed_Action
|
|
||||||
delayed_action_zero(){
|
|
||||||
Delayed_Action result = {(Action_Type)0};
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Delayed_Action*
|
|
||||||
delayed_action_(Delay *delay, Action_Type type){
|
|
||||||
Delayed_Action *result;
|
|
||||||
if (delay->count == delay->max){
|
|
||||||
delay->max *= 2;
|
|
||||||
delay->acts = (Delayed_Action*)general_memory_reallocate(delay->general, delay->acts, delay->count*sizeof(Delayed_Action), delay->max*sizeof(Delayed_Action), 0);
|
|
||||||
}
|
|
||||||
result = delay->acts + delay->count++;
|
|
||||||
*result = delayed_action_zero();
|
|
||||||
result->type = type;
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Delayed_Action*
|
|
||||||
delayed_action_(Delay *delay, Action_Type type, String string){
|
|
||||||
Delayed_Action *result;
|
|
||||||
result = delayed_action_(delay, type);
|
|
||||||
result->string = str_alloc_copy(delay->general, string);
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Delayed_Action*
|
|
||||||
delayed_action_(Delay *delay, Action_Type type, Panel* panel){
|
|
||||||
Delayed_Action *result;
|
|
||||||
result = delayed_action_(delay, type);
|
|
||||||
result->panel = panel;
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Delayed_Action*
|
|
||||||
delayed_action_(Delay *delay, Action_Type type, Editing_File* file){
|
|
||||||
Delayed_Action *result;
|
|
||||||
result = delayed_action_(delay, type);
|
|
||||||
result->file = file;
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Delayed_Action*
|
|
||||||
delayed_action_(Delay *delay, Action_Type type, Editing_File* file, Panel* panel){
|
|
||||||
Delayed_Action *result;
|
|
||||||
result = delayed_action_(delay, type);
|
|
||||||
result->file = file;
|
|
||||||
result->panel = panel;
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Delayed_Action*
|
|
||||||
delayed_action_(Delay *delay, Action_Type type, String string, Panel* panel){
|
|
||||||
Delayed_Action *result;
|
|
||||||
result = delayed_action_(delay, type);
|
|
||||||
result->string = str_alloc_copy(delay->general, string);
|
|
||||||
result->panel = panel;
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Delayed_Action*
|
|
||||||
delayed_action_(Delay *delay, Action_Type type, String string, Editing_File* file){
|
|
||||||
Delayed_Action *result;
|
|
||||||
result = delayed_action_(delay, type);
|
|
||||||
result->string = str_alloc_copy(delay->general, string);
|
|
||||||
result->file = file;
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Delayed_Action*
|
|
||||||
delayed_action_(Delay *delay, Action_Type type, Panel* panel, i32 integer){
|
|
||||||
Delayed_Action *result;
|
|
||||||
result = delayed_action_(delay, type);
|
|
||||||
result->panel = panel;
|
|
||||||
result->integer = integer;
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Delayed_Action*
|
|
||||||
delayed_action_repush(Delay *delay, Delayed_Action *act){
|
|
||||||
Delayed_Action *new_act = delayed_action_(delay, (Action_Type)0);
|
|
||||||
*new_act = *act;
|
|
||||||
if (act->string.str){
|
|
||||||
new_act->string = str_alloc_copy(delay->general, act->string);
|
|
||||||
}
|
|
||||||
return(new_act);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define delayed_set_line(delay, ...) delayed_action_(delay, DACT_SET_LINE, ##__VA_ARGS__)
|
|
24
4ed_file.cpp
24
4ed_file.cpp
|
@ -111,9 +111,6 @@ struct Editing_File_Settings{
|
||||||
// NOTE(allen): This part of the Editing_File is cleared whenever
|
// NOTE(allen): This part of the Editing_File is cleared whenever
|
||||||
// the contents of the file is set.
|
// the contents of the file is set.
|
||||||
struct Editing_File_State{
|
struct Editing_File_State{
|
||||||
b32 is_dummy;
|
|
||||||
b32 is_loading;
|
|
||||||
|
|
||||||
i16 font_id;
|
i16 font_id;
|
||||||
Buffer_Type buffer;
|
Buffer_Type buffer;
|
||||||
|
|
||||||
|
@ -135,10 +132,6 @@ struct Editing_File_State{
|
||||||
u64 last_sys_write_time;
|
u64 last_sys_write_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Editing_File_Preload{
|
|
||||||
i32 start_line;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Editing_File_Name{
|
struct Editing_File_Name{
|
||||||
char live_name_[256];
|
char live_name_[256];
|
||||||
char source_path_[256];
|
char source_path_[256];
|
||||||
|
@ -168,9 +161,10 @@ struct Editing_File{
|
||||||
// NOTE(allen): node must be the first member of Editing_File!
|
// NOTE(allen): node must be the first member of Editing_File!
|
||||||
File_Node node;
|
File_Node node;
|
||||||
Editing_File_Settings settings;
|
Editing_File_Settings settings;
|
||||||
union{
|
struct{
|
||||||
|
b32 is_loading;
|
||||||
|
b32 is_dummy;
|
||||||
Editing_File_State state;
|
Editing_File_State state;
|
||||||
Editing_File_Preload preload;
|
|
||||||
};
|
};
|
||||||
Editing_File_Name name;
|
Editing_File_Name name;
|
||||||
Buffer_Slot_ID id;
|
Buffer_Slot_ID id;
|
||||||
|
@ -317,7 +311,7 @@ working_set_alloc_always(Working_Set *working_set, General_Memory *general){
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
working_set_free_file(Working_Set *working_set, Editing_File *file){
|
working_set_free_file(Working_Set *working_set, Editing_File *file){
|
||||||
file->state.is_dummy = 1;
|
file->is_dummy = 1;
|
||||||
dll_remove(&file->node);
|
dll_remove(&file->node);
|
||||||
dll_insert(&working_set->free_sentinel, &file->node);
|
dll_insert(&working_set->free_sentinel, &file->node);
|
||||||
--working_set->file_count;
|
--working_set->file_count;
|
||||||
|
@ -349,7 +343,7 @@ inline Editing_File*
|
||||||
working_set_get_active_file(Working_Set *working_set, Buffer_Slot_ID id){
|
working_set_get_active_file(Working_Set *working_set, Buffer_Slot_ID id){
|
||||||
Editing_File *result = 0;
|
Editing_File *result = 0;
|
||||||
result = working_set_index(working_set, id);
|
result = working_set_index(working_set, id);
|
||||||
if (result && result->state.is_dummy){
|
if (result && result->is_dummy){
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -383,7 +377,7 @@ working_set_init(Working_Set *working_set, Partition *partition, General_Memory
|
||||||
|
|
||||||
null_file = working_set_index(working_set, 0);
|
null_file = working_set_index(working_set, 0);
|
||||||
dll_remove(&null_file->node);
|
dll_remove(&null_file->node);
|
||||||
null_file->state.is_dummy = 1;
|
null_file->is_dummy = 1;
|
||||||
++working_set->file_count;
|
++working_set->file_count;
|
||||||
|
|
||||||
table_size = working_set->file_max;
|
table_size = working_set->file_max;
|
||||||
|
@ -489,7 +483,7 @@ working_set_lookup_file(Working_Set *working_set, String string){
|
||||||
internal void
|
internal void
|
||||||
touch_file(Working_Set *working_set, Editing_File *file){
|
touch_file(Working_Set *working_set, Editing_File *file){
|
||||||
if (file){
|
if (file){
|
||||||
Assert(!file->state.is_dummy);
|
Assert(!file->is_dummy);
|
||||||
dll_remove(&file->node);
|
dll_remove(&file->node);
|
||||||
dll_insert(&working_set->used_sentinel, &file->node);
|
dll_insert(&working_set->used_sentinel, &file->node);
|
||||||
}
|
}
|
||||||
|
@ -650,7 +644,7 @@ buffer_needs_save(Editing_File *file){
|
||||||
inline b32
|
inline b32
|
||||||
file_is_ready(Editing_File *file){
|
file_is_ready(Editing_File *file){
|
||||||
b32 result = 0;
|
b32 result = 0;
|
||||||
if (file && file->state.is_loading == 0){
|
if (file && file->is_loading == 0){
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -672,7 +666,7 @@ inline void
|
||||||
file_set_to_loading(Editing_File *file){
|
file_set_to_loading(Editing_File *file){
|
||||||
file->state = editing_file_state_zero();
|
file->state = editing_file_state_zero();
|
||||||
file->settings = editing_file_settings_zero();
|
file->settings = editing_file_settings_zero();
|
||||||
file->state.is_loading = 1;
|
file->is_loading = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
|
@ -627,7 +627,7 @@ view_compute_lowest_line(View *view){
|
||||||
f32 max_width = view_file_width(view);
|
f32 max_width = view_file_width(view);
|
||||||
|
|
||||||
Editing_File *file = view->file_data.file;
|
Editing_File *file = view->file_data.file;
|
||||||
Assert(!file->state.is_dummy);
|
Assert(!file->is_dummy);
|
||||||
f32 width = file->state.buffer.line_widths[last_line];
|
f32 width = file->state.buffer.line_widths[last_line];
|
||||||
i32 line_span = view_wrapped_line_span(width, max_width);
|
i32 line_span = view_wrapped_line_span(width, max_width);
|
||||||
lowest_line += line_span - 1;
|
lowest_line += line_span - 1;
|
||||||
|
@ -878,7 +878,7 @@ file_first_lex_parallel(System_Functions *system,
|
||||||
General_Memory *general, Editing_File *file){
|
General_Memory *general, Editing_File *file){
|
||||||
file->settings.tokens_exist = 1;
|
file->settings.tokens_exist = 1;
|
||||||
|
|
||||||
if (file->state.is_loading == 0 && file->state.still_lexing == 0){
|
if (file->is_loading == 0 && file->state.still_lexing == 0){
|
||||||
Assert(file->state.token_stack.tokens == 0);
|
Assert(file->state.token_stack.tokens == 0);
|
||||||
|
|
||||||
file->state.tokens_complete = 0;
|
file->state.tokens_complete = 0;
|
||||||
|
@ -2428,7 +2428,7 @@ view_clean_whitespace(System_Functions *system, Models *models, View *view){
|
||||||
i32 edit_max = line_count * 2;
|
i32 edit_max = line_count * 2;
|
||||||
i32 edit_count = 0;
|
i32 edit_count = 0;
|
||||||
|
|
||||||
Assert(file && !file->state.is_dummy);
|
Assert(file && !file->is_dummy);
|
||||||
|
|
||||||
Temp_Memory temp = begin_temp_memory(part);
|
Temp_Memory temp = begin_temp_memory(part);
|
||||||
Buffer_Edit *edits = push_array(part, Buffer_Edit, edit_max);
|
Buffer_Edit *edits = push_array(part, Buffer_Edit, edit_max);
|
||||||
|
@ -2844,7 +2844,7 @@ view_auto_tab_tokens(System_Functions *system, Models *models,
|
||||||
Partition *part = &mem->part;
|
Partition *part = &mem->part;
|
||||||
Buffer *buffer = &file->state.buffer;
|
Buffer *buffer = &file->state.buffer;
|
||||||
|
|
||||||
Assert(file && !file->state.is_dummy);
|
Assert(file && !file->is_dummy);
|
||||||
Cpp_Token_Stack tokens = file->state.token_stack;
|
Cpp_Token_Stack tokens = file->state.token_stack;
|
||||||
Assert(tokens.tokens);
|
Assert(tokens.tokens);
|
||||||
|
|
||||||
|
@ -3506,7 +3506,7 @@ internal b32
|
||||||
file_step(View *view, i32_Rect region, Input_Summary *user_input, b32 is_active){
|
file_step(View *view, i32_Rect region, Input_Summary *user_input, b32 is_active){
|
||||||
i32 is_animating = 0;
|
i32 is_animating = 0;
|
||||||
Editing_File *file = view->file_data.file;
|
Editing_File *file = view->file_data.file;
|
||||||
if (file && !file->state.is_loading){
|
if (file && !file->is_loading){
|
||||||
f32 max_visible_y = view_file_height(view);
|
f32 max_visible_y = view_file_height(view);
|
||||||
f32 max_x = view_file_width(view);
|
f32 max_x = view_file_width(view);
|
||||||
|
|
||||||
|
@ -4232,7 +4232,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
used_nodes = &working_set->used_sentinel;
|
used_nodes = &working_set->used_sentinel;
|
||||||
for (dll_items(node, used_nodes)){
|
for (dll_items(node, used_nodes)){
|
||||||
file = (Editing_File*)node;
|
file = (Editing_File*)node;
|
||||||
Assert(!file->state.is_dummy);
|
Assert(!file->is_dummy);
|
||||||
|
|
||||||
if (filename_match(view->dest, &absolutes, file->name.live_name, 1)){
|
if (filename_match(view->dest, &absolutes, file->name.live_name, 1)){
|
||||||
iter = file_view_iter_init(layout, file, 0);
|
iter = file_view_iter_init(layout, file, 0);
|
||||||
|
@ -4687,7 +4687,7 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
|
||||||
i32 max_x = rect.x1 - rect.x0;
|
i32 max_x = rect.x1 - rect.x0;
|
||||||
i32 max_y = rect.y1 - rect.y0 + line_height;
|
i32 max_y = rect.y1 - rect.y0 + line_height;
|
||||||
|
|
||||||
Assert(file && !file->state.is_dummy && buffer_good(&file->state.buffer));
|
Assert(file && !file->is_dummy && buffer_good(&file->state.buffer));
|
||||||
|
|
||||||
b32 tokens_use = 0;
|
b32 tokens_use = 0;
|
||||||
Cpp_Token_Stack token_stack = {};
|
Cpp_Token_Stack token_stack = {};
|
||||||
|
@ -4941,7 +4941,7 @@ draw_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Rect re
|
||||||
intbar_draw_string(target, &bar, file->name.live_name, base_color);
|
intbar_draw_string(target, &bar, file->name.live_name, base_color);
|
||||||
intbar_draw_string(target, &bar, make_lit_string(" -"), base_color);
|
intbar_draw_string(target, &bar, make_lit_string(" -"), base_color);
|
||||||
|
|
||||||
if (file->state.is_loading){
|
if (file->is_loading){
|
||||||
intbar_draw_string(target, &bar, make_lit_string(" loading"), base_color);
|
intbar_draw_string(target, &bar, make_lit_string(" loading"), base_color);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
185
4ed_metagen.cpp
185
4ed_metagen.cpp
|
@ -143,188 +143,6 @@ char* generate_keycode_enum(){
|
||||||
return(filename);
|
return(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
char daction_enum_name[] = "Action_Type";
|
|
||||||
char *daction_enum[] = {
|
|
||||||
#if 0
|
|
||||||
"OPEN",
|
|
||||||
"OPEN_BACKGROUND",
|
|
||||||
#endif
|
|
||||||
"SET_LINE",
|
|
||||||
#if 0
|
|
||||||
"SAVE_AS",
|
|
||||||
"SAVE",
|
|
||||||
"NEW",
|
|
||||||
"SWITCH",
|
|
||||||
"TRY_KILL",
|
|
||||||
"KILL",
|
|
||||||
"TOUCH_FILE",
|
|
||||||
"CLOSE",
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
char str_alloc_copy[] =
|
|
||||||
"internal String\n"
|
|
||||||
"str_alloc_copy(General_Memory *general, String str){\n"
|
|
||||||
" String result;\n"
|
|
||||||
" result.memory_size = str.memory_size + 1;\n"
|
|
||||||
" result.size = str.size;\n"
|
|
||||||
" result.str = (char*)general_memory_allocate(general, result.memory_size, 0);\n"
|
|
||||||
" memcpy(result.str, str.str, str.size);\n"
|
|
||||||
" result.str[result.size] = 0;\n"
|
|
||||||
" return(result);\n"
|
|
||||||
"}\n\n";
|
|
||||||
|
|
||||||
char delayed_action_zero[] =
|
|
||||||
"inline Delayed_Action\n"
|
|
||||||
"delayed_action_zero(){\n"
|
|
||||||
" Delayed_Action result = {(Action_Type)0};\n"
|
|
||||||
" return(result);\n"
|
|
||||||
"}\n\n"
|
|
||||||
;
|
|
||||||
|
|
||||||
char daction_name[] = "Delayed_Action";
|
|
||||||
Struct_Field daction_fields[] = {
|
|
||||||
{"Action_Type", "type"},
|
|
||||||
};
|
|
||||||
Struct_Field daction_fields_primary[] = {
|
|
||||||
{"String", "string"},
|
|
||||||
{"Panel*", "panel"},
|
|
||||||
{"Editing_File*", "file"},
|
|
||||||
{"i32", "integer"},
|
|
||||||
};
|
|
||||||
enum Daction_Field_Handle{
|
|
||||||
dfph_null,
|
|
||||||
dfph_string,
|
|
||||||
dfph_panel,
|
|
||||||
dfph_file,
|
|
||||||
dfph_integer,
|
|
||||||
};
|
|
||||||
Daction_Field_Handle dact_param_sets[] = {
|
|
||||||
dfph_string, dfph_null,
|
|
||||||
dfph_panel, dfph_null,
|
|
||||||
dfph_file, dfph_null,
|
|
||||||
dfph_file, dfph_panel, dfph_null,
|
|
||||||
dfph_string, dfph_panel, dfph_null,
|
|
||||||
dfph_string, dfph_file, dfph_null,
|
|
||||||
dfph_panel, dfph_integer, dfph_null,
|
|
||||||
};
|
|
||||||
|
|
||||||
char delay_name[] = "Delay";
|
|
||||||
Struct_Field delay_fields[] = {
|
|
||||||
{"General_Memory*", "general"},
|
|
||||||
{"Delayed_Action*", "acts"},
|
|
||||||
{"i32", "count"},
|
|
||||||
{"i32", "max"},
|
|
||||||
};
|
|
||||||
|
|
||||||
char delayed_action_function_top[] =
|
|
||||||
"inline Delayed_Action*\n"
|
|
||||||
"delayed_action_(Delay *delay, Action_Type type";
|
|
||||||
|
|
||||||
char delayed_action_function_bottom[] =
|
|
||||||
"){\n"
|
|
||||||
" Delayed_Action *result;\n"
|
|
||||||
" if (delay->count == delay->max){\n"
|
|
||||||
" delay->max *= 2;\n"
|
|
||||||
" delay->acts = (Delayed_Action*)general_memory_reallocate("
|
|
||||||
"delay->general, delay->acts, delay->count*sizeof(Delayed_Action), delay->max*sizeof(Delayed_Action), 0);\n"
|
|
||||||
" }\n"
|
|
||||||
" result = delay->acts + delay->count++;\n"
|
|
||||||
" *result = delayed_action_zero();\n"
|
|
||||||
" result->type = type;\n"
|
|
||||||
" return(result);\n"
|
|
||||||
"}\n\n";
|
|
||||||
|
|
||||||
char delayed_action_special_param[] = ", %s %s";
|
|
||||||
|
|
||||||
char delayed_action_specialized_middle[] =
|
|
||||||
"){\n"
|
|
||||||
" Delayed_Action *result;\n"
|
|
||||||
" result = delayed_action_(delay, type);\n";
|
|
||||||
|
|
||||||
char delayed_action_special_line[] =
|
|
||||||
" result->%s = %s;\n";
|
|
||||||
|
|
||||||
char delayed_action_special_string_line[] =
|
|
||||||
" result->%s = str_alloc_copy(delay->general, %s);\n";
|
|
||||||
|
|
||||||
char delayed_action_specialized_bottom[] =
|
|
||||||
" return(result);\n"
|
|
||||||
"}\n\n";
|
|
||||||
|
|
||||||
char delayed_action_macro[] =
|
|
||||||
"#define delayed_%s(delay, ...) delayed_action_(delay, DACT_%s, ##__VA_ARGS__)\n";
|
|
||||||
|
|
||||||
char delayed_action_repush_function[] =
|
|
||||||
"inline Delayed_Action*\n"
|
|
||||||
"delayed_action_repush(Delay *delay, Delayed_Action *act){\n"
|
|
||||||
" Delayed_Action *new_act = delayed_action_(delay, (Action_Type)0);\n"
|
|
||||||
" *new_act = *act;\n"
|
|
||||||
" if (act->string.str){\n"
|
|
||||||
" new_act->string = str_alloc_copy(delay->general, act->string);\n"
|
|
||||||
" }\n"
|
|
||||||
" return(new_act);\n"
|
|
||||||
"}\n\n";
|
|
||||||
|
|
||||||
char* generate_delayed_action(){
|
|
||||||
FILE *file;
|
|
||||||
char *filename = "4ed_delay.cpp";
|
|
||||||
char scratch[256];
|
|
||||||
int i,j;
|
|
||||||
|
|
||||||
file = fopen(filename, "wb");
|
|
||||||
|
|
||||||
fprintf(file, "enum %s{\n", daction_enum_name);
|
|
||||||
for (i = 0; i < ArrayCount(daction_enum); ++i){
|
|
||||||
fprintf(file, " DACT_%s,\n", daction_enum[i]);
|
|
||||||
}
|
|
||||||
fprintf(file, "};\n\n");
|
|
||||||
|
|
||||||
struct_begin(file, daction_name);
|
|
||||||
struct_fields(file, daction_fields, ArrayCount(daction_fields));
|
|
||||||
struct_fields(file, daction_fields_primary, ArrayCount(daction_fields_primary));
|
|
||||||
struct_end(file);
|
|
||||||
|
|
||||||
struct_begin(file, delay_name);
|
|
||||||
struct_fields(file, delay_fields, ArrayCount(delay_fields));
|
|
||||||
struct_end(file);
|
|
||||||
|
|
||||||
fprintf(file, "%s", str_alloc_copy);
|
|
||||||
fprintf(file, "%s", delayed_action_zero);
|
|
||||||
fprintf(file, "%s%s", delayed_action_function_top, delayed_action_function_bottom);
|
|
||||||
|
|
||||||
for (i = 0; i < ArrayCount(dact_param_sets); ++i){
|
|
||||||
j = i;
|
|
||||||
fprintf(file, "%s", delayed_action_function_top);
|
|
||||||
for (; dact_param_sets[i] != dfph_null; ++i){
|
|
||||||
Struct_Field field = daction_fields_primary[dact_param_sets[i] - 1];
|
|
||||||
fprintf(file, delayed_action_special_param, field.type, field.name);
|
|
||||||
}
|
|
||||||
fprintf(file, "%s", delayed_action_specialized_middle);
|
|
||||||
for (; dact_param_sets[j] != dfph_null; ++j){
|
|
||||||
int handle = (int)(dact_param_sets[j]);
|
|
||||||
Struct_Field field = daction_fields_primary[handle - 1];
|
|
||||||
if (handle == dfph_string){
|
|
||||||
fprintf(file, delayed_action_special_string_line, field.name, field.name);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
fprintf(file, delayed_action_special_line, field.name, field.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(file, "%s", delayed_action_specialized_bottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(file, "%s", delayed_action_repush_function);
|
|
||||||
|
|
||||||
for (i = 0; i < ArrayCount(daction_enum); ++i){
|
|
||||||
to_lower(daction_enum[i], scratch);
|
|
||||||
fprintf(file, delayed_action_macro, scratch, daction_enum[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
char* bar_style_fields[] = {
|
char* bar_style_fields[] = {
|
||||||
"bar",
|
"bar",
|
||||||
|
@ -669,9 +487,6 @@ int main(){
|
||||||
filename = generate_keycode_enum();
|
filename = generate_keycode_enum();
|
||||||
printf("gen success: %s\n", filename);
|
printf("gen success: %s\n", filename);
|
||||||
|
|
||||||
filename = generate_delayed_action();
|
|
||||||
printf("gen success: %s\n", filename);
|
|
||||||
|
|
||||||
filename = generate_style();
|
filename = generate_style();
|
||||||
printf("gen success: %s\n", filename);
|
printf("gen success: %s\n", filename);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue