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 :
2014-07-29 15:36:12 +02:00
int32_t start ;
int32_t stop ;
2013-10-23 21:19:30 +02:00
bool notEnded ;
appl : : HighlightPattern * patern ; // pointer on class :
} ;
} ;
2011-07-20 10:33:24 +02:00
2014-05-27 21:43:02 +02:00
# include <memory>
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 :
2014-08-07 23:41:48 +02:00
std : : shared_ptr < appl : : GlyphPainting > m_paintingProperties ;
public :
2013-10-23 21:19:30 +02:00
// Constructeur
2014-08-07 23:41:48 +02:00
Highlight ( ) ;
void init ( const std : : string & _xmlFilename , const std : : string & _colorFile = " THEME:COLOR:textViewer.json " ) ;
2014-05-20 23:25:58 +02:00
public :
2014-08-07 23:41:48 +02:00
DECLARE_RESOURCE_NAMED_FACTORY ( Highlight ) ;
2014-05-27 21:43:02 +02:00
virtual ~ 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 :
2014-10-09 21:23:19 +02:00
bool isCompatible ( const std : : string & _name ) ;
2013-11-14 21:57:10 +01:00
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 ,
2014-10-05 23:46:57 +02:00
std : : string & _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 ,
2014-10-05 23:46:57 +02:00
std : : string & _buffer ) ;
2013-10-23 21:19:30 +02:00
private :
void parseRules ( exml : : Element * _child ,
2014-05-27 21:43:02 +02:00
std : : vector < std : : unique_ptr < HighlightPattern > > & _mListPatern ,
2014-10-02 22:40:40 +02:00
int32_t _level ,
bool forceMaximize = false ) ;
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"
2014-05-27 21:43:02 +02:00
std : : vector < std : : unique_ptr < HighlightPattern > > m_listHighlightPass1 ; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer)
std : : vector < std : : unique_ptr < 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 : // 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