* src/frontends/LyXKeySym.h:
* src/frontends/qt4/QLyXKeySym.h:
* src/frontends/qt4/QLyXKeySym.C (print): add a forgui boolean that
tells whether the string should used localized names and special
characters.
* src/MenuBackend.C (binding):
* src/kbmap.C (print):
* src/kbsequence.C (print, printOptions): add forgui parameter.
* src/frontends/qt4/QLPopupMenu.C (addBinding): use a non-localaized
binding for Qt/Mac (because it needs to be parsed back) and a
localized one for the others (so that it looks good).
* src/kbmap.C (defkey,printbindings):
* src/lyxfunc.C (processKeySym,dispatch,viewStatusMessage): adapt to
above changes.
* src/kbmap.C (printKey): remove.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16510
a592a061-630c-0410-9148-
cb99ea01b6c8
}
-docstring const MenuItem::binding() const
+docstring const MenuItem::binding(bool forgui) const
{
if (kind_ != Command)
return docstring();
kb_keymap::Bindings bindings = theTopLevelKeymap().findbindings(func_);
if (bindings.size()) {
- return bindings.begin()->print();
+ return bindings.begin()->print(forgui);
} else {
lyxerr[Debug::KBMAP]
<< "No binding for "
FuncStatus & status() { return status_; }
/// returns the status of the lfun associated with this entry
void status(FuncStatus const & status) { status_ = status; }
- /// returns the binding associated to this action
- docstring const binding() const;
+ /**
+ * returns the binding associated to this action.
+ * Use the native UI format when \c forgui is true.
+ */
+ docstring const binding(bool forgui) const;
/// the description of the submenu (if relevant)
docstring const & submenuname() const { return submenuname_; }
/// set the description of the submenu
/**
* Return a string describing the KeySym with modifier mod.
- * This should use the native UI format when applicable
+ * Use the native UI format when \c forgui is true.
*/
- virtual docstring const print(key_modifier::state mod) const = 0;
+ virtual docstring const print(key_modifier::state mod, bool forgui) const = 0;
};
void QLPopupMenu::addBinding(docstring & label, MenuItem const & mi)
{
- docstring const binding(mi.binding());
+#ifdef Q_WS_MACX
+ docstring const binding(mi.binding(false));
+#else
+ docstring const binding(mi.binding(true));
+#endif
if (!binding.empty()) {
label += '\t' + binding;
}
}
-docstring const QLyXKeySym::print(key_modifier::state mod) const
+docstring const QLyXKeySym::print(key_modifier::state mod, bool forgui) const
{
int tmpkey = key_;
tmpkey += Qt::CTRL;
if (mod & key_modifier::alt)
tmpkey += Qt::ALT;
+
+ QKeySequence seq(tmpkey);
- return qstring_to_ucs4(QKeySequence(tmpkey).toString());
+ return qstring_to_ucs4(seq.toString(forgui ? QKeySequence::NativeText
+ : QKeySequence::PortableText));
}
*/
virtual size_t getUCSEncoded() const;
- /// Return a human-readable version of a key+modifier pair.
- virtual docstring const print(key_modifier::state mod) const;
+ /**
+ * Return a human-readable version of a key+modifier pair.
+ * This will be the GUI version (translated and with special
+ * characters for Mac OS X) when \c forgui is true.
+ */
+ virtual docstring const print(key_modifier::state mod, bool forgui) const;
///
int key() const {
}
-docstring const kb_keymap::printKey(kb_key const & key) const
-{
- return key.code->print(key.mod.first);
-}
-
-
string::size_type kb_keymap::bind(string const & seq, FuncRequest const & func)
{
if (lyxerr.debugging(Debug::KBMAP)) {
}
-docstring const kb_keymap::print() const
+docstring const kb_keymap::print(bool forgui) const
{
docstring buf;
Table::const_iterator end = table.end();
for (Table::const_iterator cit = table.begin(); cit != end; ++cit) {
- buf += printKey((*cit));
+ buf += cit->code->print(cit->mod.first, forgui);
buf += ' ';
}
return buf;
if (r + 1 == seq->length()) {
lyxerr[Debug::KBMAP]
<< "Warning: New binding for '"
- << to_utf8(seq->print())
+ << to_utf8(seq->print(false))
<< "' is overriding old binding..."
<< endl;
if (it->table.get()) {
return;
} else if (!it->table.get()) {
lyxerr << "Error: New binding for '"
- << to_utf8(seq->print())
+ << to_utf8(seq->print(false))
<< "' is overriding old binding..."
<< endl;
return;
Bindings bindings = findbindings(func);
for (Bindings::const_iterator cit = bindings.begin();
cit != bindings.end() ; ++cit)
- res << '[' << cit->print() << ']';
+ res << '[' << cit->print(true) << ']';
return res.str();
}
// Parse a bind file
bool read(std::string const & bind_file);
- /// print all available keysyms
- docstring const print() const;
+ /**
+ * print all available keysyms
+ * @param forgui true if the string should use translations and
+ * special characters.
+ */
+ docstring const print(bool forgui) const;
/**
* Look up a key press in the keymap.
void defkey(kb_sequence * seq, FuncRequest const & func,
unsigned int r = 0);
- /// Returns a string of the given key
- docstring const printKey(kb_key const & key) const;
-
/**
* Given an action, find all keybindings
* @param func the action
}
-docstring const kb_sequence::print() const
+docstring const kb_sequence::print(bool forgui) const
{
docstring buf;
- //if (deleted_)
- // return buf;
+ const KeySequence::size_type length = sequence.size();
- KeySequence::size_type i, length = sequence.size();
-
- for (i = 0; i < length; ++i) {
- buf += sequence[i]->print(modifiers[i].first);
+ for (KeySequence::size_type i = 0; i < length; ++i) {
+ buf += sequence[i]->print(modifiers[i].first, forgui);
// append a blank
if (i + 1 < length) {
}
-docstring const kb_sequence::printOptions() const
+docstring const kb_sequence::printOptions(bool forgui) const
{
docstring buf;
- buf += print();
+ buf += print(forgui);
if (!curmap)
return buf;
buf += _(" options: ");
- buf += curmap->print();
+ buf += curmap->print(forgui);
return buf;
}
/**
* Return the current sequence as a string.
+ * @param forgui true if the string should use translations and
+ * special characters.
* @see parse()
*/
- docstring const print() const;
+ docstring const print(bool forgui) const;
/**
* Return the current sequence and available options as
* a string. No options are added if no curmap kb map exists.
+ * @param forgui true if the string should use translations and
+ * special characters.
*/
- docstring const printOptions() const;
+ docstring const printOptions(bool forgui) const;
/// Mark the sequence as deleted.
void mark_deleted();
lyxerr << BOOST_CURRENT_FUNCTION
<< " Key [action="
<< func.action << "]["
- << to_utf8(keyseq->print()) << ']'
+ << to_utf8(keyseq->print(false)) << ']'
<< endl;
}
// num_bytes == 0? (Lgb)
if (keyseq->length() > 1) {
- lyx_view_->message(keyseq->print());
+ lyx_view_->message(keyseq->print(true));
}
case LFUN_COMMAND_PREFIX:
BOOST_ASSERT(lyx_view_);
- lyx_view_->message(keyseq->printOptions());
+ lyx_view_->message(keyseq->printOptions(true));
break;
case LFUN_COMMAND_EXECUTE:
case LFUN_META_PREFIX:
meta_fake_bit = key_modifier::alt;
- setMessage(keyseq->print());
+ setMessage(keyseq->print(true));
break;
case LFUN_BUFFER_TOGGLE_READ_ONLY:
break;
case LFUN_SERVER_NOTIFY:
- dispatch_buffer = keyseq->print();
+ dispatch_buffer = keyseq->print(false);
theLyXServer().notifyClient(to_utf8(dispatch_buffer));
break;
{
// When meta-fake key is pressed, show the key sequence so far + "M-".
if (wasMetaKey())
- return keyseq->print() + "M-";
+ return keyseq->print(true) + "M-";
// Else, when a non-complete key sequence is pressed,
// show the available options.
if (keyseq->length() > 0 && !keyseq->deleted())
- return keyseq->printOptions();
+ return keyseq->printOptions(true);
if (!view()->buffer())
return _("Welcome to LyX!");