[DEV] correct display with highlight ==> maybe rework the highlight

This commit is contained in:
Edouard DUPIN 2013-10-27 20:36:54 +01:00
parent 4d35830559
commit 01692bdd13
14 changed files with 147 additions and 106 deletions

View File

@ -1,42 +0,0 @@
<?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="#d9d7d7"/>
<color name="CODE_space" val="#b7b6b6"/>
<color name="CODE_tabulation" val="#a7a5a5"/>
<color name="CODE_cursor" val="#2a00ff"/>
<color name="CODE_lineNumber" val="#1a00a0"/>
<!-- Buffer list property -->
<color name="LIST_backgroung1" val="#d9d7d7"/>
<color name="LIST_backgroung2" val="#b7b6b6"/>
<color name="LIST_backgroungSelected" val="#3da3f9"/>
<color name="LIST_textNormal" val="#000000"/>
<color name="LIST_textModify" val="#FF0000"/>
</gui>
<syntax>
<color name="normal" FG="#000000"/>
<color name="SelectedText" FG="#292929" BG="#009ce7"/>
<color name="error" FG="#FF0000"/>
<color name="doubleQuoteText" FG="#008e00"/>
<!-- hightline description : -->
<color name="type" FG="#376d0a" bold="yes"/>
<color name="memberClass" FG="#7c5406" bold="yes"/>
<color name="inputFunction" FG="#B80000" bold="yes" italic="yes"/>
<color name="storageKeyword" FG="#466cb4"/>
<color name="number" FG="#007b00"/>
<color name="systemFunction" FG="#acaa00"/>
<color name="commonDefine" FG="#3c850b"/>
<color name="boolean" FG="#1633a3"/>
<color name="preprocesseur" FG="#ac0000"/>
<color name="comment" FG="#b704b5" italic="yes"/>
<color name="commentDoxygen" FG="#bf3e00" bold="yes" italic="yes"/>
<color name="keyword" FG="#215eb8" bold="yes"/>
<color name="macro" FG="#571793" bold="yes"/>
<color name="SYNTAX_ERROR" FG="#000000" BG="#c20000" bold="yes"/>
<color name="functionName" FG="#09857e" bold="yes"/>
<color name="TestResultOK" FG="#000000" BG="#009c00" bold="yes"/>
<color name="TestResultERROR" FG="#000000" BG="#c20000" bold="yes"/>
</syntax>
</EdnColor>

View File

@ -0,0 +1,9 @@
{
"ednColor": [
{ 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" },
]
}

View File

@ -0,0 +1,31 @@
{
"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:"normal", foreground:"#EEEEEE"},
{ name:"SelectedText", foreground:"#AAAAAA", background:"#225a09"},
{ name:"error", foreground:"#FF0000"},
{ name:"doubleQuoteText", foreground:"#00FF00"},
{ name:"type", foreground:"#56bf10", bold:true},
{ name:"storageKeyword", foreground:"#5c8fed"},
{ name:"inputFunction", foreground:"#B80000", bold:true, italic:true},
{ name:"memberClass", foreground:"#7c5406", bold:true},
{ 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:true},
{ name:"commentDoxygen", foreground:"#ef4d00", bold:true, italic:true},
{ name:"keyword", foreground:"#5c8fed", bold:true},
{ name:"macro", foreground:"#6c09c8", bold:true},
{ name:"SYNTAX_ERROR", foreground:"#000000", background:"#FF0000", bold:true},
{ name:"functionName", foreground:"#24d1e0", bold:true},
{ name:"TestResultOK", foreground:"#000000", background:"#00FF00", bold:true},
{ name:"TestResultERROR", FG:"#000000", background:"#FF0000", bold:true}
]
}

View File

@ -0,0 +1,9 @@
{
"ednColor": [
{ name:"LIST_backgroung1", foreground:"#d9d7d7"},
{ name:"LIST_backgroung2", foreground:"#b7b6b6"},
{ name:"LIST_backgroungSelected", foreground:"#3da3f9"},
{ name:"LIST_textNormal", foreground:"#000000"},
{ name:"LIST_textModify", foreground:"#FF0000"}
]
}

View File

