2016-05-02 22:01:55 +02:00
|
|
|
/** @file
|
2011-07-20 10:33:24 +02:00
|
|
|
* @author Edouard DUPIN
|
2012-11-25 11:55:06 +01:00
|
|
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
|
|
|
* @license GPL v3 (see license file)
|
2011-07-20 10:33:24 +02:00
|
|
|
*/
|
2016-05-02 22:01:55 +02:00
|
|
|
#pragma once
|
2013-11-23 18:30:52 +01:00
|
|
|
#include <appl/Highlight.h>
|
2011-07-29 10:44:12 +02:00
|
|
|
|
2011-07-20 10:33:24 +02:00
|
|
|
class HighlightPattern;
|
|
|
|
|
2013-10-28 21:47:51 +01:00
|
|
|
#include <appl/GlyphPainting.h>
|
2013-11-19 21:43:43 +01:00
|
|
|
#include <vector>
|
2014-10-03 21:44:13 +02:00
|
|
|
#include <regex>
|
2013-06-24 21:17:45 +02:00
|
|
|
#include <exml/exml.h>
|
2011-07-20 10:33:24 +02:00
|
|
|
|
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);
|
2014-05-27 21:43:02 +02:00
|
|
|
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:
|
2014-10-05 23:46:57 +02:00
|
|
|
bool m_hasParsingError;
|
2016-07-21 15:29:56 +02:00
|
|
|
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:
|
2016-07-21 15:29:56 +02:00
|
|
|
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
|
2013-11-27 21:33:34 +01:00
|
|
|
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);
|
2014-05-15 21:37:39 +02:00
|
|
|
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;
|
|
|
|
};
|
2014-05-15 21:37:39 +02:00
|
|
|
int32_t getLevel() {
|
2013-10-23 21:19:30 +02:00
|
|
|
return m_level;
|
|
|
|
};
|
|
|
|
private:
|
|
|
|
|
|
|
|
public:
|
2014-05-15 21:37:39 +02:00
|
|
|
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
|
2016-01-15 00:01:58 +01:00
|
|
|
* @return true We find a compleate pattern
|
|
|
|
* @return false Not find the pattern
|
2013-10-25 22:12:34 +02:00
|
|
|
*/
|
2016-01-15 00:01:58 +01: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
|
|
|
}
|
2011-07-20 10:33:24 +02:00
|
|
|
|