1 /*****************************************************************************/
2 /** Copyright 1988 by Evans & Sutherland Computer Corporation, **/
3 /** Salt Lake City, Utah **/
4 /** Portions Copyright 1989 by the Massachusetts Institute of Technology **/
5 /** Cambridge, Massachusetts **/
7 /** All Rights Reserved **/
9 /** Permission to use, copy, modify, and distribute this software and **/
10 /** its documentation for any purpose and without fee is hereby **/
11 /** granted, provided that the above copyright notice appear in all **/
12 /** copies and that both that copyright notice and this permis- **/
13 /** sion notice appear in supporting documentation, and that the **/
14 /** names of Evans & Sutherland and M.I.T. not be used in advertising **/
15 /** in publicity pertaining to distribution of the software without **/
16 /** specific, written prior permission. **/
18 /** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/
19 /** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/
20 /** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/
21 /** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/
22 /** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/
23 /** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/
24 /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/
25 /** OR PERFORMANCE OF THIS SOFTWARE. **/
26 /*****************************************************************************/
29 /***********************************************************************
31 * $XConsortium: gram.y,v 1.91 91/02/08 18:21:56 dave Exp $
33 * .twmrc command grammer
35 * 07-Jan-86 Thomas E. LaStrange File created
36 * 11-Nov-90 Dave Sternlicht Adding SaveColors
37 * 10-Oct-90 David M. Sternlicht Storing saved colors on root
39 ***********************************************************************/
52 /* djhjr - 10/30/02 */
57 #include <X11/Xmu/CharSet.h>
59 /* Submitted by Nelson H. F. Beebe */
62 #define isascii(c) ((0 <= (int)(c)) && ((int)(c) <= 127))
65 static char *Action = "";
66 static char *Name = "";
67 static MenuRoot *root, *pull = NULL;
69 static MenuRoot *GetRoot();
70 /* was type 'void' - djhjr - 10/20/01 */
71 static char *RemoveDQuote();
72 /* djhjr - 10/20/01 */
73 static char *RemoveRESlash();
74 /* djhjr - 10/16/02 */
75 static int ParseWarpCentered();
77 static int ParseUsePPosition();
78 void twmrc_error_prefix();
81 static MenuItem *lastmenuitem = (MenuItem*) 0;
83 static Bool CheckWarpScreenArg(), CheckWarpRingArg();
84 static Bool CheckColormapArg();
85 static void GotButton(), GotKey(), GotTitleButton();
86 static void yyerror();
87 static name_list **list;
89 static RootRegion *ARlist;
93 unsigned int mods_used = (ShiftMask | ControlMask | Mod1Mask);
96 /* djhjr - 10/16/02 */
99 extern void SetHighlightPixmap();
100 extern void SetVirtualPixmap(), SetVirtualDesktop(), SetRealScreenPixmap();
101 extern void NewBitmapCursor();
102 extern void AddIconRegion();
103 /* next two - djhjr - 4/26/99 */
104 extern RootRegion *AddAppletRegion();
105 extern int AddToAppletList();
106 extern int do_single_keyword(), do_string_keyword(), do_number_keyword();
107 extern name_list **do_colorlist_keyword();
108 extern int do_color_keyword();
109 extern void do_string_savecolor(), do_var_savecolor(), do_squeeze_entry();
110 /* djhjr - 6/22/01 */
111 extern int SetSound();
114 * this used to be the definition - now making the assumption it's
115 * defined in lex's skeleton file (submitted by Nelson H. F. Beebe)
127 /* djhjr - 10/20/01 */
135 %token <num> LP RP MENUS MENU BUTTON DEFAULT_FUNCTION PLUS MINUS
136 %token <num> ALL OR CURSORS PIXMAPS ICONS COLOR MONOCHROME FUNCTION
137 %token <num> ICONMGR_SHOW ICONMGR WINDOW_FUNCTION ZOOM ICONMGRS
138 %token <num> ICONMGR_GEOMETRY ICONMGR_NOSHOW MAKE_TITLE
139 %token <num> ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING
140 %token <num> NO_TITLE AUTO_RAISE NO_HILITE NO_ICONMGR_HILITE ICON_REGION
141 /* djhjr - 10/16/02 */
142 %token <num> WARP_CENTERED
143 /* djhjr - 9/24/02 */
144 %token <num> USE_PPOSITION
145 /* submitted by Tim Wiess - 8/23/02 */
146 %token <num> NO_BORDER
147 /* djhjr - 4/26/99 */
148 %token <num> APPLET_REGION
149 %token <num> META SHIFT LOCK CONTROL WINDOW TITLE ICON ROOT FRAME VIRTUAL VIRTUAL_WIN
150 /* TILDE - djhjr - 10/20/01 */
151 %token <num> COLON EQUALS TILDE SQUEEZE_TITLE DONT_SQUEEZE_TITLE
152 /* opaque stuff - djhjr - 4/7/98 */
153 %token <num> OPAQUE_MOVE NO_OPAQUE_MOVE OPAQUE_RESIZE NO_OPAQUE_RESIZE
154 %token <num> START_ICONIFIED NO_TITLE_HILITE TITLE_HILITE
155 %token <num> MOVE RESIZE WAIT SELECT KILL LEFT_TITLEBUTTON RIGHT_TITLEBUTTON
156 /* MKEYWORD - djhjr - 10/20/01 */
157 %token <num> NUMBER KEYWORD MKEYWORD NKEYWORD CKEYWORD CLKEYWORD FKEYWORD FSKEYWORD
158 /* SNKEYWORD - djhjr - 10/18/02 */
159 /* NO_WINDOW_RING submitted by Jonathan Paisley - 10/27/02 */
160 %token <num> SNKEYWORD SKEYWORD DKEYWORD JKEYWORD WINDOW_RING NO_WINDOW_RING WARP_CURSOR
161 %token <num> ERRORTOKEN NO_STACKMODE NAILEDDOWN VIRTUALDESKTOP NO_SHOW_IN_DISPLAY
162 /* Submitted by Erik Agsjo <erik.agsjo@aktiedirekt.com> */
163 %token <num> NO_SHOW_IN_TWMWINDOWS
166 %token <num> VIRTUALMAP
167 %token <num> REALSCREENMAP
168 /* two pixmaps - djhjr - 10/30/02 */
169 %token <num> ICONMGRICONMAP
170 %token <num> MENUICONMAP
172 /* djhjr - 6/22/01 */
174 /* REGEXP - djhjr - 10/20/01 */
175 %token <ptr> STRING REGEXP
176 /* djhjr - 9/10/03 */
177 %token <num> IGNORE_MODS
182 /* regex stuff - djhjr - 10/20/01 */
183 %type <match> matcher
184 %type <ptr> string regexp
185 %type <num> action button number signed_number full fullkey
204 | ICON_REGION string DKEYWORD DKEYWORD number number
205 { AddIconRegion($2, $3, $4, $5, $6); }
206 | APPLET_REGION string DKEYWORD DKEYWORD number number
207 { ARlist = AddAppletRegion($2, $3, $4, $5, $6); }
209 | ICONMGR_GEOMETRY string number { if (Scr->FirstTime)
211 Scr->iconmgr.geometry=$2;
212 Scr->iconmgr.columns=$3;
215 | ICONMGR_GEOMETRY string { if (Scr->FirstTime)
216 Scr->iconmgr.geometry = $2;
218 | ZOOM number { if (Scr->FirstTime)
224 | ZOOM { if (Scr->FirstTime)
225 Scr->DoZoom = TRUE; }
226 | PIXMAPS pixmap_list {}
227 | CURSORS cursor_list {}
228 | ICONIFY_BY_UNMAPPING { list = &Scr->IconifyByUn; }
230 | ICONIFY_BY_UNMAPPING { if (Scr->FirstTime)
231 Scr->IconifyByUnmapping = TRUE; }
233 | OPAQUE_MOVE { list = &Scr->OpaqueMoveL; }
235 | OPAQUE_MOVE { if (Scr->FirstTime) Scr->OpaqueMove = TRUE; }
236 | NO_OPAQUE_MOVE { list = &Scr->NoOpaqueMoveL; }
238 | NO_OPAQUE_MOVE { if (Scr->FirstTime) Scr->OpaqueMove = FALSE; }
239 | OPAQUE_RESIZE { list = &Scr->OpaqueResizeL; }
241 | OPAQUE_RESIZE { if (Scr->FirstTime) Scr->OpaqueResize = TRUE; }
242 | NO_OPAQUE_RESIZE { list = &Scr->NoOpaqueResizeL; }
244 | NO_OPAQUE_RESIZE { if (Scr->FirstTime) Scr->OpaqueResize = FALSE; }
246 | LEFT_TITLEBUTTON string EQUALS action {
247 GotTitleButton ($2, $4, False);
249 | RIGHT_TITLEBUTTON string EQUALS action {
250 GotTitleButton ($2, $4, True);
252 | button string { root = GetRoot($2, NULLSTR, NULLSTR);
253 Scr->Mouse[$1][C_ROOT][0].func = F_MENU;
254 Scr->Mouse[$1][C_ROOT][0].menu = root;
256 | button action { Scr->Mouse[$1][C_ROOT][0].func = $2;
260 Scr->Mouse[$1][C_ROOT][0].menu = pull;
264 root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR);
265 Scr->Mouse[$1][C_ROOT][0].item =
266 AddToMenu(root,"x",Action,
267 NULLSTR,$2,NULLSTR,NULLSTR);
272 | string fullkey { GotKey($1, $2); }
273 | button full { GotButton($1, $2); }
274 | IGNORE_MODS keys { Scr->IgnoreModifiers = mods;
277 | DONT_ICONIFY_BY_UNMAPPING { list = &Scr->DontIconify; }
279 | ICONMGR_NOSHOW { list = &Scr->IconMgrNoShow; }
281 | ICONMGR_NOSHOW { Scr->IconManagerDontShow = TRUE; }
282 | ICONMGRS { list = &Scr->IconMgrs; }
284 | ICONMGR_SHOW { list = &Scr->IconMgrShow; }
286 | NO_TITLE_HILITE { list = &Scr->NoTitleHighlight; }
288 | NO_TITLE_HILITE { if (Scr->FirstTime)
289 Scr->TitleHighlight = FALSE; }
290 | NO_ICONMGR_HILITE { Scr->IconMgrHighlight = FALSE; }
291 | NO_HILITE { list = &Scr->NoHighlight; }
293 | NO_HILITE { if (Scr->FirstTime)
294 Scr->Highlight = FALSE; }
295 | NO_STACKMODE { list = &Scr->NoStackModeL; }
297 | NO_STACKMODE { if (Scr->FirstTime)
298 Scr->StackMode = FALSE; }
299 | NO_TITLE { list = &Scr->NoTitle; }
301 | NO_TITLE { if (Scr->FirstTime)
302 Scr->NoTitlebar = TRUE; }
303 | NO_BORDER { list = &Scr->NoBorder; }
305 | NO_BORDER { if (Scr->FirstTime)
306 Scr->NoBorders = TRUE; }
307 | MAKE_TITLE { list = &Scr->MakeTitle; }
309 | START_ICONIFIED { list = &Scr->StartIconified; }
311 | AUTO_RAISE { list = &Scr->AutoRaise; }
313 | AUTO_RAISE { Scr->AutoRaiseDefault = TRUE; }
314 | WARP_CENTERED string { if (Scr->FirstTime) {
315 if ((warpc = ParseWarpCentered($2)) != -1)
316 Scr->WarpCentered = warpc;
319 | USE_PPOSITION string { if (Scr->FirstTime) {
320 if ((ppos = ParseUsePPosition($2)) != -1)
321 Scr->UsePPosition = ppos;
324 | USE_PPOSITION { list = &Scr->UsePPositionL; }
326 | USE_PPOSITION string { if (Scr->FirstTime) {
327 if ((ppos = ParseUsePPosition($2)) != -1)
328 Scr->UsePPosition = ppos;
330 list = &Scr->UsePPositionL;
333 | MENU string LP string COLON string RP {
334 root = GetRoot($2, $4, $6); }
335 menu { root->real_menu = TRUE;}
336 | MENU string { root = GetRoot($2, NULLSTR, NULLSTR); }
337 menu { root->real_menu = TRUE; }
338 | FUNCTION string { root = GetRoot($2, NULLSTR, NULLSTR); }
340 | ICONS { list = &Scr->IconNames; }
344 | COLOR { color = COLOR; }
348 | MONOCHROME { color = MONOCHROME; }
350 | DEFAULT_FUNCTION action { Scr->DefaultFunction.func = $2;
354 Scr->DefaultFunction.menu = pull;
358 root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR);
359 Scr->DefaultFunction.item =
360 AddToMenu(root,"x",Action,
361 NULLSTR,$2, NULLSTR, NULLSTR);
366 | WINDOW_FUNCTION action { Scr->WindowFunction.func = $2;
367 root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR);
368 Scr->WindowFunction.item =
369 AddToMenu(root,"x",Action,
370 NULLSTR,$2, NULLSTR, NULLSTR);
374 | WARP_CURSOR { list = &Scr->WarpCursorL; }
376 | WARP_CURSOR { if (Scr->FirstTime)
377 Scr->WarpCursor = TRUE; }
378 | WINDOW_RING { list = &Scr->WindowRingL; }
380 | WINDOW_RING { if (Scr->FirstTime)
381 Scr->UseWindowRing = TRUE; }
382 | NO_WINDOW_RING { list = &Scr->NoWindowRingL; }
384 | NAILEDDOWN { list = &Scr->NailedDown; }
386 | VIRTUALDESKTOP string number
387 { SetVirtualDesktop($2, $3); }
388 | NO_SHOW_IN_DISPLAY { list = &Scr->DontShowInDisplay; }
390 | NO_SHOW_IN_TWMWINDOWS { list = &Scr->DontShowInTWMWindows; }
395 noarg : KEYWORD { if (!do_single_keyword ($1)) {
396 twmrc_error_prefix();
398 "unknown singleton keyword %d\n",
405 sarg : SKEYWORD string { if (!do_string_keyword ($1, $2)) {
406 twmrc_error_prefix();
408 "unknown string keyword %d (value \"%s\")\n",
415 narg : NKEYWORD number { if (!do_number_keyword ($1, $2)) {
416 twmrc_error_prefix();
418 "unknown numeric keyword %d (value %d)\n",
425 /* djhjr - 10/18/02 */
426 snarg : SNKEYWORD signed_number { if (!do_number_keyword ($1, $2)) {
427 twmrc_error_prefix();
429 "unknown signed keyword %d (value %d)\n",
438 full : EQUALS keys COLON contexts COLON action { $$ = $6; }
441 fullkey : EQUALS keys COLON contextkeys COLON action { $$ = $6; }
448 key : META { mods |= Mod1Mask; }
449 | SHIFT { mods |= ShiftMask; }
450 | LOCK { mods |= LockMask; }
451 | CONTROL { mods |= ControlMask; }
452 | META number { if ($2 < 1 || $2 > 5) {
453 twmrc_error_prefix();
455 "bad modifier number (%d), must be 1-5\n",
459 mods |= (Mod1Mask << ($2 - 1));
465 contexts : /* Empty */
469 context : WINDOW { cont |= C_WINDOW_BIT; }
470 | TITLE { cont |= C_TITLE_BIT; }
471 | ICON { cont |= C_ICON_BIT; }
472 | ROOT { cont |= C_ROOT_BIT; }
473 | FRAME { cont |= C_FRAME_BIT; }
474 | ICONMGR { cont |= C_ICONMGR_BIT; }
475 | META { cont |= C_ICONMGR_BIT; }
476 | VIRTUAL { cont |= C_VIRTUAL_BIT; }
477 | VIRTUAL_WIN { cont |= C_VIRTUAL_WIN_BIT; }
478 | DOOR { cont |= C_DOOR_BIT; }
479 | ALL { cont |= C_ALL_BITS; }
483 contextkeys : /* Empty */
484 | contextkeys contextkey
487 contextkey : WINDOW { cont |= C_WINDOW_BIT; }
488 | TITLE { cont |= C_TITLE_BIT; }
489 | ICON { cont |= C_ICON_BIT; }
490 | ROOT { cont |= C_ROOT_BIT; }
491 | FRAME { cont |= C_FRAME_BIT; }
492 | ICONMGR { cont |= C_ICONMGR_BIT; }
493 | META { cont |= C_ICONMGR_BIT; }
494 | VIRTUAL { cont |= C_VIRTUAL_BIT; }
495 | VIRTUAL_WIN { cont |= C_VIRTUAL_WIN_BIT; }
496 | DOOR { cont |= C_DOOR_BIT; }
497 | ALL { cont |= C_ALL_BITS; }
499 | string { Name = $1; cont |= C_NAME_BIT; }
503 pixmap_list : LB pixmap_entries RB
506 pixmap_entries : /* Empty */
507 | pixmap_entries pixmap_entry
510 pixmap_entry : TITLE_HILITE string { SetHighlightPixmap ($2); }
511 | VIRTUALMAP string { SetVirtualPixmap ($2); }/*RFB PIXMAP*/
512 | REALSCREENMAP string { SetRealScreenPixmap ($2); }/*RFB PIXMAP*/
513 | ICONMGRICONMAP string { SetIconMgrPixmap($2); } /* djhjr - 10/30/02 */
514 | MENUICONMAP string { SetMenuIconPixmap($2); } /* djhjr - 10/30/02 */
518 cursor_list : LB cursor_entries RB
521 cursor_entries : /* Empty */
522 | cursor_entries cursor_entry
525 cursor_entry : FRAME string string {
526 NewBitmapCursor(&Scr->FrameCursor, $2, $3); }
528 NewFontCursor(&Scr->FrameCursor, $2); }
529 | TITLE string string {
530 NewBitmapCursor(&Scr->TitleCursor, $2, $3); }
532 NewFontCursor(&Scr->TitleCursor, $2); }
533 | ICON string string {
534 NewBitmapCursor(&Scr->IconCursor, $2, $3); }
536 NewFontCursor(&Scr->IconCursor, $2); }
537 | ICONMGR string string {
538 NewBitmapCursor(&Scr->IconMgrCursor, $2, $3); }
540 NewFontCursor(&Scr->IconMgrCursor, $2); }
541 | BUTTON string string {
542 NewBitmapCursor(&Scr->ButtonCursor, $2, $3); }
544 NewFontCursor(&Scr->ButtonCursor, $2); }
545 | MOVE string string {
546 NewBitmapCursor(&Scr->MoveCursor, $2, $3); }
548 NewFontCursor(&Scr->MoveCursor, $2); }
549 | RESIZE string string {
550 NewBitmapCursor(&Scr->ResizeCursor, $2, $3); }
552 NewFontCursor(&Scr->ResizeCursor, $2); }
553 | WAIT string string {
554 NewBitmapCursor(&Scr->WaitCursor, $2, $3); }
556 NewFontCursor(&Scr->WaitCursor, $2); }
557 | MENU string string {
558 NewBitmapCursor(&Scr->MenuCursor, $2, $3); }
560 NewFontCursor(&Scr->MenuCursor, $2); }
561 | SELECT string string {
562 NewBitmapCursor(&Scr->SelectCursor, $2, $3); }
564 NewFontCursor(&Scr->SelectCursor, $2); }
565 | KILL string string {
566 NewBitmapCursor(&Scr->DestroyCursor, $2, $3); }
568 NewFontCursor(&Scr->DestroyCursor, $2); }
569 | DOOR string string {/*RFBCURSOR*/
570 NewBitmapCursor(&Scr->DoorCursor, $2, $3); }/*RFBCURSOR*/
571 | DOOR string {/*RFBCURSOR*/
572 NewFontCursor(&Scr->DoorCursor, $2); }/*RFBCURSOR*/
573 | VIRTUAL string string {/*RFBCURSOR*/
574 NewBitmapCursor(&Scr->VirtualCursor, $2, $3); }/*RFBCURSOR*/
575 | VIRTUAL string {/*RFBCURSOR*/
576 NewFontCursor(&Scr->VirtualCursor, $2); }/*RFBCURSOR*/
577 | VIRTUAL_WIN string string {/*RFBCURSOR*/
578 NewBitmapCursor(&Scr->DesktopCursor, $2, $3); }/*RFBCURSOR*/
579 | VIRTUAL_WIN string {/*RFBCURSOR*/
580 NewFontCursor(&Scr->DesktopCursor, $2); }/*RFBCURSOR*/
583 color_list : LB color_entries RB
587 color_entries : /* Empty */
588 | color_entries color_entry
591 color_entry : CLKEYWORD string { if (!do_colorlist_keyword ($1, color,
593 twmrc_error_prefix();
595 "unhandled list color keyword %d (string \"%s\")\n",
600 | CLKEYWORD string { list = do_colorlist_keyword($1,color,
603 twmrc_error_prefix();
605 "unhandled color list keyword %d (string \"%s\")\n",
611 | CKEYWORD string { if (!do_color_keyword ($1, color,
613 twmrc_error_prefix();
615 "unhandled color keyword %d (string \"%s\")\n",
622 save_color_list : LB s_color_entries RB
625 s_color_entries : /* Empty */
626 | s_color_entries s_color_entry
629 s_color_entry : string { do_string_savecolor(color, $1); }
630 | CLKEYWORD { do_var_savecolor($1); }
633 win_color_list : LB win_color_entries RB
636 win_color_entries : /* Empty */
637 | win_color_entries win_color_entry
640 /* 'matcher', mods to 'AddToList()' - djhjr - 10/20/01 */
641 win_color_entry : matcher string { if (Scr->FirstTime &&
642 color == Scr->Monochrome)
643 AddToList(list, $1.lval, $1.ltype,
647 squeeze : SQUEEZE_TITLE {
648 if (HasShape) Scr->SqueezeTitle = TRUE;
650 | SQUEEZE_TITLE { list = &Scr->SqueezeTitleL;
651 if (HasShape && Scr->SqueezeTitle == -1)
652 Scr->SqueezeTitle = TRUE;
654 LB win_sqz_entries RB
655 | DONT_SQUEEZE_TITLE { Scr->SqueezeTitle = FALSE; }
656 | DONT_SQUEEZE_TITLE { list = &Scr->DontSqueezeTitleL; }
660 /* 'matcher', mods to 'do_sqeeze_entry()' - djhjr - 10/20/01 */
661 win_sqz_entries : /* Empty */
662 | win_sqz_entries matcher JKEYWORD signed_number signed_number {
663 if (Scr->FirstTime) {
664 do_squeeze_entry (list, $2.lval, $2.ltype,
670 doors : DOORS LB door_list RB
673 door_list : /* Empty */
674 | door_list door_entry
677 door_entry : string string string
679 (void) door_add($1, $2, $3);
683 iconm_list : LB iconm_entries RB
686 iconm_entries : /* Empty */
687 | iconm_entries iconm_entry
690 /* 'matcher', mods to 'AddToList()', 'AllocateIconManager()' - djhjr - 10/20/01 */
691 iconm_entry : matcher string number { if (Scr->FirstTime)
692 AddToList(list, $1.lval, $1.ltype, (char *)
693 AllocateIconManager($1.lval,
696 | matcher string string number
697 { if (Scr->FirstTime)
698 AddToList(list, $1.lval, $1.ltype, (char *)
699 AllocateIconManager($1.lval,
704 win_list : LB win_entries RB
707 win_entries : /* Empty */
708 | win_entries win_entry
711 /* 'matcher', mods to 'AddToList()' - djhjr - 10/20/01 */
712 win_entry : matcher { if (Scr->FirstTime)
713 AddToList(list, $1.lval, $1.ltype, 0);
717 icon_list : LB icon_entries RB
720 icon_entries : /* Empty */
721 | icon_entries icon_entry
724 /* 'matcher', mods to 'AddToList()' - djhjr - 10/20/01 */
725 icon_entry : matcher string { if (Scr->FirstTime)
726 AddToList(list, $1.lval, $1.ltype, $2);
730 /* djhjr - 9/24/02 */
731 ppos_list : LB ppos_entries RB
734 ppos_entries : /* Empty */
735 | ppos_entries ppos_entry
738 /* 'matcher', mods to 'AddToList()' - djhjr - 10/20/01 */
739 ppos_entry : matcher string { if (Scr->FirstTime) {
740 if ((ppos = ParseUsePPosition($2)) != -1)
741 AddToList(list, $1.lval, $1.ltype, (char *)&ppos);
746 /* djhjr - 6/22/01 */
747 sound_list : LB sound_entries RB
750 /* djhjr - 6/22/01 */
751 sound_entries : /* Empty */
752 | sound_entries sound_entry
755 /* djhjr - 8/16/01 */
756 sound_entry : string string { if (Scr->FirstTime) SetSound($1, $2, -1); }
757 | string string number { if (Scr->FirstTime) SetSound($1, $2, $3); }
760 /* djhjr - 4/26/99 */
761 applet_list : LB applet_entries RB
764 /* djhjr - 4/26/99 */
765 applet_entries : /* Empty */
766 | applet_entries applet_entry
769 /* djhjr - 4/26/99 */
770 /* 'matcher', mods to 'AddToAppletList()' - djhjr - 10/20/01 */
771 applet_entry : matcher { if (Scr->FirstTime)
772 AddToAppletList(ARlist,
777 function : LB function_entries RB
780 function_entries: /* Empty */
781 | function_entries function_entry
784 function_entry : action { AddToMenu(root, "", Action, NULLSTR, $1,
791 menu : LB menu_entries RB
793 menu : LB menu_entries RB {lastmenuitem = (MenuItem*) 0;}
796 menu_entries : /* Empty */
797 | menu_entries menu_entry
801 menu_entry : string action { AddToMenu(root, $1, Action, pull, $2,
806 | string LP string COLON string RP action {
807 AddToMenu(root, $1, Action, pull, $7,
814 menu_entry : string action {
815 if ($2 == F_SEPARATOR) {
816 if (lastmenuitem) lastmenuitem->separated = 1;
819 lastmenuitem = AddToMenu(root, $1, Action, pull, $2, NULLSTR, NULLSTR);
824 | string LP string COLON string RP action {
825 if ($7 == F_SEPARATOR) {
826 if (lastmenuitem) lastmenuitem->separated = 1;
829 lastmenuitem = AddToMenu(root, $1, Action, pull, $7, $3, $5);
836 action : FKEYWORD { $$ = $1; }
842 pull = GetRoot ($2, NULLSTR,NULLSTR);
846 if (!CheckWarpRingArg (Action)) {
847 twmrc_error_prefix();
849 "ignoring invalid f.warptoring argument \"%s\"\n",
854 if (!CheckWarpScreenArg (Action)) {
855 twmrc_error_prefix();
857 "ignoring invalid f.warptoscreen argument \"%s\"\n",
863 if (CheckColormapArg (Action)) {
866 twmrc_error_prefix();
868 "ignoring invalid f.colormap argument \"%s\"\n",
878 button : BUTTON number { $$ = $2;
880 yyerror("bad button 0");
882 if ($2 > MAX_BUTTONS)
885 yyerror("button number too large");
890 /* djhjr - 10/20/01 */
891 matcher : string { $$.ltype = LTYPE_ANY_STRING;
894 | regexp { $$.ltype = LTYPE_ANY_REGEXP;
897 | MKEYWORD EQUALS string { $$.ltype = $1 | LTYPE_STRING;
900 | MKEYWORD TILDE regexp { $$.ltype = $1 | LTYPE_REGEXP;
905 string : STRING { $$ = RemoveDQuote($1); }
908 /* djhjr - 10/20/01 */
909 regexp : REGEXP { $$ = RemoveRESlash($1); }
912 signed_number : number { $$ = $1; }
913 | PLUS number { $$ = $2; }
914 | MINUS number { $$ = -($2); }
917 number : NUMBER { $$ = $1; }
924 twmrc_error_prefix();
925 fprintf (stderr, "error in input file: %s\n", s ? s : "");
929 /* do manipulations in place, then copy it - djhjr - 10/20/01 */
930 static char *RemoveDQuote(str)
933 register char *i, *o;
934 register int n, count;
938 for (i = str + 1, o = str; *i && *i != '\"'; o++)
969 case '1': case '2': case '3':
970 case '4': case '5': case '6': case '7':
973 while (*i >= '0' && *i <= '7' && count < 3)
975 n = (n << 3) + (*i++ - '0');
984 while (i++, count++ < 2)
986 if (*i >= '0' && *i <= '9')
987 n = (n << 4) + (*i - '0');
988 else if (*i >= 'a' && *i <= 'f')
989 n = (n << 4) + (*i - 'a') + 10;
990 else if (*i >= 'A' && *i <= 'F')
991 n = (n << 4) + (*i - 'A') + 10;
994 length--; /* account for length++ at loop end */
1002 o--; /* to account for o++ at end of loop */
1003 length--; /* account for length++ at loop end */
1022 ptr = (char *)malloc(length + 1);
1023 memcpy(ptr, str, length);
1027 fprintf(stderr, "RemoveDQuote(): '");
1028 for (n = 0; n < length; n++)
1029 fprintf(stderr, "%c", ptr[n]);
1030 fprintf(stderr, "'\n", ptr);
1037 /* djhjr - 10/20/01 */
1038 static char *RemoveRESlash(str)
1042 #ifndef NO_REGEX_SUPPORT
1043 int length = strlen(str);
1047 ptr = (char *)malloc(length - 1);
1048 memcpy(ptr, str + 1, length - 2);
1049 ptr[length - 2] = '\0';
1052 fprintf(stderr, "RemoveRESlash(): '%s'\n", ptr);
1056 twmrc_error_prefix();
1057 fprintf(stderr, "no regex support for %s\n", str);
1064 /* was in parse.c - djhjr - 9/24/02 */
1065 static int ParseUsePPosition(s)
1068 XmuCopyISOLatin1Lowered (s, s);
1070 if (strcmp(s, "off") == 0)
1072 else if (strcmp(s, "on") == 0)
1074 else if (strcmp(s, "non-zero") == 0 || strcmp(s, "nonzero") == 0)
1075 return PPOS_NON_ZERO;
1077 twmrc_error_prefix();
1078 fprintf(stderr, "ignoring invalid UsePPosition argument \"%s\"\n", s);
1082 /* djhjr - 10/16/02 */
1083 static int ParseWarpCentered(s)
1086 XmuCopyISOLatin1Lowered (s, s);
1088 if (strcmp(s, "off") == 0)
1090 else if (strcmp(s, "on") == 0)
1092 else if (strcmp(s, "titled") == 0)
1093 return WARPC_TITLED;
1094 else if (strcmp(s, "untitled") == 0)
1095 return WARPC_UNTITLED;
1097 twmrc_error_prefix();
1098 fprintf(stderr, "ignoring invalid WarpCentered argument \"%s\"\n", s);
1102 static MenuRoot *GetRoot(name, fore, back)
1108 tmp = FindMenuRoot(name);
1110 tmp = NewMenuRoot(name);
1116 save = Scr->FirstTime;
1117 Scr->FirstTime = TRUE;
1120 GetColor(COLOR, &tmp->hi_fore, fore);
1121 GetColor(COLOR, &tmp->hi_back, back);
1123 GetColor(COLOR, &tmp->highlight.fore, fore);
1124 GetColor(COLOR, &tmp->highlight.back, back);
1126 Scr->FirstTime = save;
1132 static void GotButton(butt, func)
1137 for (i = 0; i < NUM_CONTEXTS; i++)
1139 if ((cont & (1 << i)) == 0)
1142 Scr->Mouse[butt][i][mods].func = func;
1148 Scr->Mouse[butt][i][mods].menu = pull;
1152 root = GetRoot(TWM_ROOT, NULLSTR, NULLSTR);
1154 Scr->Mouse[butt][i][mods].item = AddToMenu(root,"x",Action,
1155 NULLSTR, func, NULLSTR, NULLSTR);
1166 static void GotKey(key, func)
1172 for (i = 0; i < NUM_CONTEXTS; i++)
1174 if ((cont & (1 << i)) == 0)
1176 if (!AddFuncKey(key, i, mods, func, Name, Action))
1188 static void GotTitleButton (bitmapname, func, rightside)
1193 if (!CreateTitleButton (bitmapname, func, Action, pull, rightside, True)) {
1194 twmrc_error_prefix();
1196 "unable to create %s titlebutton \"%s\"\n",
1197 rightside ? "right" : "left", bitmapname);
1203 static Bool CheckWarpScreenArg (s)
1206 XmuCopyISOLatin1Lowered (s, s);
1208 if (strcmp (s, WARPSCREEN_NEXT) == 0 ||
1209 strcmp (s, WARPSCREEN_PREV) == 0 ||
1210 strcmp (s, WARPSCREEN_BACK) == 0)
1213 for (; *s && isascii(*s) && isdigit(*s); s++) ; /* SUPPRESS 530 */
1214 return (*s ? False : True);
1218 static Bool CheckWarpRingArg (s)
1221 XmuCopyISOLatin1Lowered (s, s);
1223 if (strcmp (s, WARPSCREEN_NEXT) == 0 ||
1224 strcmp (s, WARPSCREEN_PREV) == 0)
1231 static Bool CheckColormapArg (s)
1234 XmuCopyISOLatin1Lowered (s, s);
1236 if (strcmp (s, COLORMAP_NEXT) == 0 ||
1237 strcmp (s, COLORMAP_PREV) == 0 ||
1238 strcmp (s, COLORMAP_DEFAULT) == 0)
1245 void twmrc_error_prefix ()
1247 fprintf (stderr, "%s: line %d: ", ProgramName, yylineno);