void LyXFunc::handleKeyFunc(kb_action action)
{
- char c = 0;
+ char c = keyseq.getiso();
- if (keyseq.length == -1 && keyseq.getiso() != 0)
- c = keyseq.getiso();
+ if (keyseq.length != -1) c = 0;
+
owner->getIntl()->getTrans()
.deadkey(c, get_accent(action).accent, TEXT(false));
// Need to reset, in case the minibuffer calls these
}
-int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
+void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
{
string argument;
if (lyxerr.debugging(Debug::KEY)) {
- char * tmp = XKeysymToString(keysym);
+ char const * tmp = XKeysymToString(keysym);
string const stm = (tmp ? tmp : "");
lyxerr << "KeySym is "
<< stm
lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
<< endl;
//return 0;
- return FL_PREEMPT;
+ //return FL_PREEMPT;
+ return;
}
+#if 0
+ // This if clause should not be here, but should rather be changed
+ // to a lyxfunc and get XK_Escape bound to it (Lgb)
+#warning Fix this please. (Lgb)
if (owner->view()->available()) {
// this function should be used always [asierra060396]
UpdatableInset * tli = owner->view()->theLockingInset();
true);
}
//return 0;
- return FL_PREEMPT;
+ //return FL_PREEMPT;
+ return;
}
}
+#endif
// Can we be sure that this will work for all X-Windows
// implementations? (Lgb)
// This code snippet makes lyx ignore some keys. Perhaps
// all of them should be explictly mentioned?
if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
- || keysym == XK_Mode_switch || keysym == 0x0)
- return 0;
-
+ || keysym == XK_Mode_switch || keysym == 0x0) {
+ //return 0;
+ return;
+ }
+
// Do a one-deep top-level lookup for
// cancel and meta-fake keys. RVDK_PATCH_5
cancel_meta_seq.reset();
}
if (action == -1) {
- if (keyseq.length < -1) { // unknown key sequence...
- string buf;
- keyseq.print(buf);
- owner->message(_("Unknown sequence:") + ' ' + buf);
- return 0;
- }
-
- char const isochar = keyseq.getiso();
- if (!(state & ControlMask) &&
- !(state & Mod1Mask) &&
- (isochar && keysym < 0xF000)) {
- argument += isochar;
+ // It is unknown, but what if we remove all
+ // the modifiers? (Lgb)
+ action = keyseq.addkey(keysym, 0);
+
+ // We keep the shift state, but remove the others.
+ // This is for the sake of the LFUN_SELFINSERT below.
+ state &= ShiftMask;
+
+ if (lyxerr.debugging(Debug::KEY)) {
+ lyxerr << "Removing modifiers...\n"
+ << "Action now set to ["
+ << action << "]" << endl;
}
- if (argument.empty()) {
- lyxerr.debug() << "Empty argument!" << endl;
- // This can`t possibly be of any use
- // so we`ll skip the dispatch.
- return 0;
+ if (action == -1) {
+ owner->message(_("Unknown function."));
+ //return 0;
+ return;
}
- } else if (action == LFUN_SELFINSERT) {
+ }
+
+ if (action == LFUN_SELFINSERT) {
// We must set the argument to the char looked up by
// XKeysymToString
XKeyEvent xke;
xke.same_screen = True;
char ret[10];
KeySym tmpkeysym;
- int res = XLookupString(&xke, ret, 10, &tmpkeysym, 0);
+ int const res = XLookupString(&xke, ret, 10, &tmpkeysym, 0);
//Assert(keysym == tmpkeysym);
lyxerr[Debug::KEY] << "TmpKeysym ["
<< tmpkeysym << "]" << endl;
if (res > 0)
argument = string(ret, res);
+
lyxerr[Debug::KEY] << "SelfInsert arg["
<< argument << "]" << endl;
}
Dispatch(action, argument);
show_sc = tmp_sc;
- return 0;
+ //return 0;
}
break;
case LFUN_INSERTFOOTNOTE:
-#if 0
- case LFUN_FOOTMELT:
- case LFUN_MARGINMELT:
-#endif
// Disable insertion of floats in a tabular.
disable = false;
if (owner->view()->theLockingInset()) {
Dispatch(s);
}
+
string const LyXFunc::Dispatch(string const & s)
{
// Split command string into command and argument
lyx::Assert(action != LFUN_SELECT_FILE_SYNC);
switch (action) {
+
+ case LFUN_ESCAPE:
+ {
+ if (!owner->view()->available()) break;
+
+ // this function should be used always [asierra060396]
+ UpdatableInset * tli =
+ owner->view()->theLockingInset();
+ if (tli) {
+ UpdatableInset * lock = tli->GetLockingInset();
+
+ if (tli == lock) {
+ owner->view()->unlockInset(tli);
+ TEXT()->CursorRight(owner->view());
+ moveCursorUpdate(true, false);
+ owner->showState();
+ } else {
+ tli->UnlockInsetInInset(owner->view(),
+ lock,
+ true);
+ }
+ }
+ }
+ break;
+
// --- Misc -------------------------------------------
case LFUN_WORDFINDFORWARD :
case LFUN_WORDFINDBACKWARD : {
}
string buf;
keyseq.print(buf, true);
- //owner->getMiniBuffer()->Set(buf, string(), string(), 1);
owner->message(buf);
}
break;
break;
case LFUN_TOCVIEW:
+#if 0
case LFUN_LOFVIEW:
case LFUN_LOTVIEW:
case LFUN_LOAVIEW:
+#endif
{
InsetCommandParams p;
-
+
+#if 0
if (action == LFUN_TOCVIEW)
+#endif
p.setCmdName("tableofcontents");
+#if 0
else if (action == LFUN_LOAVIEW )
p.setCmdName("listof{algorithm}{List of Algorithms}");
else if (action == LFUN_LOFVIEW)
p.setCmdName("listoffigures");
else
p.setCmdName("listoftables");
-
+#endif
owner->getDialogs()->createTOC(p.getAsString());
break;
}
}
break;
-#ifndef NEW_INSETS
- case LFUN_OPENSTUFF:
- owner->view()->openStuff();
- break;
-#endif
-
case LFUN_HYPHENATION:
owner->view()->hyphenationPoint();
break;
owner->view()->setState();
owner->showState();
break;
-#ifndef NEW_INSETS
- case LFUN_MELT:
- Melt(owner->view());
- break;
-#endif
+
case LFUN_RECONFIGURE:
Reconfigure(owner->view());
break;
-#ifndef NEW_INSETS
- case LFUN_FOOTMELT:
- if (owner->view()->available()
- && !TEXT()->selection
- && TEXT()->cursor.par()->footnoteflag
- != LyXParagraph::NO_FOOTNOTE)
- { // only melt footnotes with FOOTMELT, not margins etc
- if (TEXT()->cursor.par()->footnotekind == LyXParagraph::FOOTNOTE)
- Melt(owner->view());
- }
- else
- Foot(owner->view());
- owner->view()->setState();
- break;
- case LFUN_MARGINMELT:
- if (owner->view()->available()
- && !TEXT()->selection
- && TEXT()->cursor.par()->footnoteflag
- != LyXParagraph::NO_FOOTNOTE) {
- // only melt margins
- if (TEXT()->cursor.par()->footnotekind == LyXParagraph::MARGIN)
- Melt(owner->view());
- } else
- Margin(owner->view());
- owner->view()->setState();
- break;
-#endif
-#ifndef NEW_INSETS
+#if 0
case LFUN_FLOATSOPERATE:
if (argument == "openfoot")
owner->view()->allFloats(1,0);
}
break;
-#ifndef NEW_INSETS
- case LFUN_INSERTFOOTNOTE:
- {
- LyXParagraph::footnote_kind kind;
- if (argument == "footnote") {
- kind = LyXParagraph::FOOTNOTE;
- } else if (argument == "margin") {
- kind = LyXParagraph::MARGIN;
- } else if (argument == "figure") {
- kind = LyXParagraph::FIG;
- } else if (argument == "table") {
- kind = LyXParagraph::TAB;
- } else if (argument == "wide-fig") {
- kind = LyXParagraph::WIDE_FIG;
- } else if (argument == "wide-tab") {
- kind = LyXParagraph::WIDE_TAB;
- } else if (argument == "algorithm") {
- kind = LyXParagraph::ALGORITHM;
- } else {
- setErrorMessage(N_("Unknown kind of footnote"));
- break;
- }
- TEXT()->InsertFootnoteEnvironment(owner->view(), kind);
- owner->view()->update(TEXT(),
- BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- owner->view()->setState();
- }
- break;
-#endif
case LFUN_TOGGLECURSORFOLLOW:
lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
break;
default:
// Then if it was none of the above
if (!owner->view()->Dispatch(action, argument))
- lyxerr << "A truly unknown func!" << endl;
+ lyxerr << "A truly unknown func ["
+ << action << "]!" << endl;
break;
} // end of switch