*/
#include <config.h>
+#include <vector>
#include "LyXFunc.h"
enable = LyX::ref().session().bookmarks().size() > 0;
break;
- case LFUN_TOOLBAR_TOGGLE_STATE: {
- ToolbarInfo::Flags flags = lyx_view_->getToolbarState(to_utf8(cmd.argument()));
- if (!(flags & ToolbarInfo::AUTO))
- flag.setOnOff(flags & ToolbarInfo::ON);
- break;
- }
-
case LFUN_TOOLBAR_TOGGLE: {
bool const current = lyx_view_->getToolbars().visible(cmd.getArg(0));
flag.setOnOff(current);
break;
}
+ case LFUN_WINDOW_CLOSE: {
+ enable = (theApp()->gui().viewIds().size() > 1);
+ break;
+ }
+
// this one is difficult to get right. As a half-baked
// solution, we consider only the first action of the sequence
case LFUN_COMMAND_SEQUENCE: {
case LFUN_BUFFER_NEXT:
case LFUN_BUFFER_PREVIOUS:
case LFUN_WINDOW_NEW:
- case LFUN_WINDOW_CLOSE:
case LFUN_LYX_QUIT:
// these are handled in our dispatch()
break;
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));
if (fs::exists(filename.toFilesystemEncoding())) {
docstring text = bformat(
_("The file %1$s already exists.\n\n"
- "Do you want to over-write that file?"),
+ "Do you want to overwrite that file?"),
makeDisplayPath(filename.absFilename()));
- if (Alert::prompt(_("Over-write file?"),
- text, 0, 1, _("&Over-write"), _("&Cancel")) != 0)
+ if (Alert::prompt(_("Overwrite file?"),
+ text, 0, 1, _("&Overwrite"), _("&Cancel")) != 0)
break;
}
command += lyxrc.print_to_file
}
case LFUN_BUFFER_CHILD_OPEN: {
+ // takes an optional argument, "|bool", at the end
+ // indicating whether this file is being opened automatically
+ // by LyX itself, in which case we will not want to switch
+ // buffers after opening. The default is false, so in practice
+ // it is used only when true.
BOOST_ASSERT(lyx_view_);
- FileName const filename =
+ int const arglength = argument.length();
+ FileName filename;
+ bool autoOpen = false;
+ if (argument.substr(arglength - 5, 5) == "|true") {
+ autoOpen = true;
+ filename = makeAbsPath(argument.substr(0, arglength - 5),
+ lyx_view_->buffer()->filePath());
+ } else if (argument.substr(arglength - 6, 6) == "|false") {
+ filename = makeAbsPath(argument.substr(0, arglength - 6),
+ lyx_view_->buffer()->filePath());
+ } else filename =
makeAbsPath(argument, lyx_view_->buffer()->filePath());
view()->saveBookmark(false);
- string const parentfilename = lyx_view_->buffer()->fileName();
- if (theBufferList().exists(filename.absFilename()))
- lyx_view_->setBuffer(theBufferList().getBuffer(filename.absFilename()));
- else
- if (lyx_view_->loadLyXFile(filename)) {
- // 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.
- lyx_view_->buffer()->setParentName(parentfilename);
- setMessage(bformat(_("Opening child document %1$s..."),
- makeDisplayPath(filename.absFilename())));
- } else
- setMessage(_("Document not loaded."));
+ if (theBufferList().exists(filename.absFilename())) {
+ Buffer * buf = theBufferList().getBuffer(filename.absFilename());
+ if (!autoOpen)
+ lyx_view_->setBuffer(buf, true);
+ else
+ buf->setParentName(lyx_view_->buffer()->fileName());
+ } else
+ lyx_view_->loadLyXFile(filename, true, true, autoOpen);
+
break;
}
LyX::ref().session().bookmarks().clear();
break;
- case LFUN_TOOLBAR_TOGGLE_STATE:
- lyx_view_->toggleToolbarState(argument);
- break;
-
case LFUN_TOOLBAR_TOGGLE: {
BOOST_ASSERT(lyx_view_);
- string const name = to_utf8(cmd.argument());
- bool const current = lyx_view_->getToolbars().visible(name);
- lyx_view_->getToolbars().display(name, !current);
+ string const name = cmd.getArg(0);
+ bool const allowauto = cmd.getArg(1) == "allowauto";
+ lyx_view_->toggleToolbarState(name, allowauto);
+ ToolbarInfo::Flags const flags =
+ lyx_view_->getToolbarState(name);
+ docstring state;
+ if (flags & ToolbarInfo::ON)
+ state = _("on");
+ else if (flags & ToolbarInfo::OFF)
+ state = _("off");
+ else if (flags & ToolbarInfo::AUTO)
+ state = _("auto");
+
+ setMessage(bformat(_("Toolbar \"%1$s\" state set to %2$s"),
+ from_ascii(name), state));
break;
}
docstring const file = makeDisplayPath(lyxfile.absFilename(), 30);
docstring text = bformat(_("The document %1$s already exists.\n\n"
- "Do you want to over-write that document?"), file);
- int const ret = Alert::prompt(_("Over-write document?"),
- text, 0, 1, _("&Over-write"), _("&Cancel"));
+ "Do you want to overwrite that document?"), file);
+ int const ret = Alert::prompt(_("Overwrite document?"),
+ text, 0, 1, _("&Overwrite"), _("&Cancel"));
if (ret == 1) {
lyx_view_->message(_("Canceled."));