Fix problem with LC_NUMERIC, more updates to bind files, fix problem with bogus actions in menus, fix problem with menu-open

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1262 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-12-06 13:41:44 +00:00
parent 87e0dfe896
commit b7736f5af3
11 changed files with 122 additions and 80 deletions

View File

@ -1,5 +1,23 @@
2000-12-06 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr> 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. * INSTALL: update PROBLEMS section.
* src/lyxlookup.h: remove condition on xforms version, since we * src/lyxlookup.h: remove condition on xforms version, since we

View File

@ -88,7 +88,7 @@
\bind "C-x bracketleft" "screen-up" \bind "C-x bracketleft" "screen-up"
\bind "C-x bracketright" "screen-down" \bind "C-x bracketright" "screen-down"
\bind "C-x C-a" "buffer-auto-save" \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-c" "lyx-quit"
\bind "C-x C-d" "buffer-new" \bind "C-x C-d" "buffer-new"
\bind "C-x C-f" "buffer-open" \bind "C-x C-f" "buffer-open"

View File

@ -158,7 +158,7 @@
\bind "M-e t" "math-mode" \bind "M-e t" "math-mode"
\bind "M-e k" "math-display" \bind "M-e k" "math-display"
#bind "M-e p" "display-math-panel-or-something" # What function to use? #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 # Options menu

View File

@ -156,7 +156,7 @@
# These are now defined in cua or emacs bind files so their "standard" # 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 # bindings are available. (eg M-d "word-delete-forward" in emacs) ARRae
#\bind "M-d p" "buffer-previous" #\bind "M-d p" "buffer-previous"
\bind "M-d space" "menu-open Dokumentumok" #\bind "M-d space" "menu-open Dokumentumok"
# #

View File

@ -173,7 +173,7 @@
# These are now defined in cua or emacs bind files so their "standard" # 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 # bindings are available. (eg M-d "word-delete-forward" in emacs) ARRae
#\bind "M-d a" "buffer-previous" #\bind "M-d a" "buffer-previous"
\bind "M-d space" "menu-open Documentos" #\bind "M-d space" "menu-open Documentos"
# #

View File