@ -0,0 +1,31 @@
{
"ednColor": [
{ name:"CODE_basicBackgroung", foreground:"#d9d7d7"},
{ name:"CODE_space", foreground:"#b7b6b6"},
{ name:"CODE_tabulation", foreground:"#a7a5a5"},
{ name:"CODE_cursor", foreground:"#2a00ff"},
{ name:"CODE_lineNumber", foreground:"#1a00a0"},
{ name:"normal", foreground:"#000000"},
{ name:"SelectedText", foreground:"#292929", background:"#009ce7"},
{ name:"error", foreground:"#FF0000"},
{ name:"doubleQuoteText", foreground:"#008e00"},
{ name:"type", foreground:"#376d0a", bold:true},
{ name:"memberClass", foreground:"#7c5406", bold:true},
{ name:"inputFunction", foreground:"#B80000", bold:true, italic:true},
{ name:"storageKeyword", foreground:"#466cb4"},
{ name:"number", foreground:"#007b00"},
{ name:"systemFunction", foreground:"#acaa00"},
{ name:"commonDefine", foreground:"#3c850b"},
{ name:"boolean", foreground:"#1633a3"},
{ name:"preprocesseur", foreground:"#ac0000"},
{ name:"comment", foreground:"#b704b5", italic:true},
{ name:"commentDoxygen", foreground:"#bf3e00", bold:true, italic:true},
{ name:"keyword", foreground:"#215eb8", bold:true},
{ name:"macro", foreground:"#571793", bold:true},
{ name:"SYNTAX_ERROR", foreground:"#000000", background:"#c20000", bold:true},
{ name:"functionName", foreground:"#09857e", bold:true},
{ name:"TestResultOK", foreground:"#000000", background:"#009c00", bold:true},
{ name:"TestResultERROR", foreground:"#000000", background:"#c20000", bold:true}
]
}

View File

@ -1,9 +0,0 @@
{
"ednColor": [
{ 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" },
]
}

View File

@ -1,29 +0,0 @@
{
"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="normal", foreground="#EEEEEE"},
{ name="SelectedText", foreground="#AAAAAA", background="#225a09"},
{ name="error", foreground="#FF0000"},
{ name="doubleQuoteText", foreground="#00fF00"},
{ name="type", foreground="#56bf10", bold=true},
{ 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=true},
{ name="commentDoxygen", foreground="#ef4d00", bold=true, italic=true},
{ name="keyword", foreground="#5c8fed", bold=true},
{ name="macro", foreground="#6c09c8", bold=true},
{ name="SYNTAX_ERROR", foreground="#000000", background="#FF0000", bold=true},
{ name="functionName", foreground="#24d1e0", bold=true},
{ name="TestResultOK", foreground="#000000", background="#00FF00", bold=true},
{ name="TestResultERROR", FG="#000000", background="#FF0000", bold=true}
]
}

View File

