#include <sstream>
#include <srchilite/sourcehighlight.h>
#include <srchilite/langmap.h>
+#include <srchilite/settings.h>
#endif
/* The number of source files we'll cache. */
return false;
const char *lang_name = get_language_name (lang);
- if (lang_name == nullptr)
- return false;
/* The global source highlight object, or null if one was
never constructed. This is stored here rather than in
conditional compilation in source-cache.h. */
static srchilite::SourceHighlight *highlighter;
+ /* The global source highlight language map object. */
+ static srchilite::LangMap *langmap;
+
bool styled = false;
try
{
{
highlighter = new srchilite::SourceHighlight ("esc.outlang");
highlighter->setStyleFile ("esc.style");
+
+ const std::string &datadir = srchilite::Settings::retrieveDataDir ();
+ langmap = new srchilite::LangMap (datadir, "lang.map");
+ }
+
+ std::string detected_lang;
+ if (lang_name == nullptr)
+ {
+ detected_lang = langmap->getMappedFileNameFromFileName (fullname);
+ if (detected_lang.empty ())
+ return false;
+ lang_name = detected_lang.c_str ();
}
std::istringstream input (contents);