rem: while (!done) {
add: while (!done && menu->flags.mapped) {
context: keyboardMenu(WMenu *menu){    XEvent event;    KeySym ksym=NoSymbol;    int done=0;    int index;    WMenuEntry *entry;    int old_pos_x = menu->frame_x;    int old_pos_y = menu->frame_y;    int new_x = old_pos_x, new_y = old_pos_y;    int scr_width = menu->frame->screen_ptr->scr_width;    int scr_height = menu->frame->screen_ptr->scr_height;    if (menu->flags.editing)	return False;    XGrabKeyboard(dpy, menu->frame->core->window, True, GrabModeAsync,		  GrabModeAsync, CurrentTime);    if (menu->frame_y+menu->frame->top_width >= scr_height)	new_y = scr_height - menu->frame->top_width;        if (menu->frame_x+MENUW(menu) >= scr_width)	new_x = scr_width-MENUW(menu)-1;        move_menus(menu, new_x, new_y);        while (!done) {	XAllowEvents(dpy, AsyncKeyboard, CurrentTime);	WMMaskEvent(dpy, ExposureMask|ButtonMotionMask|ButtonPressMask		    |ButtonReleaseMask|KeyPressMask|KeyReleaseMask		    |SubstructureNotifyMask, &event);		switch (event.type) {	 case KeyPress:	    ksym = XLookupKeysym(&event.xkey, 0);	    switch (ksym) {	     case XK_Escape:		done = 1;		break;	     case XK_Home:	     case XK_KP_Home:		selectEntry(menu, 0);		makeVisible(menu);		break;			     case XK_End:	     case XK_KP_End:		selectEntry(menu, menu->entry_no-1);		makeVisible(menu);		break;			     case XK_Up:#ifdef ARROWLESS_KBD	     case XK_k:#endif	     case XK_KP_Up:		if (menu->selected_entry <= 0)                    selectEntry(menu, menu->entry_no-1);		else		    selectEntry(menu, menu->selected_entry-1);		makeVisible(menu);		break;			     case XK_Down:#ifdef ARROWLESS_KBD	     case XK_j:#endif	     case XK_KP_Down:		if (menu->selected_entry<0)                     selectEntry(menu, 0);                else if (menu->selected_entry == menu->entry_no-1)                    selectEntry(menu, 0);		else if (menu->selected_entry < menu->entry_no-1)		    selectEntry(menu, menu->selected_entry+1);		makeVisible(menu);		break;			     case XK_Right:#ifdef ARROWLESS_KBD	     case XK_l:#endif	     case XK_KP_Right:		if (menu->selected_entry>=0) {		    WMenuEntry *entry;		    entry = menu->entries[menu->selected_entry];		    if (entry->cascade >= 0 && menu->cascades			&& menu->cascades[entry->cascade]->entry_no > 0) {			XUngrabKeyboard(dpy, CurrentTime);			selectEntry(menu->cascades[entry->cascade], 0);			if (!keyboardMenu(menu->cascades[entry->cascade]))			    done = 1;			XGrabKeyboard(dpy, menu->frame->core->window, True,				      GrabModeAsync, GrabModeAsync,				      CurrentTime);		    }		}		break;	     case XK_Left:#ifdef ARROWLESS_KBD	     case XK_h:#endif	     case XK_KP_Left:		if (menu->parent!=NULL && menu->parent->selected_entry>=0) {		    selectEntry(menu, -1);		    move_menus(menu, old_pos_x, old_pos_y);		    return True;		}		break;			     case XK_Return:		done = 2;		break;			     default:		index = check_key(menu, &event.xkey);		if (index>=0) {		    selectEntry(menu, index);		}	    }	    break;	    	 default:	    if (event.type==ButtonPress)		done = 1;	    WMHandleEvent(&event);	}    }    XUngrabKeyboard(dpy, CurrentTime);    if (done==2 && menu->selected_entry>=0) {	entry = menu->entries[menu->selected_entry];    } else {	entry = NULL;    }    if (entry && entry->callback!=NULL && entry->flags.enabled	&& entry->cascade < 0) {#if (MENU_BLINK_COUNT > 0)	int sel = menu->selected_entry;	int i;		for (i=0; i<MENU_BLINK_COUNT; i++) {	    paintEntry(menu, sel, False);	    XSync(dpy, 0);	    wusleep(MENU_BLINK_DELAY);	    paintEntry(menu, sel, True);	    XSync(dpy, 0);	    wusleep(MENU_BLINK_DELAY);	}#endif	selectEntry(menu, -1);	if (!menu->flags.buttoned) {	    wMenuUnmap(menu);	    move_menus(menu, old_pos_x, old_pos_y);	}	closeCascade(menu);	 	(*entry->callback)(menu, entry);    } else {	if (!menu->flags.buttoned) {	    wMenuUnmap(menu);	    move_menus(menu, old_pos_x, old_pos_y);	}	selectEntry(menu, -1);    }        /* returns True if returning from a submenu to a parent menu,     * False if exiting from menu */    return False;}