#include "gettext.h"
#include "Lsstream.h"
#include "trans_mgr.h"
+#include "encoding.h"
#include "layout.h"
#include "bufferview_funcs.h"
#include "frontends/LyXView.h"
LyXFunc::LyXFunc(LyXView * o)
: owner(o),
+ encoded_last_key(0),
keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()),
meta_fake_bit(key_modifier::none)
void LyXFunc::handleKeyFunc(kb_action action)
{
- char c = keyseq.getLastKeyEncoded();
+ char c = encoded_last_key;
- if (keyseq.length() > 1) {
+ if (keyseq.length()) {
c = 0;
}
return;
}
+ Encoding const * encoding = view()->getEncoding();
+
+ encoded_last_key = keysym->getISOEncoded(encoding ? encoding->Name() : "");
+
// Do a one-deep top-level lookup for
// cancel and meta-fake keys. RVDK_PATCH_5
cancel_meta_seq.reset();
}
if (action == LFUN_SELFINSERT) {
- char c = keysym->getISOEncoded();
- string argument;
+ if (encoded_last_key != 0) {
+ string arg;
+ arg += encoded_last_key;
- // FIXME: why ...
- if (c != 0)
- argument = c;
+ dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
- dispatch(FuncRequest(view(), LFUN_SELFINSERT, argument));
- lyxerr[Debug::KEY] << "SelfInsert arg[`"
+ lyxerr[Debug::KEY] << "SelfInsert arg[`"
<< argument << "']" << endl;
+ }
} else {
dispatch(action);
}
return flag.disabled(true);
}
- if (ev.action == LFUN_UNKNOWN_ACTION) {
+ switch (ev.action) {
+ case LFUN_UNKNOWN_ACTION:
+#ifndef HAVE_LIBAIKSAURUS
+ case LFUN_THESAURUS_ENTRY:
+#endif
+ flag.unknown(true);
+ break;
+ default:
+ flag |= lyx_gui::getStatus(ev);
+ }
+
+ if (flag.unknown()) {
setStatusMessage(N_("Unknown action"));
- return flag.unknown(true);
+ return flag;
}
// the default error message if we disable the command
|| lyxrc.print_command == "none";
break;
case LFUN_EXPORT:
- disable = ev.argument == "fax" &&
- !Exporter::IsExportable(buf, ev.argument);
+ disable = ev.argument != "custom"
+ && !Exporter::IsExportable(buf, ev.argument);
break;
case LFUN_UNDO:
disable = buf->undostack.empty();
break;
case LFUN_CUT:
case LFUN_COPY:
- if (tli && tli->lyxCode() == Inset::TABULAR_CODE) {
- InsetTabular * t(static_cast<InsetTabular*>(tli));
- if (t->hasSelection()) {
+ if (tli) {
+ UpdatableInset * in = tli;
+ if (in->lyxCode() != Inset::TABULAR_CODE) {
+ in = tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
+ }
+ if (in && static_cast<InsetTabular*>(in)->hasSelection()) {
disable = false;
break;
}
}
disable = !mathcursor && !view()->getLyXText()->selection.set();
break;
-#ifndef HAVE_LIBAIKSAURUS
- case LFUN_THESAURUS_ENTRY:
- disable = true;
- break;
-#endif
case LFUN_RUNCHKTEX:
disable = lyxrc.chktex_command == "none";
break;
disable = !view()->
isSavedPosition(strToUnsignedInt(ev.argument));
break;
+ case LFUN_MERGE_CHANGES:
+ case LFUN_ACCEPT_CHANGE:
+ case LFUN_REJECT_CHANGE:
+ case LFUN_ACCEPT_ALL_CHANGES:
+ case LFUN_REJECT_ALL_CHANGES:
+ disable = !buf->params.tracking_changes;
+ break;
case LFUN_INSET_TOGGLE: {
LyXText * lt = view()->getLyXText();
disable = !(isEditableInset(lt->getInset())
if (ev.argument == buf->fileName())
flag.setOnOff(true);
break;
+ case LFUN_TRACK_CHANGES:
+ flag.setOnOff(buf->params.tracking_changes);
+ break;
default:
break;
}
#endif
if ((action == LFUN_UNKNOWN_ACTION)
&& argument.empty()) {
- argument = keyseq.getLastKeyEncoded();
+ argument = encoded_last_key;
}
// Undo/Redo is a bit tricky for insets.
if (action == LFUN_UNDO) {
FileDialog::Result result =
fileDlg.open(lyxrc.template_path,
- _("*.lyx|LyX Documents (*.lyx)"));
+ _("*.lyx| LyX Documents (*.lyx)"));
if (result.first == FileDialog::Later)
return;
FileDialog::Result result =
fileDlg.open(initpath,
- "*.lyx|LyX Documents (*.lyx)");
+ _("*.lyx| LyX Documents (*.lyx)"));
if (result.first == FileDialog::Later)
return;
if (!f.exist()) {
if (!Alert::askQuestion(_("No such file"), disp_fn,
_("Start a new document with this filename ?"))) {
- owner->message(_("Canceled"));
+ owner->message(_("Canceled."));
return;
}
// the user specifically chose this name. Believe them.
if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
if (!Alert::askQuestion(_("A document by the name"),
MakeDisplayPath(lyxfile), _("already exists. Overwrite?"))) {
- owner->message(_("Canceled"));
+ owner->message(_("Canceled."));
return;
}
}