#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "lyxfunc.h"
#include "version.h"
#include "kbmap.h"
#include "frontends/lyx_gui.h"
#include "vspace.h"
#include "FloatList.h"
-#include "converter.h"
+#include "format.h"
#include "exporter.h"
#include "importer.h"
#include "TextCache.h"
#include "ParagraphParameters.h"
#include "insets/insetcommand.h"
+#include "insets/inseterror.h"
+#include "insets/insetert.h"
#include "insets/insettabular.h"
#include "mathed/formulamacro.h"
{
if (selecting || TEXT(flag)->selection.mark()) {
TEXT(flag)->setSelection(view());
- if (TEXT(flag)->bv_owner)
+ if (TEXT(flag)->isTopLevel())
view()->toggleToggle();
}
view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
owner->message(keyseq.print());
}
-
+
// Maybe user can only reach the key via holding down shift.
// Let's see. But only if shift is the only modifier
if (action == LFUN_UNKNOWN_ACTION && state == key_modifier::shift) {
action = keyseq.addkey(keysym, key_modifier::none);
lyxerr[Debug::KEY] << "Action now " << action << endl;
}
-
+
if (action == LFUN_UNKNOWN_ACTION) {
// Hmm, we didn't match any of the keysequences. See
// if it's normal insertable text not already covered
default:
flag |= lyx_gui::getStatus(ev);
}
-
+
if (flag.unknown()) {
setStatusMessage(N_("Unknown action"));
return flag;
case LFUN_VC_HISTORY:
disable = !buf->lyxvc.inUse();
break;
+ case LFUN_MENURELOAD:
+ disable = buf->isUnnamed() || buf->isClean();
+ break;
case LFUN_BOOKMARK_GOTO:
disable = !view()->
isSavedPosition(strToUnsignedInt(ev.argument));
case LFUN_REF_INSERT:
code = Inset::REF_CODE;
break;
- case LFUN_CITATION_CREATE:
- case LFUN_CITATION_INSERT:
- code = Inset::CITE_CODE;
- break;
- case LFUN_INSERT_BIBTEX:
- code = Inset::BIBTEX_CODE;
- break;
case LFUN_INDEX_INSERT:
code = Inset::INDEX_CODE;
break;
} else if (((result=inset->
// Hand-over to inset's own dispatch:
localDispatch(FuncRequest(view(), action, argument))) ==
- UpdatableInset::DISPATCHED) ||
- (result == UpdatableInset::DISPATCHED_NOUPDATE))
+ DISPATCHED) ||
+ (result == DISPATCHED_NOUPDATE))
goto exit_with_message;
// If UNDISPATCHED, just soldier on
- else if (result == UpdatableInset::FINISHED) {
+ else if (result == FINISHED) {
goto exit_with_message;
// We do not need special RTL handling here:
// FINISHED means that the cursor should be
// one position after the inset.
- } else if (result == UpdatableInset::FINISHED_RIGHT) {
+ } else if (result == FINISHED_RIGHT) {
TEXT()->cursorRight(view());
moveCursorUpdate(true, false);
owner->view_state_changed();
goto exit_with_message;
- } else if (result == UpdatableInset::FINISHED_UP) {
+ } else if (result == FINISHED_UP) {
if (TEXT()->cursor.irow()->previous()) {
#if 1
TEXT()->setCursorFromCoordinates(
view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR);
}
goto exit_with_message;
- } else if (result == UpdatableInset::FINISHED_DOWN) {
+ } else if (result == FINISHED_DOWN) {
if (TEXT()->cursor.irow()->next()) {
#if 1
TEXT()->setCursorFromCoordinates(
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());
+ InsetCommandParams p("tableofcontents");
+ string const data = InsetCommandMailer::params2string("toc", p);
+ owner->getDialogs().show("toc", data, 0);
break;
}
setErrorMessage(N_("Missing argument"));
break;
}
- owner->prohibitInput();
string const fname = i18nLibFileSearch("doc", arg, "lyx");
if (fname.empty()) {
lyxerr << "LyX: unable to find documentation file `"
<< arg << "'. Bad installation?" << endl;
- owner->allowInput();
break;
}
ostringstream str;
#endif
owner->message(STRCONV(str.str()));
view()->buffer(bufferlist.loadLyXFile(fname, false));
- owner->allowInput();
break;
}
owner->getDialogs().showMathPanel();
break;
- case LFUN_CITATION_CREATE:
- {
- InsetCommandParams p("cite");
+ case LFUN_DIALOG_SHOW_NEW_INSET: {
+ string const & name = argument;
+ string data;
+ if (name == "bibitem" ||
+ name == "bibtex" ||
+ name == "index" ||
+ name == "ref" ||
+ name == "toc" ||
+ name == "url") {
+ InsetCommandParams p(name);
+ data = InsetCommandMailer::params2string(name, p);
+ } else if (name == "citation") {
+ InsetCommandParams p("cite");
+ data = InsetCommandMailer::params2string(name, p);
+ } else if (name == "ert") {
+ data = InsetERTMailer::params2string(name,
+ InsetERT::Open);
+ }
+ owner->getDialogs().show(name, data, 0);
+ }
+ break;
- if (!argument.empty()) {
- // This should be set at source, ie when typing
- // "citation-insert foo" in the minibuffer.
- // Question: would pybibliographer also need to be
- // changed. Suspect so. Leave as-is therefore.
- if (contains(argument, "|")) {
- p.setContents(token(argument, '|', 0));
- p.setOptions(token(argument, '|', 1));
- } else {
- p.setContents(argument);
- }
- dispatch(FuncRequest(view(), LFUN_CITATION_INSERT, p.getAsString()));
- } else
- owner->getDialogs().createCitation(p.getAsString());
+ case LFUN_DIALOG_SHOW_NEXT_INSET: {
}
break;
+ case LFUN_DIALOG_UPDATE: {
+ string const & name = argument;
+ // Can only update a dialog connected to an existing inset
+ InsetBase * i = owner->getDialogs().getOpenInset(name);
+ if (!i)
+ break;
+
+ if (name == "bibitem" ||
+ name == "bibtex" ||
+ name == "citation" ||
+ name == "index" ||
+ name == "ref" ||
+ name == "toc" ||
+ name == "url") {
+ InsetCommand * inset = dynamic_cast<InsetCommand *>(i);
+ if (!inset)
+ break;
+
+ InsetCommandMailer mailer(name, *inset);
+ mailer.updateDialog();
+
+ } else if (name == "error") {
+ InsetError * inset = dynamic_cast<InsetError *>(i);
+ if (!inset)
+ break;
+
+ owner->getDialogs().update("error",
+ inset->getContents());
+
+ } else if (name == "ert") {
+ InsetERT * inset = dynamic_cast<InsetERT *>(i);
+ if (!inset)
+ break;
+
+ InsetERTMailer mailer(*inset);
+ mailer.updateDialog();
+ }
+ }
+ break;
+
+ case LFUN_DIALOG_HIDE:
+ owner ->getDialogs().hide(argument);
+ break;
+
+ case LFUN_DIALOG_DISCONNECT_INSET:
+ owner->getDialogs().disconnect(argument);
+ break;
+
case LFUN_CHILDOPEN:
{
string const filename =
// The template stuff
string templname;
if (fromTemplate) {
- FileDialog fileDlg(owner, _("Select template file"),
+ FileDialog fileDlg(_("Select template file"),
LFUN_SELECT_FILE_SYNC,
make_pair(string(_("Documents|#o#O")),
string(lyxrc.document_path)),
string filename;
if (fname.empty()) {
- FileDialog fileDlg(owner, _("Select document to open"),
+ FileDialog fileDlg(_("Select document to open"),
LFUN_FILE_OPEN,
make_pair(string(_("Documents|#o#O")),
string(lyxrc.document_path)),
+ _(" file to import");;
#endif
- FileDialog fileDlg(owner, text,
+ FileDialog fileDlg(text,
LFUN_IMPORT,
make_pair(string(_("Documents|#o#O")),
string(lyxrc.document_path)),