get_event_message setup, need a little more on coroutine yield checking though
This commit is contained in:
parent
5274ecd4e9
commit
ddf06aecc2
|
@ -422,8 +422,8 @@ struct Application_Links;
|
|||
#define START_QUERY_BAR_SIG(n) int n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
||||
#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
||||
#define PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *string, int len)
|
||||
#define GET_GUI_FUNCTIONS_SIG(n) GUI_Functions* n(Application_Links *app);
|
||||
#define GET_GUI_SIG(n) GUI* n(Application_Links *app, int view_id);
|
||||
#define GET_GUI_FUNCTIONS_SIG(n) GUI_Functions* n(Application_Links *app)
|
||||
#define GET_GUI_SIG(n) GUI* n(Application_Links *app, int view_id)
|
||||
|
||||
// Color settings
|
||||
#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int len)
|
||||
|
@ -591,6 +591,8 @@ struct Application_Links{
|
|||
|
||||
// Internal
|
||||
void *cmd_context;
|
||||
void *current_coroutine;
|
||||
void *system_links;
|
||||
};
|
||||
|
||||
#define _GET_VERSION_SIG(n) int n(int maj, int min, int patch)
|
||||
|
|
95
4ed.cpp
95
4ed.cpp
|
@ -87,6 +87,36 @@ struct App_Vars{
|
|||
Command_Data command_data;
|
||||
};
|
||||
|
||||
inline Coroutine*
|
||||
app_launch_coroutine(System_Functions *system, Application_Links *app,
|
||||
Coroutine *co, void *in, void *out){
|
||||
Coroutine* result = 0;
|
||||
|
||||
Coroutine *prev_coroutine = (Coroutine*)app->current_coroutine;
|
||||
app->current_coroutine = co;
|
||||
{
|
||||
result = system->launch_coroutine(co, in, out);
|
||||
}
|
||||
app->current_coroutine = prev_coroutine;
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
inline Coroutine*
|
||||
app_resume_coroutine(System_Functions *system, Application_Links *app,
|
||||
Coroutine *co, void *in, void *out){
|
||||
Coroutine* result = 0;
|
||||
|
||||
Coroutine *prev_coroutine = (Coroutine*)app->current_coroutine;
|
||||
app->current_coroutine = co;
|
||||
{
|
||||
result = system->resume_coroutine(co, in, out);
|
||||
}
|
||||
app->current_coroutine = prev_coroutine;
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
inline void
|
||||
output_file_append(System_Functions *system, Models *models, Editing_File *file, String value, b32 cursor_at_end){
|
||||
i32 end = buffer_size(&file->state.buffer);
|
||||
|
@ -2421,6 +2451,18 @@ extern "C"{
|
|||
return(result);
|
||||
}
|
||||
|
||||
GET_EVENT_MESSAGE_SIG(external_get_event_message){
|
||||
Event_Message message = {0};
|
||||
System_Functions *system = (System_Functions*)app->system_links;
|
||||
Coroutine *coroutine = (Coroutine*)app->current_coroutine;
|
||||
|
||||
Assert(coroutine);
|
||||
system->yield_coroutine(coroutine);
|
||||
message = *(Event_Message*)coroutine->in;
|
||||
|
||||
return(message);
|
||||
}
|
||||
|
||||
START_QUERY_BAR_SIG(external_start_query_bar){
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
Query_Slot *slot = 0;
|
||||
|
@ -2447,6 +2489,18 @@ extern "C"{
|
|||
do_feedback_message(cmd->system, models, make_string(string, len));
|
||||
}
|
||||
|
||||
GET_GUI_FUNCTIONS_SIG(external_get_gui_functions){
|
||||
GUI_Functions *guifn = 0;
|
||||
NotImplemented;
|
||||
return(guifn);
|
||||
}
|
||||
|
||||
GET_GUI_SIG(external_get_gui){
|
||||
GUI *gui = 0;
|
||||
NotImplemented;
|
||||
return(gui);
|
||||
}
|
||||
|
||||
CHANGE_THEME_SIG(external_change_theme){
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
Style_Library *styles = &cmd->models->styles;
|
||||
|
@ -2565,14 +2619,20 @@ app_links_init(System_Functions *system, Application_Links *app_links, void *dat
|
|||
|
||||
app_links->get_user_input = external_get_user_input;
|
||||
app_links->get_command_input = external_get_command_input;
|
||||
app_links->get_event_message = external_get_event_message;
|
||||
|
||||
app_links->start_query_bar = external_start_query_bar;
|
||||
app_links->end_query_bar = external_end_query_bar;
|
||||
app_links->print_message = external_print_message;
|
||||
app_links->get_gui_functions = external_get_gui_functions;
|
||||
app_links->get_gui = external_get_gui;
|
||||
|
||||
app_links->change_theme = external_change_theme;
|
||||
app_links->change_font = external_change_font;
|
||||
app_links->set_theme_colors = external_set_theme_colors;
|
||||
|
||||
app_links->current_coroutine = 0;
|
||||
app_links->system_links = system;
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -3177,7 +3237,7 @@ App_Init_Sig(app_init){
|
|||
}
|
||||
|
||||
{
|
||||
Command_Map *global;
|
||||
Command_Map *global = 0;
|
||||
i32 wanted_size = 0;
|
||||
b32 did_top = 0;
|
||||
b32 did_file = 0;
|
||||
|
@ -3774,10 +3834,12 @@ App_Step_Sig(app_step){
|
|||
system->create_coroutine(view_caller);
|
||||
|
||||
models->command_coroutine = persistent->coroutine;
|
||||
|
||||
persistent->coroutine =
|
||||
system->launch_coroutine(persistent->coroutine,
|
||||
app_launch_coroutine(system, &models->app_links,
|
||||
persistent->coroutine,
|
||||
view,
|
||||
&view->persistent.coroutine_flags);
|
||||
0);
|
||||
|
||||
if (!persistent->coroutine){
|
||||
// TODO(allen): Error message and recover
|
||||
|
@ -3848,7 +3910,13 @@ App_Step_Sig(app_step){
|
|||
while (command_coroutine){
|
||||
User_Input user_in = {0};
|
||||
user_in.abort = 1;
|
||||
command_coroutine = system->resume_coroutine(command_coroutine, &user_in, models->command_coroutine_flags);
|
||||
|
||||
command_coroutine =
|
||||
app_resume_coroutine(system, &models->app_links,
|
||||
command_coroutine,
|
||||
&user_in,
|
||||
models->command_coroutine_flags);
|
||||
|
||||
++i;
|
||||
if (i >= 128){
|
||||
// TODO(allen): post grave warning, resource cleanup system.
|
||||
|
@ -3925,7 +3993,11 @@ App_Step_Sig(app_step){
|
|||
|
||||
if (pass_in){
|
||||
models->command_coroutine =
|
||||
system->resume_coroutine(command_coroutine, &user_in, models->command_coroutine_flags);
|
||||
app_resume_coroutine(system, &models->app_links,
|
||||
command_coroutine,
|
||||
&user_in,
|
||||
models->command_coroutine_flags);
|
||||
|
||||
app_result.animating = 1;
|
||||
|
||||
// TOOD(allen): Deduplicate
|
||||
|
@ -3989,7 +4061,10 @@ App_Step_Sig(app_step){
|
|||
}
|
||||
|
||||
if (pass_in){
|
||||
models->command_coroutine = system->resume_coroutine(command_coroutine, &user_in,
|
||||
models->command_coroutine =
|
||||
app_resume_coroutine(system, &models->app_links,
|
||||
command_coroutine,
|
||||
&user_in,
|
||||
models->command_coroutine_flags);
|
||||
|
||||
app_result.animating = 1;
|
||||
|
@ -4115,8 +4190,12 @@ App_Step_Sig(app_step){
|
|||
cmd_in.cmd = cmd;
|
||||
cmd_in.bind = cmd_bind;
|
||||
|
||||
models->command_coroutine = system->launch_coroutine(models->command_coroutine,
|
||||
&cmd_in, models->command_coroutine_flags);
|
||||
models->command_coroutine =
|
||||
app_launch_coroutine(system, &models->app_links,
|
||||
models->command_coroutine,
|
||||
&cmd_in,
|
||||
models->command_coroutine_flags);
|
||||
|
||||
models->prev_command = cmd_bind;
|
||||
|
||||
app_result.animating = 1;
|
||||
|
|
|
@ -209,7 +209,7 @@ struct View_Persistent{
|
|||
|
||||
View_Routine_Function *view_routine;
|
||||
Coroutine *coroutine;
|
||||
u32 coroutine_flags[2];
|
||||
Event_Message message_passing_slot;
|
||||
|
||||
// TODO(allen): eliminate this models pointer: explicitly parameterize.
|
||||
Models *models;
|
||||
|
|
|
@ -21,8 +21,8 @@ if %ERRORLEVEL% neq 0 (set FirstError=1)
|
|||
popd
|
||||
|
||||
pushd ..\build
|
||||
REM call "..\code\buildsuper.bat" ..\code\4coder_default_bindings.cpp
|
||||
call "..\code\buildsuper.bat" ..\code\power\4coder_experiments.cpp
|
||||
call "..\code\buildsuper.bat" ..\code\4coder_default_bindings.cpp
|
||||
REM call "..\code\buildsuper.bat" ..\code\power\4coder_experiments.cpp
|
||||
REM call "..\code\buildsuper.bat" ..\code\power\4coder_casey.cpp
|
||||
if %ERRORLEVEL% neq 0 (set FirstError=1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue