#include "lyxrow.h"
#include "bufferlist.h"
#include "buffer.h"
+#include "buffer_funcs.h"
#include "BufferView.h"
#include "lyxserver.h"
#include "intl.h"
#include "ParagraphParameters.h"
#include "insets/insetcommand.h"
+#include "insets/insetexternal.h"
#include "insets/insettabular.h"
#include "mathed/formulamacro.h"
// encode this in the function itself.
bool disable = false;
switch (ev.action) {
- case LFUN_MENUPRINT:
- disable = !Exporter::IsExportable(buf, "dvi")
- || lyxrc.print_command == "none";
- break;
case LFUN_EXPORT:
disable = ev.argument != "custom"
&& !Exporter::IsExportable(buf, ev.argument);
disable = !Exporter::IsExportable(buf, "program");
break;
- case LFUN_LAYOUT_CHARACTER:
- disable = tli && tli->lyxCode() == Inset::ERT_CODE;
- break;
-
case LFUN_LAYOUT_TABULAR:
disable = !tli
|| (tli->lyxCode() != Inset::TABULAR_CODE
break;
case LFUN_VC_REVERT:
case LFUN_VC_UNDO:
- case LFUN_VC_HISTORY:
disable = !buf->lyxvc.inUse();
break;
case LFUN_MENURELOAD:
break;
}
- case LFUN_LATEX_LOG:
- disable = !IsFileReadable(buf->getLogName().second);
- break;
-
case LFUN_MATH_MUTATE:
if (mathcursor)
//flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
disable = !mathcursor;
break;
+ case LFUN_DIALOG_SHOW: {
+ string const name = ev.getArg(0);
+ if (!buf) {
+ disable = !(name == "aboutlyx" ||
+ name == "file" ||
+ name == "forks" ||
+ name == "preferences" ||
+ name == "texinfo");
+ break;
+ }
+
+ if (name == "print") {
+ disable = !Exporter::IsExportable(buf, "dvi") ||
+ lyxrc.print_command == "none";
+ } else if (name == "character") {
+ UpdatableInset * tli = view()->theLockingInset();
+ disable = tli && tli->lyxCode() == Inset::ERT_CODE;
+ } else if (name == "vclog") {
+ disable = !buf->lyxvc.inUse();
+ } else if (name == "latexlog") {
+ disable = !IsFileReadable(buf->getLogName().second);
+ }
+ break;
+ }
+
default:
break;
}
owner->buffer()->runChktex();
break;
- case LFUN_MENUPRINT:
- owner->getDialogs().showPrint();
- break;
-
case LFUN_EXPORT:
if (argument == "custom")
owner->getDialogs().showSendto();
view()->redo();
break;
- case LFUN_MENUSEARCH:
- owner->getDialogs().showSearch();
- break;
-
case LFUN_DEPTH_MIN:
changeDepth(view(), TEXT(false), DEC_DEPTH, false);
owner->view_state_changed();
//#warning Find another implementation here (or another lyxfunc)!
#endif
#endif
- case LFUN_HELP_ABOUTLYX:
- owner->getDialogs().show("about");
- break;
-
- case LFUN_HELP_TEXINFO:
- owner->getDialogs().showTexinfo();
- break;
-
case LFUN_HELP_OPEN:
{
string const arg = argument;
}
owner->message(bformat(_("Opening help file %1$s..."),
MakeDisplayPath(fname)));
- view()->buffer(bufferlist.loadLyXFile(fname, false));
+ view()->loadLyXFile(fname, false);
break;
}
}
break;
- case LFUN_VC_HISTORY:
- {
- owner->getDialogs().show("vclog");
- break;
- }
-
// --- buffers ----------------------------------------
case LFUN_SWITCHBUFFER:
open(argument);
break;
- case LFUN_LATEX_LOG:
- owner->getDialogs().show("log");
- break;
-
- case LFUN_LAYOUT_DOCUMENT:
- owner->getDialogs().showDocument();
- break;
-
- case LFUN_LAYOUT_CHARACTER: {
- string data = freefont2string();
- if (!data.empty())
- owner->getDialogs().show("character", data);
- break;
- }
-
case LFUN_LAYOUT_TABULAR:
if (view()->theLockingInset()) {
if (view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
}
break;
- case LFUN_LAYOUT_PREAMBLE:
- owner->getDialogs().showPreamble();
- break;
-
case LFUN_DROP_LAYOUTS_CHOICE:
owner->getToolbar().openLayoutList();
break;
owner->getMenubar().openByName(argument);
break; // RVDK_PATCH_5
- case LFUN_SPELLCHECK:
- owner->getDialogs().showSpellchecker();
- break;
-
// --- lyxserver commands ----------------------------
if (bufferlist.exists(s)) {
view()->buffer(bufferlist.getBuffer(s));
} else {
- view()->buffer(bufferlist.loadLyXFile(s));
+ view()->loadLyXFile(s);
}
view()->setCursorFromRow(row);
<< id << ']' << endl;
break;
} else {
- lyxerr[Debug::INFO] << "Paragraph " << (*par)->id()
+ lyxerr[Debug::INFO] << "Paragraph " << par->id()
<< " found." << endl;
}
if (view()->theLockingInset())
view()->unlockInset(view()->theLockingInset());
- if ((*par)->inInset()) {
+ if (par->inInset()) {
FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
- (*par)->inInset()->localDispatch(cmd);
+ par->inInset()->localDispatch(cmd);
}
// Set the cursor
- view()->getLyXText()->setCursor(*par, 0);
+ view()->getLyXText()->setCursor(par.pit(), 0);
view()->switchKeyMap();
owner->view_state_changed();
dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
break;
- case LFUN_MATH_PANEL:
- owner->getDialogs().showMathPanel();
+ case LFUN_DIALOG_SHOW: {
+ string const name = ev.getArg(0);
+ string data = trim(ev.argument.substr(name.size()));
+
+ if (name == "character") {
+ data = freefont2string();
+ if (!data.empty())
+ owner->getDialogs().show("character", data);
+ } else if (name == "document")
+ owner->getDialogs().showDocument();
+ else if (name == "findreplace")
+ owner->getDialogs().showSearch();
+ else if (name == "forks")
+ owner->getDialogs().showForks();
+ else if (name == "preamble")
+ owner->getDialogs().showPreamble();
+ else if (name == "preferences")
+ owner->getDialogs().showPreferences();
+ else if (name == "print")
+ owner->getDialogs().showPrint();
+ else if (name == "spellchecker")
+ owner->getDialogs().showSpellchecker();
+ else
+ owner->getDialogs().show(name, data);
break;
+ }
case LFUN_DIALOG_SHOW_NEW_INSET: {
string const & name = argument;
if (bufferlist.exists(filename))
view()->buffer(bufferlist.getBuffer(filename));
else
- view()->buffer(bufferlist.loadLyXFile(filename));
+ view()->loadLyXFile(filename);
}
break;
}
break;
- case LFUN_DIALOG_PREFERENCES:
- owner->getDialogs().showPreferences();
- break;
-
case LFUN_SAVEPREFERENCES:
{
Path p(user_lyxdir);
owner->message(argument);
break;
- case LFUN_FORKS_SHOW:
- owner->getDialogs().showForks();
- break;
-
case LFUN_FORKS_KILL:
{
if (!isStrInt(argument))
owner->getDialogs().toggleTooltips();
break;
+ case LFUN_EXTERNAL_EDIT: {
+ InsetExternal()
+ .localDispatch(FuncRequest(view(), action, argument));
+ break;
+ }
+
default:
// Then if it was none of the above
// Trying the BufferView::pimpl dispatch:
templname = fname;
}
- view()->buffer(bufferlist.newFile(filename, templname, !name.empty()));
+ view()->buffer(newFile(filename, templname, !name.empty()));
}
FileInfo const f(filename, true);
if (!f.exist()) {
// the user specifically chose this name. Believe them.
- Buffer * buffer = bufferlist.newFile(filename, "", true);
+ Buffer * buffer = newFile(filename, "", true);
view()->buffer(buffer);
return;
}
owner->message(bformat(_("Opening document %1$s..."), disp_fn));
- Buffer * openbuf = bufferlist.loadLyXFile(filename);
string str2;
- if (openbuf) {
- view()->buffer(openbuf);
+ if (view()->loadLyXFile(filename)) {
str2 = bformat(_("Document %1$s opened."), disp_fn);
} else {
str2 = bformat(_("Could not open document %1$s"), disp_fn);