@ -136,7 +136,7 @@ MainWindows::MainWindows(void) {
mySizerHori->subWidgetAdd(mySizerVert2);
// main buffer Area :
myTextView = new appl::TextViewer("FreeSerif;FreeMono;DejaVuSansMono", 11);
myTextView = new appl::TextViewer("FreeMono;DejaVuSansMono;FreeSerif", 11);
myTextView->setExpand(bvec2(true,true));
myTextView->setFill(bvec2(true,true));
mySizerVert2->subWidgetAdd(myTextView);

View File

@ -40,6 +40,17 @@ appl::TextViewer::TextViewer(const etk::UString& _fontName, int32_t _fontSize) :
shortCutAdd("ctrl+a", ednMsgGuiSelect, "ALL");
shortCutAdd("ctrl+shift+a", ednMsgGuiSelect, "NONE");
// load color properties
m_paintingProperties = appl::GlyphPainting::keep("THEME:COLOR:textViewer.json");
// get all id properties ...
m_colorBackground = m_paintingProperties->request("CODE_basicBackgroung");
m_colorSpace = m_paintingProperties->request("CODE_space");
m_colorTabulation = m_paintingProperties->request("CODE_tabulation");
m_colorCursor = m_paintingProperties->request("CODE_cursor");
m_colorLineNumber = m_paintingProperties->request("CODE_lineNumber");
m_colorSelection = m_paintingProperties->request("SelectedText");
m_colorNormal = m_paintingProperties->request("normal");
// by default we load an example object:
m_buffer = new appl::Buffer();
@ -78,7 +89,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
// reset the background :
m_displayDrawing.setPos(vec3(0, 0, 0));
m_displayDrawing.setColor(etk::Color<>(220, 220, 220, 256));
m_displayDrawing.setColor((*m_paintingProperties)[m_colorBackground].getForeground());
m_displayDrawing.rectangleWidth(m_size);
if (m_buffer == NULL) {
@ -116,7 +127,6 @@ void appl::TextViewer::onRegenerateDisplay(void) {
// the siplay string :
etk::UString stringToDisplay;
esize_t bufferElementSize = 0;
etk::UChar currentValue;
bool isSelect = false;
appl::Buffer::Iterator selectPosStart = m_buffer->begin();
appl::Buffer::Iterator selectPosStop = m_buffer->begin();
@ -154,8 +164,10 @@ void appl::TextViewer::onRegenerateDisplay(void) {
nbLineCalc /= 10.0f;
}
m_lastOffsetDisplay = tmpLetterSize.x() * (float)nbChar + 1.0f;
m_displayText.setColorBg(etk::Color<>(0xB0B0B0FF));
m_displayText.setColor(etk::Color<>(0x000080FF));
m_displayText.setFontItalic((*m_paintingProperties)[m_colorLineNumber].getItalic());
m_displayText.setFontBold((*m_paintingProperties)[m_colorLineNumber].getBold());
m_displayText.setColorBg((*m_paintingProperties)[m_colorLineNumber].getBackground());
m_displayText.setColor((*m_paintingProperties)[m_colorLineNumber].getForeground());
m_displayText.setClippingMode(false);
vec3 startWriteRealPosition = m_displayText.getPos();
@ -172,11 +184,12 @@ void appl::TextViewer::onRegenerateDisplay(void) {
}
}
m_displayText.setPos(vec3(-m_originScrooled.x()+m_lastOffsetDisplay, startWriteRealPosition.y(), 0.0f));
m_displayText.setColorBg(etk::Color<>(0xFFFFFF00));
m_displayText.setColor(etk::Color<>(0x000000FF));
m_displayText.setClipping(vec2(m_lastOffsetDisplay, 0), m_size);
}
appl::DisplayHLData displayLocalSyntax;
m_buffer->hightlightGenerateLines(displayLocalSyntax, (esize_t)startingIt, m_size.y());
float maxSizeX = 0;
appl::HighlightInfo * HLColor = NULL;
for (appl::Buffer::Iterator it = startingIt;
(bool)it == true;
++it) {
@ -184,10 +197,9 @@ void appl::TextViewer::onRegenerateDisplay(void) {
// need to display the cursor :
tmpCursorPosition = m_displayText.getPos();
}
currentValue = *it;
//APPL_DEBUG("display element '" << currentValue << "'at pos : " << m_displayText.getPos() );
//APPL_DEBUG(" element size : " << iii << " : " << bufferElementSize);
if (currentValue == etk::UChar::Return) {
if (*it == etk::UChar::Return) {
countNbLine += 1;
countColomn = 0;
maxSizeX = etk_max(m_displayText.getPos().x(), maxSizeX);
@ -205,16 +217,31 @@ void appl::TextViewer::onRegenerateDisplay(void) {
}
continue;
}
m_displayText.setColorBg(etk::Color<>(0x00000000));
// TODO : move tis section in a plugin, but haw to do this ???
if (*it == etk::UChar::Space) {
m_displayText.setColorBg(etk::Color<>(0x00000022));
} else if (*it == etk::UChar::Tabulation) {
m_displayText.setColorBg(etk::Color<>(0x00000044));
HLColor = m_buffer->getElementColorAtPosition(displayLocalSyntax, (esize_t)it);
bool haveBackground = false;
if ( HLColor != NULL
&& HLColor->patern != NULL) {
m_displayText.setColor(HLColor->patern->getColorGlyph().getForeground());
m_displayText.setColorBg(HLColor->patern->getColorGlyph().getBackground());
haveBackground = HLColor->patern->getColorGlyph().haveBackground();
m_displayText.setFontItalic(HLColor->patern->getColorGlyph().getItalic());
m_displayText.setFontBold(HLColor->patern->getColorGlyph().getBold());
} else {
m_displayText.setFontItalic((*m_paintingProperties)[m_colorNormal].getItalic());
m_displayText.setFontBold((*m_paintingProperties)[m_colorNormal].getBold());
m_displayText.setColorBg((*m_paintingProperties)[m_colorNormal].getBackground());
m_displayText.setColor((*m_paintingProperties)[m_colorNormal].getForeground());
}
m_buffer->expand(countColomn, currentValue, stringToDisplay);
if (haveBackground == false) {
if (*it == etk::UChar::Space) {
m_displayText.setColorBg((*m_paintingProperties)[m_colorSpace].getForeground());
} else if (*it == etk::UChar::Tabulation) {
m_displayText.setColorBg((*m_paintingProperties)[m_colorTabulation].getForeground());
}
}
m_buffer->expand(countColomn, *it, stringToDisplay);
if (it >= selectPosStart && it < selectPosStop) {
m_displayText.setColorBg(etk::Color<>(0x00FF00FF));
m_displayText.setColorBg((*m_paintingProperties)[m_colorSelection].getForeground());
}
//APPL_DEBUG("display : '" << currentValue << "' == > '" << stringToDisplay << "'");
m_displayText.print(stringToDisplay);
@ -225,8 +252,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
// display the cursor:
//APPL_DEBUG("display cursor at position : " << tmpCursorPosition);
m_displayText.setPos(tmpCursorPosition);
m_displayText.setColor(etk::Color<>(0xFF0000FF));
m_displayText.setColorBg(etk::Color<>(0xFF0000FF));
m_displayText.setColorBg((*m_paintingProperties)[m_colorCursor].getForeground());
m_displayText.printCursor(m_insertMode);
}
// set maximum size (X&Y) :

View File

@ -29,6 +29,15 @@ namespace appl {
friend class appl::TextPluginMultiLineTab;
friend class appl::TextPluginAutoIndent;
friend class appl::TextPluginHistory;
private:
appl::GlyphPainting* m_paintingProperties; //!< element painting property
esize_t m_colorBackground;
esize_t m_colorSpace;
esize_t m_colorTabulation;
esize_t m_colorCursor;
esize_t m_colorLineNumber;
esize_t m_colorSelection;
esize_t m_colorNormal;
public:
TextViewer(const etk::UString& _fontName="", int32_t _fontSize=-1);
virtual ~TextViewer(void);

View File

@ -65,6 +65,7 @@ void appl::HighlightPattern::setEscapeChar(const etk::UChar& _EscapeChar) {
void appl::HighlightPattern::setColorGlyph(etk::UString& _colorName) {
m_colorName = _colorName;
m_colorId = m_glyphPainting->request(m_colorName);
APPL_DEBUG("Resuest color name '" << m_colorName << "' => id=" << m_colorId);
}
void appl::HighlightPattern::display(void) {

View File

@ -31,7 +31,7 @@ appl::GlyphPainting::~GlyphPainting(void) {
void appl::GlyphPainting::reload(void) {
ejson::Document doc;
if (false == doc.load(m_name)) {
APPL_ERROR("Can not load file : '" << m_name << "'");
APPL_ERROR("Can not load file : '" << m_name << "' = " << etk::FSNode(m_name).getFileSystemName());
return;
}
ejson::Array* baseArray = doc.getArray("ednColor");
@ -45,11 +45,12 @@ void appl::GlyphPainting::reload(void) {
APPL_DEBUG(" can not get object in 'ednColor' id=" << iii);
continue;
}
etk::UString name = tmpObj->getString("name");
etk::UString background = tmpObj->getString("background");
etk::UString foreground = tmpObj->getString("foreground");
bool italic = tmpObj->getString("italic");
bool bold = tmpObj->getString("bold");
etk::UString name = tmpObj->getStringValue("name", "");
etk::UString background = tmpObj->getStringValue("background", "#FFF0");
etk::UString foreground = tmpObj->getStringValue("foreground", "#000F");
bool italic = tmpObj->getBooleanValue("italic", false);
bool bold = tmpObj->getBooleanValue("bold", false);
APPL_DEBUG("find new color : '" << name << "' fg='" << foreground << "' bg='" << background << "' italic='" << italic << "' bold='" << bold << "'");
bool findElement = false;
for (esize_t jjj=0; jjj<m_list.size(); ++jjj) {
if (m_list[jjj].getName() != name) {

View File

@ -63,6 +63,9 @@ bool APP_Init(ewol::eContext& _context)
// set the application icon ...
_context.setIcon("DATA:icon.png");
etk::theme::setName("COLOR", "colorBlack/");
etk::theme::setName("COLOR", "colorWhite/");
// init internal global value
globals::init();

View File

@ -57,7 +57,6 @@ def Create(target):
myModule.CopyFile('../data/icon.png','icon.png')
myModule.CopyFolder('../data/icon.*','')
myModule.CopyFolder('../data/theme/default/color/*.xml','theme/default/color/')
myModule.CopyFolder('../data/languages/asm/*.xml','languages/asm/')
myModule.CopyFolder('../data/languages/bash/*.xml','languages/bash/')
myModule.CopyFolder('../data/languages/boo/*.xml','languages/boo/')
@ -73,6 +72,8 @@ def Create(target):
myModule.CopyFolder('../data/languages/xml/*.xml','languages/xml/')
myModule.CopyFolder('../data/languages/python/*.xml','languages/python/')
myModule.CopyFolder('../data/theme/default/*.svg','theme/default/')
myModule.CopyFolder('../data/theme/colorWhite/*.json','theme/colorWhite/')
myModule.CopyFolder('../data/theme/colorClack/*.json','theme/colorBlack/')
myModule.AddPath(lutinTools.GetCurrentPath(__file__))
myModule.AddPath(lutinTools.GetCurrentPath(__file__)+"/appl")