2323#define WAIT_INTERVAL 10
2424#define EVENT_TYPE_RESTART 101
2525#define EVENT_TYPE_SHOW_MENU 102
26+ #define EVENT_TYPE_RESIZE 103
2627
2728Runtime *runtime;
2829
@@ -52,6 +53,15 @@ EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *user
5253 return 0 ;
5354}
5455
56+ EM_BOOL resize_callback (int eventType, const EmscriptenUiEvent *e, void *userData) {
57+ MAEvent *event = new MAEvent ();
58+ event->type = EVENT_TYPE_RESIZE;
59+ event->point .x = e->documentBodyClientWidth ;
60+ event->point .y = e->documentBodyClientHeight ;
61+ runtime->pushEvent (event);
62+ return 0 ;
63+ }
64+
5565Runtime::Runtime () :
5666 System() {
5767 logEntered ();
@@ -62,6 +72,7 @@ Runtime::Runtime() :
6272 emscripten_set_mouseup_callback (EMSCRIPTEN_EVENT_TARGET_WINDOW, this , true , mouse_callback);
6373 emscripten_set_mousemove_callback (EMSCRIPTEN_EVENT_TARGET_WINDOW, this , true , mouse_callback);
6474 emscripten_set_keydown_callback (EMSCRIPTEN_EVENT_TARGET_WINDOW, this , true , key_callback);
75+ emscripten_set_resize_callback (EMSCRIPTEN_EVENT_TARGET_WINDOW, this , true , resize_callback);
6576
6677 MAExtent screenSize = maGetScrSize ();
6778 _output = new AnsiWidget (EXTENT_X (screenSize), EXTENT_Y (screenSize));
@@ -221,10 +232,6 @@ MAEvent Runtime::processEvents(int waitFlag) {
221232
222233void Runtime::processEvent (MAEvent &event) {
223234 switch (event.type ) {
224- case EVENT_TYPE_KEY_PRESSED:
225- // handleKeyEvent(event);
226- handleEvent (event);
227- break ;
228235 case EVENT_TYPE_RESTART:
229236 setRestart ();
230237 break ;
@@ -233,6 +240,9 @@ void Runtime::processEvent(MAEvent &event) {
233240 _menuY = event.point .y ;
234241 showMenu ();
235242 break ;
243+ case EVENT_TYPE_RESIZE:
244+ resize ();
245+ break ;
236246 default :
237247 handleEvent (event);
238248 break ;
@@ -241,8 +251,9 @@ void Runtime::processEvent(MAEvent &event) {
241251
242252void Runtime::runShell () {
243253 logEntered ();
244- runMain (MAIN_BAS);
245- _state = kDoneState ;
254+ while (1 ) {
255+ runMain (MAIN_BAS);
256+ }
246257}
247258
248259void Runtime::showCursor (CursorType cursorType) {
0 commit comments