static int gtkKeyMap2Iup(guint keyval, int state) { int code = (int)keyval; if (state & (GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_MOD5_MASK|GDK_MOD4_MASK)) { /* If it has some of the other modifiers then use upper case version */ if (keyval >= K_a && keyval <= K_z) code = iup_toupper(keyval); else if (keyval==K_ccedilla) code = K_Ccedilla; } if (state & GDK_SHIFT_MASK) /* Shift */ { /* only add Shift modifiers for non-ASCii codes, except for K_SP and bellow, and except when other modifiers are used */ if ((keyval < K_exclam || keyval > K_tilde) || (state & (GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_MOD5_MASK|GDK_MOD4_MASK))) code |= iup_XkeyShift(code); } if (state & GDK_CONTROL_MASK) /* Ctrl */ code |= iup_XkeyCtrl(code); if (state & GDK_MOD1_MASK || state & GDK_MOD5_MASK) /* Alt */ code |= iup_XkeyAlt(code); if (state & GDK_MOD4_MASK) /* Apple/Win */ code |= iup_XkeySys(code); return code; }
static int motKeyMap2Iup(KeySym motcode, unsigned int state) { int code = (int)motcode; if (state & (ControlMask|Mod1Mask|Mod5Mask|Mod4Mask)) { /* If it has some of the other modifiers then use upper case version */ if (motcode >= K_a && motcode <= K_z) code = iup_toupper(motcode); else if (motcode==K_ccedilla) code = K_Ccedilla; } if (state & ShiftMask) /* Shift */ { /* only add Shift modifiers for non-ASCii codes, except for K_SP and bellow, and except when other modifiers are used */ if ((motcode < K_exclam || motcode > K_tilde) || (state & (ControlMask|Mod1Mask|Mod5Mask|Mod4Mask))) code |= iup_XkeyShift(code); } if (state & ControlMask) /* Ctrl */ code = iup_XkeyCtrl(code); if (state & Mod1Mask || state & Mod5Mask) /* Alt */ code = iup_XkeyAlt(code); if (state & Mod4Mask) /* Apple/Win */ code = iup_XkeySys(code); return code; }
static void iKeyCallFunc(void (*func)(const char *name, int code, void* user_data), void* user_data, const char *name, int code, unsigned char mod) { char mod_name[30]; func(name, code, user_data); if (mod==0) { iKeyMakeXName(mod_name, "K_s", name); func(mod_name, iup_XkeyShift(code), user_data); } if (mod!=1) { iKeyMakeXName(mod_name, "K_c", name); func(mod_name, iup_XkeyCtrl(code), user_data); iKeyMakeXName(mod_name, "K_m", name); func(mod_name, iup_XkeyAlt(code), user_data); iKeyMakeXName(mod_name, "K_y", name); func(mod_name, iup_XkeySys(code), user_data); } }
IupSetAttribute(list, "REMOVEITEM", NULL); //Purge the linked list LL_purge(&images); main_window_set_menu_state(); return IUP_DEFAULT; } //////////////////////////////////////////////WINDOW CALLBACKS////////////////////////////////// //Keyboard shortcuts. Format: {shortcut, callback} static Keyboard keyboard[] = { {iup_XkeyCtrl(K_O), &image_open_file}, {iup_XkeyCtrl(K_W), &_close_image}, {iup_XkeyCtrl(iup_XkeyShift(K_W)), &_close_all}, {iup_XkeyCtrl(K_S), &image_save_file}, {iup_XkeyCtrl(K_E), &export_dialog_world}, {iup_XkeyCtrl(iup_XkeyShift(K_E)), &export_dialog_folder}, {K_F1, &_wiki}, {(int)NULL} }; int _k_any(Ihandle* ih, int c) { int i; for(i = 0; keyboard[i].key; i++) { if(c == keyboard[i].key) { if(keyboard[i].cb != NULL) //TEMPORARY, all keyboard shortcuts will be mapped eventually
static int cf_XkeyShift(lua_State *L) { int value = (int)luaL_checkinteger(L, 1); lua_pushinteger(L, iup_XkeyShift(value)); return 1; }