@ -230,14 +230,14 @@
# Visible Menu access menu # Visible Menu access menu
# #
\bind "F10 d" "menu-open Documents" #\bind "F10 d" "menu-open Documents"
\bind "F10 e" "menu-open Edit" #\bind "F10 e" "menu-open Edit"
\bind "F10 f" "menu-open File" #\bind "F10 f" "menu-open File"
\bind "F10 h" "menu-open Help" #\bind "F10 h" "menu-open Help"
\bind "F10 i" "menu-open Insert" #\bind "F10 i" "menu-open Insert"
\bind "F10 l" "menu-open Layout" #\bind "F10 l" "menu-open Layout"
\bind "F10 m" "menu-open Math" #\bind "F10 m" "menu-open Math"
\bind "F10 o" "menu-open Options" #\bind "F10 o" "menu-open Options"
@ -245,59 +245,59 @@
# File menu # File menu
# #
\bind "M-f a" "buffer-write-as" #\bind "M-f a" "buffer-write-as"
\bind "M-f c" "buffer-close" #\bind "M-f c" "buffer-close"
\bind "M-f n" "buffer-new" #\bind "M-f n" "buffer-new"
#\bind "M-f l" "file-last" # Not yet implemented. #\bind "M-f l" "file-last" # Not yet implemented.
\bind "M-f o" "buffer-open" #\bind "M-f o" "buffer-open"
\bind "M-f p" "buffer-print" #\bind "M-f p" "buffer-print"
\bind "M-f q" "lyx-quit" #\bind "M-f q" "lyx-quit"
\bind "M-f r" "buffer-update dvi" #\bind "M-f r" "buffer-update dvi"
# Obsolete # Obsolete
\bind "M-f s" "buffer-write" #\bind "M-f s" "buffer-write"
\bind "M-f t" "buffer-update dvi" #\bind "M-f t" "buffer-update dvi"
\bind "M-f x" "buffer-view dvi" #\bind "M-f x" "buffer-view dvi"
\bind "M-f g" "buffer-view ps" #\bind "M-f g" "buffer-view ps"
\bind "M-f space" "menu-open File" #\bind "M-f space" "menu-open File"
# #
# Edit menu # Edit menu
# #
#\bind "M-e b" "table" # Not yet implemented! ##\bind "M-e b" "table" # Not yet implemented!
\bind "M-e c" "cut" #\bind "M-e c" "cut"
\bind "M-e e" "error-next" #\bind "M-e e" "error-next"
\bind "M-e f" "find-replace" #\bind "M-e f" "find-replace"
\bind "M-e k" "line-delete-forward" #\bind "M-e k" "line-delete-forward"
\bind "M-e m" "mark-on" #\bind "M-e m" "mark-on"
\bind "M-e S-M" "mark-off" #\bind "M-e S-M" "mark-off"
\bind "M-e n" "note-next" #\bind "M-e n" "note-next"
\bind "M-e o" "copy" #\bind "M-e o" "copy"
\bind "M-e p" "paste" #\bind "M-e p" "paste"
\bind "M-e r" "redo" #\bind "M-e r" "redo"
\bind "M-e s" "spellchecker" #\bind "M-e s" "spellchecker"
#\bind "M-e t" "toc-update" #\bind "M-e t" "toc-update"
\bind "M-e u" "undo" #\bind "M-e u" "undo"
\bind "M-e space" "menu-open Edit" #\bind "M-e space" "menu-open Edit"
# #
# Layout menu # Layout menu
# #
\bind "M-l c" "layout-character" #\bind "M-l c" "layout-character"
\bind "M-l p" "layout-paragraph" #\bind "M-l p" "layout-paragraph"
\bind "M-l d" "layout-document" #\bind "M-l d" "layout-document"
\bind "M-l q" "layout-quotes" #\bind "M-l q" "layout-quotes"
\bind "M-l l" "layout-preamble" #\bind "M-l l" "layout-preamble"
\bind "M-l e" "font-emph" #\bind "M-l e" "font-emph"
#\bind "M-l n" "font-smallcaps" #\bind "M-l n" "font-smallcaps"
\bind "M-l b" "font-bold" #\bind "M-l b" "font-bold"
\bind "M-l t" "tex-mode" #\bind "M-l t" "tex-mode"
\bind "M-l v" "depth-next" #\bind "M-l v" "depth-next"
\bind "M-l space" "menu-open Layout" #\bind "M-l space" "menu-open Layout"
@ -305,17 +305,17 @@
# Insert menu # Insert menu
# #
\bind "M-i c" "citation-insert" #\bind "M-i c" "citation-insert"
\bind "M-i f" "footnote-insert" #\bind "M-i f" "footnote-insert"
\bind "M-i h" "hfill-insert" #\bind "M-i h" "hfill-insert"
\bind "M-i m" "marginpar-insert" #\bind "M-i m" "marginpar-insert"
\bind "M-i n" "note-insert" #\bind "M-i n" "note-insert"
\bind "M-i l" "label-insert" #\bind "M-i l" "label-insert"
\bind "M-i r" "reference-insert" #\bind "M-i r" "reference-insert"
\bind "M-i minus" "hyphenation-point-insert" #\bind "M-i minus" "hyphenation-point-insert"
\bind "M-i apostrophe" "quote-insert" #\bind "M-i apostrophe" "quote-insert"
\bind "M-i S-quotedbl" "quote-insert" #\bind "M-i S-quotedbl" "quote-insert"
\bind "M-i space" "menu-open Insert" #\bind "M-i space" "menu-open Insert"
@ -327,7 +327,7 @@
#\bind "M-o s" "spellcheck-options" # Not yet implemented! #\bind "M-o s" "spellcheck-options" # Not yet implemented!
#\bind "M-o k" "keyboard-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 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 # Documents menu
# #
\bind "M-d p" "buffer-previous" #\bind "M-d p" "buffer-previous"
\bind "M-d space" "menu-open Documents" #\bind "M-d space" "menu-open Documents"
@ -349,7 +349,7 @@
#\bind "M-h w" "help-warranty" # Not yet implemented! #\bind "M-h w" "help-warranty" # Not yet implemented!
#\bind "M-h c" "help-credits" # Not yet implemented! #\bind "M-h c" "help-credits" # Not yet implemented!
#\bind "M-h v" "help-version" # 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"

View File

@ -93,7 +93,7 @@
\bind "C-x bracketright" "screen-down" \bind "C-x bracketright" "screen-down"
\bind "C-x quoteleft" "error-next" \bind "C-x quoteleft" "error-next"
\bind "C-x C-a" "buffer-auto-save" \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-c" "lyx-quit"
\bind "C-x C-d" "buffer-new" \bind "C-x C-d" "buffer-new"
\bind "C-x C-f" "buffer-open" \bind "C-x C-f" "buffer-open"

View File

