edn/sources/appl/Highlight.hpp

81 lines
2.6 KiB
C++
Raw Normal View History

2016-05-02 22:01:55 +02:00
/** @file
* @author Edouard DUPIN
2012-11-25 11:55:06 +01:00
* @copyright 2010, Edouard DUPIN, all right reserved
* @license GPL v3 (see license file)
*/
2016-05-02 22:01:55 +02:00
#pragma once
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
};
2016-05-02 22:01:55 +02:00
}
2016-10-03 22:01:55 +02:00
#include <ememory/memory.hpp>
#include <appl/HighlightPattern.hpp>
#include <appl/GlyphPainting.hpp>
#include <etk/Buffer.hpp>
2016-10-03 22:01:55 +02:00
#include <exml/exml.hpp>
2013-10-25 22:12:34 +02:00
namespace appl {
class Highlight : public gale::Resource {
2013-10-25 22:12:34 +02:00
private:
2016-07-19 22:03:39 +02:00
ememory::SharedPtr<appl::GlyphPainting> m_paintingProperties;
public:
2013-10-23 21:19:30 +02:00
// Constructeur
Highlight();
2018-09-29 21:59:06 +02:00
void init(const etk::Uri& _uriXML, const etk::Uri& _uriColorFile = "THEME_COLOR://textViewer.json");
public:
2018-09-29 21:59:06 +02:00
DECLARE_RESOURCE_URI_FACTORY(Highlight);
virtual ~Highlight();
2013-10-27 11:34:45 +01:00
private:
2017-08-28 00:09:10 +02:00
etk::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
*/
2017-08-28 00:09:10 +02:00
const etk::String& getTypeName() {
2013-10-27 11:34:45 +01:00
return m_typeName;
}
2013-10-25 22:12:34 +02:00
public:
2018-09-29 21:59:06 +02:00
bool isCompatible(const etk::Path& _name);
bool fileNameCompatible(const etk::Path& _fileName);
void display();
2013-11-22 21:48:05 +01:00
void parse(int64_t _start,
int64_t _stop,
2017-08-28 00:09:10 +02:00
etk::Vector<appl::HighlightInfo>& _metaData,
2013-11-22 21:48:05 +01:00
int64_t _addingPos,
etk::Buffer& _buffer);
2013-11-22 21:48:05 +01:00
void parse2(int64_t _start,
int64_t _stop,
2017-08-28 00:09:10 +02:00
etk::Vector<appl::HighlightInfo>& _metaData,
etk::Buffer& _buffer);
2014-10-13 22:39:49 +02:00
void parseSubElement(const appl::HighlightInfo& _upper,
2017-08-28 00:09:10 +02:00
etk::Vector<appl::HighlightInfo>& _metaData,
etk::Buffer& _buffer);
2013-10-23 21:19:30 +02:00
private:
2017-08-28 00:09:10 +02:00
etk::String m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
etk::Vector<etk::String> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
2017-11-06 14:07:04 +01:00
etk::Vector<etk::String> m_listFiles; //!< List of possible filename
2017-08-28 00:09:10 +02:00
etk::Vector<HighlightPattern> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer)
etk::Vector<HighlightPattern> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 == > When we display the buffer( only the display area (100 lines)) )
// TODO : This is bad ==> the patern ar unordered ...
2017-08-28 00:09:10 +02:00
etk::Map<etk::String, etk::Vector<HighlightPattern>> m_listHighlightNamed; //!< list of all sub partern to parse...
2013-10-25 22:12:34 +02:00
public: // herited function :
virtual bool updateContext() {
2013-10-25 22:12:34 +02:00
// no upfate to do ...
return true;
2013-10-25 22:12:34 +02:00
};
2013-10-23 21:19:30 +02:00
};
2016-05-02 22:01:55 +02:00
}