#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"
void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
{
if (selecting || TEXT(flag)->selection.mark()) {
- TEXT(flag)->setSelection(view());
- if (TEXT(flag)->isTopLevel())
+ TEXT(flag)->setSelection();
+ if (!TEXT(flag)->isInInset())
view()->toggleToggle();
}
- view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
+ view()->update(TEXT(flag), BufferView::SELECT);
view()->showCursor();
view()->switchKeyMap();
// actions
keyseq.clear();
// copied verbatim from do_accent_char
- view()->update(TEXT(false),
- BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ view()->update(TEXT(false), BufferView::SELECT);
TEXT(false)->selection.cursor = TEXT(false)->cursor;
}
// the functions which insert insets
Inset::Code code = Inset::NO_CODE;
switch (ev.action) {
+ case LFUN_DIALOG_SHOW_NEW_INSET:
+ if (ev.argument == "bibitem")
+ code = Inset::BIBITEM_CODE;
+ else if (ev.argument == "bibtex")
+ code = Inset::BIBTEX_CODE;
+ else if (ev.argument == "citation")
+ code = Inset::CITE_CODE;
+ else if (ev.argument == "ert")
+ code = Inset::ERT_CODE;
+ else if (ev.argument == "external")
+ code = Inset::EXTERNAL_CODE;
+ else if (ev.argument == "float")
+ code = Inset::FLOAT_CODE;
+ else if (ev.argument == "graphics")
+ code = Inset::GRAPHICS_CODE;
+ else if (ev.argument == "include")
+ code = Inset::INCLUDE_CODE;
+ else if (ev.argument == "index")
+ code = Inset::INDEX_CODE;
+ else if (ev.argument == "label")
+ code = Inset::LABEL_CODE;
+ else if (ev.argument == "minipage")
+ code = Inset::MINIPAGE_CODE;
+ else if (ev.argument == "ref")
+ code = Inset::REF_CODE;
+ else if (ev.argument == "toc")
+ code = Inset::TOC_CODE;
+ else if (ev.argument == "url")
+ code = Inset::URL_CODE;
+ else if (ev.argument == "wrap")
+ code = Inset::WRAP_CODE;
+ break;
+
case LFUN_INSET_ERT:
code = Inset::ERT_CODE;
break;
- case LFUN_INSET_GRAPHICS:
- code = Inset::GRAPHICS_CODE;
- break;
case LFUN_INSET_FOOTNOTE:
code = Inset::FOOT_CODE;
break;
case LFUN_TABULAR_INSERT:
code = Inset::TABULAR_CODE;
break;
- case LFUN_INSET_EXTERNAL:
- code = Inset::EXTERNAL_CODE;
- break;
case LFUN_INSET_MARGINAL:
code = Inset::MARGIN_CODE;
break;
case LFUN_INSET_OPTARG:
code = Inset::OPTARG_CODE;
break;
- 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;
+ case LFUN_ENVIRONMENT_INSERT:
+ code = Inset::MINIPAGE_CODE;
break;
case LFUN_INDEX_INSERT:
code = Inset::INDEX_CODE;
case LFUN_INDEX_PRINT:
code = Inset::INDEX_PRINT_CODE;
break;
- case LFUN_CHILD_INSERT:
- code = Inset::INCLUDE_CODE;
- break;
case LFUN_TOC_INSERT:
code = Inset::TOC_CODE;
break;
break;
case LFUN_HTMLURL:
case LFUN_URL:
- case LFUN_INSERT_URL:
code = Inset::URL_CODE;
break;
case LFUN_QUOTE:
} 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(), TEXT()->cursor.ix() + inset_x,
+ TEXT()->cursor.ix() + inset_x,
TEXT()->cursor.iy() -
TEXT()->cursor.irow()->baseline() - 1);
TEXT()->cursor.x_fix(TEXT()->cursor.x());
moveCursorUpdate(true, false);
owner->view_state_changed();
} else {
- view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR);
+ view()->update(TEXT(), BufferView::SELECT);
}
goto exit_with_message;
- } else if (result == UpdatableInset::FINISHED_DOWN) {
+ } else if (result == FINISHED_DOWN) {
if (TEXT()->cursor.irow()->next()) {
#if 1
TEXT()->setCursorFromCoordinates(
- view(), TEXT()->cursor.ix() + inset_x,
+ TEXT()->cursor.ix() + inset_x,
TEXT()->cursor.iy() -
TEXT()->cursor.irow()->baseline() +
TEXT()->cursor.irow()->height() + 1);
}
finishUndo();
// Tell the paragraph dialog that we changed paragraph
- owner->getDialogs().updateParagraph();
+ dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
}
}
break;
case LFUN_PREFIX:
{
if (view()->available() && !view()->theLockingInset()) {
- view()->update(TEXT(),
- BufferView::SELECT|BufferView::FITCUR);
+ view()->update(TEXT(), BufferView::SELECT);
}
owner->message(keyseq.printOptions());
}
break;
case LFUN_MENURELOAD:
- reloadBuffer();
+ view()->reload();
break;
case LFUN_UPDATE:
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;
}
changeDepth(view(), TEXT(false), 1);
break;
- case LFUN_FREE:
- owner->getDialogs().setUserFreeFont();
+ case LFUN_FREEFONT_APPLY:
+ apply_freefont(view());
+ break;
+
+ case LFUN_FREEFONT_UPDATE:
+ update_and_apply_freefont(view(), argument);
break;
case LFUN_RECONFIGURE:
#endif
#endif
case LFUN_HELP_ABOUTLYX:
- owner->getDialogs().showAboutlyx();
+ owner->getDialogs().show("about");
break;
case LFUN_HELP_TEXINFO:
case LFUN_VC_HISTORY:
{
- owner->getDialogs().showVCLogFile();
+ owner->getDialogs().show("vclog");
break;
}
break;
case LFUN_LATEX_LOG:
- owner->getDialogs().showLogFile();
+ owner->getDialogs().show("log");
break;
case LFUN_LAYOUT_DOCUMENT:
owner->getDialogs().showDocument();
break;
- case LFUN_LAYOUT_PARAGRAPH:
- owner->getDialogs().showParagraph();
- break;
-
- case LFUN_LAYOUT_CHARACTER:
- owner->getDialogs().showCharacter();
+ case LFUN_LAYOUT_CHARACTER: {
+ string data = freefont2string();
+ if (!data.empty())
+ owner->getDialogs().show("character", data);
break;
+ }
case LFUN_LAYOUT_TABULAR:
if (view()->theLockingInset()) {
par->inInset()->edit(view());
}
// Set the cursor
- view()->getLyXText()->setCursor(view(), par, 0);
+ view()->getLyXText()->setCursor(par, 0);
view()->switchKeyMap();
owner->view_state_changed();
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 == "include" ||
+ 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);
+ }
+ 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 * inset = owner->getDialogs().getOpenInset(name);
+ if (inset) {
+ FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
+ ev.argument);
+ inset->localDispatch(fr);
+ } else if (name == "paragraph") {
+ dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
+ }
+ }
+ break;
+
+ case LFUN_DIALOG_HIDE:
+ Dialogs::hide(argument, 0);
+ break;
+
+ case LFUN_DIALOG_DISCONNECT_INSET:
+ owner->getDialogs().disconnect(argument);
+ break;
+
case LFUN_CHILDOPEN:
{
string const filename =
} // end of switch
exit_with_message:
+
+ view()->owner()->updateLayoutChoice();
+
+ if (view()->available()) {
+ view()->fitCursor();
+
+ // If we executed a mutating lfun, mark the buffer as dirty
+ if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)
+ && !lyxaction.funcHasFlag(ev.action, LyXAction::ReadOnly))
+ view()->buffer()->markDirty();
+ }
+
sendDispatchMessage(getMessage(), ev, verbose);
}
// 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)),
}
-void LyXFunc::reloadBuffer()
-{
- string const fn = owner->buffer()->fileName();
- if (bufferlist.close(owner->buffer()))
- view()->buffer(bufferlist.loadLyXFile(fn));
-}
-
-
void LyXFunc::closeBuffer()
{
if (bufferlist.close(owner->buffer()) && !quitting) {