-void LyXFunc::processKeySym(KeySymbol const & keysym, KeyModifier state)
-{
- LYXERR(Debug::KEY, "KeySym is " << keysym.getSymbolName());
-
- LyXView * lv = theApp()->currentWindow();
-
- // Do nothing if we have nothing (JMarc)
- if (!keysym.isOK()) {
- LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
- lv->restartCursor();
- return;
- }
-
- if (keysym.isModifier()) {
- LYXERR(Debug::KEY, "isModifier true");
- if (lv)
- lv->restartCursor();
- return;
- }
-
- //Encoding const * encoding = lv->documentBufferView()->cursor().getEncoding();
- //encoded_last_key = keysym.getISOEncoded(encoding ? encoding->name() : "");
- // FIXME: encoded_last_key shadows the member variable of the same
- // name. Is that intended?
- char_type encoded_last_key = keysym.getUCSEncoded();
-
- // Do a one-deep top-level lookup for
- // cancel and meta-fake keys. RVDK_PATCH_5
- cancel_meta_seq.reset();
-
- FuncRequest func = cancel_meta_seq.addkey(keysym, state);
- LYXERR(Debug::KEY, "action first set to [" << func.action << ']');
-
- // When not cancel or meta-fake, do the normal lookup.
- // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
- // Mostly, meta_fake_bit = NoModifier. RVDK_PATCH_5.
- if ((func.action != LFUN_CANCEL) && (func.action != LFUN_META_PREFIX)) {
- // remove Caps Lock and Mod2 as a modifiers
- func = keyseq.addkey(keysym, (state | meta_fake_bit));
- LYXERR(Debug::KEY, "action now set to [" << func.action << ']');
- }
-
- // Dont remove this unless you know what you are doing.
- meta_fake_bit = NoModifier;
-
- // Can this happen now ?
- if (func.action == LFUN_NOACTION)
- func = FuncRequest(LFUN_COMMAND_PREFIX);
-
- LYXERR(Debug::KEY, " Key [action=" << func.action << "]["
- << keyseq.print(KeySequence::Portable) << ']');
-
- // already here we know if it any point in going further
- // why not return already here if action == -1 and
- // num_bytes == 0? (Lgb)
-
- if (keyseq.length() > 1)
- lv->message(keyseq.print(KeySequence::ForGui));
-
-
- // Maybe user can only reach the key via holding down shift.
- // Let's see. But only if shift is the only modifier
- if (func.action == LFUN_UNKNOWN_ACTION && state == ShiftModifier) {
- LYXERR(Debug::KEY, "Trying without shift");
- func = keyseq.addkey(keysym, NoModifier);
- LYXERR(Debug::KEY, "Action now " << func.action);
- }
-
- if (func.action == LFUN_UNKNOWN_ACTION) {
- // Hmm, we didn't match any of the keysequences. See
- // if it's normal insertable text not already covered
- // by a binding
- if (keysym.isText() && keyseq.length() == 1) {
- LYXERR(Debug::KEY, "isText() is true, inserting.");
- func = FuncRequest(LFUN_SELF_INSERT,
- FuncRequest::KEYBOARD);
- } else {
- LYXERR(Debug::KEY, "Unknown, !isText() - giving up");
- lv->message(_("Unknown function."));
- lv->restartCursor();
- return;
- }
- }
-
- if (func.action == LFUN_SELF_INSERT) {
- if (encoded_last_key != 0) {
- docstring const arg(1, encoded_last_key);
- dispatch(FuncRequest(LFUN_SELF_INSERT, arg,
- FuncRequest::KEYBOARD));
- LYXERR(Debug::KEY, "SelfInsert arg[`" << to_utf8(arg) << "']");
- }
- } else {
- dispatch(func);
- if (!lv)
- return;
- }
-}
-
-