diff --git a/ChangeLog b/ChangeLog index ce56d6b26c..4dd15dc6b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ 2000-12-06 Jean-Marc Lasgouttes + * src/frontends/xforms/Menubar_pimpl.C (openByName): check that + the menu exists in the current menubar before opening it. + + * src/MenuBackend.C (hasSubmenu): new method. + + * src/frontends/xforms/Menubar_pimpl.C: fix problem with bogus + action value by offsetting actions by a large constant (so that + bogs choice result will be less than this constant). + + * lib/bind/fi_menus.bind: more cleanup to menus. + * lib/bind/sciword.bind: ditto. + * lib/bind/xemacs.bind: ditto. + * lib/bind/emacs.bind: ditto. + * lib/bind/pt_menus.bind: ditto. + * lib/bind/hu_menus.bind: ditto. + + * src/gettext.h (locale_init): set locale LC_NUMERIC to "C". + * INSTALL: update PROBLEMS section. * src/lyxlookup.h: remove condition on xforms version, since we diff --git a/lib/bind/emacs.bind b/lib/bind/emacs.bind index 6ed4aa2606..80deaaa71f 100644 --- a/lib/bind/emacs.bind +++ b/lib/bind/emacs.bind @@ -88,7 +88,7 @@ \bind "C-x bracketleft" "screen-up" \bind "C-x bracketright" "screen-down" \bind "C-x C-a" "buffer-auto-save" -\bind "C-x C-b" "menu-open Documents" +\bind "C-x C-b" "menu-open documents" \bind "C-x C-c" "lyx-quit" \bind "C-x C-d" "buffer-new" \bind "C-x C-f" "buffer-open" diff --git a/lib/bind/fi_menus.bind b/lib/bind/fi_menus.bind index fb989d2929..54d62caf48 100644 --- a/lib/bind/fi_menus.bind +++ b/lib/bind/fi_menus.bind @@ -158,7 +158,7 @@ \bind "M-e t" "math-mode" \bind "M-e k" "math-display" #bind "M-e p" "display-math-panel-or-something" # What function to use? -\bind "M-e space" "menu-open Math" +#\bind "M-e space" "menu-open Math" # # Options menu diff --git a/lib/bind/hu_menus.bind b/lib/bind/hu_menus.bind index 85a590ff68..0967ede760 100644 --- a/lib/bind/hu_menus.bind +++ b/lib/bind/hu_menus.bind @@ -156,7 +156,7 @@ # These are now defined in cua or emacs bind files so their "standard" # bindings are available. (eg M-d "word-delete-forward" in emacs) ARRae #\bind "M-d p" "buffer-previous" -\bind "M-d space" "menu-open Dokumentumok" +#\bind "M-d space" "menu-open Dokumentumok" # diff --git a/lib/bind/pt_menus.bind b/lib/bind/pt_menus.bind index 6ae407f6e3..2afeb2a3d3 100644 --- a/lib/bind/pt_menus.bind +++ b/lib/bind/pt_menus.bind @@ -173,7 +173,7 @@ # These are now defined in cua or emacs bind files so their "standard" # bindings are available. (eg M-d "word-delete-forward" in emacs) ARRae #\bind "M-d a" "buffer-previous" -\bind "M-d space" "menu-open Documentos" +#\bind "M-d space" "menu-open Documentos" # diff --git a/lib/bind/sciword.bind b/lib/bind/sciword.bind index cd13a48e8a..5bb71c2d3b 100644 --- a/lib/bind/sciword.bind +++ b/lib/bind/sciword.bind @@ -230,14 +230,14 @@ # Visible Menu access menu # -\bind "F10 d" "menu-open Documents" -\bind "F10 e" "menu-open Edit" -\bind "F10 f" "menu-open File" -\bind "F10 h" "menu-open Help" -\bind "F10 i" "menu-open Insert" -\bind "F10 l" "menu-open Layout" -\bind "F10 m" "menu-open Math" -\bind "F10 o" "menu-open Options" +#\bind "F10 d" "menu-open Documents" +#\bind "F10 e" "menu-open Edit" +#\bind "F10 f" "menu-open File" +#\bind "F10 h" "menu-open Help" +#\bind "F10 i" "menu-open Insert" +#\bind "F10 l" "menu-open Layout" +#\bind "F10 m" "menu-open Math" +#\bind "F10 o" "menu-open Options" @@ -245,59 +245,59 @@ # File menu # -\bind "M-f a" "buffer-write-as" -\bind "M-f c" "buffer-close" -\bind "M-f n" "buffer-new" +#\bind "M-f a" "buffer-write-as" +#\bind "M-f c" "buffer-close" +#\bind "M-f n" "buffer-new" #\bind "M-f l" "file-last" # Not yet implemented. -\bind "M-f o" "buffer-open" -\bind "M-f p" "buffer-print" -\bind "M-f q" "lyx-quit" -\bind "M-f r" "buffer-update dvi" +#\bind "M-f o" "buffer-open" +#\bind "M-f p" "buffer-print" +#\bind "M-f q" "lyx-quit" +#\bind "M-f r" "buffer-update dvi" # Obsolete -\bind "M-f s" "buffer-write" -\bind "M-f t" "buffer-update dvi" +#\bind "M-f s" "buffer-write" +#\bind "M-f t" "buffer-update dvi" -\bind "M-f x" "buffer-view dvi" -\bind "M-f g" "buffer-view ps" -\bind "M-f space" "menu-open File" +#\bind "M-f x" "buffer-view dvi" +#\bind "M-f g" "buffer-view ps" +#\bind "M-f space" "menu-open File" # # Edit menu # -#\bind "M-e b" "table" # Not yet implemented! -\bind "M-e c" "cut" -\bind "M-e e" "error-next" -\bind "M-e f" "find-replace" -\bind "M-e k" "line-delete-forward" -\bind "M-e m" "mark-on" -\bind "M-e S-M" "mark-off" -\bind "M-e n" "note-next" -\bind "M-e o" "copy" -\bind "M-e p" "paste" -\bind "M-e r" "redo" -\bind "M-e s" "spellchecker" +##\bind "M-e b" "table" # Not yet implemented! +#\bind "M-e c" "cut" +#\bind "M-e e" "error-next" +#\bind "M-e f" "find-replace" +#\bind "M-e k" "line-delete-forward" +#\bind "M-e m" "mark-on" +#\bind "M-e S-M" "mark-off" +#\bind "M-e n" "note-next" +#\bind "M-e o" "copy" +#\bind "M-e p" "paste" +#\bind "M-e r" "redo" +#\bind "M-e s" "spellchecker" #\bind "M-e t" "toc-update" -\bind "M-e u" "undo" -\bind "M-e space" "menu-open Edit" +#\bind "M-e u" "undo" +#\bind "M-e space" "menu-open Edit" # # Layout menu # -\bind "M-l c" "layout-character" -\bind "M-l p" "layout-paragraph" -\bind "M-l d" "layout-document" -\bind "M-l q" "layout-quotes" -\bind "M-l l" "layout-preamble" -\bind "M-l e" "font-emph" +#\bind "M-l c" "layout-character" +#\bind "M-l p" "layout-paragraph" +#\bind "M-l d" "layout-document" +#\bind "M-l q" "layout-quotes" +#\bind "M-l l" "layout-preamble" +#\bind "M-l e" "font-emph" #\bind "M-l n" "font-smallcaps" -\bind "M-l b" "font-bold" -\bind "M-l t" "tex-mode" -\bind "M-l v" "depth-next" -\bind "M-l space" "menu-open Layout" +#\bind "M-l b" "font-bold" +#\bind "M-l t" "tex-mode" +#\bind "M-l v" "depth-next" +#\bind "M-l space" "menu-open Layout" @@ -305,17 +305,17 @@ # Insert menu # -\bind "M-i c" "citation-insert" -\bind "M-i f" "footnote-insert" -\bind "M-i h" "hfill-insert" -\bind "M-i m" "marginpar-insert" -\bind "M-i n" "note-insert" -\bind "M-i l" "label-insert" -\bind "M-i r" "reference-insert" -\bind "M-i minus" "hyphenation-point-insert" -\bind "M-i apostrophe" "quote-insert" -\bind "M-i S-quotedbl" "quote-insert" -\bind "M-i space" "menu-open Insert" +#\bind "M-i c" "citation-insert" +#\bind "M-i f" "footnote-insert" +#\bind "M-i h" "hfill-insert" +#\bind "M-i m" "marginpar-insert" +#\bind "M-i n" "note-insert" +#\bind "M-i l" "label-insert" +#\bind "M-i r" "reference-insert" +#\bind "M-i minus" "hyphenation-point-insert" +#\bind "M-i apostrophe" "quote-insert" +#\bind "M-i S-quotedbl" "quote-insert" +#\bind "M-i space" "menu-open Insert" @@ -327,7 +327,7 @@ #\bind "M-o s" "spellcheck-options" # Not yet implemented! #\bind "M-o k" "keyboard-options" # Not yet implemented! #\bind "M-o l" "latex-options" # Not yet implemented! -\bind "M-o space" "menu-open Options" +#\bind "M-o space" "menu-open Options" @@ -335,8 +335,8 @@ # Documents menu # -\bind "M-d p" "buffer-previous" -\bind "M-d space" "menu-open Documents" +#\bind "M-d p" "buffer-previous" +#\bind "M-d space" "menu-open Documents" @@ -349,7 +349,7 @@ #\bind "M-h w" "help-warranty" # Not yet implemented! #\bind "M-h c" "help-credits" # Not yet implemented! #\bind "M-h v" "help-version" # Not yet implemented! -\bind "M-h space" "menu-open Help" +#\bind "M-h space" "menu-open Help" diff --git a/lib/bind/xemacs.bind b/lib/bind/xemacs.bind index 13acaf8816..f964fd6e2a 100644 --- a/lib/bind/xemacs.bind +++ b/lib/bind/xemacs.bind @@ -93,7 +93,7 @@ \bind "C-x bracketright" "screen-down" \bind "C-x quoteleft" "error-next" \bind "C-x C-a" "buffer-auto-save" -\bind "C-x C-b" "menu-open Documents" # list all buffers +\bind "C-x C-b" "menu-open documents" # list all buffers \bind "C-x C-c" "lyx-quit" \bind "C-x C-d" "buffer-new" \bind "C-x C-f" "buffer-open" diff --git a/src/MenuBackend.C b/src/MenuBackend.C index 455a49c3db..1196dbaf2c 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -324,6 +324,12 @@ void Menu::expand(Menu & tomenu, Buffer * buf) const checkShortcuts(); } +bool Menu::hasSubmenu(string const & name) const +{ + return find_if(begin(), end(), + compare_memfun(&MenuItem::submenu, name)) != end(); +} + void MenuBackend::read(LyXLex & lex) { diff --git a/src/MenuBackend.h b/src/MenuBackend.h index 169b9d5618..192c45d5c4 100644 --- a/src/MenuBackend.h +++ b/src/MenuBackend.h @@ -127,6 +127,8 @@ public: bool empty() const { return items_.empty(); } /// ItemList::size_type size() const { return items_.size(); } + /// + bool hasSubmenu(string const &) const; /// const_iterator begin() const { return items_.begin(); @@ -163,7 +165,7 @@ public: /// void add(Menu const &); /// - bool hasMenu (string const &) const; + bool hasMenu(string const &) const; /// Menu & getMenu (string const &); /// diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C index 244289d8f2..28b757d1ae 100644 --- a/src/frontends/xforms/Menubar_pimpl.C +++ b/src/frontends/xforms/Menubar_pimpl.C @@ -46,6 +46,12 @@ static const int mbadd = 20; // menu button add (to width) static const int air = 2; static char const * menu_tabstop = "aa"; static char const * default_tabstop = "aaaaaaaa"; +// We do not want to mix position values in a menu (like the index of +// a submenu) with the action numbers which convey actual information. +// Therefore we offset all the action values by an arbitrary large +// constant. +static const int action_offset = 1000; + //Defined later, used in makeMenubar(). extern "C" @@ -169,11 +175,13 @@ void Menubar::Pimpl::set(string const & menu_name) void Menubar::Pimpl::openByName(string const & name) { - for (ButtonList::const_iterator cit = buttonlist_.begin(); - cit != buttonlist_.end(); ++cit) { - if ((*cit)->item_->submenu() == name) { - MenuCallback((*cit)->obj_, 1); - return; + if (menubackend_->getMenu(current_menu_name_).hasSubmenu(name)) { + for (ButtonList::const_iterator cit = buttonlist_.begin(); + cit != buttonlist_.end(); ++cit) { + if ((*cit)->item_->submenu() == name) { + MenuCallback((*cit)->obj_, 1); + return; + } } } lyxerr << "Menubar::Pimpl::openByName: menu " @@ -228,7 +236,7 @@ void add_toc2(int menu, string const & extra_label, string label(4 * max(0, toc_list[i].depth - depth),' '); label += fixlabel(toc_list[i].str); label = limit_string_length(label); - label += "%x" + tostr(action); + label += "%x" + tostr(action + action_offset); if (i == to - 1 && depth == 0) label += extra_label; fl_addtopup(menu, label.c_str()); @@ -264,7 +272,7 @@ void add_toc2(int menu, string const & extra_label, label += extra_label; if (new_pos == pos + 1) { - label += "%x" + tostr(action); + label += "%x" + tostr(action + action_offset); fl_addtopup(menu, label.c_str()); } else { int menu2 = get_new_submenu(smn, win); @@ -310,7 +318,7 @@ void Menubar::Pimpl::add_toc(int menu, string const & extra_label, tostr(toc_list[j][i].par->id())); string label = fixlabel(toc_list[j][i].str); label = limit_string_length(label); - label += "%x" + tostr(action); + label += "%x" + tostr(action + action_offset); fl_addtopup(menu2, label.c_str()); } if (j == max_nonempty) { @@ -351,7 +359,7 @@ void add_references2(int menu, vector & smn, Window win, string label = label_list[i]; if (label.size() > max_item_length) label = label.substr(0, max_item_length-1) + "$"; - label += "%x" + tostr(action); + label += "%x" + tostr(action + action_offset); fl_addtopup(menu, label.c_str()); } else { @@ -386,7 +394,7 @@ void add_references2(int menu, vector & smn, Window win, string label2 = label_list[k]; if (label2.size() > max_item_length) label2 = label2.substr(0, max_item_length-1) + "$"; - label2 += "%x" + tostr(action); + label2 += "%x" + tostr(action + action_offset); fl_addtopup(menu2, label2.c_str()); } label += "%m"; @@ -537,7 +545,8 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view, while (string_width(label) < max_width); label += accel.substr(1,accel.find(']') - 1); } - label += "%x" + tostr(item.action()) + extra_label; + label += "%x" + tostr(item.action() + action_offset) + + extra_label; // Modify the entry using the function status string pupmode; @@ -661,9 +670,16 @@ void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button) fl_set_object_boxtype(ob, FL_FLAT_BOX); fl_redraw_object(ob); } - - if (choice >= 1) { - view->getLyXFunc()->Dispatch(choice); + + // If the action value is too low, then it is not a + // valid action, but something else. + if (choice >= action_offset + 1) { + view->getLyXFunc()->Dispatch(choice - action_offset); + } + else { + lyxerr[Debug::GUI] + << "MenuCallback: ignoring bogus action " + << choice << endl; } } else diff --git a/src/gettext.h b/src/gettext.h index a60e5c52f9..121e0428bd 100644 --- a/src/gettext.h +++ b/src/gettext.h @@ -52,7 +52,7 @@ string const _(string const &); # ifdef HAVE_LC_MESSAGES // LC_TIME, LC_CTYPE, even LC_ALL -# define locale_init() { setlocale (LC_MESSAGES, ""); setlocale (LC_CTYPE, "");} +# define locale_init() { setlocale (LC_MESSAGES, ""); setlocale (LC_CTYPE, ""); setlocale(LC_NUMERIC, "C"); } # else # define locale_init() # endif