edn/sources/appl/HighlightPattern.h

90 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-11-23 18:30:52 +01:00
#include <appl/Highlight.h>
class HighlightPattern;
#include <appl/GlyphPainting.h>
#include <vector>
#include <regex>
2013-06-24 21:17:45 +02:00
#include <exml/exml.h>
2013-10-23 21:19:30 +02:00
namespace appl {
class HighlightPattern {
2013-10-25 22:12:34 +02:00
private:
2016-07-19 22:03:39 +02:00
ememory::SharedPtr<appl::GlyphPainting> m_glyphPainting;
2013-10-23 21:19:30 +02:00
public:
// Constructeur
2014-10-13 22:39:49 +02:00
HighlightPattern();
2016-07-19 22:03:39 +02:00
HighlightPattern(const ememory::SharedPtr<appl::GlyphPainting>& _glyphPainting, const exml::Element& _child, int32_t _level);
virtual ~HighlightPattern();
2013-10-23 21:19:30 +02:00
private:
2013-11-14 21:57:10 +01:00
std::string m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
2013-10-23 21:19:30 +02:00
public:
2014-10-13 22:39:49 +02:00
void setName(const std::string& _name) {
2013-10-23 21:19:30 +02:00
m_paternName = _name;
};
2014-10-13 22:39:49 +02:00
const std::string& getName() {
2013-10-23 21:19:30 +02:00
return m_paternName;
};
2014-10-13 22:39:49 +02:00
private:
std::string m_paternSubName; //!< Sub patern name if needed
public:
void setSubPatternName(const std::string& _name) {
m_paternSubName = _name;
};
const std::string& getSubPatternName() {
return m_paternSubName;
};
2013-10-23 21:19:30 +02:00
private:
bool m_hasParsingError;
std::string m_regexValue[2];
bool m_hasEndRegEx;
std::regex m_regExp[2]; //!< Start of Regular expression
2013-10-23 21:19:30 +02:00
public:
void setPatern(const std::string& _regExp, const std::string& _regExpStop="", bool _hasEndRegEx=false);
std::pair<std::string,std::string> getPaternString();
2013-10-23 21:19:30 +02:00
private:
2013-11-14 21:57:10 +01:00
std::string m_colorName; //!< Current color name
int32_t m_colorId; //!< Id of the the glyph painting
2013-10-23 21:19:30 +02:00
public:
2014-10-13 22:39:49 +02:00
void setColorGlyph(const std::string& _colorName);
const appl::GlyphDecoration& getColorGlyph() {
2013-10-25 22:12:34 +02:00
return (*m_glyphPainting)[m_colorId];
2013-10-23 21:19:30 +02:00
};
private:
int32_t m_level; //!< Level of the pattern == > this is to overwrite next pattern when we create an higher ....
public:
void setLevel(int32_t _newLevel) {
m_level = _newLevel;
};
int32_t getLevel() {
2013-10-23 21:19:30 +02:00
return m_level;
};
private:
public:
void display();
2013-10-25 22:12:34 +02:00
/**
* @brief find Element only in the specify start characters and find the end with the range done
* @param[in] _start First character to search data (if recognise it start here)
* @param[in] _stop End of the possibility whe search can continue
* @param[out] _resultat Position where find data
* @param[in] _buffer : Where to search data
* @return true We find a compleate pattern
* @return false Not find the pattern
2013-10-25 22:12:34 +02:00
*/
bool find(int32_t _start,
int32_t _stop,
appl::HighlightInfo& _resultat,
const std::string& _buffer);
2013-10-23 21:19:30 +02:00
2016-04-18 21:01:17 +02:00
void parseRules(const exml::Element& _child, int32_t _level);
2013-10-23 21:19:30 +02:00
};
2016-05-02 22:01:55 +02:00
}