comparison src/gui.c @ 1913:7473844a83d3

[xemacs-hg @ 2004-02-17 15:20:41 by james] Check in_display instead of passing fallible in_redisplay parameters.
author james
date Tue, 17 Feb 2004 15:20:57 +0000
parents b531bf8658e9
children 04bc9d2f42c7
comparison
equal deleted inserted replaced
1912:2c839fb06642 1913:7473844a83d3
381 if (!NILP (pgui_item->value)) 381 if (!NILP (pgui_item->value))
382 Fplist_put (plist, Q_value, pgui_item->value); 382 Fplist_put (plist, Q_value, pgui_item->value);
383 } 383 }
384 384
385 static int 385 static int
386 gui_item_value (Lisp_Object form, int in_redisplay) 386 gui_item_value (Lisp_Object form)
387 { 387 {
388 /* This function can call Lisp. */ 388 /* This function can call Lisp. */
389 389
390 #ifndef ERROR_CHECK_DISPLAY 390 #ifndef ERROR_CHECK_DISPLAY
391 /* Shortcut to avoid evaluating Qt/Qnil each time; but don't do it when 391 /* Shortcut to avoid evaluating Qt/Qnil each time; but don't do it when
393 if (NILP (form)) 393 if (NILP (form))
394 return 0; 394 return 0;
395 if (EQ (form, Qt)) 395 if (EQ (form, Qt))
396 return 1; 396 return 1;
397 #endif 397 #endif
398 if (in_redisplay) 398 return !NILP (in_display ? eval_within_redisplay (form) : Feval (form));
399 return !NILP (eval_within_redisplay (form));
400 else
401 return !NILP (Feval (form));
402 } 399 }
403 400
404 /* 401 /*
405 * Decide whether a GUI item is active by evaluating its :active form 402 * Decide whether a GUI item is active by evaluating its :active form
406 * if any 403 * if any
407 */ 404 */
408 int 405 int
409 gui_item_active_p (Lisp_Object gui_item, int in_redisplay) 406 gui_item_active_p (Lisp_Object gui_item)
410 { 407 {
411 return gui_item_value (XGUI_ITEM (gui_item)->active, in_redisplay); 408 return gui_item_value (XGUI_ITEM (gui_item)->active);
412 } 409 }
413 410
414 /* set menu accelerator key to first underlined character in menu name */ 411 /* set menu accelerator key to first underlined character in menu name */
415 Lisp_Object 412 Lisp_Object
416 gui_item_accelerator (Lisp_Object gui_item) 413 gui_item_accelerator (Lisp_Object gui_item)
450 /* 447 /*
451 * Decide whether a GUI item is selected by evaluating its :selected form 448 * Decide whether a GUI item is selected by evaluating its :selected form
452 * if any 449 * if any
453 */ 450 */
454 int 451 int
455 gui_item_selected_p (Lisp_Object gui_item, int in_redisplay) 452 gui_item_selected_p (Lisp_Object gui_item)
456 { 453 {
457 return gui_item_value (XGUI_ITEM (gui_item)->selected, in_redisplay); 454 return gui_item_value (XGUI_ITEM (gui_item)->selected);
458 } 455 }
459 456
460 Lisp_Object 457 Lisp_Object
461 gui_item_list_find_selected (Lisp_Object gui_item_list) 458 gui_item_list_find_selected (Lisp_Object gui_item_list)
462 { 459 {
463 /* This function can call Lisp but cannot GC because it is called within 460 /* This function can call Lisp but cannot GC because it is called within
464 redisplay, and redisplay disables GC. */ 461 redisplay, and redisplay disables GC. */
465 Lisp_Object rest; 462 Lisp_Object rest;
466 LIST_LOOP (rest, gui_item_list) 463 LIST_LOOP (rest, gui_item_list)
467 { 464 {
468 if (gui_item_selected_p (XCAR (rest), 1)) 465 if (gui_item_selected_p (XCAR (rest)))
469 return XCAR (rest); 466 return XCAR (rest);
470 } 467 }
471 return XCAR (gui_item_list); 468 return XCAR (gui_item_list);
472 } 469 }
473 470
481 { 478 {
482 /* This function can call lisp */ 479 /* This function can call lisp */
483 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item); 480 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
484 481
485 /* Evaluate :included first. Shortcut to avoid evaluating Qt each time */ 482 /* Evaluate :included first. Shortcut to avoid evaluating Qt each time */
486 if (!gui_item_value (pgui_item->included, 0)) 483 if (!gui_item_value (pgui_item->included))
487 return 0; 484 return 0;
488 485
489 /* Do :config if conflist is given */ 486 /* Do :config if conflist is given */
490 if (!NILP (conflist) && !NILP (pgui_item->config) 487 if (!NILP (conflist) && !NILP (pgui_item->config)
491 && NILP (Fmemq (pgui_item->config, conflist))) 488 && NILP (Fmemq (pgui_item->config, conflist)))
630 } 627 }
631 return id; 628 return id;
632 } 629 }
633 630
634 static int 631 static int
635 gui_value_equal (Lisp_Object a, Lisp_Object b, int depth, int in_redisplay) 632 gui_value_equal (Lisp_Object a, Lisp_Object b, int depth)
636 { 633 {
637 if (in_redisplay) 634 if (in_display)
638 return internal_equal_trapping_problems 635 return internal_equal_trapping_problems
639 (Qredisplay, "Error calling function within redisplay", 0, 0, 636 (Qredisplay, "Error calling function within redisplay", 0, 0,
640 /* say they're not equal in case of error; code calling 637 /* say they're not equal in case of error; code calling
641 gui_item_equal_sans_selected() in redisplay does extra stuff 638 gui_item_equal_sans_selected() in redisplay does extra stuff
642 only when equal */ 639 only when equal */
644 else 641 else
645 return internal_equal (a, b, depth); 642 return internal_equal (a, b, depth);
646 } 643 }
647 644
648 int 645 int
649 gui_item_equal_sans_selected (Lisp_Object obj1, Lisp_Object obj2, int depth, 646 gui_item_equal_sans_selected (Lisp_Object obj1, Lisp_Object obj2, int depth)
650 int in_redisplay)
651 { 647 {
652 Lisp_Gui_Item *p1 = XGUI_ITEM (obj1); 648 Lisp_Gui_Item *p1 = XGUI_ITEM (obj1);
653 Lisp_Gui_Item *p2 = XGUI_ITEM (obj2); 649 Lisp_Gui_Item *p2 = XGUI_ITEM (obj2);
654 650
655 if (!(gui_value_equal (p1->name, p2->name, depth + 1, in_redisplay) 651 if (!(gui_value_equal (p1->name, p2->name, depth + 1)
656 && 652 &&
657 gui_value_equal (p1->callback, p2->callback, depth + 1, in_redisplay) 653 gui_value_equal (p1->callback, p2->callback, depth + 1)
658 && 654 &&
659 gui_value_equal (p1->callback_ex, p2->callback_ex, depth + 1, 655 gui_value_equal (p1->callback_ex, p2->callback_ex, depth + 1)
660 in_redisplay)
661 && 656 &&
662 EQ (p1->suffix, p2->suffix) 657 EQ (p1->suffix, p2->suffix)
663 && 658 &&
664 EQ (p1->active, p2->active) 659 EQ (p1->active, p2->active)
665 && 660 &&
684 gui_item_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) 679 gui_item_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
685 { 680 {
686 Lisp_Gui_Item *p1 = XGUI_ITEM (obj1); 681 Lisp_Gui_Item *p1 = XGUI_ITEM (obj1);
687 Lisp_Gui_Item *p2 = XGUI_ITEM (obj2); 682 Lisp_Gui_Item *p2 = XGUI_ITEM (obj2);
688 683
689 if (!(gui_item_equal_sans_selected (obj1, obj2, depth, 0) && 684 if (!(gui_item_equal_sans_selected (obj1, obj2, depth) &&
690 EQ (p1->selected, p2->selected))) 685 EQ (p1->selected, p2->selected)))
691 return 0; 686 return 0;
692 return 1; 687 return 1;
693 } 688 }
694 689