edn/sources/appl/Highlight.h

89 lines
2.5 KiB
C
Raw Normal View History

/**
* @author Edouard DUPIN
2012-11-25 11:55:06 +01:00
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __HIGHLIGHT_H__
#define __HIGHLIGHT_H__
2013-10-25 22:12:34 +02:00
namespace appl {
2013-10-23 21:19:30 +02:00
class Highlight;
class HighlightPattern;
2013-10-27 11:34:45 +01:00
class HighlightInfo {
2013-10-23 21:19:30 +02:00
public:
int32_t start;
int32_t stop;
2013-10-23 21:19:30 +02:00
bool notEnded;
2014-10-13 22:39:49 +02:00
appl::HighlightPattern* patern;
2013-10-23 21:19:30 +02:00
};
};
#include <memory>
2012-11-01 10:47:36 +01:00
#include <etk/os/FSNode.h>
#include <appl/HighlightPattern.h>
#include <appl/GlyphPainting.h>
2013-06-24 21:17:45 +02:00
#include <exml/exml.h>
2013-10-25 22:12:34 +02:00
namespace appl {
class Highlight : public gale::Resource {
2013-10-25 22:12:34 +02:00
private:
std::shared_ptr<appl::GlyphPainting> m_paintingProperties;
public:
2013-10-23 21:19:30 +02:00
// Constructeur
Highlight();
void init(const std::string& _xmlFilename, const std::string& _colorFile = "THEME:COLOR:textViewer.json");
public:
DECLARE_RESOURCE_NAMED_FACTORY(Highlight);
virtual ~Highlight();
2013-10-27 11:34:45 +01:00
private:
2013-11-14 21:57:10 +01:00
std::string m_typeName; //!< descriptive string type like "C/C++"
2013-10-27 11:34:45 +01:00
public:
2014-10-13 22:39:49 +02:00
/**
* @brief Get the Type of the Hightlight like c++/Bash/...
* @return descriptive string
*/
const std::string& getTypeName() {
2013-10-27 11:34:45 +01:00
return m_typeName;
}
2013-10-25 22:12:34 +02:00
public:
bool isCompatible(const std::string& _name);
2013-11-14 21:57:10 +01:00
bool fileNameCompatible(const std::string& _fileName);
void display();
2013-11-22 21:48:05 +01:00
void parse(int64_t _start,
int64_t _stop,
2014-10-13 22:39:49 +02:00
std::vector<appl::HighlightInfo>& _metaData,
2013-11-22 21:48:05 +01:00
int64_t _addingPos,
2014-10-13 22:39:49 +02:00
std::string& _buffer);
2013-11-22 21:48:05 +01:00
void parse2(int64_t _start,
int64_t _stop,
2014-10-13 22:39:49 +02:00
std::vector<appl::HighlightInfo>& _metaData,
std::string& _buffer);
void parseSubElement(const appl::HighlightInfo& _upper,
std::vector<appl::HighlightInfo>& _metaData,
std::string &_buffer);
2013-10-23 21:19:30 +02:00
private:
2013-11-14 21:57:10 +01:00
std::string m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
std::vector<std::string> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
2014-10-13 22:39:49 +02:00
std::vector<HighlightPattern> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer)
std::vector<HighlightPattern> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 == > When we display the buffer( only the display area (100 lines)) )
std::map<std::string, std::vector<HighlightPattern>> m_listHighlightNamed; //!< list of all sub partern to parse...
2013-10-25 22:12:34 +02:00
public: // herited function :
virtual void updateContext() {
2013-10-25 22:12:34 +02:00
// no upfate to do ...
};
2013-10-23 21:19:30 +02:00
};
};
#endif