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
2011-07-20 10:33:24 +02:00
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 ;
2014-10-13 22:39:49 +02:00
appl : : HighlightPattern * patern ;
2013-10-23 21:19:30 +02:00
} ;
2016-05-02 22:01:55 +02:00
}
2011-07-20 10:33:24 +02:00
2016-10-03 22:01:55 +02:00
# include <ememory/memory.hpp>
# include <appl/HighlightPattern.hpp>
# include <appl/GlyphPainting.hpp>
2017-03-14 21:56:56 +01:00
# include <etk/Buffer.hpp>
2016-10-03 22:01:55 +02:00
# include <exml/exml.hpp>
2011-07-20 10:33:24 +02:00
2013-10-25 22:12:34 +02:00
namespace appl {
2015-08-11 23:21:41 +02:00
class Highlight : public gale : : Resource {
2013-10-25 22:12:34 +02:00
private :
2016-07-19 22:03:39 +02:00
ememory : : SharedPtr < appl : : GlyphPainting > m_paintingProperties ;
2014-08-07 23:41:48 +02:00
public :
2013-10-23 21:19:30 +02:00
// Constructeur
2014-08-07 23:41:48 +02:00
Highlight ( ) ;
2018-10-09 21:31:47 +02:00
void init ( const etk : : Uri & _uriXML , const etk : : Uri & _uriColorFile = " THEME_COLOR:///textViewer.json " ) ;
2014-05-20 23:25:58 +02:00
public :
2018-09-29 21:59:06 +02:00
DECLARE_RESOURCE_URI_FACTORY ( Highlight ) ;
2014-05-27 21:43:02 +02:00
virtual ~ Highlight ( ) ;
2013-10-27 11:34:45 +01:00
private :
2017-08-28 00:09:10 +02:00
etk : : String m_typeName ; //!< descriptive string type like "C/C++"
2013-10-27 11:34:45 +01:00
public :
2014-10-13 22:39:49 +02:00
/**
* @ brief Get the Type of the Hightlight like c + + / Bash / . . .
* @ return descriptive string
*/
2017-08-28 00:09:10 +02:00
const etk : : String & getTypeName ( ) {
2013-10-27 11:34:45 +01:00
return m_typeName ;
}
2013-10-25 22:12:34 +02:00
public :
2018-09-29 21:59:06 +02:00
bool isCompatible ( const etk : : Path & _name ) ;
bool fileNameCompatible ( const etk : : Path & _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 ,
2017-08-28 00:09:10 +02:00
etk : : Vector < appl : : HighlightInfo > & _metaData ,
2013-11-22 21:48:05 +01:00
int64_t _addingPos ,
2017-03-14 21:56:56 +01:00
etk : : Buffer & _buffer ) ;
2013-11-22 21:48:05 +01:00
void parse2 ( int64_t _start ,
int64_t _stop ,
2017-08-28 00:09:10 +02:00
etk : : Vector < appl : : HighlightInfo > & _metaData ,
2017-03-14 21:56:56 +01:00
etk : : Buffer & _buffer ) ;
2014-10-13 22:39:49 +02:00
void parseSubElement ( const appl : : HighlightInfo & _upper ,
2017-08-28 00:09:10 +02:00
etk : : Vector < appl : : HighlightInfo > & _metaData ,
2017-03-14 21:56:56 +01:00
etk : : Buffer & _buffer ) ;
2013-10-23 21:19:30 +02:00
private :
2017-08-28 00:09:10 +02:00
etk : : String m_styleName ; //!< curent style name (like "c++" or "c" or "script Bash")
etk : : Vector < etk : : String > m_listExtentions ; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
2017-11-06 14:07:04 +01:00
etk : : Vector < etk : : String > m_listFiles ; //!< List of possible filename
2017-08-28 00:09:10 +02:00
etk : : Vector < HighlightPattern > m_listHighlightPass1 ; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer)
etk : : Vector < HighlightPattern > m_listHighlightPass2 ; //!< List of ALL hightlight modules (pass 2 == > When we display the buffer( only the display area (100 lines)) )
2017-03-14 21:56:56 +01:00
// TODO : This is bad ==> the patern ar unordered ...
2017-08-28 00:09:10 +02:00
etk : : Map < etk : : String , etk : : Vector < HighlightPattern > > m_listHighlightNamed ; //!< list of all sub partern to parse...
2013-10-25 22:12:34 +02:00
public : // herited function :
2015-09-07 22:15:33 +02:00
virtual bool updateContext ( ) {
2013-10-25 22:12:34 +02:00
// no upfate to do ...
2015-09-07 22:15:33 +02:00
return true ;
2013-10-25 22:12:34 +02:00
} ;
2013-10-23 21:19:30 +02:00
} ;
2016-05-02 22:01:55 +02:00
}
2011-07-20 10:33:24 +02:00