added coroutines, fixed _YET_ another scroll bug
This commit is contained in:
parent
8cf1447714
commit
8d2b575b68
|
@ -337,13 +337,14 @@ struct Theme_Color{
|
|||
};
|
||||
|
||||
|
||||
|
||||
#define VIEW_ROUTINE_SIG(name) void name(int view_id)
|
||||
#define GET_BINDING_DATA(name) int name(void *data, int size)
|
||||
#define CUSTOM_COMMAND_SIG(name) void name(struct Application_Links *app)
|
||||
#define HOOK_SIG(name) int name(struct Application_Links *app)
|
||||
#define SCROLL_RULE_SIG(name) int name(float target_x, float target_y, float *scroll_x, float *scroll_y, int view_id, int is_new_target)
|
||||
|
||||
extern "C"{
|
||||
typedef VIEW_ROUTINE_SIG(View_Routine_Function);
|
||||
typedef CUSTOM_COMMAND_SIG(Custom_Command_Function);
|
||||
typedef GET_BINDING_DATA(Get_Binding_Data_Function);
|
||||
typedef HOOK_SIG(Hook_Function);
|
||||
|
@ -576,6 +577,7 @@ extern "C" _GET_VERSION_SIG(get_alpha_4coder_version){
|
|||
}
|
||||
|
||||
struct Custom_API{
|
||||
View_Routine_Function *view_routine;
|
||||
Get_Binding_Data_Function *get_bindings;
|
||||
_Get_Version_Function *get_alpha_4coder_version;
|
||||
};
|
||||
|
|
51
4ed.cpp
51
4ed.cpp
|
@ -2510,6 +2510,13 @@ command_caller(Coroutine *coroutine){
|
|||
view->mode = view->next_mode;
|
||||
}
|
||||
|
||||
internal void
|
||||
view_caller(Coroutine *coroutine){
|
||||
View *view = (View*)coroutine->in;
|
||||
|
||||
view->view_routine(view->id);
|
||||
}
|
||||
|
||||
internal void
|
||||
app_links_init(System_Functions *system, Application_Links *app_links, void *data, int size){
|
||||
app_links->memory = data;
|
||||
|
@ -3142,41 +3149,63 @@ App_Init_Sig(app_init){
|
|||
div->next = 0;
|
||||
models->layout.free_divider = dividers;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
View *vptr = 0;
|
||||
i32 i = 0;
|
||||
i32 max = 0;
|
||||
|
||||
|
||||
vars->live_set.count = 0;
|
||||
vars->live_set.max = panel_max_count;
|
||||
|
||||
|
||||
vars->live_set.views = push_array(partition, View, vars->live_set.max);
|
||||
|
||||
|
||||
dll_init_sentinel(&vars->live_set.free_sentinel);
|
||||
|
||||
|
||||
max = vars->live_set.max;
|
||||
vptr = vars->live_set.views;
|
||||
for (i = 0; i < max; ++i, ++vptr){
|
||||
dll_insert(&vars->live_set.free_sentinel, vptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
Panel *panel = 0, *used_panels = 0;
|
||||
View *view = 0;
|
||||
|
||||
used_panels = &models->layout.used_sentinel;
|
||||
for (dll_items(panel, used_panels)){
|
||||
view = panel->view;
|
||||
|
||||
view->view_routine = models->config_api.view_routine;
|
||||
view->coroutine =
|
||||
system->create_coroutine(view_caller);
|
||||
|
||||
view->coroutine =
|
||||
system->launch_coroutine(view->coroutine, view, view);
|
||||
|
||||
if (!view->coroutine){
|
||||
// TODO(allen): Error message and recover
|
||||
NotImplemented;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Command_Map *global;
|
||||
i32 wanted_size = 0;
|
||||
b32 did_top = 0;
|
||||
b32 did_file = 0;
|
||||
|
||||
|
||||
models->scroll_rule = fallback_scroll_rule;
|
||||
|
||||
|
||||
setup_command_table();
|
||||
|
||||
|
||||
global = &models->map_top;
|
||||
Assert(models->config_api.get_bindings != 0);
|
||||
|
||||
|
||||
wanted_size = models->config_api.get_bindings(models->app_links.memory, models->app_links.memory_size);
|
||||
|
||||
|
||||
if (wanted_size <= models->app_links.memory_size){
|
||||
Command_Map *map_ptr = 0;
|
||||
Binding_Unit *unit, *end;
|
||||
|
|
|
@ -206,13 +206,16 @@ context_eq(Scroll_Context a, Scroll_Context b){
|
|||
|
||||
struct View{
|
||||
View *next, *prev;
|
||||
Panel *panel;
|
||||
b32 in_use;
|
||||
i32 id;
|
||||
|
||||
Coroutine *coroutine;
|
||||
View_Routine_Function *view_routine;
|
||||
|
||||
// TODO(allen): eliminate this models pointer: explicitly parameterize.
|
||||
Models *models;
|
||||
|
||||
Panel *panel;
|
||||
Command_Map *map;
|
||||
|
||||
File_Viewing_Data file_data;
|
||||
|
@ -1520,6 +1523,7 @@ view_set_file(View *view, Editing_File *file, Models *models){
|
|||
if (file_is_ready(file)){
|
||||
view_measure_wraps(&models->mem.general, view);
|
||||
view->recent->cursor = view_compute_cursor_from_pos(view, view->recent->cursor.pos);
|
||||
view->recent->scroll.max_y = 1000000000.f;
|
||||
view_move_view_to_cursor(view, &view->recent->scroll);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ _OutDbgStr(u8*);
|
|||
#endif
|
||||
|
||||
#define TentativeAssert(c) Assert(c)
|
||||
#define NotImplemented Assert(!"This is not implemented yet!")
|
||||
|
||||
#define FatalError(message) system_fatal_error((u8*)message)
|
||||
|
||||
|
|
Loading…
Reference in New Issue