X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FFormat.cpp;h=ec61b84387ea2a5c620f8d2e1ddf380ed13a0fd2;hb=dc7c7ca03eca25cf7a6395c155b70dac1594e481;hp=7e82f9a3b073756f4eadaed6ebc4bc702f9ed9d7;hpb=c68d754a749f2b5d162868544c07c21d6168b84b;p=lyx.git diff --git a/src/Format.cpp b/src/Format.cpp index 7e82f9a3b0..ec61b84387 100644 --- a/src/Format.cpp +++ b/src/Format.cpp @@ -24,6 +24,8 @@ #include "support/lstrings.h" #include "support/os.h" #include "support/Systemcall.h" +#include "support/textutils.h" +#include "support/Translator.h" #include @@ -102,7 +104,7 @@ bool Format::isChildFormat() const { if (name_.empty()) return false; - return isdigit(name_[name_.length() - 1]); + return isDigitASCII(name_[name_.length() - 1]); } @@ -259,27 +261,6 @@ void Formats::setEditor(string const & name, string const & command) } -bool Formats::viewURL(docstring const & url) { - Format const * format = getFormat("html"); - if (!format) - return false; - - string command = libScriptSearch(format->viewer()); - - if (!contains(command, token_from_format)) - command += ' ' + token_from_format; - command = subst(command, token_from_format, quoteName(to_utf8(url))); - - LYXERR(Debug::FILES, "Executing command: " << command); - - Systemcall one; - one.startscript(Systemcall::DontWait, command); - - // we can't report any sort of error, since we aren't waiting - return true; -} - - bool Formats::view(Buffer const & buffer, FileName const & filename, string const & format_name) const { @@ -380,7 +361,7 @@ bool Formats::edit(Buffer const & buffer, FileName const & filename, prettyName(format_name))); return false; } - + // editor is 'auto' if (format->editor() == "auto") { if (os::autoOpenFile(filename.absFileName(), os::EDIT)) @@ -433,8 +414,42 @@ string const Formats::extension(string const & name) const } +namespace { +typedef Translator FlavorTranslator; + +FlavorTranslator initFlavorTranslator() +{ + FlavorTranslator f(OutputParams::LATEX, "latex"); + f.addPair(OutputParams::LUATEX, "luatex"); + f.addPair(OutputParams::PDFLATEX, "pdflatex"); + f.addPair(OutputParams::XETEX, "xetex"); + f.addPair(OutputParams::XML, "docbook-xml"); + f.addPair(OutputParams::HTML, "xhtml"); + f.addPair(OutputParams::TEXT, "text"); + return f; +} + + +FlavorTranslator const & flavorTranslator() +{ + static FlavorTranslator translator = initFlavorTranslator(); + return translator; +} +} + + +std::string flavor2format(OutputParams::FLAVOR flavor) +{ + return flavorTranslator().find(flavor); +} +/* Not currently needed, but I'll leave the code in case it is. +OutputParams::FLAVOR format2flavor(std::string fmt) +{ + return flavorTranslator().find(fmt); +} */ + Formats formats; Formats system_formats;