]> git.lyx.org Git - lyx.git/commitdiff
Fix problem with LC_NUMERIC, more updates to bind files, fix problem with bogus actio...
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 6 Dec 2000 13:41:44 +0000 (13:41 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 6 Dec 2000 13:41:44 +0000 (13:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1262 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
lib/bind/emacs.bind
lib/bind/fi_menus.bind
lib/bind/hu_menus.bind
lib/bind/pt_menus.bind
lib/bind/sciword.bind
lib/bind/xemacs.bind
src/MenuBackend.C
src/MenuBackend.h
src/frontends/xforms/Menubar_pimpl.C
src/gettext.h

index ce56d6b26c69ac2c1a1d7a1c6e578cea04a6e485..4dd15dc6b05d2dee3432c373b5de51eabb5d438a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 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
index 6ed4aa260643221083ba6a37ee942ee6b169d542..80deaaa71f4cc1e85f16d9332f22a87990005b46 100644 (file)
@@ -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"
index fb989d2929fb3dcda53a0a7c81d724ac9f96ca8a..54d62caf48b43dba942711d22a6305999e9a4acc 100644 (file)
 \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
index 85a590ff68fe70b7db5f6b970788d8b688c06d6d..0967ede76067cb1ec0842fa9275d765b97173fab 100644 (file)
 # 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"
 
 
 #
index 6ae407f6e3eb1bfa58c1ddc91710a2189c0086f2..2afeb2a3d3c772186e25da79a381aa081c958d4f 100644 (file)
 # 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"
 
 
 #
index cd13a48e8a402c02598648242e9cc400888e866e..5bb71c2d3b9815a32d0966df9d35168a2fc677cd 100644 (file)
 # 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"
 
 
 
index 13acaf88166d46b53a4345780e9284bc75a2621b..f964fd6e2af337a91e95dea5c7322d8162fa70fd 100644 (file)
@@ -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"
index 455a49c3dbaf303d0e314414d0e63ee639c00afb..1196dbaf2c23aeb7fc1b906dc3136d837d93cffd 100644 (file)
@@ -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)
 {
index 169b9d56183794d59f6761d4035f4f9cd4a22250..192c45d5c4e9f03f771f830539a3003a352cd67d 100644 (file)
@@ -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 &);
        ///
index 244289d8f2a6ae84be5d623e30779f356912747a..28b757d1ae8246fadd440f6ecc8901f091f7c351 100644 (file)
@@ -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<int> & 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<int> & 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 
index a60e5c52f9e345e2d716ddee34cac5b05ded6d9e..121e0428bd8bac87a6df35d0a55e2488cb047637 100644 (file)
@@ -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