#include "support/os.h"
#include "support/Systemcall.h"
+#include <algorithm>
+
// FIXME: Q_WS_MACX is not available, it's in Qt
#ifdef USE_MACOSX_PACKAGING
#include "support/linkback/LinkBackProxy.h"
return format;
// try to find a format from the file extension.
- string const ext = getExtension(filename.absFilename());
+ string const ext = getExtension(filename.absFileName());
if (!ext.empty()) {
// this is ambigous if two formats have the same extension,
// but better than nothing
it->setEditor(command);
}
+bool Formats::viewURL(string const &url){
+ Format const * format = getFormat("html");
+ string command = libScriptSearch(format->viewer());
+
+ if (!contains(command, token_from_format))
+ command += ' ' + token_from_format;
+ command = subst(command, token_from_format, quoteName(url));
+
+ LYXERR(Debug::FILES, "Executing command: " << command);
+ //buffer.message(_("Executing command: ") + from_utf8(command));
+
+ Systemcall one;
+ int const res = one.startscript(Systemcall::DontWait, command);
+
+ if (res) {
+ Alert::error(_("Cannot view URL"),
+ bformat(_("An error occurred whilst running %1$s"),
+ makeDisplayPath(command, 50)));
+ return false;
+ }
+ return true;
+}
bool Formats::view(Buffer const & buffer, FileName const & filename,
string const & format_name) const
if (filename.empty() || !filename.exists()) {
Alert::error(_("Cannot view file"),
bformat(_("File does not exist: %1$s"),
- from_utf8(filename.absFilename())));
+ from_utf8(filename.absFileName())));
return false;
}
}
// viewer is 'auto'
if (format->viewer() == "auto") {
- if (os::autoOpenFile(filename.absFilename(), os::VIEW))
+ if (os::autoOpenFile(filename.absFileName(), os::VIEW))
return true;
else {
Alert::error(_("Cannot view file"),
bformat(_("Auto-view file %1$s failed"),
- from_utf8(filename.absFilename())));
+ from_utf8(filename.absFileName())));
return false;
}
}
if (filename.empty() || !filename.exists()) {
Alert::error(_("Cannot edit file"),
bformat(_("File does not exist: %1$s"),
- from_utf8(filename.absFilename())));
+ from_utf8(filename.absFileName())));
return false;
}
// LinkBack files look like PDF, but have the .linkback extension
- string const ext = getExtension(filename.absFilename());
+ string const ext = getExtension(filename.absFileName());
if (format_name == "pdf" && ext == "linkback") {
#ifdef USE_MACOSX_PACKAGING
- return editLinkBackFile(filename.absFilename().c_str());
+ return editLinkBackFile(filename.absFileName().c_str());
#else
Alert::error(_("Cannot edit file"),
_("LinkBack files can only be edited on Apple Mac OSX."));
// editor is 'auto'
if (format->editor() == "auto") {
- if (os::autoOpenFile(filename.absFilename(), os::EDIT))
+ if (os::autoOpenFile(filename.absFileName(), os::EDIT))
return true;
else {
Alert::error(_("Cannot edit file"),
bformat(_("Auto-edit file %1$s failed"),
- from_utf8(filename.absFilename())));
+ from_utf8(filename.absFileName())));
return false;
}
}