@ -324,6 +324,12 @@ void Menu::expand(Menu & tomenu, Buffer * buf) const
checkShortcuts(); checkShortcuts();
} }
bool Menu::hasSubmenu(string const & name) const
{
return find_if(begin(), end(),
compare_memfun(&MenuItem::submenu, name)) != end();
}
void MenuBackend::read(LyXLex & lex) void MenuBackend::read(LyXLex & lex)
{ {

View File

@ -127,6 +127,8 @@ public:
bool empty() const { return items_.empty(); } bool empty() const { return items_.empty(); }
/// ///
ItemList::size_type size() const { return items_.size(); } ItemList::size_type size() const { return items_.size(); }
///
bool hasSubmenu(string const &) const;
/// ///
const_iterator begin() const { const_iterator begin() const {
return items_.begin(); return items_.begin();
@ -163,7 +165,7 @@ public:
/// ///
void add(Menu const &); void add(Menu const &);
/// ///
bool hasMenu (string const &) const; bool hasMenu(string const &) const;
/// ///
Menu & getMenu (string const &); Menu & getMenu (string const &);
/// ///

View File

@ -46,6 +46,12 @@ static const int mbadd = 20; // menu button add (to width)
static const int air = 2; static const int air = 2;
static char const * menu_tabstop = "aa"; static char const * menu_tabstop = "aa";
static char const * default_tabstop = "aaaaaaaa"; 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(). //Defined later, used in makeMenubar().
extern "C" extern "C"
@ -169,11 +175,13 @@ void Menubar::Pimpl::set(string const & menu_name)
void Menubar::Pimpl::openByName(string const & name) void Menubar::Pimpl::openByName(string const & name)
{ {
for (ButtonList::const_iterator cit = buttonlist_.begin(); if (menubackend_->getMenu(current_menu_name_).hasSubmenu(name)) {
cit != buttonlist_.end(); ++cit) { for (ButtonList::const_iterator cit = buttonlist_.begin();
if ((*cit)->item_->submenu() == name) { cit != buttonlist_.end(); ++cit) {
MenuCallback((*cit)->obj_, 1); if ((*cit)->item_->submenu() == name) {
return; MenuCallback((*cit)->obj_, 1);
return;
}
} }
} }
lyxerr << "Menubar::Pimpl::openByName: menu " 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),' '); string label(4 * max(0, toc_list[i].depth - depth),' ');
label += fixlabel(toc_list[i].str); label += fixlabel(toc_list[i].str);
label = limit_string_length(label); label = limit_string_length(label);
label += "%x" + tostr(action); label += "%x" + tostr(action + action_offset);
if (i == to - 1 && depth == 0) if (i == to - 1 && depth == 0)
label += extra_label; label += extra_label;
fl_addtopup(menu, label.c_str()); fl_addtopup(menu, label.c_str());
@ -264,7 +272,7 @@ void add_toc2(int menu, string const & extra_label,
label += extra_label; label += extra_label;
if (new_pos == pos + 1) { if (new_pos == pos + 1) {
label += "%x" + tostr(action); label += "%x" + tostr(action + action_offset);
fl_addtopup(menu, label.c_str()); fl_addtopup(menu, label.c_str());
} else { } else {
int menu2 = get_new_submenu(smn, win); 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())); tostr(toc_list[j][i].par->id()));
string label = fixlabel(toc_list[j][i].str); string label = fixlabel(toc_list[j][i].str);
label = limit_string_length(label); label = limit_string_length(label);
label += "%x" + tostr(action); label += "%x" + tostr(action + action_offset);
fl_addtopup(menu2, label.c_str()); fl_addtopup(menu2, label.c_str());
} }
if (j == max_nonempty) { if (j == max_nonempty) {
@ -351,7 +359,7 @@ void add_references2(int menu, vector<int> & smn, Window win,
string label = label_list[i]; string label = label_list[i];
if (label.size() > max_item_length) if (label.size() > max_item_length)
label = label.substr(0, max_item_length-1) + "$"; label = label.substr(0, max_item_length-1) + "$";
label += "%x" + tostr(action); label += "%x" + tostr(action + action_offset);
fl_addtopup(menu, label.c_str()); fl_addtopup(menu, label.c_str());
} }
else { else {
@ -386,7 +394,7 @@ void add_references2(int menu, vector<int> & smn, Window win,
string label2 = label_list[k]; string label2 = label_list[k];
if (label2.size() > max_item_length) if (label2.size() > max_item_length)
label2 = label2.substr(0, max_item_length-1) + "$"; label2 = label2.substr(0, max_item_length-1) + "$";
label2 += "%x" + tostr(action); label2 += "%x" + tostr(action + action_offset);
fl_addtopup(menu2, label2.c_str()); fl_addtopup(menu2, label2.c_str());
} }
label += "%m"; label += "%m";
@ -537,7 +545,8 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
while (string_width(label) < max_width); while (string_width(label) < max_width);
label += accel.substr(1,accel.find(']') - 1); 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 // Modify the entry using the function status
string pupmode; string pupmode;
@ -661,9 +670,16 @@ void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button)
fl_set_object_boxtype(ob, FL_FLAT_BOX); fl_set_object_boxtype(ob, FL_FLAT_BOX);
fl_redraw_object(ob); fl_redraw_object(ob);
} }
if (choice >= 1) { // If the action value is too low, then it is not a
view->getLyXFunc()->Dispatch(choice); // 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 else

View File

@ -52,7 +52,7 @@ string const _(string const &);
# ifdef HAVE_LC_MESSAGES # ifdef HAVE_LC_MESSAGES
// LC_TIME, LC_CTYPE, even LC_ALL // 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 # else
# define locale_init() # define locale_init()
# endif # endif