mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Add code to check shortcuts in menu files
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1190 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1e341fda01
commit
48750ce6d8
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
2000-11-03 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* src/MenuBackend.h (fulllabel): new method.
|
||||
|
||||
* src/MenuBackend.C (checkShortcuts): new method. Checks whether
|
||||
the menu shortcuts of a menu are unique and whether they
|
||||
correspond to a letter of the label.
|
||||
(expand): call checkShortcuts when debugging.
|
||||
|
||||
2000-11-03 Andre Poenitz <poenitz@HTWM.De>
|
||||
|
||||
* src/insets/insettext.C (InsetButtonPress): shut off warning.
|
||||
|
||||
2000-11-02 Lior Silberman <lior@Princeton.EDU>
|
||||
|
||||
* lib/examples/*.lyx : '\language default' => '\language english'
|
||||
|
@ -198,6 +198,31 @@ struct compare_formatpair {
|
||||
}
|
||||
};
|
||||
|
||||
void Menu::checkShortcuts() const
|
||||
{
|
||||
// This is a quadratic algorithm, but we do not care because
|
||||
// it is used for debugging only.
|
||||
for (const_iterator it1 = begin(); it1 != end(); ++it1) {
|
||||
string shortcut = it1->shortcut();
|
||||
if (shortcut.empty())
|
||||
continue;
|
||||
if (!contains(it1->label(), shortcut))
|
||||
lyxerr << "Menu warning: menu entry \""
|
||||
<< it1->label()
|
||||
<< "\" does not contain shortcut `"
|
||||
<< shortcut << '\'' << endl;
|
||||
for (const_iterator it2 = begin(); it2 != it1 ; ++it2) {
|
||||
if (!compare_no_case(it2->shortcut(), shortcut)) {
|
||||
lyxerr << "Menu warning: menu entries "
|
||||
<< '"' << it1->fulllabel()
|
||||
<< "\" and \"" << it2->fulllabel()
|
||||
<< "\" share the same shortcut."
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::expand(Menu & tomenu, Buffer * buf) const
|
||||
{
|
||||
for (const_iterator cit = begin();
|
||||
@ -291,6 +316,10 @@ void Menu::expand(Menu & tomenu, Buffer * buf) const
|
||||
tomenu.add(*cit);
|
||||
}
|
||||
}
|
||||
|
||||
// Check whether the shortcuts are unique
|
||||
if (lyxerr.debugging(Debug::GUI))
|
||||
checkShortcuts();
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,8 +70,10 @@ public:
|
||||
|
||||
/// The label of a given menuitem
|
||||
string const label() const { return token(label_, '|', 0); }
|
||||
///
|
||||
/// The keyboard shortcut (usually underlined in the entry)
|
||||
string const shortcut() const { return token(label_, '|', 1); }
|
||||
/// The complete label, with label and shortcut separated by a '|'
|
||||
string const fulllabel() const { return label_;}
|
||||
/// The kind of entry
|
||||
Kind kind() const { return kind_; }
|
||||
/// the action (if relevant)
|
||||
@ -109,7 +111,7 @@ public:
|
||||
///
|
||||
Menu & read(LyXLex &);
|
||||
/// Expands some special entries of the menu
|
||||
/** The entries with the following kind are exanded to a
|
||||
/** The entries with the following kind are expanded to a
|
||||
sequence of Command MenuItems: Lastfiles, Documents,
|
||||
ViewFormats, ExportFormats, UpdateFormats
|
||||
*/
|
||||
@ -130,6 +132,10 @@ public:
|
||||
const_iterator end() const {
|
||||
return items_.end();
|
||||
}
|
||||
|
||||
// Check whether the menu shortcuts are unique
|
||||
void checkShortcuts() const;
|
||||
|
||||
private:
|
||||
///
|
||||
ItemList items_;
|
||||
|
@ -595,9 +595,8 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
|
||||
no_selection = false;
|
||||
|
||||
int tmp_x = x - drawTextXOffset;
|
||||
int tmp_y = y + insetAscent;
|
||||
Inset * inset = bv->checkInsetHit(TEXT(bv), tmp_x, tmp_y-TEXT(bv)->first,
|
||||
button);
|
||||
int tmp_y = y + insetAscent - TEXT(bv)->first;
|
||||
Inset * inset = bv->checkInsetHit(TEXT(bv), tmp_x, tmp_y, button);
|
||||
|
||||
HideInsetCursor(bv);
|
||||
if (the_locking_inset) {
|
||||
|
Loading…
Reference in New Issue
Block a user