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
*/
# 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 beginStart ;
int32_t beginStop ;
int32_t endStart ;
int32_t endStop ;
bool notEnded ;
appl : : HighlightPattern * patern ; // pointer on class :
} ;
} ;
2011-07-20 10:33:24 +02:00
2012-11-01 10:47:36 +01:00
# include <etk/os/FSNode.h>
2013-10-28 21:47:51 +01:00
# include <appl/HighlightPattern.h>
# include <appl/GlyphPainting.h>
2012-11-19 22:45:55 +01:00
# include <etk/Buffer.h>
2013-06-24 21:17:45 +02:00
# include <exml/exml.h>
2011-07-20 10:33:24 +02:00
2013-10-25 22:12:34 +02:00
namespace appl {
class Highlight : public ewol : : Resource {
private :
appl : : GlyphPainting * m_paintingProperties ;
protected :
2013-10-23 21:19:30 +02:00
// Constructeur
2013-11-14 21:57:10 +01:00
Highlight ( const std : : string & _xmlFilename , const std : : string & _colorFile ) ;
2014-05-15 21:37:39 +02:00
~ 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-05-15 21:37:39 +02:00
const std : : string & getTypeName ( ) {
2013-10-27 11:34:45 +01:00
return m_typeName ;
}
2013-10-25 22:12:34 +02:00
public :
2013-11-14 21:57:10 +01:00
bool hasExtention ( const std : : string & _ext ) ;
bool fileNameCompatible ( const std : : string & _fileName ) ;
2014-05-15 21:37:39 +02:00
void display ( ) ;
2013-11-22 21:48:05 +01:00
void parse ( int64_t _start ,
int64_t _stop ,
2013-11-14 21:57:10 +01:00
std : : vector < appl : : HighlightInfo > & _metaData ,
2013-11-22 21:48:05 +01:00
int64_t _addingPos ,
2013-10-23 21:19:30 +02:00
etk : : Buffer & _buffer ) ;
2013-11-22 21:48:05 +01:00
void parse2 ( int64_t _start ,
int64_t _stop ,
2013-11-14 21:57:10 +01:00
std : : vector < appl : : HighlightInfo > & _metaData ,
2013-10-23 21:19:30 +02:00
etk : : Buffer & _buffer ) ;
private :
void parseRules ( exml : : Element * _child ,
2013-11-14 21:57:10 +01:00
std : : vector < HighlightPattern * > & _mListPatern ,
2013-10-23 21:19:30 +02:00
int32_t _level ) ;
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"
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)) )
2013-10-25 22:12:34 +02:00
public :
/**
* @ brief keep the resource pointer .
* @ note Never free this pointer by your own . . .
* @ param [ in ] _filename Name of the configuration file .
* @ return pointer on the resource or NULL if an error occured .
*/
2013-11-14 21:57:10 +01:00
static appl : : Highlight * keep ( const std : : string & _filename ) ;
2013-10-25 22:12:34 +02:00
/**
* @ brief release the keeped resources
* @ param [ in , out ] reference on the object pointer
*/
static void release ( appl : : Highlight * & _object ) ;
public : // herited function :
2014-05-15 21:37:39 +02:00
virtual void updateContext ( ) {
2013-10-25 22:12:34 +02:00
// no upfate to do ...
} ;
2013-10-23 21:19:30 +02:00
} ;
2011-07-20 10:33:24 +02:00
} ;
# endif