* Licence details can be found in the file COPYING.
*
* \author Alfredo Braunstein
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
* \author Jean-Marc Lasgouttes
* \author Angus Leeming
* \author John Levon
- * \author André Pönitz
+ * \author André Pönitz
* \author Allan Rae
* \author Dekel Tsur
* \author Martin Vermeer
- * \author Jürgen Vigna
+ * \author Jürgen Vigna
*
* Full author contact details are available in file CREDITS.
*/
#include "insets/InsetERT.h"
#include "insets/InsetExternal.h"
#include "insets/InsetFloat.h"
-#include "insets/InsetListings.h"
#include "insets/InsetGraphics.h"
#include "insets/InsetInclude.h"
+#include "insets/InsetListings.h"
#include "insets/InsetNote.h"
+#include "insets/InsetPhantom.h"
#include "insets/InsetSpace.h"
#include "insets/InsetTabular.h"
#include "insets/InsetVSpace.h"
bool res = false;
for ( ; cursor.depth(); cursor.pop()) {
//lyxerr << "\nCursor::getStatus: cmd: " << cmd << endl << *this << endl;
- BOOST_ASSERT(cursor.idx() <= cursor.lastidx());
- BOOST_ASSERT(cursor.pit() <= cursor.lastpit());
- BOOST_ASSERT(cursor.pos() <= cursor.lastpos());
+ LASSERT(cursor.idx() <= cursor.lastidx(), /**/);
+ LASSERT(cursor.pit() <= cursor.lastpit(), /**/);
+ LASSERT(cursor.pos() <= cursor.lastpos(), /**/);
// The inset's getStatus() will return 'true' if it made
// a definitive decision on whether it want to handle the
if (keyseq.length())
c = 0;
- BOOST_ASSERT(lyx_view_ && lyx_view_->view());
+ LASSERT(lyx_view_ && lyx_view_->view(), /**/);
lyx_view_->view()->getIntl().getTransManager().deadkey(
c, get_accent(action).accent, view()->cursor().innerText(), view()->cursor());
// Need to clear, in case the minibuffer calls these
// to GuiView and be GuiView and be window dependent.
void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
{
- BOOST_ASSERT(lyx_view_);
- if (!LyX::ref().session().bookmarks().isValid(idx))
+ LASSERT(lyx_view_, /**/);
+ if (!theSession().bookmarks().isValid(idx))
return;
- BookmarksSection::Bookmark const & bm = LyX::ref().session().bookmarks().bookmark(idx);
- BOOST_ASSERT(!bm.filename.empty());
+ BookmarksSection::Bookmark const & bm = theSession().bookmarks().bookmark(idx);
+ LASSERT(!bm.filename.empty(), /**/);
string const file = bm.filename.absFilename();
// if the file is not opened, open it.
- if (!theBufferList().exists(file)) {
+ if (!theBufferList().exists(bm.filename)) {
if (openFile)
dispatch(FuncRequest(LFUN_FILE_OPEN, file));
else
return;
}
// open may fail, so we need to test it again
- if (!theBufferList().exists(file))
+ if (!theBufferList().exists(bm.filename))
return;
+ // bm can be changed when saving
+ BookmarksSection::Bookmark tmp = bm;
+
+ // Special case idx == 0 used for back-from-back jump navigation
+ if (idx == 0)
+ dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
+
// if the current buffer is not that one, switch to it.
- if (lyx_view_->buffer()->absFileName() != file) {
+ if (lyx_view_->buffer()->fileName() != tmp.filename) {
if (!switchToBuffer)
return;
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
}
+
// moveToPosition try paragraph id first and then paragraph (pit, pos).
- if (!view()->moveToPosition(bm.bottom_pit, bm.bottom_pos,
- bm.top_id, bm.top_pos))
+ if (!view()->moveToPosition(tmp.bottom_pit, tmp.bottom_pos,
+ tmp.top_id, tmp.top_pos))
+ return;
+
+ // bm changed
+ if (idx == 0)
return;
// Cursor jump succeeded!
if (!lyx_view_)
return;
}
-
- if (lyx_view_)
- lyx_view_->restartCursor();
}
if (cmd.action == LFUN_NOACTION) {
flag.message(from_utf8(N_("Nothing to do")));
- flag.enabled(false);
+ flag.setEnabled(false);
return flag;
}
switch (cmd.action) {
case LFUN_UNKNOWN_ACTION:
-#ifndef HAVE_LIBAIKSAURUS
+#if !defined(HAVE_LIBMYTHES) && !defined(HAVE_LIBAIKSAURUS)
case LFUN_THESAURUS_ENTRY:
#endif
flag.unknown(true);
- flag.enabled(false);
+ flag.setEnabled(false);
break;
default:
// no, exit directly
flag.message(from_utf8(N_("Command not allowed with"
"out any document open")));
- flag.enabled(false);
+ flag.setEnabled(false);
return flag;
}
bool enable = true;
switch (cmd.action) {
- // FIXME: these cases should be hidden in GuiApplication::getStatus().
- case LFUN_WINDOW_CLOSE:
- if (theApp())
- return theApp()->getStatus(cmd);
- enable = false;
- break;
-
- // FIXME: these cases should be hidden in GuiView::getStatus().
- case LFUN_DIALOG_TOGGLE:
- case LFUN_DIALOG_SHOW:
- case LFUN_UI_TOGGLE:
- case LFUN_DIALOG_UPDATE:
- // FIXME: add special handling for about and prefs dialogs here
- // which do not depend on GuiView.
- if (lyx_view_)
- return lyx_view_->getStatus(cmd);
- else
- enable = false;
- break;
-
- case LFUN_TOOLBAR_TOGGLE:
- case LFUN_INSET_APPLY:
- case LFUN_BUFFER_WRITE:
- case LFUN_BUFFER_WRITE_AS:
- case LFUN_SPLIT_VIEW:
- case LFUN_CLOSE_TAB_GROUP:
- case LFUN_COMPLETION_POPUP:
- case LFUN_COMPLETION_INLINE:
- case LFUN_COMPLETION_COMPLETE:
- if (lyx_view_)
- return lyx_view_->getStatus(cmd);
- enable = false;
- break;
-
case LFUN_BUFFER_TOGGLE_READ_ONLY:
flag.setOnOff(buf->isReadonly());
break;
flag.setOnOff(true);
break;
- case LFUN_BUFFER_EXPORT:
- enable = cmd.argument() == "custom"
- || buf->isExportable(to_utf8(cmd.argument()));
- break;
-
case LFUN_BUFFER_CHKTEX:
enable = buf->isLatex() && !lyxrc.chktex_command.empty();
break;
enable = !buf->lyxvc().inUse();
break;
case LFUN_VC_CHECK_IN:
- enable = buf->lyxvc().inUse() && !buf->isReadonly();
+ enable = buf->lyxvc().checkInEnabled();
break;
case LFUN_VC_CHECK_OUT:
- enable = buf->lyxvc().inUse() && buf->isReadonly();
+ enable = buf->lyxvc().checkOutEnabled();
break;
case LFUN_VC_REVERT:
- case LFUN_VC_UNDO_LAST:
enable = buf->lyxvc().inUse();
break;
+ case LFUN_VC_UNDO_LAST:
+ enable = buf->lyxvc().undoLastEnabled();
+ break;
case LFUN_BUFFER_RELOAD:
enable = !buf->isUnnamed() && buf->fileName().exists()
&& (!buf->isClean() || buf->isExternallyModified(Buffer::timestamp_method));
/*
case LFUN_BUFFER_WRITE:
case LFUN_BUFFER_WRITE_AS: {
- Buffer * b = theBufferList().getBuffer(cmd.getArg(0));
+ Buffer * b = theBufferList().getBuffer(FileName(cmd.getArg(0)));
enable = b && (b->isUnnamed() || !b->isClean());
break;
}
case LFUN_BOOKMARK_GOTO: {
const unsigned int num = convert<unsigned int>(to_utf8(cmd.argument()));
- enable = LyX::ref().session().bookmarks().isValid(num);
+ enable = theSession().bookmarks().isValid(num);
break;
}
case LFUN_BOOKMARK_CLEAR:
- enable = LyX::ref().session().bookmarks().size() > 0;
+ enable = theSession().bookmarks().hasValid();
break;
// this one is difficult to get right. As a half-baked
break;
}
+ // we want to check if at least one of these is enabled
+ case LFUN_COMMAND_ALTERNATIVES: {
+ // argument contains ';'-terminated commands
+ string arg = to_utf8(cmd.argument());
+ while (!arg.empty()) {
+ string first;
+ arg = split(arg, first, ';');
+ FuncRequest func(lyxaction.lookupFunc(first));
+ func.origin = cmd.origin;
+ flag = getStatus(func);
+ // if this one is enabled, the whole thing is
+ if (flag.enabled())
+ break;
+ }
+ break;
+ }
+
case LFUN_CALL: {
FuncRequest func;
string name = to_utf8(cmd.argument());
- if (LyX::ref().topLevelCmdDef().lock(name, func)) {
+ if (theTopLevelCmdDef().lock(name, func)) {
func.origin = cmd.origin;
flag = getStatus(func);
- LyX::ref().topLevelCmdDef().release(name);
+ theTopLevelCmdDef().release(name);
} else {
// catch recursion or unknown command definiton
// all operations until the recursion or unknown command
break;
}
- case LFUN_BUFFER_NEW:
- case LFUN_BUFFER_NEW_TEMPLATE:
+ case LFUN_VC_COMMAND: {
+ if (cmd.argument().empty())
+ enable = false;
+
+ if (!buf && contains(cmd.getArg(0), 'D'))
+ enable = false;
+ break;
+ }
+
+ case LFUN_MASTER_BUFFER_UPDATE:
+ case LFUN_MASTER_BUFFER_VIEW:
+ if (!buf->parent()) {
+ enable = false;
+ break;
+ }
+ case LFUN_BUFFER_UPDATE:
+ case LFUN_BUFFER_VIEW: {
+ string format = to_utf8(cmd.argument());
+ if (cmd.argument().empty())
+ format = buf->getDefaultOutputFormat();
+ typedef vector<Format const *> Formats;
+ Formats formats;
+ formats = buf->exportableFormats(true);
+ Formats::const_iterator fit = formats.begin();
+ Formats::const_iterator end = formats.end();
+ enable = false;
+ for (; fit != end ; ++fit) {
+ if ((*fit)->name() == format)
+ enable = true;
+ }
+ break;
+ }
+
case LFUN_WORD_FIND_FORWARD:
case LFUN_WORD_FIND_BACKWARD:
+ case LFUN_WORD_FINDADV:
case LFUN_COMMAND_PREFIX:
case LFUN_COMMAND_EXECUTE:
case LFUN_CANCEL:
case LFUN_META_PREFIX:
case LFUN_BUFFER_CLOSE:
- case LFUN_BUFFER_UPDATE:
- case LFUN_BUFFER_VIEW:
- case LFUN_MASTER_BUFFER_UPDATE:
- case LFUN_MASTER_BUFFER_VIEW:
case LFUN_BUFFER_IMPORT:
case LFUN_BUFFER_AUTO_SAVE:
case LFUN_RECONFIGURE:
case LFUN_HELP_OPEN:
- case LFUN_FILE_OPEN:
case LFUN_DROP_LAYOUTS_CHOICE:
case LFUN_MENU_OPEN:
- case LFUN_SERVER_GET_NAME:
+ case LFUN_SERVER_GET_FILENAME:
case LFUN_SERVER_NOTIFY:
case LFUN_SERVER_GOTO_FILE_ROW:
case LFUN_DIALOG_HIDE:
case LFUN_KEYMAP_TOGGLE:
case LFUN_REPEAT:
case LFUN_BUFFER_EXPORT_CUSTOM:
- case LFUN_BUFFER_PRINT:
case LFUN_PREFERENCES_SAVE:
- case LFUN_SCREEN_FONT_UPDATE:
- case LFUN_SET_COLOR:
case LFUN_MESSAGE:
- case LFUN_EXTERNAL_EDIT:
- case LFUN_GRAPHICS_EDIT:
- case LFUN_ALL_INSETS_TOGGLE:
+ case LFUN_INSET_EDIT:
case LFUN_BUFFER_LANGUAGE:
case LFUN_TEXTCLASS_APPLY:
case LFUN_TEXTCLASS_LOAD:
case LFUN_LYXRC_APPLY:
case LFUN_BUFFER_NEXT:
case LFUN_BUFFER_PREVIOUS:
- case LFUN_WINDOW_NEW:
- case LFUN_LYX_QUIT:
// these are handled in our dispatch()
break;
default:
+ if (!theApp()) {
+ enable = false;
+ break;
+ }
+ if (theApp()->getStatus(cmd, flag))
+ break;
+
+ // Does the view know something?
+ if (!lyx_view_) {
+ enable = false;
+ break;
+ }
+ if (lyx_view_->getStatus(cmd, flag))
+ break;
+
+ // If we do not have a BufferView, then other functions are disabled
if (!view()) {
enable = false;
break;
}
- if (!getLocalStatus(view()->cursor(), cmd, flag))
- flag = view()->getStatus(cmd);
+
+ // Is this a function that acts on inset at point?
+ Inset * inset = view()->cursor().nextInset();
+ if (lyxaction.funcHasFlag(cmd.action, LyXAction::AtPoint)
+ && inset && inset->getStatus(view()->cursor(), cmd, flag))
+ break;
+
+ bool decided = getLocalStatus(view()->cursor(), cmd, flag);
+ if (!decided)
+ // try the BufferView
+ decided = view()->getStatus(cmd, flag);
+ if (!decided)
+ // try the Buffer
+ view()->buffer().getStatus(cmd, flag);
}
if (!enable)
- flag.enabled(false);
+ flag.setEnabled(false);
// Can we use a readonly buffer?
if (buf && buf->isReadonly()
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
flag.message(from_utf8(N_("Document is read-only")));
- flag.enabled(false);
+ flag.setEnabled(false);
}
// Are we in a DELETED change-tracking region?
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
flag.message(from_utf8(N_("This portion of the document is deleted.")));
- flag.enabled(false);
+ flag.setEnabled(false);
}
// the default error message if we disable the command
bool LyXFunc::ensureBufferClean(BufferView * bv)
{
Buffer & buf = bv->buffer();
- if (buf.isClean())
+ if (buf.isClean() && !buf.isUnnamed())
return true;
docstring const file = buf.fileName().displayName(30);
- docstring text = bformat(_("The document %1$s has unsaved "
+ docstring title;
+ docstring text;
+ if (!buf.isUnnamed()) {
+ text = bformat(_("The document %1$s has unsaved "
"changes.\n\nDo you want to save "
"the document?"), file);
- int const ret = Alert::prompt(_("Save changed document?"),
- text, 0, 1, _("&Save"),
- _("&Cancel"));
+ title = _("Save changed document?");
+
+ } else {
+ text = bformat(_("The document %1$s has not been "
+ "saved yet.\n\nDo you want to save "
+ "the document?"), file);
+ title = _("Save new document?");
+ }
+ int const ret = Alert::prompt(title, text, 0, 1, _("&Save"), _("&Cancel"));
if (ret == 0)
- dispatch(FuncRequest(LFUN_BUFFER_WRITE));
+ lyx_view_->dispatch(FuncRequest(LFUN_BUFFER_WRITE));
- return buf.isClean();
+ return buf.isClean() && !buf.isUnnamed();
}
namespace {
-void showPrintError(string const & name)
-{
- docstring str = bformat(_("Could not print the document %1$s.\n"
- "Check that your printer is set up correctly."),
- makeDisplayPath(name, 50));
- Alert::error(_("Print document failed"), str);
-}
-
-
bool loadLayoutFile(string const & name, string const & buf_path)
{
if (!LayoutFileList::get().haveClass(name)) {
<< lyxaction.getActionName(action)
<< " [" << action << "] is disabled at this location");
setErrorMessage(flag.message());
+ if (lyx_view_)
+ lyx_view_->restartCursor();
} else {
+ Buffer * buffer = lyx_view_ ? lyx_view_->buffer() : 0;
switch (action) {
case LFUN_WORD_FIND_FORWARD:
case LFUN_WORD_FIND_BACKWARD: {
- BOOST_ASSERT(lyx_view_ && lyx_view_->view());
+ LASSERT(lyx_view_ && lyx_view_->view(), /**/);
static docstring last_search;
docstring searched_string;
}
case LFUN_COMMAND_PREFIX:
- BOOST_ASSERT(lyx_view_);
+ LASSERT(lyx_view_, /**/);
lyx_view_->message(keyseq.printOptions(true));
break;
case LFUN_CANCEL:
- BOOST_ASSERT(lyx_view_ && lyx_view_->view());
+ LASSERT(lyx_view_ && lyx_view_->view(), /**/);
keyseq.reset();
meta_fake_bit = NoModifier;
- if (lyx_view_->buffer())
+ if (buffer)
// cancel any selection
dispatch(FuncRequest(LFUN_MARK_OFF));
setMessage(from_ascii(N_("Cancel")));
break;
case LFUN_BUFFER_TOGGLE_READ_ONLY: {
- BOOST_ASSERT(lyx_view_ && lyx_view_->view() && lyx_view_->buffer());
- Buffer * buf = lyx_view_->buffer();
- if (buf->lyxvc().inUse())
- buf->lyxvc().toggleReadOnly();
+ LASSERT(lyx_view_ && lyx_view_->view() && buffer, /**/);
+ if (buffer->lyxvc().inUse())
+ buffer->lyxvc().toggleReadOnly();
else
- buf->setReadonly(!lyx_view_->buffer()->isReadonly());
+ buffer->setReadonly(!buffer->isReadonly());
break;
}
// --- Menus -----------------------------------------------
case LFUN_BUFFER_CLOSE:
lyx_view_->closeBuffer();
+ buffer = 0;
updateFlags = Update::None;
break;
case LFUN_BUFFER_RELOAD: {
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- docstring const file = makeDisplayPath(lyx_view_->buffer()->absFileName(), 20);
+ LASSERT(lyx_view_ && buffer, /**/);
+ docstring const file = makeDisplayPath(buffer->absFileName(), 20);
docstring text = bformat(_("Any changes will be lost. Are you sure "
"you want to revert to the saved version of the document %1$s?"), file);
int const ret = Alert::prompt(_("Revert to saved document?"),
break;
}
- case LFUN_BUFFER_UPDATE:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- lyx_view_->buffer()->doExport(argument, true);
+ case LFUN_BUFFER_UPDATE: {
+ LASSERT(lyx_view_ && buffer, /**/);
+ string format = argument;
+ if (argument.empty())
+ format = buffer->getDefaultOutputFormat();
+ buffer->doExport(format, true);
break;
+ }
- case LFUN_BUFFER_VIEW:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- lyx_view_->buffer()->preview(argument);
+ case LFUN_BUFFER_VIEW: {
+ LASSERT(lyx_view_ && buffer, /**/);
+ string format = argument;
+ if (argument.empty())
+ format = buffer->getDefaultOutputFormat();
+ buffer->preview(format);
break;
+ }
- case LFUN_MASTER_BUFFER_UPDATE:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer() && lyx_view_->buffer()->masterBuffer());
- lyx_view_->buffer()->masterBuffer()->doExport(argument, true);
+ case LFUN_MASTER_BUFFER_UPDATE: {
+ LASSERT(lyx_view_ && buffer && buffer->masterBuffer(), /**/);
+ string format = argument;
+ if (argument.empty())
+ format = buffer->masterBuffer()->getDefaultOutputFormat();
+ buffer->masterBuffer()->doExport(format, true);
break;
+ }
- case LFUN_MASTER_BUFFER_VIEW:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer() && lyx_view_->buffer()->masterBuffer());
- lyx_view_->buffer()->masterBuffer()->preview(argument);
+ case LFUN_MASTER_BUFFER_VIEW: {
+ LASSERT(lyx_view_ && buffer && buffer->masterBuffer(), /**/);
+ string format = argument;
+ if (argument.empty())
+ format = buffer->masterBuffer()->getDefaultOutputFormat();
+ buffer->masterBuffer()->preview(format);
break;
+ }
case LFUN_BUILD_PROGRAM:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- lyx_view_->buffer()->doExport("program", true);
+ LASSERT(lyx_view_ && buffer, /**/);
+ buffer->doExport("program", true);
break;
case LFUN_BUFFER_CHKTEX:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- lyx_view_->buffer()->runChktex();
+ LASSERT(lyx_view_ && buffer, /**/);
+ buffer->runChktex();
break;
case LFUN_BUFFER_EXPORT:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
+ LASSERT(lyx_view_ && buffer, /**/);
if (argument == "custom")
dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"));
else
- lyx_view_->buffer()->doExport(argument, false);
+ buffer->doExport(argument, false);
break;
case LFUN_BUFFER_EXPORT_CUSTOM: {
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
+ LASSERT(lyx_view_ && buffer, /**/);
string format_name;
string command = split(argument, format_name, ' ');
Format const * format = formats.getFormat(format_name);
break;
}
- Buffer * buffer = lyx_view_->buffer();
-
// The name of the file created by the conversion process
string filename;
break;
}
- case LFUN_BUFFER_PRINT: {
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- // FIXME: cmd.getArg() might fail if one of the arguments
- // contains double quotes
- string target = cmd.getArg(0);
- string target_name = cmd.getArg(1);
- string command = cmd.getArg(2);
-
- if (target.empty()
- || target_name.empty()
- || command.empty()) {
- lyxerr << "Unable to parse \""
- << argument << '"' << endl;
- break;
- }
- if (target != "printer" && target != "file") {
- lyxerr << "Unrecognized target \""
- << target << '"' << endl;
- break;
- }
-
- Buffer * buffer = lyx_view_->buffer();
-
- if (!buffer->doExport("dvi", true)) {
- showPrintError(buffer->absFileName());
- break;
- }
-
- // Push directory path.
- string const path = buffer->temppath();
- // Prevent the compiler from optimizing away p
- FileName pp(path);
- PathChanger p(pp);
-
- // there are three cases here:
- // 1. we print to a file
- // 2. we print directly to a printer
- // 3. we print using a spool command (print to file first)
- Systemcall one;
- int res = 0;
- string const dviname =
- changeExtension(buffer->latexName(true), "dvi");
-
- if (target == "printer") {
- if (!lyxrc.print_spool_command.empty()) {
- // case 3: print using a spool
- string const psname =
- changeExtension(dviname,".ps");
- command += ' ' + lyxrc.print_to_file
- + quoteName(psname)
- + ' '
- + quoteName(dviname);
-
- string command2 =
- lyxrc.print_spool_command + ' ';
- if (target_name != "default") {
- command2 += lyxrc.print_spool_printerprefix
- + target_name
- + ' ';
- }
- command2 += quoteName(psname);
- // First run dvips.
- // If successful, then spool command
- res = one.startscript(
- Systemcall::Wait,
- command);
-
- if (res == 0)
- res = one.startscript(
- Systemcall::DontWait,
- command2);
- } else {
- // case 2: print directly to a printer
- if (target_name != "default")
- command += ' ' + lyxrc.print_to_printer + target_name + ' ';
- res = one.startscript(
- Systemcall::DontWait,
- command + quoteName(dviname));
- }
-
- } else {
- // case 1: print to a file
- FileName const filename(makeAbsPath(target_name,
- lyx_view_->buffer()->filePath()));
- FileName const dvifile(makeAbsPath(dviname, path));
- if (filename.exists()) {
- docstring text = bformat(
- _("The file %1$s already exists.\n\n"
- "Do you want to overwrite that file?"),
- makeDisplayPath(filename.absFilename()));
- if (Alert::prompt(_("Overwrite file?"),
- text, 0, 1, _("&Overwrite"), _("&Cancel")) != 0)
- break;
- }
- command += ' ' + lyxrc.print_to_file
- + quoteName(filename.toFilesystemEncoding())
- + ' '
- + quoteName(dvifile.toFilesystemEncoding());
- res = one.startscript(Systemcall::DontWait,
- command);
- }
-
- if (res != 0)
- showPrintError(buffer->absFileName());
- break;
- }
-
// FIXME: There is need for a command-line import.
/*
case LFUN_BUFFER_IMPORT:
*/
case LFUN_BUFFER_AUTO_SAVE:
- lyx_view_->buffer()->autoSave();
+ buffer->autoSave();
break;
case LFUN_RECONFIGURE:
break;
case LFUN_HELP_OPEN: {
- BOOST_ASSERT(lyx_view_);
+ if (lyx_view_ == 0)
+ theApp()->dispatch(FuncRequest(LFUN_WINDOW_NEW));
string const arg = argument;
if (arg.empty()) {
- setErrorMessage(from_ascii(N_("Missing argument")));
+ setErrorMessage(from_utf8(N_("Missing argument")));
break;
}
- FileName const fname = i18nLibFileSearch("doc", arg, "lyx");
+ FileName fname = i18nLibFileSearch("doc", arg, "lyx");
+ if (fname.empty())
+ fname = i18nLibFileSearch("examples", arg, "lyx");
+
if (fname.empty()) {
lyxerr << "LyX: unable to find documentation file `"
<< arg << "'. Bad installation?" << endl;
makeDisplayPath(fname.absFilename())));
Buffer * buf = lyx_view_->loadDocument(fname, false);
if (buf) {
- updateLabels(*buf);
+ buf->updateLabels();
lyx_view_->setBuffer(buf);
buf->errors("Parse");
}
// --- version control -------------------------------
case LFUN_VC_REGISTER:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
+ LASSERT(lyx_view_ && buffer, /**/);
if (!ensureBufferClean(view()))
break;
- if (!lyx_view_->buffer()->lyxvc().inUse()) {
- lyx_view_->buffer()->lyxvc().registrer();
- reloadBuffer();
+ if (!buffer->lyxvc().inUse()) {
+ if (buffer->lyxvc().registrer())
+ reloadBuffer();
}
updateFlags = Update::Force;
break;
case LFUN_VC_CHECK_IN:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
+ LASSERT(lyx_view_ && buffer, /**/);
if (!ensureBufferClean(view()))
break;
- if (lyx_view_->buffer()->lyxvc().inUse()
- && !lyx_view_->buffer()->isReadonly()) {
- lyx_view_->buffer()->lyxvc().checkIn();
+ if (buffer->lyxvc().inUse()
+ && !buffer->isReadonly()) {
+ setMessage(from_utf8(buffer->lyxvc().checkIn()));
reloadBuffer();
}
break;
case LFUN_VC_CHECK_OUT:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
+ LASSERT(lyx_view_ && buffer, /**/);
if (!ensureBufferClean(view()))
break;
- if (lyx_view_->buffer()->lyxvc().inUse()
- && lyx_view_->buffer()->isReadonly()) {
- lyx_view_->buffer()->lyxvc().checkOut();
+ if (buffer->lyxvc().inUse()) {
+ setMessage(from_utf8(buffer->lyxvc().checkOut()));
reloadBuffer();
}
break;
case LFUN_VC_REVERT:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- lyx_view_->buffer()->lyxvc().revert();
+ LASSERT(lyx_view_ && buffer, /**/);
+ buffer->lyxvc().revert();
reloadBuffer();
break;
case LFUN_VC_UNDO_LAST:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- lyx_view_->buffer()->lyxvc().undoLast();
+ LASSERT(lyx_view_ && buffer, /**/);
+ buffer->lyxvc().undoLast();
reloadBuffer();
break;
// --- lyxserver commands ----------------------------
- case LFUN_SERVER_GET_NAME:
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- setMessage(from_utf8(lyx_view_->buffer()->absFileName()));
+ case LFUN_SERVER_GET_FILENAME:
+ LASSERT(lyx_view_ && buffer, /**/);
+ setMessage(from_utf8(buffer->absFileName()));
LYXERR(Debug::INFO, "FNAME["
- << lyx_view_->buffer()->absFileName() << ']');
+ << buffer->absFileName() << ']');
break;
case LFUN_SERVER_NOTIFY:
break;
case LFUN_SERVER_GOTO_FILE_ROW: {
- BOOST_ASSERT(lyx_view_);
+ LASSERT(lyx_view_, /**/);
string file_name;
int row;
istringstream is(argument);
// and get full path
FileName const s = fileSearch(string(), changeExtension(file_name, ".lyx"), "lyx");
// Either change buffer or load the file
- if (theBufferList().exists(s.absFilename()))
- buf = theBufferList().getBuffer(s.absFilename());
+ if (theBufferList().exists(s))
+ buf = theBufferList().getBuffer(s);
else {
buf = lyx_view_->loadDocument(s);
loaded = true;
break;
}
- updateLabels(*buf);
+ buf->updateLabels();
lyx_view_->setBuffer(buf);
view()->setCursorFromRow(row);
if (loaded)
case LFUN_DIALOG_SHOW_NEW_INSET: {
- BOOST_ASSERT(lyx_view_);
+ LASSERT(lyx_view_, /**/);
string const name = cmd.getArg(0);
InsetCode code = insetCode(name);
string data = trim(to_utf8(cmd.argument()).substr(name.size()));
case TOC_CODE:
case HYPERLINK_CODE: {
InsetCommandParams p(code);
- data = InsetCommandMailer::params2string(name, p);
+ data = InsetCommand::params2string(name, p);
break;
- }
+ }
case INCLUDE_CODE: {
// data is the include type: one of "include",
// "input", "verbatiminput" or "verbatiminput*"
// default type is requested
data = "include";
InsetCommandParams p(INCLUDE_CODE, data);
- data = InsetCommandMailer::params2string("include", p);
+ data = InsetCommand::params2string("include", p);
break;
- }
+ }
case BOX_CODE: {
// \c data == "Boxed" || "Frameless" etc
InsetBoxParams p(data);
- data = InsetBoxMailer::params2string(p);
+ data = InsetBox::params2string(p);
break;
- }
+ }
case BRANCH_CODE: {
InsetBranchParams p;
- data = InsetBranchMailer::params2string(p);
+ data = InsetBranch::params2string(p);
break;
- }
+ }
case CITE_CODE: {
InsetCommandParams p(CITE_CODE);
- data = InsetCommandMailer::params2string(name, p);
+ data = InsetCommand::params2string(name, p);
break;
- }
+ }
case ERT_CODE: {
- data = InsetERTMailer::params2string(InsetCollapsable::Open);
+ data = InsetERT::params2string(InsetCollapsable::Open);
break;
- }
+ }
case EXTERNAL_CODE: {
InsetExternalParams p;
- Buffer const & buffer = *lyx_view_->buffer();
- data = InsetExternalMailer::params2string(p, buffer);
+ data = InsetExternal::params2string(p, *buffer);
break;
- }
+ }
case FLOAT_CODE: {
InsetFloatParams p;
- data = InsetFloatMailer::params2string(p);
+ data = InsetFloat::params2string(p);
break;
- }
+ }
case LISTINGS_CODE: {
InsetListingsParams p;
- data = InsetListingsMailer::params2string(p);
+ data = InsetListings::params2string(p);
break;
- }
+ }
case GRAPHICS_CODE: {
InsetGraphicsParams p;
- Buffer const & buffer = *lyx_view_->buffer();
- data = InsetGraphicsMailer::params2string(p, buffer);
+ data = InsetGraphics::params2string(p, *buffer);
break;
- }
+ }
case NOTE_CODE: {
InsetNoteParams p;
- data = InsetNoteMailer::params2string(p);
+ data = InsetNote::params2string(p);
break;
- }
+ }
+ case PHANTOM_CODE: {
+ InsetPhantomParams p;
+ data = InsetPhantom::params2string(p);
+ break;
+ }
case SPACE_CODE: {
InsetSpaceParams p;
- data = InsetSpaceMailer::params2string(p);
+ data = InsetSpace::params2string(p);
break;
- }
+ }
case VSPACE_CODE: {
VSpace space;
- data = InsetVSpaceMailer::params2string(space);
+ data = InsetVSpace::params2string(space);
break;
- }
+ }
case WRAP_CODE: {
InsetWrapParams p;
- data = InsetWrapMailer::params2string(p);
+ data = InsetWrap::params2string(p);
break;
}
default:
}
case LFUN_CITATION_INSERT: {
- BOOST_ASSERT(lyx_view_);
+ LASSERT(lyx_view_, /**/);
if (!argument.empty()) {
// we can have one optional argument, delimited by '|'
// citation-insert <key>|<text_before>
icp["key"] = from_utf8(arg);
if (!opt1.empty())
icp["before"] = from_utf8(opt1);
- string icstr = InsetCommandMailer::params2string("citation", icp);
+ string icstr = InsetCommand::params2string("citation", icp);
FuncRequest fr(LFUN_INSET_INSERT, icstr);
dispatch(fr);
} else
}
case LFUN_BUFFER_CHILD_OPEN: {
- BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
- Buffer * parent = lyx_view_->buffer();
- FileName filename = makeAbsPath(argument, parent->filePath());
+ LASSERT(lyx_view_ && buffer, /**/);
+ FileName filename = makeAbsPath(argument, buffer->filePath());
view()->saveBookmark(false);
Buffer * child = 0;
bool parsed = false;
- if (theBufferList().exists(filename.absFilename())) {
- child = theBufferList().getBuffer(filename.absFilename());
+ if (theBufferList().exists(filename)) {
+ child = theBufferList().getBuffer(filename);
} else {
setMessage(bformat(_("Opening child document %1$s..."),
makeDisplayPath(filename.absFilename())));
// Set the parent name of the child document.
// This makes insertion of citations and references in the child work,
// when the target is in the parent or another child document.
- child->setParent(parent);
- updateLabels(*child->masterBuffer());
+ child->setParent(buffer);
+ child->masterBuffer()->updateLabels();
lyx_view_->setBuffer(child);
if (parsed)
child->errors("Parse");
}
case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
- BOOST_ASSERT(lyx_view_);
+ LASSERT(lyx_view_, /**/);
lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
break;
case LFUN_KEYMAP_OFF:
- BOOST_ASSERT(lyx_view_ && lyx_view_->view());
+ LASSERT(lyx_view_ && lyx_view_->view(), /**/);
lyx_view_->view()->getIntl().keyMapOn(false);
break;
case LFUN_KEYMAP_PRIMARY:
- BOOST_ASSERT(lyx_view_ && lyx_view_->view());
+ LASSERT(lyx_view_ && lyx_view_->view(), /**/);
lyx_view_->view()->getIntl().keyMapPrim();
break;
case LFUN_KEYMAP_SECONDARY:
- BOOST_ASSERT(lyx_view_ && lyx_view_->view());
+ LASSERT(lyx_view_ && lyx_view_->view(), /**/);
lyx_view_->view()->getIntl().keyMapSec();
break;
case LFUN_KEYMAP_TOGGLE:
- BOOST_ASSERT(lyx_view_ && lyx_view_->view());
+ LASSERT(lyx_view_ && lyx_view_->view(), /**/);
lyx_view_->view()->getIntl().toggleKeyMap();
break;
istringstream is(countstr);
int count = 0;
is >> count;
- lyxerr << "repeat: count: " << count << " cmd: " << rest << endl;
+ //lyxerr << "repeat: count: " << count << " cmd: " << rest << endl;
for (int i = 0; i < count; ++i)
dispatch(lyxaction.lookupFunc(rest));
break;
case LFUN_COMMAND_SEQUENCE: {
// argument contains ';'-terminated commands
string arg = argument;
+ if (theBufferList().isLoaded(buffer))
+ buffer->undo().beginUndoGroup();
while (!arg.empty()) {
string first;
arg = split(arg, first, ';');
func.origin = cmd.origin;
dispatch(func);
}
+ if (theBufferList().isLoaded(buffer))
+ buffer->undo().endUndoGroup();
+ break;
+ }
+
+ case LFUN_COMMAND_ALTERNATIVES: {
+ // argument contains ';'-terminated commands
+ string arg = argument;
+ while (!arg.empty()) {
+ string first;
+ arg = split(arg, first, ';');
+ FuncRequest func(lyxaction.lookupFunc(first));
+ func.origin = cmd.origin;
+ FuncStatus stat = getStatus(func);
+ if (stat.enabled()) {
+ dispatch(func);
+ break;
+ }
+ }
break;
}
case LFUN_CALL: {
FuncRequest func;
- if (LyX::ref().topLevelCmdDef().lock(argument, func)) {
+ if (theTopLevelCmdDef().lock(argument, func)) {
func.origin = cmd.origin;
dispatch(func);
- LyX::ref().topLevelCmdDef().release(argument);
+ theTopLevelCmdDef().release(argument);
} else {
if (func.action == LFUN_UNKNOWN_ACTION) {
// unknown command definition
break;
}
- case LFUN_SET_COLOR: {
- string lyx_name;
- string const x11_name = split(argument, lyx_name, ' ');
- if (lyx_name.empty() || x11_name.empty()) {
- setErrorMessage(from_ascii(N_(
- "Syntax: set-color <lyx_name>"
- " <x11_name>")));
- break;
- }
-
- bool const graphicsbg_changed =
- (lyx_name == lcolor.getLyXName(Color_graphicsbg) &&
- x11_name != lcolor.getX11Name(Color_graphicsbg));
-
- if (!lcolor.setColor(lyx_name, x11_name)) {
- setErrorMessage(
- bformat(_("Set-color \"%1$s\" failed "
- "- color is undefined or "
- "may not be redefined"),
- from_utf8(lyx_name)));
- break;
- }
-
- theApp()->updateColor(lcolor.getFromLyXName(lyx_name));
-
- if (graphicsbg_changed) {
- // FIXME: The graphics cache no longer has a changeDisplay method.
-#if 0
- graphics::GCache::get().changeDisplay(true);
-#endif
- }
- break;
- }
-
case LFUN_MESSAGE:
- BOOST_ASSERT(lyx_view_);
+ LASSERT(lyx_view_, /**/);
lyx_view_->message(from_utf8(argument));
break;
- case LFUN_EXTERNAL_EDIT: {
- BOOST_ASSERT(lyx_view_);
- FuncRequest fr(action, argument);
- InsetExternal().dispatch(view()->cursor(), fr);
- break;
- }
-
- case LFUN_GRAPHICS_EDIT: {
- FuncRequest fr(action, argument);
- InsetGraphics().dispatch(view()->cursor(), fr);
- break;
- }
-
- case LFUN_ALL_INSETS_TOGGLE: {
- BOOST_ASSERT(lyx_view_);
- string action;
- string const name = split(argument, action, ' ');
- InsetCode const inset_code = insetCode(name);
-
- Cursor & cur = view()->cursor();
- FuncRequest fr(LFUN_INSET_TOGGLE, action);
-
- Inset & inset = lyx_view_->buffer()->inset();
- InsetIterator it = inset_iterator_begin(inset);
- InsetIterator const end = inset_iterator_end(inset);
- for (; it != end; ++it) {
- if (!it->asInsetMath()
- && (inset_code == NO_CODE
- || inset_code == it->lyxCode())) {
- Cursor tmpcur = cur;
- tmpcur.pushBackward(*it);
- it->dispatch(tmpcur, fr);
- }
- }
- updateFlags = Update::Force | Update::FitCursor;
- break;
- }
-
case LFUN_BUFFER_LANGUAGE: {
- BOOST_ASSERT(lyx_view_);
- Buffer & buffer = *lyx_view_->buffer();
- Language const * oldL = buffer.params().language;
+ LASSERT(lyx_view_, /**/);
+ Language const * oldL = buffer->params().language;
Language const * newL = languages.getLanguage(argument);
if (!newL || oldL == newL)
break;
if (oldL->rightToLeft() == newL->rightToLeft()
- && !buffer.isMultiLingual())
- buffer.changeLanguage(oldL, newL);
+ && !buffer->isMultiLingual())
+ buffer->changeLanguage(oldL, newL);
break;
}
Buffer defaults(fname);
istringstream ss(argument);
- Lexer lex(0,0);
+ Lexer lex;
lex.setStream(ss);
int const unknown_tokens = defaults.readHeader(lex);
}
case LFUN_BUFFER_PARAMS_APPLY: {
- BOOST_ASSERT(lyx_view_);
+ LASSERT(lyx_view_, /**/);
- Buffer * buffer = lyx_view_->buffer();
- DocumentClass * oldClass = buffer->params().documentClassPtr();
+ DocumentClass const * const oldClass = buffer->params().documentClassPtr();
Cursor & cur = view()->cursor();
cur.recordUndoFullDocument();
istringstream ss(argument);
- Lexer lex(0,0);
+ Lexer lex;
lex.setStream(ss);
int const unknown_tokens = buffer->readHeader(lex);
}
case LFUN_LAYOUT_MODULES_CLEAR: {
- BOOST_ASSERT(lyx_view_);
- Buffer * buffer = lyx_view_->buffer();
- DocumentClass * oldClass = buffer->params().documentClassPtr();
+ LASSERT(lyx_view_, /**/);
+ DocumentClass const * const oldClass = buffer->params().documentClassPtr();
view()->cursor().recordUndoFullDocument();
buffer->params().clearLayoutModules();
buffer->params().makeDocumentClass();
}
case LFUN_LAYOUT_MODULE_ADD: {
- BOOST_ASSERT(lyx_view_);
- Buffer * buffer = lyx_view_->buffer();
- DocumentClass * oldClass = buffer->params().documentClassPtr();
+ LASSERT(lyx_view_, /**/);
+ BufferParams const & params = buffer->params();
+ if (!params.moduleCanBeAdded(argument)) {
+ LYXERR0("Module `" << argument <<
+ "' cannot be added due to failed requirements or "
+ "conflicts with installed modules.");
+ break;
+ }
+ DocumentClass const * const oldClass = params.documentClassPtr();
view()->cursor().recordUndoFullDocument();
buffer->params().addLayoutModule(argument);
buffer->params().makeDocumentClass();
}
case LFUN_TEXTCLASS_APPLY: {
- BOOST_ASSERT(lyx_view_);
- Buffer * buffer = lyx_view_->buffer();
+ LASSERT(lyx_view_, /**/);
if (!loadLayoutFile(argument, buffer->temppath()) &&
!loadLayoutFile(argument, buffer->filePath()))
break;
//Save the old, possibly modular, layout for use in conversion.
- DocumentClass * oldDocClass = buffer->params().documentClassPtr();
+ DocumentClass const * const oldDocClass = buffer->params().documentClassPtr();
view()->cursor().recordUndoFullDocument();
buffer->params().setBaseClass(argument);
buffer->params().makeDocumentClass();
}
case LFUN_LAYOUT_RELOAD: {
- BOOST_ASSERT(lyx_view_);
- Buffer * buffer = lyx_view_->buffer();
- DocumentClass * oldClass = buffer->params().documentClassPtr();
+ LASSERT(lyx_view_, /**/);
+ DocumentClass const * const oldClass = buffer->params().documentClassPtr();
LayoutFileIndex bc = buffer->params().baseClassID();
LayoutFileList::get().reset(bc);
+ buffer->params().setBaseClass(bc);
buffer->params().makeDocumentClass();
updateLayout(oldClass, buffer);
updateFlags = Update::Force | Update::FitCursor;
}
case LFUN_TEXTCLASS_LOAD:
- loadLayoutFile(argument, lyx_view_->buffer()->temppath()) ||
- loadLayoutFile(argument, lyx_view_->buffer()->filePath());
+ loadLayoutFile(argument, buffer->temppath()) ||
+ loadLayoutFile(argument, buffer->filePath());
break;
case LFUN_LYXRC_APPLY: {
break;
case LFUN_BOOKMARK_CLEAR:
- LyX::ref().session().bookmarks().clear();
+ theSession().bookmarks().clear();
+ break;
+
+ case LFUN_VC_COMMAND: {
+ string flag = cmd.getArg(0);
+ if (buffer && contains(flag, 'R') && !ensureBufferClean(view()))
+ break;
+ docstring message;
+ if (contains(flag, 'M'))
+ if (!Alert::askForText(message, _("LyX VC: Log Message")))
+ break;
+
+ string path = cmd.getArg(1);
+ if (contains(path, "$$p") && buffer)
+ path = subst(path, "$$p", buffer->filePath());
+ LYXERR(Debug::LYXVC, "Directory: " << path);
+ FileName pp(path);
+ if (!pp.isReadableDirectory()) {
+ lyxerr << _("Directory is not accessible.") << endl;
+ break;
+ }
+ support::PathChanger p(pp);
+
+ string command = cmd.getArg(2);
+ if (command.empty())
+ break;
+ if (buffer) {
+ command = subst(command, "$$i", buffer->absFileName());
+ command = subst(command, "$$p", buffer->filePath());
+ }
+ command = subst(command, "$$m", to_utf8(message));
+ LYXERR(Debug::LYXVC, "Command: " << command);
+ Systemcall one;
+ one.startscript(Systemcall::Wait, command);
+
+ if (!buffer)
+ break;
+ if (contains(flag, 'I'))
+ buffer->markDirty();
+ if (contains(flag, 'R'))
+ reloadBuffer();
+
break;
+ }
default:
- BOOST_ASSERT(theApp());
+ LASSERT(theApp(), /**/);
// Let the frontend dispatch its own actions.
if (theApp()->dispatch(cmd))
// Nothing more to do.
if (lyx_view_ == 0)
break;
+ // Start an undo group. This may be needed for
+ // some stuff like inset-apply on labels.
+ if (theBufferList().isLoaded(buffer))
+ buffer->undo().beginUndoGroup();
+
// Let the current LyXView dispatch its own actions.
if (lyx_view_->dispatch(cmd)) {
- if (lyx_view_->view())
+ if (lyx_view_->view()) {
updateFlags = lyx_view_->view()->cursor().result().update();
+ if (theBufferList().isLoaded(buffer))
+ buffer->undo().endUndoGroup();
+ }
break;
}
- BOOST_ASSERT(lyx_view_->view());
+ LASSERT(lyx_view_->view(), /**/);
+
// Let the current BufferView dispatch its own actions.
if (view()->dispatch(cmd)) {
// The BufferView took care of its own updates if needed.
updateFlags = Update::None;
+ if (theBufferList().isLoaded(buffer))
+ buffer->undo().endUndoGroup();
break;
}
+ // OK, so try the Buffer itself
+ DispatchResult dr;
+ view()->buffer().dispatch(cmd, dr);
+ if (dr.dispatched()) {
+ updateFlags = dr.update();
+ break;
+ }
+
+ // Is this a function that acts on inset at point?
+ Inset * inset = view()->cursor().nextInset();
+ if (lyxaction.funcHasFlag(action, LyXAction::AtPoint)
+ && inset) {
+ view()->cursor().result().dispatched(true);
+ view()->cursor().result().update(Update::FitCursor | Update::Force);
+ FuncRequest tmpcmd = cmd;
+ inset->dispatch(view()->cursor(), tmpcmd);
+ if (view()->cursor().result().dispatched()) {
+ updateFlags = view()->cursor().result().update();
+ break;
+ }
+ }
+
// Let the current Cursor dispatch its own actions.
Cursor old = view()->cursor();
view()->cursor().getPos(cursorPosBeforeDispatchX_,
// notify insets we just left
if (view()->cursor() != old) {
old.fixIfBroken();
- bool badcursor = notifyCursorLeaves(old, view()->cursor());
+ bool badcursor = notifyCursorLeavesOrEnters(old, view()->cursor());
if (badcursor)
view()->cursor().fixIfBroken();
}
+ if (theBufferList().isLoaded(buffer))
+ buffer->undo().endUndoGroup();
+
// update completion. We do it here and not in
// processKeySym to avoid another redraw just for a
// changed inline completion
updateFlags = view()->cursor().result().update();
}
+ // if we executed a mutating lfun, mark the buffer as dirty
+ if (theBufferList().isLoaded(buffer) && flag.enabled()
+ && !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
+ && !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
+ buffer->markDirty();
+
if (lyx_view_ && lyx_view_->buffer()) {
// BufferView::update() updates the ViewMetricsInfo and
// also initializes the position cache for all insets in
// We will redraw the screen only if needed.
view()->processUpdateFlags(updateFlags);
- // if we executed a mutating lfun, mark the buffer as dirty
- if (flag.enabled()
- && !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
- && !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
- lyx_view_->buffer()->markDirty();
-
// Do we have a selection?
theSelection().haveSelection(view()->cursor().selection());
}
}
- docstring const shortcuts = theTopLevelKeymap().printBindings(cmd);
+ docstring const shortcuts = theTopLevelKeymap().printBindings(cmd, KeySequence::ForGui);
if (!shortcuts.empty())
comname += ": " + shortcuts;
// The user has already confirmed that the changes, if any, should
// be discarded. So we just release the Buffer and don't call closeBuffer();
theBufferList().release(lyx_view_->buffer());
+ // if the lyx_view_ has been destroyed, create a new one
+ if (!lyx_view_)
+ theApp()->dispatch(FuncRequest(LFUN_WINDOW_NEW));
Buffer * buf = lyx_view_->loadDocument(filename);
docstring const disp_fn = makeDisplayPath(filename.absFilename());
docstring str;
if (buf) {
- updateLabels(*buf);
+ buf->updateLabels();
lyx_view_->setBuffer(buf);
buf->errors("Parse");
str = bformat(_("Document %1$s reloaded."), disp_fn);
if (keyseq.length() > 0 && !keyseq.deleted())
return keyseq.printOptions(true);
- BOOST_ASSERT(lyx_view_);
+ LASSERT(lyx_view_, /**/);
if (!lyx_view_->buffer())
return _("Welcome to LyX!");
BufferView * LyXFunc::view() const
{
- BOOST_ASSERT(lyx_view_);
+ LASSERT(lyx_view_, /**/);
return lyx_view_->view();
}
}
-void LyXFunc::updateLayout(DocumentClass * oldlayout,Buffer * buffer)
+void LyXFunc::updateLayout(DocumentClass const * const oldlayout, Buffer * buf)
{
lyx_view_->message(_("Converting document to new document class..."));
StableDocIterator backcur(view()->cursor());
- ErrorList & el = buffer->errorList("Class Switch");
+ ErrorList & el = buf->errorList("Class Switch");
cap::switchBetweenClasses(
- oldlayout, buffer->params().documentClassPtr(),
- static_cast<InsetText &>(buffer->inset()), el);
+ oldlayout, buf->params().documentClassPtr(),
+ static_cast<InsetText &>(buf->inset()), el);
- view()->setCursor(backcur.asDocIterator(&(buffer->inset())));
+ view()->setCursor(backcur.asDocIterator(buf));
- buffer->errors("Class Switch");
- updateLabels(*buffer);
+ buf->errors("Class Switch");
+ buf->updateLabels();
}
switch (tag) {
case LyXRC::RC_ACCEPT_COMPOUND:
case LyXRC::RC_ALT_LANG:
- case LyXRC::RC_PLAINTEXT_ROFF_COMMAND:
case LyXRC::RC_PLAINTEXT_LINELEN:
+ case LyXRC::RC_PLAINTEXT_ROFF_COMMAND:
+ case LyXRC::RC_AUTOCORRECTION_MATH:
case LyXRC::RC_AUTOREGIONDELETE:
case LyXRC::RC_AUTORESET_OPTIONS:
case LyXRC::RC_AUTOSAVE:
case LyXRC::RC_CONVERTER_CACHE_MAXAGE:
case LyXRC::RC_COPIER:
case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
- case LyXRC::RC_CUSTOM_EXPORT_COMMAND:
- case LyXRC::RC_CUSTOM_EXPORT_FORMAT:
+ case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
case LyXRC::RC_DATE_INSERT_FORMAT:
case LyXRC::RC_DEFAULT_LANGUAGE:
+ case LyXRC::RC_GUI_LANGUAGE:
case LyXRC::RC_DEFAULT_PAPERSIZE:
+ case LyXRC::RC_DEFAULT_VIEW_FORMAT:
case LyXRC::RC_DEFFILE:
case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:
case LyXRC::RC_DISPLAY_GRAPHICS:
case LyXRC::RC_FORMAT:
case LyXRC::RC_GROUP_LAYOUTS:
case LyXRC::RC_INDEX_COMMAND:
+ case LyXRC::RC_JBIBTEX_COMMAND:
+ case LyXRC::RC_JINDEX_COMMAND:
+ case LyXRC::RC_NOMENCL_COMMAND:
case LyXRC::RC_INPUT:
case LyXRC::RC_KBMAP:
case LyXRC::RC_KBMAP_PRIMARY:
case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS:
case LyXRC::RC_LANGUAGE_PACKAGE:
case LyXRC::RC_LANGUAGE_USE_BABEL:
+ case LyXRC::RC_MAC_LIKE_WORD_MOVEMENT:
case LyXRC::RC_MACRO_EDIT_STYLE:
case LyXRC::RC_MAKE_BACKUP:
case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
case LyXRC::RC_SHOW_BANNER:
case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
case LyXRC::RC_SPELL_COMMAND:
+ case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
case LyXRC::RC_TEMPDIRPATH:
case LyXRC::RC_TEMPLATEPATH:
case LyXRC::RC_TEX_ALLOWS_SPACES:
if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
}
+ case LyXRC::RC_THESAURUSDIRPATH:
case LyXRC::RC_UIFILE:
case LyXRC::RC_USER_EMAIL:
case LyXRC::RC_USER_NAME:
}
} // namespace anon
-
-
} // namespace lyx