📄 mwmparse.y
字号:
| error { yyerror("Invalid context"); $<number>$ = 0; };button: modifier_list '<' button_event_name '>' { $<button>$ = $<button>3; $<button>$.modifiers = $1; } | '<' button_event_name '>' { $<button>$ = $<button>2; $<button>$.modifiers = 0; };key: modifier_list '<' KEY_TOK '>' STRING_TOK { $<hotkey>$.modifiers = $<modifiers>1; $<hotkey>$.key = XStringToKeysym($<string>5); } | '<' KEY_TOK '>' STRING_TOK { $<hotkey>$.modifiers = 0; $<hotkey>$.key = XStringToKeysym($<string>4); };modifier_list: modifier_list modifier_name { $<modifiers>$ = $1 | $2; } | modifier_name { $<modifiers>$ = $1; };modifier_name: CTRL_TOK { $<modifiers>$ = ControlMask; } | SHIFT_TOK { $<modifiers>$ = ShiftMask; } | ALT_TOK { $<modifiers>$ = pscr->alt_mask; } | LOCK_TOK { $<modifiers>$ = LockMask; } | MOD1_TOK { $<modifiers>$ = Mod1Mask; } | MOD2_TOK { $<modifiers>$ = Mod2Mask; } | MOD3_TOK { $<modifiers>$ = Mod3Mask; } | MOD4_TOK { $<modifiers>$ = Mod4Mask; } | MOD5_TOK { $<modifiers>$ = Mod5Mask; };button_event_name: BTN1_DOWN_TOK { $<button>$.button = Button1Mask; $<button>$.event = ButtonPressMask; $<button>$.count = 0; } | BTN1_UP_TOK { $<button>$.button = Button1Mask; $<button>$.event = ButtonReleaseMask; $<button>$.count = 0; } | BTN1_CLICK_TOK { $<button>$.button = Button1Mask; $<button>$.event = ButtonPressMask|ButtonReleaseMask; $<button>$.count = 1; } | BTN1_CLICK2_TOK { $<button>$.button = Button1Mask; $<button>$.event = ButtonPressMask|ButtonReleaseMask; $<button>$.count = 2; } | BTN2_DOWN_TOK { $<button>$.button = Button2Mask; $<button>$.event = ButtonPressMask; $<button>$.count = 0; } | BTN2_UP_TOK { $<button>$.button = Button2Mask; $<button>$.event = ButtonReleaseMask; $<button>$.count = 0; } | BTN2_CLICK_TOK { $<button>$.button = Button2Mask; $<button>$.event = ButtonPressMask|ButtonReleaseMask; $<button>$.count = 1; } | BTN2_CLICK2_TOK { $<button>$.button = Button2Mask; $<button>$.event = ButtonPressMask|ButtonReleaseMask; $<button>$.count = 2; } | BTN3_DOWN_TOK { $<button>$.button = Button3Mask; $<button>$.event = ButtonPressMask; $<button>$.count = 0; } | BTN3_UP_TOK { $<button>$.button = Button3Mask; $<button>$.event = ButtonReleaseMask; $<button>$.count = 0; } | BTN3_CLICK_TOK { $<button>$.button = Button3Mask; $<button>$.event = ButtonPressMask|ButtonReleaseMask; $<button>$.count = 1; } | BTN3_CLICK2_TOK { $<button>$.button = Button3Mask; $<button>$.event = ButtonPressMask|ButtonReleaseMask; $<button>$.count = 2; } | BTN4_DOWN_TOK { $<button>$.button = Button4Mask; $<button>$.event = ButtonPressMask; $<button>$.count = 0; } | BTN4_UP_TOK { $<button>$.button = Button4Mask; $<button>$.event = ButtonReleaseMask; $<button>$.count = 0; } | BTN4_CLICK_TOK { $<button>$.button = Button4Mask; $<button>$.event = ButtonPressMask|ButtonReleaseMask; $<button>$.count = 1; } | BTN4_CLICK2_TOK { $<button>$.button = Button4Mask; $<button>$.event = ButtonPressMask|ButtonReleaseMask; $<button>$.count = 2; } | BTN5_DOWN_TOK { $<button>$.button = Button5Mask; $<button>$.event = ButtonPressMask; $<button>$.count = 0; } | BTN5_UP_TOK { $<button>$.button = Button5Mask; $<button>$.event = ButtonReleaseMask; $<button>$.count = 0; } | BTN5_CLICK_TOK { $<button>$.button = Button5Mask; $<button>$.event = ButtonPressMask|ButtonReleaseMask; $<button>$.count = 1; } | BTN5_CLICK2_TOK { $<button>$.button = Button5Mask; $<button>$.event = ButtonPressMask|ButtonReleaseMask; $<button>$.count = 2; } | error { yyerror("Invalid button event name"); $<button>$.button = 0; $<button>$.event = 0; $<button>$.count = 0; };label: string { $<label>$.type = IS_STRING; $<label>$.string = $1; } | bitmap_file { $<label>$.type = IS_BITMAP; $<label>$.string = $1; } | error { yyerror("Invalid label"); $<label>$.type = IS_STRING; $<label>$.string = ""; };bitmap_file: '@' string { $<string>$ = $2; };mnemonic: '_' string { if (strlen($<string>2) != 1) { yyerror("Invalid mnemonic specification"); $<key>$ = 0; } else { $<key>$ = XStringToKeysym($<string>2); } } | { $<key>$ = 0; };function: FBEEP_TOK { $<function>$.func = F_BEEP; $<function>$.arg = ""; } | FCIRCLE_DOWN_TOK optional_arg { $<function>$.func = F_CIRCULATE_DOWN; $<function>$.arg = $<string>2; } | FCIRCLE_UP_TOK optional_arg { $<function>$.func = F_CIRCULATE_UP; $<function>$.arg = $<string>2; } | FEXEC_TOK string { $<function>$.func = F_EXEC; $<function>$.arg = $<string>2; } | '!' string { $<function>$.func = F_EXEC; $<function>$.arg = $<string>2; } | FFOCUS_COLOR_TOK { $<function>$.func = F_FOCUS_COLOR; $<function>$.arg = ""; } | FFOCUS_KEY_TOK { $<function>$.func = F_FOCUS_KEY; $<function>$.arg = ""; } | FKILL_TOK { $<function>$.func = F_CLOSE; $<function>$.arg = ""; } | FLOWER_TOK optional_arg { $<function>$.func = F_LOWER; $<function>$.arg = $<string>2; } | FMAXIMIZE_TOK { $<function>$.func = F_MAXIMIZE; $<function>$.arg = ""; } | FMENU_TOK string { $<function>$.func = F_POPUP; $<function>$.arg = $<string>2; } | FMINIMIZE_TOK { $<function>$.func = F_ICONIFY; $<function>$.arg = ""; } | FMOVE_TOK { $<function>$.func = F_MOVE; $<function>$.arg = ""; } | FNEXT_CMAP_TOK { $<function>$.func = F_NEXT_CMAP; $<function>$.arg = ""; } | FNEXT_KEY_TOK optional_arg { $<function>$.func = F_NEXT_KEY; $<function>$.arg = $<string>2; } | FNOP_TOK { $<function>$.func = F_NOP; $<function>$.arg = ""; } | FNORMALIZE_TOK { $<function>$.func = F_NORMALIZE; $<function>$.arg = ""; } | FNORMANDRAISE_TOK { $<function>$.func = F_NORM_AND_RAISE; $<function>$.arg = ""; } | FPACK_ICONS_TOK { $<function>$.func = F_PACK_ICONS; $<function>$.arg = ""; } | FPASS_KEYS_TOK { $<function>$.func = F_PASS_KEYS; $<function>$.arg = ""; } | FPOST_WMENU_TOK { $<function>$.func = F_W_POPUP; $<function>$.arg = ""; } | FPREV_CMAP_TOK { $<function>$.func = F_PREV_CMAP; $<function>$.arg = ""; } | FPREV_KEY_TOK optional_arg { $<function>$.func = F_PREV_KEY; $<function>$.arg = $<string>2; } | FQUIT_MWM_TOK { $<function>$.func = F_QUIT; $<function>$.arg = ""; } | FRAISE_TOK optional_arg { $<function>$.func = F_RAISE; $<function>$.arg = $<string>2; } | FRAISE_LOWER_TOK optional_arg { $<function>$.func = F_RAISELOWER; $<function>$.arg = $<string>2; } | FREFRESH_TOK { $<function>$.func = F_REFRESH; $<function>$.arg = ""; } | FREFRESH_WIN_TOK { $<function>$.func = F_REFRESH_WIN; $<function>$.arg = ""; } | FRESIZE_TOK { $<function>$.func = F_RESIZE; $<function>$.arg = ""; } | FRESTORE_TOK { $<function>$.func = F_ICONIFY; $<function>$.arg = ""; } | FRESTOREANDRAISE_TOK { $<function>$.func = F_RESTORE_AND_RAISE; $<function>$.arg = ""; } | FRESTART_TOK optional_arg { $<function>$.func = F_RESTART; $<function>$.arg = $<string>2; } | FSCREEN_TOK optional_arg { $<function>$.func = F_SCREEN; $<function>$.arg = $<string>2; } | FSEND_MSG_TOK string { $<function>$.func = F_SEND_MSG; $<function>$.arg = $<string>2; } | FSEPARATOR_TOK { $<function>$.func = F_NOP; $<function>$.arg = ""; } | FSET_BEHAVIOR_TOK { $<function>$.func = F_SET_BEHAVIOR; $<function>$.arg = ""; } | FTITLE_TOK { $<function>$.func = F_TITLE; $<function>$.arg = ""; } | FWINDOWLIST_TOK { $<function>$.func = F_WINDOWLIST; $<function>$.arg = ""; } | error { yyerror("Invalid mnemonic, accelerator, or function"); $<function>$.func = F_NOP; $<function>$.arg = ""; };optional_arg: arg { $<string>$ = $<string>1; } | { $<string>$ = ""; };arg: '-' string { $<string>$ = $<string>2; } | ROOT_TOK { $<string>$ = "ROOT"; } | WINDOW_TOK { $<string>$ = "WINDOW"; } | TRANSIENT_TOK { $<string>$ = "TRANSIENT"; } | ICON_TOK { $<string>$ = "ICON"; } | WITHIN_TOK { $<string>$ = "WITHIN"; } | FREE_FAMILY_TOK { $<string>$ = "FREE_FAMILY"; } | NEXT_TOK { $<string>$ = "NEXT"; } | PREV_TOK { $<string>$ = "PREV"; } | BACK_TOK { $<string>$ = "BACK"; };string: STRING_TOK { $<string>$ = $<string>1; };%%/* * these to variables are used by the parser to control input */#define MAX_UNGET 1024static const char *curpos;static const char *endpos;static const char *input_buf;static char unget[MAX_UNGET];static int upos = 0;static char *_MwmRootMenu = DEFAULT_MWM_ROOT_MENU;static char *_MwmKeyBindings = DEFAULT_MWM_KEY_BINDINGS;static char *_MwmWindowMenu = DEFAULT_MWM_WINDOW_MENU;static char *_MwmBehaviorKey = MWM_BEHAVIOR_KEY_BINDINGS;static char *_MwmBuiltinButtonBindings = BUILTIN_MWM_BUTTON_BINDINGS;static char *_MwmBuiltinMenuButtonBindings = BUILTIN_MENU_BUTTON_BINDINGS;static char *_MwmBuiltinKillButtonBindings = BUILTIN_KILL_BUTTON_BINDINGS;static char *_MwmBuiltinIconButtonBindings = BUILTIN_ICON_BUTTON_BINDINGS;voidyyerror(const char *fmt, ...) { va_list arg_list; va_start(arg_list, fmt); vfprintf(stderr, fmt, arg_list); va_end(arg_list); fprintf(stderr, " at line %d\n", lineno);}charmwm_getc(void) { char c; if (upos) { upos--; c = unget[upos]; if (c == '\n') lineno++; return c; } if (curpos >= endpos) return 0; else if (*curpos == 0) { curpos++; return 0; } c = *curpos; curpos++; if (c == '\n') lineno++; return c;}voidmwm_putc(char c) { printf("OUTPUT: %c\n", c);}voidmwm_unputc(char c) { if (upos == MAX_UNGET) { yyerror("Lexer can't back up anymore.\n"); return; } if (c == '\n') lineno--; unget[upos] = c; upos++;}intPARSE_buf(ScreenInfo *scr, char *buffer) { pscr = scr; lineno = 1; curpos = input_buf = buffer; endpos = input_buf + strlen(input_buf); upos = 0; return yyparse();}static voiddo_standard(ScreenInfo *scr){ skip_test = True; PARSE_buf(scr, _MwmRootMenu); PARSE_buf(scr, _MwmWindowMenu); PARSE_buf(scr, _MwmKeyBindings); PARSE_buf(scr, _MwmBehaviorKey); /* a certain amount seems to be expected as builtin */ PARSE_buf(scr, _MwmBuiltinButtonBindings); if (Mwm.w_menu_button_click) PARSE_buf(scr, _MwmBuiltinMenuButtonBindings); if (Mwm.w_menu_button_click_2) PARSE_buf(scr, _MwmBuiltinKillButtonBindings); if (Mwm.icon_click) PARSE_buf(scr, _MwmBuiltinIconButtonBindings); PROP_SetBehavior(scr, False);}static voiddo_custom(ScreenInfo *scr){ char *configfile, *ptr; int fd; configfile=find_config_file(); if (configfile==NULL) { yyerror("Cannot find configuration file. " "Using builtin defaults.\n", configfile); do_standard(scr); return; } #ifdef __EMX__ if ((fd = open(configfile, O_RDONLY|O_TEXT)) < 0)#else if ((fd = open(configfile, O_RDONLY)) < 0)#endif { yyerror("Cannot open configuration file '%s'. " "Using builtin defaults.\n", configfile); do_standard(scr); } else { int bytes_read, statrc; struct stat st; if (debugging) fprintf(stderr, "Reading configuration from '%s'\n", configfile); statrc=stat(configfile, &st); ptr = XtMalloc(st.st_size + 1); bytes_read=read(fd, ptr, st.st_size); close(fd); skip_test = False; ptr[bytes_read] = '\0'; PARSE_buf(scr, ptr); /* a certain amount seems to be expected as builtin */ skip_test = True; PARSE_buf(scr, _MwmBuiltinButtonBindings); if (Mwm.w_menu_button_click) PARSE_buf(scr, _MwmBuiltinMenuButtonBindings); if (Mwm.w_menu_button_click_2) PARSE_buf(scr, _MwmBuiltinKillButtonBindings); if (Mwm.icon_click) PARSE_buf(scr, _MwmBuiltinIconButtonBindings); PROP_SetBehavior(scr, True); XtFree(ptr); } XtFree(configfile);}voidPARSE_mwmrc(ScreenInfo *scr) { int flag; key_bind_found = False; button_bind_found = False; key_bind_match = False; button_bind_match = False; if ((flag = PROP_GetBehavior(scr)) & MWM_INFO_STARTUP_CUSTOM) { if (debugging) printf("parsing custom file.\n"); do_custom(scr); } else if (flag & MWM_INFO_STARTUP_STANDARD) { if (debugging) printf("parsing standard bindings.\n"); do_standard(scr); } else { if (debugging) printf("parsing custom file by default.\n"); do_custom(scr); } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -