Mercurial > hg > xemacs-beta
diff src/gui.c @ 420:41dbb7a9d5f2 r21-2-18
Import from CVS: tag r21-2-18
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:24:09 +0200 |
parents | e804706bfb8c |
children | 95016f13131a |
line wrap: on
line diff
--- a/src/gui.c Mon Aug 13 11:23:14 2007 +0200 +++ b/src/gui.c Mon Aug 13 11:24:09 2007 +0200 @@ -122,6 +122,13 @@ else if (EQ (key, Q_callback)) pgui_item->callback = val; else if (EQ (key, Q_key_sequence)) ; /* ignored for FSF compatability */ else if (EQ (key, Q_label)) ; /* ignored for 21.0 implement in 21.2 */ + else if (EQ (key, Q_accelerator)) + { + if (SYMBOLP (val) || CHARP (val)) + pgui_item->accelerator = val; + else if (ERRB_EQ (errb, ERROR_ME)) + signal_simple_error ("Bad keyboard accelerator", val); + } else if (ERRB_EQ (errb, ERROR_ME)) signal_simple_error_2 ("Unknown keyword in gui item", key, pgui_item->name); } @@ -141,6 +148,7 @@ lp->style = Qnil; lp->selected = Qnil; lp->keys = Qnil; + lp->accelerator = Qnil; } Lisp_Object @@ -262,6 +270,8 @@ Fplist_put (plist, Q_selected, pgui_item->selected); if (!NILP (pgui_item->keys)) Fplist_put (plist, Q_keys, pgui_item->keys); + if (!NILP (pgui_item->accelerator)) + Fplist_put (plist, Q_accelerator, pgui_item->accelerator); } /* @@ -278,6 +288,41 @@ || !NILP (Feval (XGUI_ITEM (gui_item)->active))); } +/* set menu accelerator key to first underlined character in menu name */ +Lisp_Object +gui_item_accelerator (Lisp_Object gui_item) +{ + struct Lisp_Gui_Item* pgui = XGUI_ITEM (gui_item); + + if (!NILP (pgui->accelerator)) + return pgui->accelerator; + + else + return pgui->name; +} + +Lisp_Object +gui_name_accelerator (Lisp_Object nm) +{ + /* !!#### This function has not been Mule-ized */ + char* name = (char*)XSTRING_DATA (nm); + + while (*name) { + if (*name=='%') { + ++name; + if (!(*name)) + return Qnil; + if (*name=='_' && *(name+1)) + { + int accelerator = (int) (unsigned char) (*(name+1)); + return make_char (tolower (accelerator)); + } + } + ++name; + } + return Qnil; +} + /* * Decide whether a GUI item is selected by evaluating its :selected form * if any @@ -427,6 +472,7 @@ markobj (p->name); markobj (p->callback); + markobj (p->config); markobj (p->suffix); markobj (p->active); markobj (p->included); @@ -435,6 +481,7 @@ markobj (p->style); markobj (p->selected); markobj (p->keys); + markobj (p->accelerator); return Qnil; } @@ -493,6 +540,8 @@ && EQ (p1->selected, p2->selected) && + EQ (p1->accelerator, p2->accelerator) + && EQ (p1->keys, p2->keys))) return 0; return 1; @@ -516,6 +565,7 @@ mark_gui_item, print_gui_item, 0, gui_item_equal, gui_item_hash, + 0, struct Lisp_Gui_Item); void