diff --git a/include/Mw/Core.h b/include/Mw/Core.h index 00d0007..b5e4095 100644 --- a/include/Mw/Core.h +++ b/include/Mw/Core.h @@ -37,6 +37,8 @@ MWDECL void MwDispatchUserHandler(MwWidget handle, const char* key, void* handle MWDECL void MwSetErrorHandler(MwErrorHandler handler, void* user_data); MWDECL void MwDispatchError(int code, const char* message); +MWDECL jmp_buf MwGetBeforeStep(MwWidget handle); + #ifdef __cplusplus } #endif diff --git a/include/Mw/MachDep.h b/include/Mw/MachDep.h index 5b05ddf..d9004a2 100644 --- a/include/Mw/MachDep.h +++ b/include/Mw/MachDep.h @@ -6,6 +6,7 @@ #include #include #include +#include #ifdef _WIN32 #include #else diff --git a/include/Mw/TypeDefs.h b/include/Mw/TypeDefs.h index 93829c8..9d231a1 100644 --- a/include/Mw/TypeDefs.h +++ b/include/Mw/TypeDefs.h @@ -61,8 +61,9 @@ struct _MwWidget { MwWidget* children; MwClass widget_class; - int pressed; - int close; + int pressed; + int close; + jmp_buf before_step; void* internal; diff --git a/src/core.c b/src/core.c index a6a1281..7287619 100644 --- a/src/core.c +++ b/src/core.c @@ -142,6 +142,8 @@ int MwPending(MwWidget handle) { void MwLoop(MwWidget handle) { while(!handle->close) { + setjmp(handle->before_step); + MwStep(handle); MwDispatchUserHandler(handle, MwNtickHandler, NULL); @@ -273,3 +275,7 @@ void MwDispatchError(int code, const char* message) { exit(1); } } + +jmp_buf MwGetBeforeStep(MwWidget handle) { + return handle->before_step; +}