2000-12-06 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
+ * 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
\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"
\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
# 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"
#
# 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"
#
# 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"
# 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"
# 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"
#\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"
# 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"
#\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"
\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"
checkShortcuts();
}
+bool Menu::hasSubmenu(string const & name) const
+{
+ return find_if(begin(), end(),
+ compare_memfun(&MenuItem::submenu, name)) != end();
+}
+
void MenuBackend::read(LyXLex & lex)
{
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();
///
void add(Menu const &);
///
- bool hasMenu (string const &) const;
+ bool hasMenu(string const &) const;
///
Menu & getMenu (string const &);
///
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"
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 "
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());
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);
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) {
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 {
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";
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;
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
# 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