shortcuts in menus on the Mac.
* src/frontends/qt4/QLPopupMenu.C (addBinding): remove special
OS X code (and hopefully restore shortcuts for LyX/Mac).
* src/lyxfunc.C (processKeySym, dispatch, sendDispatchMessage,
viewStatusMessage): adapt to changes below.
* src/MenuBackend.C (binding): adapt to changes below.
* src/kbmap.C (printKey, print, printbindings): return a
docstring; adapt to kbsequence changes.
* src/kbsequence.C (print, printOptions): return a docstring.
* src/frontends/LyXKeySym.h (print): return a docstring.
* src/frontends/qt4/QLyXKeySym.C (print): return a docstring.
(qprint): remove.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16265
a592a061-630c-0410-9148-
cb99ea01b6c8
kb_keymap::Bindings bindings = theTopLevelKeymap().findbindings(func_);
if (bindings.size()) {
- return from_utf8(bindings.begin()->print());
+ return bindings.begin()->print();
} else {
lyxerr[Debug::KBMAP]
<< "No binding for "
#include "key_state.h"
+#include "support/docstring.h"
+
#include <boost/shared_ptr.hpp>
* Return a string describing the KeySym with modifier mod.
* This should use the native UI format when applicable
*/
- virtual std::string const print(key_modifier::state mod) const = 0;
+ virtual docstring const print(key_modifier::state mod) const = 0;
};
#include "debug.h"
-#ifdef Q_WS_MACX
-#include "kbmap.h"
-#include "QLyXKeySym.h"
-#endif
-
using std::make_pair;
using std::string;
using std::pair;
/// \todo Mac specific binding handling.
void QLPopupMenu::addBinding(docstring & label, MenuItem const & mi)
{
-#ifndef Q_WS_MACX
-
- docstring const binding(mi.binding());
- if (!binding.empty()) {
- label += char_type('\t') + binding;
- }
-
-#else
- /* There are two constraints on Qt/Mac: (1)
- the bindings require a unicode string to be
- represented meaningfully and std::string
- does not work (2) only 1-key bindings can
- be represented in menus.
-
- This is why the unpleasant hack bellow is
- needed (JMarc)
- */
-/* pair<LyXKeySym const *, key_modifier::state>
- binding = toplevel_keymap->find1keybinding(mi.func());
- if (binding.first) {
- QLyXKeySym const *key = static_cast<QLyXKeySym const *>(binding.first);
- label += '\t' + key->qprint(binding.second);
- }
-*/
-#endif
+ docstring const binding(mi.binding());
+ if (!binding.empty()) {
+ label += '\t' + binding;
+ }
}
/// \todo Fix Mac specific menu hack
}
-QString const QLyXKeySym::qprint(key_modifier::state mod) const
+docstring const QLyXKeySym::print(key_modifier::state mod) const
{
int tmpkey = key_;
if (mod & key_modifier::alt)
tmpkey += Qt::ALT;
- return QKeySequence(tmpkey).toString();
-}
-
-
-string const QLyXKeySym::print(key_modifier::state mod) const
-{
- return fromqstr(qprint(mod));
+ return qstring_to_ucs4(QKeySequence(tmpkey).toString());
}
virtual size_t getUCSEncoded() const;
/// Return a human-readable version of a key+modifier pair.
- virtual std::string const print(key_modifier::state mod) const;
-
- ///
- QString const qprint(key_modifier::state mod) const;
+ virtual docstring const print(key_modifier::state mod) const;
///
int key() const {
}
-string const kb_keymap::printKey(kb_key const & key) const
+docstring const kb_keymap::printKey(kb_key const & key) const
{
return key.code->print(key.mod.first);
}
}
-string const kb_keymap::print() const
+docstring const kb_keymap::print() const
{
- string buf;
+ docstring buf;
Table::const_iterator end = table.end();
for (Table::const_iterator cit = table.begin(); cit != end; ++cit) {
buf += printKey((*cit));
if (r + 1 == seq->length()) {
lyxerr[Debug::KBMAP]
<< "Warning: New binding for '"
- << seq->print()
+ << to_utf8(seq->print())
<< "' is overriding old binding..."
<< endl;
if (it->table.get()) {
it->func.origin = FuncRequest::KEYBOARD;
return;
} else if (!it->table.get()) {
- lyxerr << "Error: New binding for '" << seq->print()
+ lyxerr << "Error: New binding for '"
+ << to_utf8(seq->print())
<< "' is overriding old binding..."
<< endl;
return;
}
-string const kb_keymap::printbindings(FuncRequest const & func) const
+docstring const kb_keymap::printbindings(FuncRequest const & func) const
{
- std::ostringstream res;
+ odocstringstream res;
Bindings bindings = findbindings(func);
for (Bindings::const_iterator cit = bindings.begin();
cit != bindings.end() ; ++cit)
#include "frontends/key_state.h"
#include "frontends/LyXKeySym.h"
+#include "support/docstream.h"
+
#include <boost/shared_ptr.hpp>
#include <vector>
bool read(std::string const & bind_file);
/// print all available keysyms
- std::string const print() const;
+ docstring const print() const;
/**
* Look up a key press in the keymap.
Bindings findbindings(FuncRequest const & func) const;
/// Given an action, print the keybindings.
- std::string const printbindings(FuncRequest const & func) const;
+ docstring const printbindings(FuncRequest const & func) const;
/**
* Given an action, find the first 1-key binding (if it exists).
unsigned int r = 0);
/// Returns a string of the given key
- std::string const printKey(kb_key const & key) const;
+ docstring const printKey(kb_key const & key) const;
/**
* Given an action, find all keybindings
}
-string const kb_sequence::print() const
+docstring const kb_sequence::print() const
{
- string buf;
+ docstring buf;
//if (deleted_)
// return buf;
}
-string const kb_sequence::printOptions() const
+docstring const kb_sequence::printOptions() const
{
- string buf;
+ docstring buf;
buf += print();
if (!curmap)
return buf;
- buf += to_utf8(_(" options: "));
+ buf += _(" options: ");
buf += curmap->print();
return buf;
}
* Return the current sequence as a string.
* @see parse()
*/
- std::string const print() const;
+ docstring const print() const;
/**
* Return the current sequence and available options as
* a string. No options are added if no curmap kb map exists.
*/
- std::string const printOptions() const;
+ docstring const printOptions() const;
/// Mark the sequence as deleted.
void mark_deleted();
lyxerr << BOOST_CURRENT_FUNCTION
<< " Key [action="
<< func.action << "]["
- << keyseq->print() << ']'
+ << to_utf8(keyseq->print()) << ']'
<< endl;
}
// num_bytes == 0? (Lgb)
if (keyseq->length() > 1) {
- lyx_view_->message(from_utf8(keyseq->print()));
+ lyx_view_->message(keyseq->print());
}
case LFUN_COMMAND_PREFIX:
BOOST_ASSERT(lyx_view_);
- lyx_view_->message(from_utf8(keyseq->printOptions()));
+ lyx_view_->message(keyseq->printOptions());
break;
case LFUN_COMMAND_EXECUTE:
case LFUN_META_PREFIX:
meta_fake_bit = key_modifier::alt;
- setMessage(from_utf8(keyseq->print()));
+ setMessage(keyseq->print());
break;
case LFUN_BUFFER_TOGGLE_READ_ONLY:
break;
case LFUN_SERVER_NOTIFY:
- dispatch_buffer = from_utf8(keyseq->print());
+ dispatch_buffer = keyseq->print();
theLyXServer().notifyClient(to_utf8(dispatch_buffer));
break;
}
}
- string const shortcuts = theTopLevelKeymap().printbindings(cmd);
+ string const shortcuts = to_utf8(theTopLevelKeymap().printbindings(cmd));
if (!shortcuts.empty())
comname += ": " + shortcuts;
{
// When meta-fake key is pressed, show the key sequence so far + "M-".
if (wasMetaKey())
- return keyseq->print() + "M-";
+ return to_utf8(keyseq->print() + "M-");
// Else, when a non-complete key sequence is pressed,
// show the available options.
if (keyseq->length() > 0 && !keyseq->deleted())
- return keyseq->printOptions();
+ return to_utf8(keyseq->printOptions());
if (!view()->buffer())
return to_utf8(_("Welcome to LyX!"));