ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/menubar.C
(Generate patch)

Comparing rxvt-unicode/src/menubar.C (file contents):
Revision 1.17 by root, Sat Jul 31 15:32:50 2004 UTC vs.
Revision 1.19 by root, Sun Aug 15 04:54:21 2004 UTC

29 29
30#include "rxvt.h" /* NECESSARY */ 30#include "rxvt.h" /* NECESSARY */
31#ifdef MENUBAR 31#ifdef MENUBAR
32#include "version.h" 32#include "version.h"
33#include "menubar.h" 33#include "menubar.h"
34#include "menubar.intpro" /* PROTOS for internal routines */
35 34
36#define Menu_PixelWidth(menu) \ 35#define Menu_PixelWidth(menu) \
37 (2 * SHADOW + Width2Pixel ((menu)->width + 3 * HSPACE)) 36 (2 * SHADOW + Width2Pixel ((menu)->width + 3 * HSPACE))
38 37
39static const struct 38static const struct
40 { 39 {
41 const char name; /* (l)eft, (u)p, (d)own, (r)ight */ 40 const char name; /* (l)eft, (u)p, (d)own, (r)ight */
42 const unsigned char str[5]; /* str[0] = STRLEN (str+1) */ 41 const unsigned char str[5]; /* str[0] = strlen (str+1) */
43 } 42 }
44Arrows[NARROWS] = { 43Arrows[NARROWS] = {
45 { 'l', "\003\033[D" }, 44 { 'l', "\003\033[D" },
46 { 'u', "\003\033[A" }, 45 { 'u', "\003\033[A" },
47 { 'd', "\003\033[B" }, 46 { 'd', "\003\033[B" },
90 /* find the last item in the menu, this is good for separators */ 89 /* find the last item in the menu, this is good for separators */
91 for (item = menu->tail; item != NULL; item = item->prev) 90 for (item = menu->tail; item != NULL; item = item->prev)
92 { 91 {
93 if (item->entry.type == MenuSubMenu) 92 if (item->entry.type == MenuSubMenu)
94 { 93 {
95 if (!STRCMP (name, (item->entry.submenu.menu)->name)) 94 if (!strcmp (name, (item->entry.submenu.menu)->name))
96 break; 95 break;
97 } 96 }
98 else if ((isSeparator (name) && isSeparator (item->name)) 97 else if ((isSeparator (name) && isSeparator (item->name))
99 || !STRCMP (name, item->name)) 98 || !strcmp (name, item->name))
100 break; 99 break;
101 } 100 }
102 return item; 101 return item;
103} 102}
104 103
153rxvt_action_type (action_t *action, unsigned char *str) 152rxvt_action_type (action_t *action, unsigned char *str)
154{ 153{
155 unsigned int len; 154 unsigned int len;
156 155
157#if defined (DEBUG_MENU) || defined (DEBUG_MENUARROWS) 156#if defined (DEBUG_MENU) || defined (DEBUG_MENUARROWS)
158 len = STRLEN (str); 157 len = strlen (str);
159 fprintf (stderr, " (len %d) = %s\n", len, str); 158 fprintf (stderr, " (len %d) = %s\n", len, str);
160#else 159#else
161 len = rxvt_Str_escaped ((char *)str); 160 len = rxvt_Str_escaped ((char *)str);
162#endif 161#endif
163 162
264 beg = { NULL, 0 }, 263 beg = { NULL, 0 },
265 end = { NULL, 0 }, 264 end = { NULL, 0 },
266 *cur, 265 *cur,
267 parse[NARROWS]; 266 parse[NARROWS];
268 267
269 MEMSET (parse, 0, sizeof (parse)); 268 memset (parse, 0, sizeof (parse));
270 269
271 /* fprintf (stderr, "add arrows = `%s'\n", string); */ 270 /* fprintf (stderr, "add arrows = `%s'\n", string); */
272 for (p = string; p != NULL && *p; string = p) 271 for (p = string; p != NULL && *p; string = p)
273 { 272 {
274 p = (string + 3); 273 p = (string + 3);
295 cur->str = string; 294 cur->str = string;
296 cur->len = 0; 295 cur->len = 0;
297 296
298 if (cur == &end) 297 if (cur == &end)
299 { 298 {
300 p = STRCHR (string, '\0'); 299 p = strchr (string, '\0');
301 } 300 }
302 else 301 else
303 { 302 {
304 char *next = string; 303 char *next = string;
305 304
306 while (1) 305 while (1)
307 { 306 {
308 p = STRCHR (next, '<'); 307 p = strchr (next, '<');
309 if (p != NULL) 308 if (p != NULL)
310 { 309 {
311 if (p[1] && p[2] == '>') 310 if (p[1] && p[2] == '>')
312 break; 311 break;
313 /* parsed */ 312 /* parsed */
314 } 313 }
315 else 314 else
316 { 315 {
317 if (beg.str == NULL) /* no end needed */ 316 if (beg.str == NULL) /* no end needed */
318 p = STRCHR (next, '\0'); 317 p = strchr (next, '\0');
319 break; 318 break;
320 } 319 }
321 next = (p + 1); 320 next = (p + 1);
322 } 321 }
323 } 322 }
361 str = (unsigned char *) rxvt_malloc (parse[i].len + xtra_len + 1); 360 str = (unsigned char *) rxvt_malloc (parse[i].len + xtra_len + 1);
362 361
363 len = 0; 362 len = 0;
364 if (beg.len) 363 if (beg.len)
365 { 364 {
366 STRNCPY (str + len, beg.str, beg.len); 365 strncpy (str + len, beg.str, beg.len);
367 len += beg.len; 366 len += beg.len;
368 } 367 }
369 STRNCPY (str + len, parse[i].str, parse[i].len); 368 strncpy (str + len, parse[i].str, parse[i].len);
370 len += parse[i].len; 369 len += parse[i].len;
371 370
372 if (end.len) 371 if (end.len)
373 { 372 {
374 STRNCPY (str + len, end.str, end.len); 373 strncpy (str + len, end.str, end.len);
375 len += end.len; 374 len += end.len;
376 } 375 }
377 str[len] = '\0'; 376 str[len] = '\0';
378 377
379#ifdef DEBUG_MENUARROWS 378#ifdef DEBUG_MENUARROWS
433 item = (menuitem_t *) rxvt_malloc (sizeof (menuitem_t)); 432 item = (menuitem_t *) rxvt_malloc (sizeof (menuitem_t));
434 433
435 item->len2 = 0; 434 item->len2 = 0;
436 item->name2 = NULL; 435 item->name2 = NULL;
437 436
438 len = STRLEN (name); 437 len = strlen (name);
439 item->name = (char *)rxvt_malloc (len + 1); 438 item->name = (char *)rxvt_malloc (len + 1);
440 STRCPY (item->name, name); 439 strcpy (item->name, name);
441 if (name[0] == '.' && name[1] != '.') 440 if (name[0] == '.' && name[1] != '.')
442 len = 0; /* hidden menu name */ 441 len = 0; /* hidden menu name */
443 item->len = len; 442 item->len = len;
444 443
445 /* add to tail of list */ 444 /* add to tail of list */
457 * add action 456 * add action
458 */ 457 */
459Item_Found: 458Item_Found:
460 if (name2 != NULL && item->name2 == NULL) 459 if (name2 != NULL && item->name2 == NULL)
461 { 460 {
462 len = STRLEN (name2); 461 len = strlen (name2);
463 if (len == 0) 462 if (len == 0)
464 item->name2 = NULL; 463 item->name2 = NULL;
465 else 464 else
466 { 465 {
467 item->name2 = (char *)rxvt_malloc (len + 1); 466 item->name2 = (char *)rxvt_malloc (len + 1);
468 STRCPY (item->name2, name2); 467 strcpy (item->name2, name2);
469 } 468 }
470 item->len2 = len; 469 item->len2 = len;
471 } 470 }
472 item->entry.type = MenuLabel; 471 item->entry.type = MenuLabel;
473 len = STRLEN (action); 472 len = strlen (action);
474 473
475 if (len == 0 && item->name2 != NULL) 474 if (len == 0 && item->name2 != NULL)
476 { 475 {
477 action = item->name2; 476 action = item->name2;
478 len = item->len2; 477 len = item->len2;
479 } 478 }
480 if (len) 479 if (len)
481 { 480 {
482 unsigned char *str = (unsigned char *)rxvt_malloc (len + 1); 481 unsigned char *str = (unsigned char *)rxvt_malloc (len + 1);
483 482
484 STRCPY (str, action); 483 strcpy (str, action);
485 484
486 if (rxvt_action_type (& (item->entry.action), str) < 0) 485 if (rxvt_action_type (& (item->entry.action), str) < 0)
487 free (str); 486 free (str);
488 } 487 }
489 /* new item and a possible increase in width */ 488 /* new item and a possible increase in width */
509#endif 508#endif
510 509
511 if (path[0] == '\0') 510 if (path[0] == '\0')
512 return path; 511 return path;
513 512
514 if (STRCHR (path, '/') != NULL) 513 if (strchr (path, '/') != NULL)
515 { 514 {
516 char *p = path; 515 char *p = path;
517 516
518 while ((p = STRCHR (p, '/')) != NULL) 517 while ((p = strchr (p, '/')) != NULL)
519 { 518 {
520 p++; 519 p++;
521 if (*p == '/') 520 if (*p == '/')
522 path = p; 521 path = p;
523 } 522 }
526 { 525 {
527 path++; 526 path++;
528 *menu = NULL; 527 *menu = NULL;
529 } 528 }
530 529
531 while ((p = STRCHR (path, '/')) != NULL) 530 while ((p = strchr (path, '/')) != NULL)
532 { 531 {
533 p[0] = '\0'; 532 p[0] = '\0';
534 if (path[0] == '\0') 533 if (path[0] == '\0')
535 return NULL; 534 return NULL;
536 535
537 if (!STRCMP (path, DOT)) 536 if (!strcmp (path, DOT))
538 { 537 {
539 /* nothing to do */ 538 /* nothing to do */
540 } 539 }
541 else if (!STRCMP (path, DOTS)) 540 else if (!strcmp (path, DOTS))
542 { 541 {
543 if (*menu != NULL) 542 if (*menu != NULL)
544 *menu = (*menu)->parent; 543 *menu = (*menu)->parent;
545 } 544 }
546 else 545 else
555 554
556 path = (p + 1); 555 path = (p + 1);
557 } 556 }
558 } 557 }
559 558
560 if (!STRCMP (path, DOTS)) 559 if (!strcmp (path, DOTS))
561 { 560 {
562 path += STRLEN (DOTS); 561 path += strlen (DOTS);
563 if (*menu != NULL) 562 if (*menu != NULL)
564 *menu = (*menu)->parent; 563 *menu = (*menu)->parent;
565 return path; 564 return path;
566 } 565 }
567 566
568 /* find this menu */ 567 /* find this menu */
569 if (*menu == NULL) 568 if (*menu == NULL)
570 { 569 {
571 for (m = CurrentBar->tail; m != NULL; m = m->prev) 570 for (m = CurrentBar->tail; m != NULL; m = m->prev)
572 if (!STRCMP (path, m->name)) 571 if (!strcmp (path, m->name))
573 break; 572 break;
574 } 573 }
575 else 574 else
576 { 575 {
577 /* find this menu */ 576 /* find this menu */
578 for (item = (*menu)->tail; item != NULL; item = item->prev) 577 for (item = (*menu)->tail; item != NULL; item = item->prev)
579 { 578 {
580 if (item->entry.type == MenuSubMenu 579 if (item->entry.type == MenuSubMenu
581 && !STRCMP (path, (item->entry.submenu.menu)->name)) 580 && !strcmp (path, (item->entry.submenu.menu)->name))
582 { 581 {
583 m = (item->entry.submenu.menu); 582 m = (item->entry.submenu.menu);
584 break; 583 break;
585 } 584 }
586 } 585 }
587 } 586 }
588 587
589 if (m != NULL) 588 if (m != NULL)
590 { 589 {
591 *menu = m; 590 *menu = m;
592 path += STRLEN (path); 591 path += strlen (path);
593 } 592 }
594 593
595 return path; 594 return path;
596} 595}
597 596
671 670
672#ifdef DEBUG_STRICT 671#ifdef DEBUG_STRICT
673 assert (CurrentBar != NULL); 672 assert (CurrentBar != NULL);
674#endif 673#endif
675 674
676 if (STRCHR (path, '/') != NULL) 675 if (strchr (path, '/') != NULL)
677 { 676 {
678 char *p; 677 char *p;
679 678
680 if (path[0] == '/') 679 if (path[0] == '/')
681 { 680 {
682 /* shouldn't happen */ 681 /* shouldn't happen */
683 path++; 682 path++;
684 parent = NULL; 683 parent = NULL;
685 } 684 }
686 while ((p = STRCHR (path, '/')) != NULL) 685 while ((p = strchr (path, '/')) != NULL)
687 { 686 {
688 p[0] = '\0'; 687 p[0] = '\0';
689 if (path[0] == '\0') 688 if (path[0] == '\0')
690 return NULL; 689 return NULL;
691 690
692 parent = menu_add (parent, path); 691 parent = menu_add (parent, path);
693 path = (p + 1); 692 path = (p + 1);
694 } 693 }
695 } 694 }
696 if (!STRCMP (path, DOTS)) 695 if (!strcmp (path, DOTS))
697 return (parent != NULL ? parent->parent : parent); 696 return (parent != NULL ? parent->parent : parent);
698 697
699 if (!STRCMP (path, DOT) || path[0] == '\0') 698 if (!strcmp (path, DOT) || path[0] == '\0')
700 return parent; 699 return parent;
701 700
702 /* allocate a new menu */ 701 /* allocate a new menu */
703 menu = (menu_t *) rxvt_malloc (sizeof (menu_t)); 702 menu = (menu_t *) rxvt_malloc (sizeof (menu_t));
704 703
705 menu->width = 0; 704 menu->width = 0;
706 menu->parent = parent; 705 menu->parent = parent;
707 menu->len = STRLEN (path); 706 menu->len = strlen (path);
708 menu->name = (char *)rxvt_malloc ((menu->len + 1)); 707 menu->name = (char *)rxvt_malloc ((menu->len + 1));
709 STRCPY (menu->name, path); 708 strcpy (menu->name, path);
710 709
711 /* initialize head/tail */ 710 /* initialize head/tail */
712 menu->head = menu->tail = NULL; 711 menu->head = menu->tail = NULL;
713 menu->prev = menu->next = NULL; 712 menu->prev = menu->next = NULL;
714 713
1032 y1 = (TermWin_TotalHeight () - menu->h); 1031 y1 = (TermWin_TotalHeight () - menu->h);
1033 1032
1034 menu->x = (x1 < 0 ? 0 : x1); 1033 menu->x = (x1 < 0 ? 0 : x1);
1035 menu->y = (y1 < 0 ? 0 : y1); 1034 menu->y = (y1 < 0 ? 0 : y1);
1036 } 1035 }
1037 else if (item->name2 && !STRCMP (name, item->name2)) 1036 else if (item->name2 && !strcmp (name, item->name2))
1038 name = NULL; 1037 name = NULL;
1039 1038
1040 if (len && name) 1039 if (len && name)
1041 draw_string (*ActiveMenu->drawable, gc, TermWin.fontset, 1040 draw_string (*ActiveMenu->drawable, gc, TermWin.fontset,
1042 xoff, 2 * SHADOW + y, name, len); 1041 xoff, 2 * SHADOW + y, name, len);
1143 fprintf (stderr, "looking for [menu:%s] ...", name ? name : " (nil)"); 1142 fprintf (stderr, "looking for [menu:%s] ...", name ? name : " (nil)");
1144#endif 1143#endif
1145 if (bar == NULL || name == NULL) 1144 if (bar == NULL || name == NULL)
1146 return NULL; 1145 return NULL;
1147 1146
1148 if (STRLEN (name) && STRCMP (name, "*")) 1147 if (strlen (name) && strcmp (name, "*"))
1149 { 1148 {
1150 do 1149 do
1151 { 1150 {
1152 if (!STRCMP (bar->name, name)) 1151 if (!strcmp (bar->name, name))
1153 { 1152 {
1154#ifdef DEBUG_MENUBAR_STACKING 1153#ifdef DEBUG_MENUBAR_STACKING
1155 fprintf (stderr, " found!\n"); 1154 fprintf (stderr, " found!\n");
1156#endif 1155#endif
1157 return bar; 1156 return bar;
1177 if (CurrentBar == NULL) 1176 if (CurrentBar == NULL)
1178 { 1177 {
1179 /* allocate first one */ 1178 /* allocate first one */
1180 bar = (bar_t *) rxvt_malloc (sizeof (bar_t)); 1179 bar = (bar_t *) rxvt_malloc (sizeof (bar_t));
1181 1180
1182 MEMSET (bar, 0, sizeof (bar_t)); 1181 memset (bar, 0, sizeof (bar_t));
1183 /* circular linked-list */ 1182 /* circular linked-list */
1184 bar->next = bar->prev = bar; 1183 bar->next = bar->prev = bar;
1185 bar->head = bar->tail = NULL; 1184 bar->head = bar->tail = NULL;
1186 bar->title = NULL; 1185 bar->title = NULL;
1187 CurrentBar = bar; 1186 CurrentBar = bar;
1234 menubar_clear (); 1233 menubar_clear ();
1235 } 1234 }
1236 } 1235 }
1237 1236
1238 /* give menubar this name */ 1237 /* give menubar this name */
1239 STRNCPY (CurrentBar->name, name, MAXNAME); 1238 strncpy (CurrentBar->name, name, MAXNAME);
1240 CurrentBar->name[MAXNAME - 1] = '\0'; 1239 CurrentBar->name[MAXNAME - 1] = '\0';
1241 1240
1242 return ret; 1241 return ret;
1243} 1242}
1244 1243
1277 1276
1278 free (CurrentBar); 1277 free (CurrentBar);
1279 CurrentBar = prev; 1278 CurrentBar = prev;
1280 } 1279 }
1281 } 1280 }
1282 while (CurrentBar && !STRCMP (name, "*")); 1281 while (CurrentBar && !strcmp (name, "*"));
1283} 1282}
1284 1283
1285void 1284void
1286rxvt_action_decode (FILE *fp, action_t *act) 1285rxvt_action_decode (FILE *fp, action_t *act)
1287{ 1286{
1380 else 1379 else
1381 rxvt_menu_dump (fp, item->entry.submenu.menu); 1380 rxvt_menu_dump (fp, item->entry.submenu.menu);
1382 break; 1381 break;
1383 1382
1384 case MenuLabel: 1383 case MenuLabel:
1385 fprintf (fp, "{%s}\n", (STRLEN (item->name) ? item->name : "-")); 1384 fprintf (fp, "{%s}\n", (strlen (item->name) ? item->name : "-"));
1386 break; 1385 break;
1387 1386
1388 case MenuTerminalAction: 1387 case MenuTerminalAction:
1389 case MenuAction: 1388 case MenuAction:
1390 fprintf (fp, "{%s}", item->name); 1389 fprintf (fp, "{%s}", item->name);
1391 if (item->name2 != NULL && STRLEN (item->name2)) 1390 if (item->name2 != NULL && strlen (item->name2))
1392 fprintf (fp, "{%s}", item->name2); 1391 fprintf (fp, "{%s}", item->name2);
1393 fprintf (fp, "\t"); 1392 fprintf (fp, "\t");
1394 rxvt_action_decode (fp, & (item->entry.action)); 1393 rxvt_action_decode (fp, & (item->entry.action));
1395 break; 1394 break;
1396 } 1395 }
1480 if (fp == NULL) 1479 if (fp == NULL)
1481 return; 1480 return;
1482 1481
1483#if (MENUBAR_MAX > 1) 1482#if (MENUBAR_MAX > 1)
1484 /* semi-colon delimited */ 1483 /* semi-colon delimited */
1485 if ((tag = STRCHR (filename, ';')) != NULL) 1484 if ((tag = strchr (filename, ';')) != NULL)
1486 { 1485 {
1487 tag++; 1486 tag++;
1488 if (*tag == '\0') 1487 if (*tag == '\0')
1489 tag = NULL; 1488 tag = NULL;
1490 } 1489 }
1630 if (str[0] == ':') 1629 if (str[0] == ':')
1631 { /* [:command:] */ 1630 { /* [:command:] */
1632 do 1631 do
1633 { 1632 {
1634 next++; 1633 next++;
1635 if ((next = STRCHR (next, ':')) == NULL) 1634 if ((next = strchr (next, ':')) == NULL)
1636 return; /* parse error */ 1635 return; /* parse error */
1637 } 1636 }
1638 while (next[1] != ']'); 1637 while (next[1] != ']');
1639 /* remove and skip ':]' */ 1638 /* remove and skip ':]' */
1640 *next = '\0'; 1639 *next = '\0';
1641 next += 2; 1640 next += 2;
1642 } 1641 }
1643 else 1642 else
1644 { 1643 {
1645 if ((next = STRCHR (next, ']')) == NULL) 1644 if ((next = strchr (next, ']')) == NULL)
1646 return; /* parse error */ 1645 return; /* parse error */
1647 /* remove and skip ']' */ 1646 /* remove and skip ']' */
1648 *next = '\0'; 1647 *next = '\0';
1649 next++; 1648 next++;
1650 } 1649 }
1658 menu_readonly = 0; 1657 menu_readonly = 0;
1659 menubar_dispatch (str + 1); 1658 menubar_dispatch (str + 1);
1660 menu_readonly = saved; 1659 menu_readonly = saved;
1661 } 1660 }
1662 /* these ones don't require menu stacking */ 1661 /* these ones don't require menu stacking */
1663 else if (!STRCMP (str, "clear")) 1662 else if (!strcmp (str, "clear"))
1664 { 1663 {
1665 menubar_clear (); 1664 menubar_clear ();
1666 } 1665 }
1667 else if (!STRCMP (str, "done") || rxvt_Str_match (str, "done:")) 1666 else if (!strcmp (str, "done") || rxvt_Str_match (str, "done:"))
1668 { 1667 {
1669 menu_readonly = 1; 1668 menu_readonly = 1;
1670 } 1669 }
1671 else if (!STRCMP (str, "show")) 1670 else if (!strcmp (str, "show"))
1672 { 1671 {
1673 map_menuBar (1); 1672 map_menuBar (1);
1674 menu_readonly = 1; 1673 menu_readonly = 1;
1675 } 1674 }
1676 else if (!STRCMP (str, "hide")) 1675 else if (!strcmp (str, "hide"))
1677 { 1676 {
1678 map_menuBar (0); 1677 map_menuBar (0);
1679 menu_readonly = 1; 1678 menu_readonly = 1;
1680 } 1679 }
1681 else if ((n = rxvt_Str_match (str, "read:")) != 0) 1680 else if ((n = rxvt_Str_match (str, "read:")) != 0)
1689 str += n; 1688 str += n;
1690 if (CurrentBar != NULL && !menu_readonly) 1689 if (CurrentBar != NULL && !menu_readonly)
1691 { 1690 {
1692 if (*str) 1691 if (*str)
1693 { 1692 {
1694 name = (char *)rxvt_realloc (CurrentBar->title, STRLEN (str) + 1); 1693 name = (char *)rxvt_realloc (CurrentBar->title, strlen (str) + 1);
1695 if (name != NULL) 1694 if (name != NULL)
1696 { 1695 {
1697 STRCPY (name, str); 1696 strcpy (name, str);
1698 CurrentBar->title = name; 1697 CurrentBar->title = name;
1699 } 1698 }
1700 menubar_expose (); 1699 menubar_expose ();
1701 } 1700 }
1702 else 1701 else
1747 } 1746 }
1748 1747
1749 if (CurrentBar != NULL) 1748 if (CurrentBar != NULL)
1750 menu_readonly = 0; /* allow menu build commands */ 1749 menu_readonly = 0; /* allow menu build commands */
1751 } 1750 }
1752 else if (!STRCMP (str, "dump")) 1751 else if (!strcmp (str, "dump"))
1753 { 1752 {
1754 /* dump current menubars to a file */ 1753 /* dump current menubars to a file */
1755 FILE *fp; 1754 FILE *fp;
1756 1755
1757 /* enough space to hold the results */ 1756 /* enough space to hold the results */
1765 process_xterm_seq (XTerm_title, buffer, CHAR_ST); 1764 process_xterm_seq (XTerm_title, buffer, CHAR_ST);
1766 menubar_dump (fp); 1765 menubar_dump (fp);
1767 fclose (fp); 1766 fclose (fp);
1768 } 1767 }
1769 } 1768 }
1770 else if (!STRCMP (str, "next")) 1769 else if (!strcmp (str, "next"))
1771 { 1770 {
1772 if (CurrentBar) 1771 if (CurrentBar)
1773 { 1772 {
1774 CurrentBar = CurrentBar->next; 1773 CurrentBar = CurrentBar->next;
1775 menu_readonly = 1; 1774 menu_readonly = 1;
1776 } 1775 }
1777 } 1776 }
1778 else if (!STRCMP (str, "prev")) 1777 else if (!strcmp (str, "prev"))
1779 { 1778 {
1780 if (CurrentBar) 1779 if (CurrentBar)
1781 { 1780 {
1782 CurrentBar = CurrentBar->prev; 1781 CurrentBar = CurrentBar->prev;
1783 menu_readonly = 1; 1782 menu_readonly = 1;
1784 } 1783 }
1785 } 1784 }
1786 else if (!STRCMP (str, "swap")) 1785 else if (!strcmp (str, "swap"))
1787 { 1786 {
1788 /* swap the top 2 menus */ 1787 /* swap the top 2 menus */
1789 if (CurrentBar) 1788 if (CurrentBar)
1790 { 1789 {
1791 bar_t *cbprev = CurrentBar->prev; 1790 bar_t *cbprev = CurrentBar->prev;
1840 1839
1841 name2 = NULL; 1840 name2 = NULL;
1842 /* parse STR, allow spaces inside (name) */ 1841 /* parse STR, allow spaces inside (name) */
1843 if (path[0] != '\0') 1842 if (path[0] != '\0')
1844 { 1843 {
1845 name = STRCHR (path, MENUITEM_BEG); 1844 name = strchr (path, MENUITEM_BEG);
1846 str = STRCHR (path, MENUITEM_END); 1845 str = strchr (path, MENUITEM_END);
1847 if (name != NULL || str != NULL) 1846 if (name != NULL || str != NULL)
1848 { 1847 {
1849 if (name == NULL || str == NULL || str <= (name + 1) 1848 if (name == NULL || str == NULL || str <= (name + 1)
1850 || (name > path && name[-1] != '/')) 1849 || (name > path && name[-1] != '/'))
1851 { 1850 {
1853 break; 1852 break;
1854 } 1853 }
1855 if (str[1] == MENUITEM_BEG) 1854 if (str[1] == MENUITEM_BEG)
1856 { 1855 {
1857 name2 = (str + 2); 1856 name2 = (str + 2);
1858 str = STRCHR (name2, MENUITEM_END); 1857 str = strchr (name2, MENUITEM_END);
1859 1858
1860 if (str == NULL) 1859 if (str == NULL)
1861 { 1860 {
1862 rxvt_warn ("menu error B<%s>, continuing.\n", path); 1861 rxvt_warn ("menu error B<%s>, continuing.\n", path);
1863 break; 1862 break;
1889 if (path[0] != '\0') 1888 if (path[0] != '\0')
1890 { 1889 {
1891 int len; 1890 int len;
1892 1891
1893 path = menu_find_base (& (BuildMenu), path); 1892 path = menu_find_base (& (BuildMenu), path);
1894 len = STRLEN (path); 1893 len = strlen (path);
1895 1894
1896 /* don't allow menus called `*' */ 1895 /* don't allow menus called `*' */
1897 if (path[0] == '*') 1896 if (path[0] == '*')
1898 { 1897 {
1899 menu_clear (BuildMenu); 1898 menu_clear (BuildMenu);
1900 break; 1899 break;
1901 } 1900 }
1902 else if (len >= 2 && !STRCMP ((path + len - 2), "/*")) 1901 else if (len >= 2 && !strcmp ((path + len - 2), "/*"))
1903 { 1902 {
1904 path[len - 2] = '\0'; 1903 path[len - 2] = '\0';
1905 } 1904 }
1906 if (path[0] != '\0') 1905 if (path[0] != '\0')
1907 BuildMenu = menu_add (BuildMenu, path); 1906 BuildMenu = menu_add (BuildMenu, path);
1908 } 1907 }
1909 if (name != NULL && name[0] != '\0') 1908 if (name != NULL && name[0] != '\0')
1910 rxvt_menuitem_add (BuildMenu, 1909 rxvt_menuitem_add (BuildMenu,
1911 (STRCMP (name, SEPARATOR_NAME) ? name : ""), 1910 (strcmp (name, SEPARATOR_NAME) ? name : ""),
1912 name2, str); 1911 name2, str);
1913 break; 1912 break;
1914 1913
1915 case '-': /* delete menu entry */ 1914 case '-': /* delete menu entry */
1916 if (!STRCMP (path, "/*") && (name == NULL || name[0] == '\0')) 1915 if (!strcmp (path, "/*") && (name == NULL || name[0] == '\0'))
1917 { 1916 {
1918 menubar_clear (); 1917 menubar_clear ();
1919 BuildMenu = NULL; 1918 BuildMenu = NULL;
1920 menubar_expose (); 1919 menubar_expose ();
1921 break; 1920 break;
1924 { 1923 {
1925 int len; 1924 int len;
1926 menu_t *menu = BuildMenu; 1925 menu_t *menu = BuildMenu;
1927 1926
1928 path = menu_find_base (&menu, path); 1927 path = menu_find_base (&menu, path);
1929 len = STRLEN (path); 1928 len = strlen (path);
1930 1929
1931 /* submenu called `*' clears all menu items */ 1930 /* submenu called `*' clears all menu items */
1932 if (path[0] == '*') 1931 if (path[0] == '*')
1933 { 1932 {
1934 menu_clear (menu); 1933 menu_clear (menu);
1935 break; /* done */ 1934 break; /* done */
1936 } 1935 }
1937 else if (len >= 2 && !STRCMP (&path[len - 2], "/*")) 1936 else if (len >= 2 && !strcmp (&path[len - 2], "/*"))
1938 { 1937 {
1939 /* done */ 1938 /* done */
1940 break; 1939 break;
1941 } 1940 }
1942 else if (path[0] != '\0') 1941 else if (path[0] != '\0')
1955 { 1954 {
1956 const char *n1; 1955 const char *n1;
1957 menuitem_t *item; 1956 menuitem_t *item;
1958 menu_t *BuildMenu = BuildMenu; 1957 menu_t *BuildMenu = BuildMenu;
1959 1958
1960 n1 = STRCMP (name, SEPARATOR_NAME) ? name : ""; 1959 n1 = strcmp (name, SEPARATOR_NAME) ? name : "";
1961 item = rxvt_menuitem_find (BuildMenu, n1); 1960 item = rxvt_menuitem_find (BuildMenu, n1);
1962 if (item != NULL && item->entry.type != MenuSubMenu) 1961 if (item != NULL && item->entry.type != MenuSubMenu)
1963 { 1962 {
1964 menuitem_free (BuildMenu, item); 1963 menuitem_free (BuildMenu, item);
1965 1964

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines