edn/sources/appl/HighlightPattern.h

94 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)
*/
2013-11-23 18:30:52 +01:00
#include <appl/Highlight.h>
#ifndef __HIGHLIGHT_PATTERN_H__
#define __HIGHLIGHT_PATTERN_H__
class HighlightPattern;
#include <etk/RegExp.h>
#include <appl/GlyphPainting.h>
#include <vector>
2013-06-24 21:17:45 +02:00
#include <exml/exml.h>
2012-11-19 22:45:55 +01:00
#include <etk/Buffer.h>
2013-11-11 20:20:25 +01:00
enum resultFind {
HLP_FIND_ERROR,
HLP_FIND_OK,
HLP_FIND_OK_NO_END,
2013-11-11 20:20:25 +01:00
};
2013-10-23 21:19:30 +02:00
namespace appl {
class HighlightPattern {
2013-10-25 22:12:34 +02:00
private:
std::shared_ptr<appl::GlyphPainting> m_glyphPainting;
2013-10-23 21:19:30 +02:00
public:
// Constructeur
HighlightPattern(const std::shared_ptr<appl::GlyphPainting>& _glyphPainting);
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:
2013-11-14 21:57:10 +01:00
void setName(std::string& _name) {
2013-10-23 21:19:30 +02:00
m_paternName = _name;
};
std::string getName() {
2013-10-23 21:19:30 +02:00
return m_paternName;
};
private:
std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExp; //!< Start of Regular expression
2013-10-23 21:19:30 +02:00
public:
void setPatern(std::string& _regExp, bool forceMaximize=false);
2014-07-30 23:24:26 +02:00
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:
2013-11-14 21:57:10 +01:00
void setColorGlyph(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 HLP_FIND_OK We find a compleate pattern
* @return HLP_FIND_OK_NO_END Xe find a partial pattern (missing end)
* @return HLP_FIND_ERROR Not find the pattern
*/
2013-11-11 20:20:25 +01:00
enum resultFind find(int32_t _start,
int32_t _stop,
appl::HighlightInfo& _resultat,
etk::Buffer& _buffer);
2013-10-23 21:19:30 +02:00
void parseRules(exml::Element* _child, int32_t _level, bool forceMaximize=false);
2013-10-23 21:19:30 +02:00
};
};
#endif