[DEV] start rework color and highlight
This commit is contained in:
parent
c8fd4183cd
commit
8c57b28d73
@ -1,40 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EdnColor version="0.1">
|
||||
<gui> <!-- Doivent tous y ètre de prférence ... global system acces -->
|
||||
<color name="CODE_basicBackgroung" val="#151515"/>
|
||||
<color name="CODE_space" val="#333333"/>
|
||||
<color name="CODE_tabulation" val="#444444"/>
|
||||
<color name="CODE_cursor" val="#eadd05"/>
|
||||
<color name="CODE_lineNumber" val="#fff725"/>
|
||||
<!-- Buffer list property -->
|
||||
<color name="LIST_backgroung1" val="#202020"/>
|
||||
<color name="LIST_backgroung2" val="#000000"/>
|
||||
<color name="LIST_backgroungSelected" val="#2f0ba4"/>
|
||||
<color name="LIST_textNormal" val="#EEEEEE"/>
|
||||
<color name="LIST_textModify" val="#FF0000"/>
|
||||
</gui>
|
||||
<syntax>
|
||||
<color name="normal" FG="#EEEEEE"/>
|
||||
<color name="SelectedText" FG="#AAAAAA" BG="#225a09"/>
|
||||
<color name="error" FG="#FF0000"/>
|
||||
<color name="doubleQuoteText" FG="#00fF00"/>
|
||||
|
||||
<!-- hightline description : -->
|
||||
<color name="type" FG="#56bf10" bold="yes"/>
|
||||
<color name="storageKeyword" FG="#5c8fed"/>
|
||||
<color name="number" FG="#00ff00"/>
|
||||
<color name="systemFunction" FG="#ffff00"/>
|
||||
<color name="commonDefine" FG="#56bf10"/>
|
||||
<color name="boolean" FG="#214cf1"/>
|
||||
<color name="preprocesseur" FG="#FF0000"/>
|
||||
<color name="comment" FG="#ef4def" italic="yes"/>
|
||||
<color name="commentDoxygen" FG="#ef4d00" bold="yes" italic="yes"/>
|
||||
<color name="keyword" FG="#5c8fed" bold="yes"/>
|
||||
<color name="macro" FG="#6c09c8" bold="yes"/>
|
||||
<color name="SYNTAX_ERROR" FG="#000000" BG="#FF0000" bold="yes"/>
|
||||
<color name="functionName" FG="#24d1e0" bold="yes"/>
|
||||
<color name="TestResultOK" FG="#000000" BG="#00FF00" bold="yes"/>
|
||||
<color name="TestResultERROR" FG="#000000" BG="#FF0000" bold="yes"/>
|
||||
</syntax>
|
||||
</EdnColor>
|
||||
|
||||
{
|
||||
"ednColor": [
|
||||
{ name="CODE_basicBackgroung", foreground="#151515" },
|
||||
{ name="CODE_space", foreground="#333333" },
|
||||
{ name="CODE_tabulation", foreground="#444444" },
|
||||
{ name="CODE_cursor", foreground="#eadd05" },
|
||||
{ name="CODE_lineNumber", foreground="#fff725" },
|
||||
{ name="LIST_backgroung1", foreground="#202020" },
|
||||
{ name="LIST_backgroung2", foreground="#000000" },
|
||||
{ name="LIST_backgroungSelected", foreground="#2f0ba4" },
|
||||
{ name="LIST_textNormal", foreground="#EEEEEE" },
|
||||
{ name="LIST_textModify", foreground="#FF0000" },
|
||||
|
||||
{ name="normal", foreground="#EEEEEE"},
|
||||
{ name="SelectedText", foreground="#AAAAAA", background="#225a09"},
|
||||
{ name="error", foreground="#FF0000"},
|
||||
{ name="doubleQuoteText", foreground="#00fF00"},
|
||||
|
||||
{ name="type", foreground="#56bf10", bold="yes"},
|
||||
{ name="storageKeyword", foreground="#5c8fed"},
|
||||
{ name="number", foreground="#00ff00"},
|
||||
{ name="systemFunction", foreground="#ffff00"},
|
||||
{ name="commonDefine", foreground="#56bf10"},
|
||||
{ name="boolean", foreground="#214cf1"},
|
||||
{ name="preprocesseur", foreground="#FF0000"},
|
||||
{ name="comment", foreground="#ef4def", italic="yes"},
|
||||
{ name="commentDoxygen", foreground="#ef4d00", bold="yes", italic="yes"},
|
||||
{ name="keyword", foreground="#5c8fed", bold="yes"},
|
||||
{ name="macro", foreground="#6c09c8", bold="yes"},
|
||||
{ name="SYNTAX_ERROR", foreground="#000000", background="#FF0000", bold="yes"},
|
||||
{ name="functionName", foreground="#24d1e0", bold="yes"},
|
||||
{ name="TestResultOK", foreground="#000000", background="#00FF00", bold="yes"},
|
||||
{ name="TestResultERROR", FG="#000000", background="#FF0000", bold="yes"}
|
||||
]
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ void EdnBuf::CleanHighLight(void)
|
||||
}
|
||||
|
||||
|
||||
colorInformation_ts *EdnBuf::getElementColorAtPosition(int32_t pos, int32_t &starPos)
|
||||
appl::ColorInfo *EdnBuf::getElementColorAtPosition(int32_t pos, int32_t &starPos)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t start = etk_max(0, starPos-1);
|
||||
@ -334,7 +334,7 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart,
|
||||
}
|
||||
|
||||
|
||||
colorInformation_ts * EdnBuf::getElementColorAtPosition(displayHLData_ts & MData, int32_t pos)
|
||||
appl::ColorInfo * EdnBuf::getElementColorAtPosition(displayHLData_ts & MData, int32_t pos)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t start = etk_max(0, MData.posHLPass2-1);
|
||||
|
@ -1,53 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __COLORIZE_H__
|
||||
#define __COLORIZE_H__
|
||||
#include <etk/Color.h>
|
||||
#include <etk/UString.h>
|
||||
|
||||
class Colorize {
|
||||
public:
|
||||
// Constructeur
|
||||
Colorize(const etk::UString& _newColorName="no_name");
|
||||
~Colorize(void) { };
|
||||
|
||||
private:
|
||||
etk::UString m_colorName; //!< curent color Name
|
||||
public:
|
||||
void setName(const etk::UString& _newColorName) { m_colorName = _newColorName; };
|
||||
const etk::UString& getName(void) { return m_colorName; };
|
||||
|
||||
private:
|
||||
etk::Color<> m_colorFG;
|
||||
public:
|
||||
void setFgColor(const etk::UString& _myColor) { m_colorFG=_myColor; };
|
||||
const etk::Color<>& getFG(void) { return m_colorFG; };
|
||||
bool haveFg(void) { return m_colorFG.a()!=0; };
|
||||
private:
|
||||
etk::Color<> m_colorBG;
|
||||
public:
|
||||
void setBgColor(const etk::UString& _myColor) { m_colorBG=_myColor; };
|
||||
const etk::Color<>& getBG(void) { return m_colorBG; };
|
||||
bool haveBg(void) { return m_colorBG.a()!=0; };
|
||||
private:
|
||||
bool m_italic;
|
||||
public:
|
||||
void setItalic(bool _enable);
|
||||
bool getItalic(void) { return m_italic; };
|
||||
private:
|
||||
bool m_bold;
|
||||
public:
|
||||
void setBold(bool _enable);
|
||||
bool getBold(void) { return m_bold; };
|
||||
void display(int32_t _i) { APPL_INFO(" " << _i << " : fg="<< m_colorFG << " bold=" << m_italic << " bold=" << m_italic << "\"" << m_colorName << "\""); };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __COLORIZE_MANAGER_H__
|
||||
#define __COLORIZE_MANAGER_H__
|
||||
|
||||
#include <Colorize.h>
|
||||
#include <appl/globalMsg.h>
|
||||
#include <etk/Color.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
|
||||
typedef enum {
|
||||
// BASIC color for codeViewer
|
||||
COLOR_CODE_SPACE,
|
||||
COLOR_CODE_TAB,
|
||||
COLOR_CODE_BASIC_BG,
|
||||
COLOR_CODE_CURSOR,
|
||||
COLOR_CODE_LINE_NUMBER,
|
||||
// Basic color for list viewer
|
||||
COLOR_LIST_BG_1,
|
||||
COLOR_LIST_BG_2,
|
||||
COLOR_LIST_BG_SELECTED,
|
||||
COLOR_LIST_TEXT_NORMAL,
|
||||
COLOR_LIST_TEXT_MODIFY,
|
||||
// KNOW the number of BASIC color
|
||||
COLOR_NUMBER_MAX,
|
||||
}basicColor_te;
|
||||
|
||||
|
||||
|
||||
namespace ColorizeManager
|
||||
{
|
||||
void init(void);
|
||||
void unInit(void);
|
||||
void loadFile(const etk::UString& _xmlFilename);
|
||||
Colorize * get(const etk::UString& _colorName);
|
||||
etk::Color<>& get(basicColor_te _myColor);
|
||||
bool exist(const etk::UString& _colorName);
|
||||
void displayListOfColor(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -106,7 +106,7 @@ void BufferView::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
|
||||
|
||||
etk::Color<> BufferView::getBasicBG(void) {
|
||||
return ColorizeManager::get(COLOR_LIST_BG_1);
|
||||
return etk::color::none; //ColorizeManager::get(COLOR_LIST_BG_1);
|
||||
}
|
||||
|
||||
uint32_t BufferView::getNuberOfColomn(void) {
|
||||
@ -123,6 +123,7 @@ uint32_t BufferView::getNuberOfRaw(void) {
|
||||
}
|
||||
|
||||
bool BufferView::getElement(int32_t _colomn, int32_t _raw, etk::UString& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) {
|
||||
/*
|
||||
bool isModify;
|
||||
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
|
||||
basicColor_te selectBG = COLOR_LIST_BG_1;
|
||||
@ -161,6 +162,7 @@ bool BufferView::getElement(int32_t _colomn, int32_t _raw, etk::UString& _myText
|
||||
}
|
||||
_fg = ColorizeManager::get(selectFG);
|
||||
_bg = ColorizeManager::get(selectBG);
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ void Highlight::display(void) {
|
||||
// TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas trègrave... Il suffirait juste de suprimer celuis d'avant si il n'est pas terminer...
|
||||
void Highlight::parse(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<colorInformation_ts> &metaData,
|
||||
etk::Vector<appl::ColorInfo> &metaData,
|
||||
int32_t addingPos,
|
||||
etk::Buffer &buffer) {
|
||||
if (0 > addingPos) {
|
||||
@ -171,7 +171,7 @@ void Highlight::parse(int32_t start,
|
||||
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass1.size() << " == > position search: (" << start << "," << stop << ")" );
|
||||
int32_t elementStart = start;
|
||||
int32_t elementStop = stop;
|
||||
colorInformation_ts resultat;
|
||||
appl::ColorInfo resultat;
|
||||
while (elementStart<elementStop) {
|
||||
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
|
||||
//try to fond the HL in ALL of we have
|
||||
@ -225,12 +225,12 @@ void Highlight::parse(int32_t start,
|
||||
*/
|
||||
void Highlight::parse2(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<colorInformation_ts> &metaData,
|
||||
etk::Vector<appl::ColorInfo> &metaData,
|
||||
etk::Buffer &buffer) {
|
||||
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " == > position search: (" << start << "," << stop << ")" );
|
||||
int32_t elementStart = start;
|
||||
int32_t elementStop = stop;
|
||||
colorInformation_ts resultat;
|
||||
appl::ColorInfo resultat;
|
||||
while (elementStart<elementStop) {
|
||||
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
|
||||
//try to fond the HL in ALL of we have
|
||||
|
@ -10,19 +10,20 @@
|
||||
#define __HIGHLIGHT_H__
|
||||
|
||||
|
||||
class Highlight;
|
||||
class HighlightPattern;
|
||||
|
||||
extern "C" {
|
||||
typedef struct {
|
||||
int32_t beginStart;
|
||||
int32_t beginStop;
|
||||
int32_t endStart;
|
||||
int32_t endStop;
|
||||
bool notEnded;
|
||||
HighlightPattern* patern; // pointer on class :
|
||||
} colorInformation_ts;
|
||||
}
|
||||
class appl {
|
||||
class Highlight;
|
||||
class HighlightPattern;
|
||||
|
||||
class ColorInfo{
|
||||
public:
|
||||
int32_t beginStart;
|
||||
int32_t beginStop;
|
||||
int32_t endStart;
|
||||
int32_t endStop;
|
||||
bool notEnded;
|
||||
appl::HighlightPattern* patern; // pointer on class :
|
||||
};
|
||||
};
|
||||
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <HighlightPattern.h>
|
||||
@ -30,30 +31,34 @@ extern "C" {
|
||||
#include <etk/Buffer.h>
|
||||
#include <exml/exml.h>
|
||||
|
||||
class Highlight {
|
||||
public:
|
||||
// Constructeur
|
||||
Highlight(const etk::UString& _xmlFilename);
|
||||
~Highlight(void);
|
||||
bool hasExtention(const etk::UString& _ext);
|
||||
bool fileNameCompatible(etk::FSNode &_fileName);
|
||||
void display(void);
|
||||
void reloadColor(void);
|
||||
void parse(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<colorInformation_ts> &metaData,
|
||||
int32_t addingPos,
|
||||
etk::Buffer &buffer);
|
||||
void parse2(int32_t start,
|
||||
int32_t stop,
|
||||
etk::Vector<colorInformation_ts> &metaData,
|
||||
etk::Buffer &buffer);
|
||||
private:
|
||||
void parseRules(exml::Element* child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level);
|
||||
etk::UString m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
|
||||
etk::Vector<etk::UString> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
|
||||
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)) )
|
||||
class appl {
|
||||
class Highlight : public ewol::EObject {
|
||||
public:
|
||||
// Constructeur
|
||||
Highlight(const etk::UString& _xmlFilename);
|
||||
~Highlight(void);
|
||||
bool hasExtention(const etk::UString& _ext);
|
||||
bool fileNameCompatible(etk::FSNode &_fileName);
|
||||
void display(void);
|
||||
void reloadColor(void);
|
||||
void parse(int32_t _start,
|
||||
int32_t _stop,
|
||||
etk::Vector<appl::ColorInfo> &_metaData,
|
||||
int32_t _addingPos,
|
||||
etk::Buffer &_buffer);
|
||||
void parse2(int32_t _start,
|
||||
int32_t _stop,
|
||||
etk::Vector<appl::ColorInfo> &_metaData,
|
||||
etk::Buffer &_buffer);
|
||||
private:
|
||||
void parseRules(exml::Element* _child,
|
||||
etk::Vector<HighlightPattern*> &_mListPatern,
|
||||
int32_t _level);
|
||||
etk::UString m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
|
||||
etk::Vector<etk::UString> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
|
||||
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)) )
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
@ -13,130 +13,65 @@
|
||||
#include <ewol/renderer/EObjectManager.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "HighlightManager"
|
||||
#define __class__ "highlightManager"
|
||||
|
||||
class localClassHighlightManager: public ewol::EObject {
|
||||
private:
|
||||
etk::Vector<Highlight*> listHighlight; //!< List of ALL hightlight modules
|
||||
public:
|
||||
// Constructeur
|
||||
localClassHighlightManager(void) {
|
||||
//ewol::widgetMessageMultiCast::add(getWidgetId(), ednMsgBufferColor);
|
||||
};
|
||||
~localClassHighlightManager(void) {
|
||||
int32_t i;
|
||||
// clean all Element
|
||||
for (i=0; i< listHighlight.size(); i++) {
|
||||
if (NULL != listHighlight[i]) {
|
||||
delete(listHighlight[i]);
|
||||
listHighlight[i] = NULL;
|
||||
}
|
||||
}
|
||||
// clear the compleate list
|
||||
listHighlight.clear();
|
||||
};
|
||||
|
||||
// herited function
|
||||
const char * const getObjectType(void) {
|
||||
return "ApplHighlightManager";
|
||||
}
|
||||
|
||||
// herited function
|
||||
virtual void onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
/*
|
||||
switch (id)
|
||||
{
|
||||
case APPL_MSG__COLOR_HAS_CHANGE:
|
||||
APPL_INFO("UPDATE the color pointer on the HL");
|
||||
for (int32_t i=0; i<listHighlight.size(); i++) {
|
||||
if (NULL != listHighlight[i]) {
|
||||
listHighlight[i]->ReloadColor();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Highlight* get(etk::FSNode& _fileName) {
|
||||
int32_t i;
|
||||
for (i=0; i<listHighlight.size(); ++i) {
|
||||
if (true == listHighlight[i]->fileNameCompatible(_fileName) ) {
|
||||
return listHighlight[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool exist(etk::FSNode& _fileName) {
|
||||
if (NULL != get(_fileName) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void loadLanguages(void) {
|
||||
etk::FSNode myFile("DATA:languages/");
|
||||
// get the subfolder list :
|
||||
etk::Vector<etk::FSNode *> list = myFile.folderGetSubList(false, true, false,false);
|
||||
for ( int32_t iii=0 ; iii<list.size() ; iii++ ) {
|
||||
if (NULL!=list[iii]) {
|
||||
if (list[iii]->getNodeType() == etk::FSN_FOLDER) {
|
||||
etk::UString filename = list[iii]->getName() + "/highlight.xml";
|
||||
APPL_DEBUG("Load xml name : " << filename);
|
||||
Highlight *myHightline = new Highlight(filename);
|
||||
listHighlight.pushBack(myHightline);
|
||||
}
|
||||
}
|
||||
}
|
||||
//myHightline->display();
|
||||
}
|
||||
};
|
||||
|
||||
static localClassHighlightManager * localManager = NULL;
|
||||
static etk::Vector<Highlight*>& s_list(void) {
|
||||
static etk::Vector<Highlight*> list;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
void HighlightManager::init(void) {
|
||||
if (NULL != localManager) {
|
||||
void appl::highlightManager::init(void) {
|
||||
etk::Vector<Highlight*>& hlList = s_list();
|
||||
if (hlList.size() != 0) {
|
||||
APPL_ERROR("HighlightManager == > already exist, just unlink the previous ...");
|
||||
localManager = NULL;
|
||||
hlList.clear();
|
||||
}
|
||||
localManager = new localClassHighlightManager();
|
||||
|
||||
if (NULL == localManager) {
|
||||
APPL_CRITICAL("Allocation of HighlightManager not done ...");
|
||||
etk::FSNode myFile("DATA:languages/");
|
||||
// get the subfolder list :
|
||||
etk::Vector<etk::FSNode *> list = myFile.folderGetSubList(false, true, false,false);
|
||||
for (esize_t iii=0;
|
||||
iii<list.size();
|
||||
++iii ) {
|
||||
if (list[iii] == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (list[iii]->getNodeType() != etk::FSN_FOLDER) {
|
||||
continue;
|
||||
}
|
||||
etk::UString filename = list[iii]->getName() + "/highlight.xml";
|
||||
APPL_DEBUG("Load xml name : " << filename);
|
||||
appl::Highlight *myHightline = appl::Highlight::keep(filename);
|
||||
hlList.pushBack(myHightline);
|
||||
}
|
||||
}
|
||||
|
||||
void HighlightManager::unInit(void) {
|
||||
if (NULL == localManager) {
|
||||
APPL_ERROR("HighlightManager == > request UnInit, but does not exist ...");
|
||||
void appl::highlightManager::unInit(void) {
|
||||
etk::Vector<Highlight*>& hlList = s_list();
|
||||
if (hlList.size() == 0) {
|
||||
APPL_DEBUG("HighlightManager ==> no highlight");
|
||||
hlList.clear();
|
||||
return;
|
||||
}
|
||||
delete(localManager);
|
||||
localManager = NULL;
|
||||
}
|
||||
|
||||
void HighlightManager::loadLanguages(void) {
|
||||
if (NULL == localManager) {
|
||||
return;
|
||||
for (esize_t iii = 0;
|
||||
iii < hlList.size();
|
||||
++iii ) {
|
||||
if (hlList[iii] == NULL) {
|
||||
continue;
|
||||
}
|
||||
appl::Highlight::release(hlList[iii]);
|
||||
hlList[iii] = NULL;
|
||||
}
|
||||
localManager->loadLanguages();
|
||||
hlList.clear();
|
||||
}
|
||||
|
||||
Highlight* HighlightManager::get(etk::FSNode& _fileName) {
|
||||
if (NULL == localManager) {
|
||||
return NULL;
|
||||
}
|
||||
return localManager->get(_fileName);
|
||||
etk::UString appl::highlightManager::getTypeExtention(const etk::UString& _extention) {
|
||||
return "";
|
||||
}
|
||||
|
||||
bool HighlightManager::exist(etk::FSNode& _fileName) {
|
||||
if (NULL == localManager) {
|
||||
return false;
|
||||
}
|
||||
return localManager->exist(_fileName);
|
||||
etk::Vector<etk::UString> appl::highlightManager::getTypeList(void) {
|
||||
etk::Vector<etk::UString> ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -15,12 +15,28 @@
|
||||
#include <Highlight.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
|
||||
namespace HighlightManager{
|
||||
void init(void);
|
||||
void unInit(void);
|
||||
void loadLanguages(void);
|
||||
Highlight* get(etk::FSNode &fileName);
|
||||
bool exist(etk::FSNode &fileName);
|
||||
namespace appl {
|
||||
namespace highlightManager {
|
||||
/**
|
||||
* @brief Init the Highlight manager
|
||||
*/
|
||||
void init(void);
|
||||
/**
|
||||
* @brief Un-Init the Highlight manager
|
||||
*/
|
||||
void unInit(void);
|
||||
/**
|
||||
* @brief Un-Init the Highlight manager
|
||||
* @param[in] extention of the file
|
||||
* @return type of highlight
|
||||
*/
|
||||
etk::UString getTypeExtention(const etk::UString& _extention);
|
||||
/**
|
||||
* @brief Get the list of extention type
|
||||
* @return the requested list.
|
||||
*/
|
||||
etk::Vector<etk::UString> getTypeList(void);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ void HighlightPattern::setEscapeChar(etk::UString& _EscapeChar) {
|
||||
}
|
||||
}
|
||||
|
||||
void HighlightPattern::setColor(etk::UString& _colorName) {
|
||||
void HighlightPattern::setColorGlyph(etk::UString& _colorName) {
|
||||
m_colorName = _colorName;
|
||||
m_color = ColorizeManager::get(m_colorName);
|
||||
}
|
||||
@ -79,11 +79,6 @@ void HighlightPattern::display(void) {
|
||||
APPL_INFO(" == > multiline pattern: NO");
|
||||
}
|
||||
*/
|
||||
// display all elements
|
||||
for (int32_t i=0; i< m_subPatern.size(); i++) {
|
||||
APPL_INFO(" " << i << " subPattern : " << m_subPatern[i]->getName() );
|
||||
m_subPatern[i]->display();
|
||||
}
|
||||
}
|
||||
|
||||
void HighlightPattern::parseRules(exml::Element *child, int32_t level) {
|
||||
@ -142,18 +137,6 @@ void HighlightPattern::parseRules(exml::Element *child, int32_t level) {
|
||||
setEscapeChar(myEdnData);
|
||||
}
|
||||
}
|
||||
xChild = (exml::Element*)child->getNamed("rule");
|
||||
if (NULL != xChild) {
|
||||
/*
|
||||
// Create the patern ...
|
||||
HighlightPattern *myPattern = new HighlightPattern();
|
||||
// parse under Element
|
||||
myPattern->ParseRules(ruleChild, level+1);
|
||||
// add element in the list
|
||||
m_subPatern.pushBack(myPattern);
|
||||
//ParseRules(passChild, m_listHighlightPass1, level1++);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,57 +26,71 @@ typedef enum {
|
||||
HLP_FIND_OK_NO_END,
|
||||
}resultFind_te;
|
||||
|
||||
|
||||
class HighlightPattern {
|
||||
public:
|
||||
// Constructeur
|
||||
HighlightPattern(void);
|
||||
~HighlightPattern(void);
|
||||
|
||||
void setName(etk::UString& _name) {
|
||||
m_paternName = _name;
|
||||
};
|
||||
etk::UString getName(void) {
|
||||
return m_paternName;
|
||||
};
|
||||
|
||||
void setPaternStart(etk::UString& _regExp);
|
||||
void setPaternStop(etk::UString& _regExp);
|
||||
void setColor(etk::UString& _colorName);
|
||||
void setEscapeChar(etk::UString& _EscapeChar);
|
||||
void setMultiline(bool _enable) {
|
||||
m_multiline = _enable;
|
||||
};
|
||||
|
||||
void setLevel(int32_t _newLevel) {
|
||||
m_level = _newLevel;
|
||||
};
|
||||
int32_t getLevel(void) {
|
||||
return m_level;
|
||||
};
|
||||
|
||||
bool isEnable(void);
|
||||
void display(void);
|
||||
resultFind_te find(int32_t _start, int32_t _stop, colorInformation_ts& _resultat, etk::Buffer& _buffer);
|
||||
Colorize* getColor(void) {
|
||||
return m_color;
|
||||
};
|
||||
void parseRules(exml::Element* _child, int32_t _level);
|
||||
|
||||
void reloadColor(void);
|
||||
|
||||
private:
|
||||
int32_t m_level; //!< Level of the pattern == > this is to overwrite next pattern when we create an higher ....
|
||||
etk::UString m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
|
||||
etk::UString m_colorName; //!< Current color name
|
||||
Colorize* m_color; //!< Link to the color manager
|
||||
etk::RegExp<etk::Buffer>* m_regExpStart; //!< Start of Regular expression
|
||||
etk::RegExp<etk::Buffer>* m_regExpStop; //!< Stop of Regular Expression
|
||||
bool m_haveStopPatern; //!< Stop patern presence
|
||||
bool m_multiline; //!< The patern is multiline
|
||||
etk::UChar m_escapeChar; //!< Escape char to prevent exeit of patern ....
|
||||
etk::Vector<HighlightPattern*> m_subPatern; //!< Under patern of this one
|
||||
// etk::Vector<HighlightPattern*> m_subColor; //!< Under Color in the start RegExp ...
|
||||
namespace appl {
|
||||
class HighlightPattern {
|
||||
public:
|
||||
// Constructeur
|
||||
HighlightPattern(void);
|
||||
~HighlightPattern(void);
|
||||
private:
|
||||
etk::UString m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
|
||||
public:
|
||||
void setName(etk::UString& _name) {
|
||||
m_paternName = _name;
|
||||
};
|
||||
etk::UString getName(void) {
|
||||
return m_paternName;
|
||||
};
|
||||
private:
|
||||
etk::RegExp<etk::Buffer>* m_regExpStart; //!< Start of Regular expression
|
||||
public:
|
||||
void setPaternStart(etk::UString& _regExp);
|
||||
private:
|
||||
bool m_haveStopPatern; //!< Stop patern presence
|
||||
etk::RegExp<etk::Buffer>* m_regExpStop; //!< Stop of Regular Expression
|
||||
public:
|
||||
void setPaternStop(etk::UString& _regExp);
|
||||
private:
|
||||
etk::UString m_colorName; //!< Current color name
|
||||
appl::ColorGlyph* m_color; //!< Link to the color manager
|
||||
public:
|
||||
void setColorGlyph(etk::UString& _colorName);
|
||||
appl::ColorGlyph* getColorGlyph(void) {
|
||||
return m_color;
|
||||
};
|
||||
private:
|
||||
etk::UChar m_escapeChar; //!< Escape char to prevent exeit of patern ....
|
||||
public:
|
||||
void setEscapeChar(etk::UString& _EscapeChar);
|
||||
private:
|
||||
bool m_multiline; //!< The patern is multiline
|
||||
public:
|
||||
void setMultiline(bool _enable) {
|
||||
m_multiline = _enable;
|
||||
};
|
||||
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(void) {
|
||||
return m_level;
|
||||
};
|
||||
private:
|
||||
|
||||
public:
|
||||
bool isEnable(void);
|
||||
void display(void);
|
||||
resultFind_te find(int32_t _start,
|
||||
int32_t _stop,
|
||||
colorInformation_ts& _resultat,
|
||||
etk::Buffer& _buffer);
|
||||
|
||||
void parseRules(exml::Element* _child, int32_t _level);
|
||||
|
||||
void reloadColor(void);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -8,24 +8,23 @@
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <Colorize.h>
|
||||
|
||||
#include <appl/glyphDecoration/GlyphDecoration.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Colorize"
|
||||
#define __class__ "GlyphDecoration"
|
||||
|
||||
|
||||
Colorize::Colorize(const etk::UString &_newColorName) :
|
||||
appl::GlyphDecoration::GlyphDecoration(const etk::UString &_newColorName) :
|
||||
m_colorName(_newColorName),
|
||||
m_colorFG(etk::color::black),
|
||||
m_colorBG(etk::color::none),
|
||||
m_italic(false),
|
||||
m_bold(false)
|
||||
{
|
||||
APPL_VERBOSE("New(Colorise)");
|
||||
APPL_VERBOSE("New(" << __class__ << ")");
|
||||
}
|
||||
|
||||
void Colorize::setItalic(bool _enable)
|
||||
void appl::GlyphDecoration::setItalic(bool _enable)
|
||||
{
|
||||
m_italic = _enable;
|
||||
if (true == _enable) {
|
||||
@ -35,7 +34,7 @@ void Colorize::setItalic(bool _enable)
|
||||
}
|
||||
}
|
||||
|
||||
void Colorize::setBold(bool _enable)
|
||||
void appl::GlyphDecoration::setBold(bool _enable)
|
||||
{
|
||||
m_bold = _enable;
|
||||
if (true == _enable) {
|
||||
@ -45,5 +44,12 @@ void Colorize::setBold(bool _enable)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
etk::CCout& appl::operator <<(etk::CCout& _os, const appl::GlyphDecoration& _obj)
|
||||
{
|
||||
_os << "{fg=" << _obj.getForeground();
|
||||
_os << ",bg=" << _obj.getBackground();
|
||||
_os << ",italic=" << _obj.getItalic();
|
||||
_os << ",bold=" << _obj.getBold();
|
||||
_os << "name='" << _obj.getName() << "'}";
|
||||
return _os;
|
||||
}
|
124
sources/appl/glyphDecoration/GlyphDecoration.h
Normal file
124
sources/appl/glyphDecoration/GlyphDecoration.h
Normal file
@ -0,0 +1,124 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __GLYPH_DECORATION_H__
|
||||
#define __GLYPH_DECORATION_H__
|
||||
|
||||
#include <etk/Color.h>
|
||||
#include <etk/UString.h>
|
||||
|
||||
namespace appl {
|
||||
class GlyphDecoration {
|
||||
public:
|
||||
// Constructeur
|
||||
GlyphDecoration(const etk::UString& _newColorName = "no_name");
|
||||
~GlyphDecoration(void) {
|
||||
// nothing to do ...
|
||||
};
|
||||
private:
|
||||
etk::UString m_colorName; //!< curent color Name
|
||||
public:
|
||||
/**
|
||||
* @brief Set color name of the element.
|
||||
* @param[in] _newColorName new color name.
|
||||
*/
|
||||
void setName(const etk::UString& _newColorName) {
|
||||
m_colorName = _newColorName;
|
||||
};
|
||||
/**
|
||||
* @brief Get the color name.
|
||||
* @return The name of the color.
|
||||
*/
|
||||
const etk::UString& getName(void) const {
|
||||
return m_colorName;
|
||||
};
|
||||
private:
|
||||
etk::Color<> m_colorFG; //!< Foreground color
|
||||
public:
|
||||
/**
|
||||
* @brief Set foreground color.
|
||||
* @param[in] _myColor new color description.
|
||||
*/
|
||||
void setForeground(const etk::UString& _myColor) {
|
||||
m_colorFG = _myColor;
|
||||
};
|
||||
/**
|
||||
* @brief Get the foreground color.
|
||||
* @return The color.
|
||||
*/
|
||||
const etk::Color<>& getForeground(void) const {
|
||||
return m_colorFG;
|
||||
};
|
||||
/**
|
||||
* @brief Get the foreground color status.
|
||||
* @return true if the color is visible.
|
||||
*/
|
||||
bool haveFg(void) const {
|
||||
return m_colorFG.a() != 0;
|
||||
};
|
||||
private:
|
||||
etk::Color<> m_colorBG; //!< Background color
|
||||
public:
|
||||
/**
|
||||
* @brief Set background color.
|
||||
* @param[in] _myColor new color description.
|
||||
*/
|
||||
void setBackground(const etk::UString& _myColor) {
|
||||
m_colorBG = _myColor;
|
||||
};
|
||||
/**
|
||||
* @brief Get the background color.
|
||||
* @return The color.
|
||||
*/
|
||||
const etk::Color<>& getBackground(void) const {
|
||||
return m_colorBG;
|
||||
};
|
||||
/**
|
||||
* @brief Get the background color status.
|
||||
* @return true if the color is visible.
|
||||
*/
|
||||
bool haveBackground(void) const {
|
||||
return m_colorBG.a()!=0;
|
||||
};
|
||||
private:
|
||||
bool m_italic; //!< the gryph might be italic.
|
||||
public:
|
||||
/**
|
||||
* @brief Set the italic status.
|
||||
* @param[in] _enable new status of italic request.
|
||||
*/
|
||||
void setItalic(bool _enable);
|
||||
/**
|
||||
* @brief Get the italic status.
|
||||
* @return true if the glyph might be display in italic.
|
||||
*/
|
||||
bool getItalic(void) const {
|
||||
return m_italic;
|
||||
};
|
||||
private:
|
||||
bool m_bold; //!< the gryph might be bold.
|
||||
public:
|
||||
/**
|
||||
* @brief Set the bold status.
|
||||
* @param[in] _enable new status of bold request.
|
||||
*/
|
||||
void setBold(bool _enable);
|
||||
/**
|
||||
* @brief Get the bold status.
|
||||
* @return true if the glyph might be display in bold.
|
||||
*/
|
||||
bool getBold(void) const {
|
||||
return m_bold;
|
||||
};
|
||||
};
|
||||
etk::CCout& operator <<(etk::CCout& _os, const appl::GlyphDecoration& _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,13 +8,86 @@
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/global.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <appl/glyphDecoration/GlyphPainting.h>
|
||||
#include <exml/exml.h>
|
||||
#include <ewol/renderer/EObject.h>
|
||||
#include <ewol/renderer/EObjectManager.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <ewol/resources/ResourceManager.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "GlyphPainting"
|
||||
|
||||
|
||||
|
||||
appl::GlyphPainting::GlyphPainting(const etk::UString& _filename) :
|
||||
ewol::Resource(_filename) {
|
||||
EWOL_DEBUG("SFP : load \"" << _filename << "\"");
|
||||
reload();
|
||||
}
|
||||
|
||||
appl::GlyphPainting::~GlyphPainting(void) {
|
||||
// remove all element
|
||||
for (int32_t iii=0; iii<m_list.size(); iii++){
|
||||
if (NULL != m_list[iii]) {
|
||||
delete(m_list[iii]);
|
||||
m_list[iii] = NULL;
|
||||
}
|
||||
}
|
||||
m_list.clear();
|
||||
}
|
||||
|
||||
void appl::GlyphPainting::reload(void) {
|
||||
|
||||
}
|
||||
|
||||
appl::GlyphPainting* appl::GlyphPainting::keep(const etk::UString& _filename) {
|
||||
EWOL_INFO("KEEP : SimpleConfig : file : \"" << _filename << "\"");
|
||||
appl::GlyphPainting* object = static_cast<appl::GlyphPainting*>(getManager().localKeep(_filename));
|
||||
if (NULL != object) {
|
||||
return object;
|
||||
}
|
||||
// this element create a new one every time ....
|
||||
object = new appl::GlyphPainting(_filename);
|
||||
if (NULL == object) {
|
||||
EWOL_ERROR("allocation error of a resource : ??Mesh.obj??");
|
||||
return NULL;
|
||||
}
|
||||
getManager().localAdd(object);
|
||||
return object;
|
||||
}
|
||||
|
||||
void appl::GlyphPainting::release(appl::GlyphPainting*& _object) {
|
||||
if (NULL == _object) {
|
||||
return;
|
||||
}
|
||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
|
||||
getManager().release(object2);
|
||||
_object = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define PFX "ColorizeManager "
|
||||
|
||||
class classColorManager: public ewol::EObject {
|
||||
private:
|
47
sources/appl/glyphDecoration/GlyphPainting.h
Normal file
47
sources/appl/glyphDecoration/GlyphPainting.h
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __GLYPH_DECORATION_MANAGER_H__
|
||||
#define __GLYPH_DECORATION_MANAGER_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/resources/Resource.h>
|
||||
#include <appl/glyphDecoration/GlyphDecoration.h>
|
||||
|
||||
namespace appl {
|
||||
class GlyphPainting : public ewol::Resource {
|
||||
private:
|
||||
etk::Vector<appl::GlyphDecoration*> m_list;
|
||||
protected:
|
||||
GlyphPainting(const etk::UString& _filename);
|
||||
virtual ~GlyphPainting(void);
|
||||
public:
|
||||
const char* getType(void) {
|
||||
return "appl::GlyphPainting";
|
||||
};
|
||||
void reload(void);
|
||||
|
||||
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.
|
||||
*/
|
||||
static appl::GlyphPainting* keep(const etk::UString& _filename = "GlyphPainting::default");
|
||||
/**
|
||||
* @brief release the keeped resources
|
||||
* @param[in,out] reference on the object pointer
|
||||
*/
|
||||
static void release(appl::GlyphPainting*& _object);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
*/
|
@ -40,14 +40,14 @@ def Create(target):
|
||||
|
||||
# Generic color management for the text editor :
|
||||
myModule.AddSrcFile([
|
||||
'appl/Colorize/Colorize.cpp',
|
||||
'appl/Colorize/ColorizeManager.cpp'])
|
||||
'appl/glyphDecoration/GlyphDecoration.cpp'])
|
||||
# 'appl/Colorize/ColorizeManager.cpp'])
|
||||
|
||||
# syntax coloration for the text editor
|
||||
myModule.AddSrcFile([
|
||||
'appl/Highlight/HighlightPattern.cpp',
|
||||
'appl/Highlight/Highlight.cpp',
|
||||
'appl/Highlight/HighlightManager.cpp'])
|
||||
#myModule.AddSrcFile([
|
||||
# 'appl/Highlight/HighlightPattern.cpp',
|
||||
# 'appl/Highlight/Highlight.cpp',
|
||||
# 'appl/Highlight/HighlightManager.cpp'])
|
||||
|
||||
myModule.AddModuleDepend('ewol')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user