# $Id: events.py.in,v 1.9 2003/10/06 02:08:01 mackstann Exp $
import types
import kahakai
kahakaiInst = kahakai.Kahakai.Instance()
screen = kahakaiInst.script_current_screen
if isinstance(kahakaiInst, str):
print "Error! What should be a kahakai instance is in fact a string,"
print "which is weird. You most likely have an error in your userconfig."
_modifiers = dict([(comp.first, comp.second)
for comp in kahakai.getXModifiers(screen.display)])
# Define some alias, will use this so the keynames are case insensitive
# (which is not the case for X keyname, like Return != return)
alias = {
# you can add some aliases here
# do not remove the following line !!!
# GENERATED ALIAS TABLE GOES HERE
'greek_mu' : 'Greek_MU',
'cyrillic_ghe_bar' : 'Cyrillic_GHE_bar',
'hangul_j_rieulkiyeog' : 'Hangul_J_RieulKiyeog',
'greek_nu' : 'Greek_NU',
'terminate_server' : 'Terminate_Server',
'lirasign' : 'LiraSign',
'hangul_j_kiyeog' : 'Hangul_J_Kiyeog',
'armenian_ke' : 'Armenian_KE',
'hangul_rieulsios' : 'Hangul_RieulSios',
'armenian_vo' : 'Armenian_VO',
'hangul_kkogjidalrinieung' : 'Hangul_KkogjiDalrinIeung',
'greek_pi' : 'Greek_PI',
'kp_right' : 'KP_Right',
'pointer_downleft' : 'Pointer_DownLeft',
'hangul_j_pansios' : 'Hangul_J_PanSios',
'hangul_j_pieub' : 'Hangul_J_Pieub',
'page_down' : 'Page_Down',
'greek_iotaaccent' : 'Greek_IOTAaccent',
'greek_delta' : 'Greek_DELTA',
'hangul_sunkyeongeumphieuf' : 'Hangul_SunkyeongeumPhieuf',
'greek_alpha' : 'Greek_ALPHA',
'hangul_nieunhieuh' : 'Hangul_NieunHieuh',
'cyrillic_shcha' : 'Cyrillic_SHCHA',
'hangul_prehanja' : 'Hangul_PreHanja',
'greek_beta' : 'Greek_BETA',
'hangul_ieung' : 'Hangul_Ieung',
'meta_l' : 'Meta_L',
'armenian_ghat' : 'Armenian_GHAT',
'cyrillic_ka_descender' : 'Cyrillic_KA_descender',
'greek_upsilon' : 'Greek_UPSILON',
'zen_koho' : 'Zen_Koho',
'armenian_ra' : 'Armenian_RA',
'armenian_re' : 'Armenian_RE',
'greek_omicron' : 'Greek_OMICRON',
'cyrillic_hardsign' : 'Cyrillic_HARDSIGN',
'armenian_se' : 'Armenian_SE',
'hangul_cieuc' : 'Hangul_Cieuc',
'cyrillic_ha_descender' : 'Cyrillic_HA_descender',
'greek_xi' : 'Greek_XI',
'pointer_enablekeys' : 'Pointer_EnableKeys',
'greek_iota' : 'Greek_IOTA',
'armenian_to' : 'Armenian_TO',
'hangul_codeinput' : 'Hangul_Codeinput',
'hangul_j_ssangkiyeog' : 'Hangul_J_SsangKiyeog',
'last_virtual_screen' : 'Last_Virtual_Screen',
'pointer_dblclick1' : 'Pointer_DblClick1',
'pointer_dblclick2' : 'Pointer_DblClick2',
'pointer_dblclick3' : 'Pointer_DblClick3',
'pointer_dblclick4' : 'Pointer_DblClick4',
'pointer_dblclick5' : 'Pointer_DblClick5',
'hangul_j_rieulhieuh' : 'Hangul_J_RieulHieuh',
'armenian_lyun' : 'Armenian_LYUN',
'armenian_pe' : 'Armenian_PE',
'zenkaku_hankaku' : 'Zenkaku_Hankaku',
'iso_center_object' : 'ISO_Center_Object',
'pesetasign' : 'PesetaSign',
'mousekeys_accel_enable' : 'MouseKeys_Accel_Enable',
'hangul_jieuj' : 'Hangul_Jieuj',
'armenian_za' : 'Armenian_ZA',
'cyrillic_tse' : 'Cyrillic_TSE',
'armenian_gim' : 'Armenian_GIM',
'iso_last_group_lock' : 'ISO_Last_Group_Lock',
'hangul_wae' : 'Hangul_WAE',
'hangul_rieulkiyeog' : 'Hangul_RieulKiyeog',
'serbian_je' : 'Serbian_JE',
'iso_prev_group' : 'ISO_Prev_Group',
'armenian_e' : 'Armenian_E',
'dongsign' : 'DongSign',
'iso_prev_group_lock' : 'ISO_Prev_Group_Lock',
'mae_koho' : 'Mae_Koho',
'iso_fast_cursor_left' : 'ISO_Fast_Cursor_Left',
'kana_a' : 'kana_A',
'kana_i' : 'kana_I',
'kana_n' : 'kana_N',
'kana_o' : 'kana_O',
'kana_u' : 'kana_U',
'kana_e' : 'kana_E',
'greek_omicronaccent' : 'Greek_OMICRONaccent',
'newsheqelsign' : 'NewSheqelSign',
'serbian_tshe' : 'Serbian_TSHE',
'hangul_pieubsios' : 'Hangul_PieubSios',
'audiblebell_enable' : 'AudibleBell_Enable',
'iso_group_shift' : 'ISO_Group_Shift',
'hangul_pieub' : 'Hangul_Pieub',
'pointer_dblclick_dflt' : 'Pointer_DblClick_Dflt',
'hangul_weo' : 'Hangul_WEO',
'hangul_sunkyeongeummieum' : 'Hangul_SunkyeongeumMieum',
'meta_r' : 'Meta_R',
'hangul_j_sios' : 'Hangul_J_Sios',
'pointer_right' : 'Pointer_Right',
'pointer_button_dflt' : 'Pointer_Button_Dflt',
'hangul_j_yeorinhieuh' : 'Hangul_J_YeorinHieuh',
'kp_f1' : 'KP_F1',
'kp_f2' : 'KP_F2',
'kp_f3' : 'KP_F3',
'kp_f4' : 'KP_F4',
'hangul_j_hieuh' : 'Hangul_J_Hieuh',
'iso_group_latch' : 'ISO_Group_Latch',
'kana_lock' : 'Kana_Lock',
'cruzeirosign' : 'CruzeiroSign',
'hangul_ssangdikeud' : 'Hangul_SsangDikeud',
'armenian_je' : 'Armenian_JE',
'hangul_sunkyeongeumpieub' : 'Hangul_SunkyeongeumPieub',
'greek_epsilonaccent' : 'Greek_EPSILONaccent',
'hangul_jeonja' : 'Hangul_Jeonja',
'hangul_yae' : 'Hangul_YAE',
'iso_release_both_margins' : 'ISO_Release_Both_Margins',
'ae' : 'AE',
'serbian_dje' : 'Serbian_DJE',
'byelorussian_shortu' : 'Byelorussian_SHORTU',
'armenian_vyun' : 'Armenian_VYUN',
'kp_equal' : 'KP_Equal',
'kp_add' : 'KP_Add',
'cyrillic_o_bar' : 'Cyrillic_O_bar',
'iso_continuous_underline' : 'ISO_Continuous_Underline',
'eurosign' : 'EuroSign',
'armenian_ini' : 'Armenian_INI',
'schwa' : 'SCHWA',
'hangul_yeo' : 'Hangul_YEO',
'hangul_multiplecandidate' : 'Hangul_MultipleCandidate',
'iso_first_group_lock' : 'ISO_First_Group_Lock',
'armenian_ken' : 'Armenian_KEN',
'pointer_dfltbtnprev' : 'Pointer_DfltBtnPrev',
'hangul_yeorinhieuh' : 'Hangul_YeorinHieuh',
'hyper_l' : 'Hyper_L',
'hyper_r' : 'Hyper_R',
'super_l' : 'Super_L',
'super_r' : 'Super_R',
'armenian_tsa' : 'Armenian_TSA',
'hangul_j_nieunjieuj' : 'Hangul_J_NieunJieuj',
'kana_shi' : 'kana_SHI',
'cyrillic_i_macron' : 'Cyrillic_I_macron',
'ie' : 'IE',
'armenian_yech' : 'Armenian_YECH',
'page_up' : 'Page_Up',
'iso_lock' : 'ISO_Lock',
'hangul_j_nieun' : 'Hangul_J_Nieun',
'iso_level3_lock' : 'ISO_Level3_Lock',
'kp_up' : 'KP_Up',
'armenian_vev' : 'Armenian_VEV',
'iso_fast_cursor_down' : 'ISO_Fast_Cursor_Down',
'iso_emphasize' : 'ISO_Emphasize',
'hangul_posthanja' : 'Hangul_PostHanja',
'armenian_tso' : 'Armenian_TSO',
'cyrillic_zhe' : 'Cyrillic_ZHE',
'cyrillic_be' : 'Cyrillic_BE',
'hangul_pansios' : 'Hangul_PanSios',
'cyrillic_schwa' : 'Cyrillic_SCHWA',
'pointer_upleft' : 'Pointer_UpLeft',
'hangul_hieuh' : 'Hangul_Hieuh',
'hangul_j_rieultieut' : 'Hangul_J_RieulTieut',
'greek_etaaccent' : 'Greek_ETAaccent',
'mousekeys_enable' : 'MouseKeys_Enable',
'oe' : 'OE',
'armenian_ben' : 'Armenian_BEN',
'greek_sigma' : 'Greek_SIGMA',
'alt_l' : 'Alt_L',
'alt_r' : 'Alt_R',
'hangul_rieulpieub' : 'Hangul_RieulPieub',
'hangul_j_nieunhieuh' : 'Hangul_J_NieunHieuh',
'hangul_j_rieulmieum' : 'Hangul_J_RieulMieum',
'hangul_start' : 'Hangul_Start',
'kp_divide' : 'KP_Divide',
'serbian_dze' : 'Serbian_DZE',
'hangul_j_rieulsios' : 'Hangul_J_RieulSios',
'greek_epsilon' : 'Greek_EPSILON',
'armenian_men' : 'Armenian_MEN',
'kp_0' : 'KP_0',
'kp_1' : 'KP_1',
'kp_2' : 'KP_2',
'kp_3' : 'KP_3',
'kp_4' : 'KP_4',
'kp_5' : 'KP_5',
'kp_6' : 'KP_6',
'kp_7' : 'KP_7',
'kp_8' : 'KP_8',
'kp_9' : 'KP_9',
'kp_insert' : 'KP_Insert',
'accessx_enable' : 'AccessX_Enable',
'cyrillic_che_descender' : 'Cyrillic_CHE_descender',
'control_l' : 'Control_L',
'control_r' : 'Control_R',
'overlay2_enable' : 'Overlay2_Enable',
'pointer_up' : 'Pointer_Up',
'hangul_previouscandidate' : 'Hangul_PreviousCandidate',
'cyrillic_u_straight_bar' : 'Cyrillic_U_straight_bar',
'pointer_down' : 'Pointer_Down',
'greek_lambda' : 'Greek_LAMBDA',
'iso_next_group_lock' : 'ISO_Next_Group_Lock',
'hangul_we' : 'Hangul_WE',
'pointer_downright' : 'Pointer_DownRight',
'kana_shift' : 'Kana_Shift',
'iso_level3_shift' : 'ISO_Level3_Shift',
'kp_next' : 'KP_Next',
'hangul_j_tieut' : 'Hangul_J_Tieut',
'iso_next_group' : 'ISO_Next_Group',
'hangul_j_rieulphieuf' : 'Hangul_J_RieulPhieuf',
'ukranian_i' : 'Ukranian_I',
'eng' : 'ENG',
'iso_fast_cursor_right' : 'ISO_Fast_Cursor_Right',
'iso_enter' : 'ISO_Enter',
'cyrillic_pe' : 'Cyrillic_PE',
'iso_level3_latch' : 'ISO_Level3_Latch',
'pointer_button1' : 'Pointer_Button1',
'pointer_button2' : 'Pointer_Button2',
'pointer_button3' : 'Pointer_Button3',
'pointer_button4' : 'Pointer_Button4',
'pointer_button5' : 'Pointer_Button5',
'hangul_j_mieum' : 'Hangul_J_Mieum',
'hangul_nieun' : 'Hangul_Nieun',
'greek_theta' : 'Greek_THETA',
'hangul_araea' : 'Hangul_AraeA',
'hangul_hanja' : 'Hangul_Hanja',
'cyrillic_de' : 'Cyrillic_DE',
'kp_multiply' : 'KP_Multiply',
'kp_subtract' : 'KP_Subtract',
'iso_discontinuous_underline' : 'ISO_Discontinuous_Underline',
'cyrillic_ef' : 'Cyrillic_EF',
'cyrillic_el' : 'Cyrillic_EL',
'cyrillic_em' : 'Cyrillic_EM',
'cyrillic_en' : 'Cyrillic_EN',
'cyrillic_er' : 'Cyrillic_ER',
'cyrillic_es' : 'Cyrillic_ES',
'iso_level2_latch' : 'ISO_Level2_Latch',
'hangul_singlecandidate' : 'Hangul_SingleCandidate',
'hangul_banja' : 'Hangul_Banja',
'cyrillic_yeru' : 'Cyrillic_YERU',
'iso_release_margin_right' : 'ISO_Release_Margin_Right',
'colonsign' : 'ColonSign',
'cyrillic_sha' : 'Cyrillic_SHA',
'thorn' : 'THORN',
'iso_group_lock' : 'ISO_Group_Lock',
'eth' : 'ETH',
'hangul_ae' : 'Hangul_AE',
'cyrillic_ha' : 'Cyrillic_HA',
'kp_begin' : 'KP_Begin',
'scroll_lock' : 'Scroll_Lock',
'cyrillic_ie' : 'Cyrillic_IE',
'cyrillic_io' : 'Cyrillic_IO',
'pointer_left' : 'Pointer_Left',
'cyrillic_je' : 'Cyrillic_JE',
'kp_end' : 'KP_End',
'armenian_khe' : 'Armenian_KHE',
'greek_omegaaccent' : 'Greek_OMEGAaccent',
'hangul_j_kiyeogsios' : 'Hangul_J_KiyeogSios',
'cyrillic_ka' : 'Cyrillic_KA',
'nairasign' : 'NairaSign',
'iso_release_margin_left' : 'ISO_Release_Margin_Left',
'macedonia_gje' : 'Macedonia_GJE',
'iso_partial_line_down' : 'ISO_Partial_Line_Down',
'hangul_romaja' : 'Hangul_Romaja',
'kana_chi' : 'kana_CHI',
'kp_space' : 'KP_Space',
'kp_home' : 'KP_Home',
'hangul_rieulhieuh' : 'Hangul_RieulHieuh',
'cyrillic_shorti' : 'Cyrillic_SHORTI',
'iso_set_margin_left' : 'ISO_Set_Margin_Left',
'armenian_pyur' : 'Armenian_PYUR',
'hiragana_katakana' : 'Hiragana_Katakana',
'hangul_dikeud' : 'Hangul_Dikeud',
'hangul_a' : 'Hangul_A',
'hangul_ssangsios' : 'Hangul_SsangSios',
'iso_fast_cursor_up' : 'ISO_Fast_Cursor_Up',
'pointer_drag_dflt' : 'Pointer_Drag_Dflt',
'uo' : 'UO',
'hangul_tieut' : 'Hangul_Tieut',
'kp_enter' : 'KP_Enter',
'hangul_i' : 'Hangul_I',
'hangul_phieuf' : 'Hangul_Phieuf',
'cyrillic_te' : 'Cyrillic_TE',
'greek_phi' : 'Greek_PHI',
'num_lock' : 'Num_Lock',
'hangul_mieum' : 'Hangul_Mieum',
'hangul_oe' : 'Hangul_OE',
'shift_l' : 'Shift_L',
'greek_alphaaccent' : 'Greek_ALPHAaccent',
'shift_r' : 'Shift_R',
'hangul_ssangpieub' : 'Hangul_SsangPieub',
'cyrillic_ve' : 'Cyrillic_VE',
'kp_separator' : 'KP_Separator',
'iso_set_margin_right' : 'ISO_Set_Margin_Right',
'wonsign' : 'WonSign',
'armenian_dza' : 'Armenian_DZA',
'serbian_lje' : 'Serbian_LJE',
'hangul_khieuq' : 'Hangul_Khieuq',
'armenian_fe' : 'Armenian_FE',
'kp_tab' : 'KP_Tab',
'cyrillic_ya' : 'Cyrillic_YA',
'pointer_accelerate' : 'Pointer_Accelerate',
'cyrillic_yu' : 'Cyrillic_YU',
'iso_first_group' : 'ISO_First_Group',
'cyrillic_ze' : 'Cyrillic_ZE',
'hangul_end' : 'Hangul_End',
'multiplecandidate' : 'MultipleCandidate',
'armenian_tche' : 'Armenian_TCHE',
'kp_page_up' : 'KP_Page_Up',
'greek_omega' : 'Greek_OMEGA',
'hangul_j_ssangsios' : 'Hangul_J_SsangSios',
'greek_iotadieresis' : 'Greek_IOTAdieresis',
'greek_eta' : 'Greek_ETA',
'cyrillic_lje' : 'Cyrillic_LJE',
'hangul_wa' : 'Hangul_WA',
'hangul_wi' : 'Hangul_WI',
'hangul_j_kkogjidalrinieung' : 'Hangul_J_KkogjiDalrinIeung',
'first_virtual_screen' : 'First_Virtual_Screen',
'greek_psi' : 'Greek_PSI',
'hangul_ye' : 'Hangul_YE',
'ukranian_je' : 'Ukranian_JE',
'hangul_ssangkiyeog' : 'Hangul_SsangKiyeog',
'hangul_yi' : 'Hangul_YI',
'hangul_yo' : 'Hangul_YO',
'hangul_rieulyeorinhieuh' : 'Hangul_RieulYeorinHieuh',
'hangul_yu' : 'Hangul_YU',
'greek_gamma' : 'Greek_GAMMA',
'ukrainian_ie' : 'Ukrainian_IE',
'greek_rho' : 'Greek_RHO',
'greek_upsilonaccent' : 'Greek_UPSILONaccent',
'armenian_sha' : 'Armenian_SHA',
'ukrainian_i' : 'Ukrainian_I',
'cyrillic_zhe_descender' : 'Cyrillic_ZHE_descender',
'hangul_special' : 'Hangul_Special',
'hangul_ssangjieuj' : 'Hangul_SsangJieuj',
'macedonia_kje' : 'Macedonia_KJE',
'hangul_ya' : 'Hangul_YA',
'cyrillic_che' : 'Cyrillic_CHE',
'serbian_nje' : 'Serbian_NJE',
'pointer_drag1' : 'Pointer_Drag1',
'pointer_drag2' : 'Pointer_Drag2',
'pointer_drag3' : 'Pointer_Drag3',
'pointer_drag4' : 'Pointer_Drag4',
'pointer_drag5' : 'Pointer_Drag5',
'hangul_kiyeog' : 'Hangul_Kiyeog',
'hangul_j_rieul' : 'Hangul_J_Rieul',
'greek_tau' : 'Greek_TAU',
'ffrancsign' : 'FFrancSign',
'hangul_j_phieuf' : 'Hangul_J_Phieuf',
'greek_zeta' : 'Greek_ZETA',
'hangul_nieunjieuj' : 'Hangul_NieunJieuj',
'kanji_bangou' : 'Kanji_Bangou',
'hangul_araeae' : 'Hangul_AraeAE',
'rupeesign' : 'RupeeSign',
'kana_fu' : 'kana_FU',
'caps_lock' : 'Caps_Lock',
'kp_delete' : 'KP_Delete',
'cyrillic_shha' : 'Cyrillic_SHHA',
'eisu_shift' : 'Eisu_Shift',
'kp_down' : 'KP_Down',
'kana_ha' : 'kana_HA',
'kana_he' : 'kana_HE',
'kana_hi' : 'kana_HI',
'cyrillic_nje' : 'Cyrillic_NJE',
'kana_ho' : 'kana_HO',
'kana_hu' : 'kana_HU',
'overlay1_enable' : 'Overlay1_Enable',
'iso_partial_space_left' : 'ISO_Partial_Space_Left',
'hangul_j_khieuq' : 'Hangul_J_Khieuq',
'greek_upsilondieresis' : 'Greek_UPSILONdieresis',
'backspace' : 'BackSpace',
'greek_kappa' : 'Greek_KAPPA',
'next_virtual_screen' : 'Next_Virtual_Screen',
'cyrillic_ka_vertstroke' : 'Cyrillic_KA_vertstroke',
'previouscandidate' : 'PreviousCandidate',
'hangul_rieultieut' : 'Hangul_RieulTieut',
'kana_ka' : 'kana_KA',
'kana_ke' : 'kana_KE',
'kana_ki' : 'kana_KI',
'kana_ko' : 'kana_KO',
'kana_ku' : 'kana_KU',
'hangul_eo' : 'Hangul_EO',
'hangul_sios' : 'Hangul_Sios',
'stickykeys_enable' : 'StickyKeys_Enable',
'pointer_upright' : 'Pointer_UpRight',
'kana_ma' : 'kana_MA',
'hangul_eu' : 'Hangul_EU',
'kana_me' : 'kana_ME',
'kana_mi' : 'kana_MI',
'hangul_rieulmieum' : 'Hangul_RieulMieum',
'kana_mo' : 'kana_MO',
'kana_mu' : 'kana_MU',
'hangul_j_dikeud' : 'Hangul_J_Dikeud',
'kana_na' : 'kana_NA',
'kana_ne' : 'kana_NE',
'kana_ni' : 'kana_NI',
'kana_no' : 'kana_NO',
'armenian_tyun' : 'Armenian_TYUN',
'kana_nu' : 'kana_NU',
'ukrainian_yi' : 'Ukrainian_YI',
'ecusign' : 'EcuSign',
'singlecandidate' : 'SingleCandidate',
'hangul_e' : 'Hangul_E',
'hangul_o' : 'Hangul_O',
'accessx_feedback_enable' : 'AccessX_Feedback_Enable',
'hangul_u' : 'Hangul_U',
'repeatkeys_enable' : 'RepeatKeys_Enable',
'armenian_nu' : 'Armenian_NU',
'greek_chi' : 'Greek_CHI',
'kana_ra' : 'kana_RA',
'kana_re' : 'kana_RE',
'prev_virtual_screen' : 'Prev_Virtual_Screen',
'kana_ri' : 'kana_RI',
'kana_ro' : 'kana_RO',
'kana_ru' : 'kana_RU',
'kana_sa' : 'kana_SA',
'kana_se' : 'kana_SE',
'kana_so' : 'kana_SO',
'kana_su' : 'kana_SU',
'kp_left' : 'KP_Left',
'millsign' : 'MillSign',
'hangul_j_pieubsios' : 'Hangul_J_PieubSios',
'sys_req' : 'Sys_Req',
'kana_ta' : 'kana_TA',
'kana_te' : 'kana_TE',
'kana_ti' : 'kana_TI',
'kana_to' : 'kana_TO',
'kana_tu' : 'kana_TU',
'armenian_zhe' : 'Armenian_ZHE',
'iso_last_group' : 'ISO_Last_Group',
'hangul_rieul' : 'Hangul_Rieul',
'hangul_rieulphieuf' : 'Hangul_RieulPhieuf',
'iso_partial_line_up' : 'ISO_Partial_Line_Up',
'kana_wa' : 'kana_WA',
'kp_prior' : 'KP_Prior',
'greek_lamda' : 'Greek_LAMDA',
'kana_wo' : 'kana_WO',
'kp_decimal' : 'KP_Decimal',
'pointer_dfltbtnnext' : 'Pointer_DfltBtnNext',
'bouncekeys_enable' : 'BounceKeys_Enable',
'hangul_j_ieung' : 'Hangul_J_Ieung',
'hangul_j_jieuj' : 'Hangul_J_Jieuj',
'kana_ya' : 'kana_YA',
'iso_move_line_down' : 'ISO_Move_Line_Down',
'kana_yo' : 'kana_YO',
'kana_yu' : 'kana_YU',
'iso_left_tab' : 'ISO_Left_Tab',
'cyrillic_dzhe' : 'Cyrillic_DZHE',
'voidsymbol' : 'VoidSymbol',
'cyrillic_che_vertstroke' : 'Cyrillic_CHE_vertstroke',
'cyrillic_ghe' : 'Cyrillic_GHE',
'cyrillic_u_macron' : 'Cyrillic_U_macron',
'hangul_j_cieuc' : 'Hangul_J_Cieuc',
'armenian_at' : 'Armenian_AT',
'hangul_j_rieulpieub' : 'Hangul_J_RieulPieub',
'armenian_cha' : 'Armenian_CHA',
'henkan_mode' : 'Henkan_Mode',
'ukranian_yi' : 'Ukranian_YI',
'cyrillic_u_straight' : 'Cyrillic_U_straight',
'shift_lock' : 'Shift_Lock',
'korean_won' : 'Korean_Won',
'kana_tsu' : 'kana_TSU',
'armenian_da' : 'Armenian_DA',
'iso_partial_space_right' : 'ISO_Partial_Space_Right',
'macedonia_dse' : 'Macedonia_DSE',
'cyrillic_softsign' : 'Cyrillic_SOFTSIGN',
'hangul_kiyeogsios' : 'Hangul_KiyeogSios',
'cyrillic_a' : 'Cyrillic_A',
'cyrillic_e' : 'Cyrillic_E',
'cyrillic_i' : 'Cyrillic_I',
'cyrillic_o' : 'Cyrillic_O',
'cyrillic_en_descender' : 'Cyrillic_EN_descender',
'cyrillic_u' : 'Cyrillic_U',
'hangul_jamo' : 'Hangul_Jamo',
'kp_page_down' : 'KP_Page_Down',
'armenian_ayb' : 'Armenian_AYB',
'iso_move_line_up' : 'ISO_Move_Line_Up',
'ukrainian_ghe_with_upturn' : 'Ukrainian_GHE_WITH_UPTURN',
'slowkeys_enable' : 'SlowKeys_Enable',
'armenian_hi' : 'Armenian_HI',
'armenian_ho' : 'Armenian_HO',
'armenian_o' : 'Armenian_O'
# GENERATED ALIAS TABLE GOES HERE
}
for mod in ['MoveResizeMask']:
_modifiers[mod] = getattr(kahakai, mod)
def warn(s):
print "*** Warning: %s" % s
class Modifiers(object):
def __init__(self, mods=0, nmods=0):
self.mod = mods
self.nmod = nmods
def fromString(s):
if s in _modifiers:
return Modifiers(_modifiers[s])
else:
warn("Unknown modifier %s" % s)
return Modifiers()
def normalize(obj):
if isinstance(obj, Modifiers):
return obj
elif isinstance(obj, str):
return Modifiers.fromString(obj)
elif isinstance(obj, int):
return Modifiers(mods=obj)
elif isinstance(obj, types.NoneType):
return Modifiers()
else:
warn("Wrong type for a modifier: %s with type %s."%(obj, type(obj)))
return Modifiers()
def __add__(self, other):
if isinstance(other, str):
if other in _modifiers:
return self + Modifiers(_modifiers[other])
else:
warn("Unknown modifier %s" % other)
elif isinstance(other, Modifiers):
return Modifiers(self.mod | other.mod,
self.nmod | other.nmod)
elif isinstance(other, int):
return Modifiers(self.mod | other,
self.nmod)
else:
raise ValueError, "Can't add Modifiers and %s objects" % type(other)
def __sub__(self, other):
return self + (-Modifiers.normalize(other))
def __repr__(self):
return '<Modifiers: mods = %s, nmods = %s>' % (self.mod, self.nmod)
def __neg__(self):
return Modifiers(self.nmod, self.mod)
fromString = staticmethod(fromString)
normalize = staticmethod(normalize)
# Define some common modifiers
Ctrl = Modifiers.fromString('Control_L')
Alt = Modifiers.fromString('Alt_L')
Shift = Modifiers.fromString('Shift_L')
Super = Modifiers.fromString('Super_L')
MoveResizeMask = Modifiers.fromString('MoveResizeMask')
if 'Mode_switch' in _modifiers:
AltGr = Modifiers.fromString('Mode_switch')
else:
AltGr = Modifiers()
C, A, S, W = Ctrl, Alt, Shift, Super
class ActionEvent(object):
delayBreaks = []
def __init__(self, delay=0.0):
self.delay = delay
def set(self, action):
# Decompose delay into second and micro second
action.delay.tv_sec = int(self.delay)
action.delay.tv_usec = (self.delay - int(self.delay)) * 1e6
action.delay_breaks = kahakai.Vector_int()
for delayBreak in self.delayBreaks:
action.delay_breaks.append(delayBreak)
class _Default: pass
class KeyEvent(ActionEvent):
def __init__(self, a, b=_Default, replay=False, delay=0):
ActionEvent.__init__(self, delay)
# we can be called with either ("keyname"), or (modifiers, "keyname"),
# so at this point we don't know which is which, thus the generic
# names `a' and `b'
# and here we determine which is which
if b is _Default:
# We are just called with a keyname
modifiers, keyName = Modifiers(), a
else:
# We are called with modifier, keyname
modifiers, keyName = a, b
modifiers = Modifiers.normalize(modifiers)
if not keyName:
self.keySym = 0
else:
self.keySym = self._parseKey(keyName)
self.nmod, self.mod = modifiers.nmod, modifiers.mod
self.replay = replay
def _parseKey(self, keyName):
if isinstance(keyName, (int, long)): # Keycode
return keyName
if len(keyName) == 1:
keyName = keyName.lower()
keyName = alias.get(keyName.lower(), keyName)
keySym = kahakai.XStringToKeysym(keyName)
if keySym == kahakai.NoSymbol and len(keyName) > 1:
keySym = kahakai.XStringToKeysym(keyName.capitalize())
if keySym == kahakai.NoSymbol:
print "** Warning: %s not a valid key name" % keyName
return None
return keySym
def set(self, action):
if not self.keySym: return False
ActionEvent.set(self, action)
action.type = self.type
action.replay = self.replay
action.detail = self.keySym
action.nmod, action.mod = self.nmod, self.mod
return True
def bindToCommand(self, screen, command):
action = kahakai.Action()
_objects.append(action)
if not self.set(action): return
action.command = command
for actionList in screen.config.awinacts, screen.config.rootacts:
actionList.append(action)
class KeyPress(KeyEvent):
type = kahakai.KeyPress
class KeyRelease(KeyEvent):
type = kahakai.KeyRelease
class SimpleActionEvent(ActionEvent):
def __init__(self, modifiers=Modifiers(), delay=0):
ActionEvent.__init__(self, delay)
modifiers = Modifiers.normalize(modifiers)
self.nmod, self.mod = modifiers.nmod, modifiers.mod
def set(self, action):
ActionEvent.set(self, action)
action.type = self.type
action.detail = 0
action.nmod, action.mod = self.nmod, self.mod
return True
class EnterNotify(SimpleActionEvent):
type = kahakai.EnterNotify
delayBreaks = kahakai.LeaveNotify,
class LeaveNotify(SimpleActionEvent):
type = kahakai.LeaveNotify
delayBreaks = kahakai.EnterNotify,
class MapRequest(SimpleActionEvent):
type = kahakai.MapRequest
class MouseEvent(ActionEvent):
def __init__(self, a, b=None, replay=False, delay=0):
# see KeyEvent for notes about arguments a and b
ActionEvent.__init__(self, delay);
if b is None:
# We are just called with a buttonName
modifiers, buttonName = Modifiers(), a
else:
# We are called modifier, buttonName
modifiers, buttonName = a, b
modifiers = Modifiers.normalize(modifiers)
self.detail = self._parseButton(buttonName)
self.nmod, self.mod = modifiers.nmod, modifiers.mod
self.replay = replay
def set(self, action):
if not self.detail: return False
ActionEvent.set(self, action)
action.type = self.type
action.detail = self.detail
action.replay = self.replay
action.nmod, action.mod = self.nmod, self.mod
return True
def _parseButton(self, buttonName):
buttons = {
'anybutton': 0,
'button1': kahakai.Button1,
'button2': kahakai.Button2,
'button3': kahakai.Button3,
'button4': kahakai.Button4,
'button5': kahakai.Button5,
}
if buttonName.lower() in buttons:
return buttons[buttonName.lower()]
elif buttonName.startswith('button'):
return int(buttonName[len('button'):])
else:
warn("Unknown button: %s" % buttonName)
class ButtonPress(MouseEvent):
type = kahakai.ButtonPress
class DoubleClick(MouseEvent):
type = kahakai.DoubleClick
class ButtonRelease(MouseEvent):
type = kahakai.ButtonRelease
|