GUI : Reload on the fly the Color file

This commit is contained in:
Edouard Dupin 2011-08-19 16:09:58 +02:00
parent 0c1f6004eb
commit 514a5cf003
15 changed files with 161 additions and 35 deletions

View File

@ -30,7 +30,7 @@
#define PFX "ColorizeManager "
ColorizeManager::ColorizeManager(void)
ColorizeManager::ColorizeManager(void) : MsgBroadcast("Colorize Manager", EDN_CAT_COLOR)
{
}
@ -51,6 +51,33 @@ ColorizeManager::~ColorizeManager(void)
}
void ColorizeManager::OnMessage(int32_t id, int32_t dataID)
{
switch (id)
{
case EDN_MSG__RELOAD_COLOR_FILE:
{
// Remove all current color
int32_t i;
// clean all Element
for (i=0; i< listMyColor.Size(); i++) {
if (NULL != listMyColor[i]) {
delete(listMyColor[i]);
listMyColor[i] = NULL;
}
}
// clear the compleate list
listMyColor.Clear();
// Reaload File
// TODO : Check this :
Edn::String plop = m_fileColor;
LoadFile(plop.c_str());
}
break;
}
}
void ColorizeManager::LoadFile(Edn::String &xmlFilename)
{
LoadFile(xmlFilename.c_str());
@ -58,6 +85,8 @@ void ColorizeManager::LoadFile(Edn::String &xmlFilename)
void ColorizeManager::LoadFile(const char * xmlFilename)
{
m_fileColor = xmlFilename;
EDN_DEBUG("open file (COLOR) \"" << xmlFilename << "\" ? = \"" << m_fileColor << "\"");
errorColor = new Colorize();
errorColor->SetBgColor("#000000");
errorColor->SetFgColor("#FFFFFF");
@ -203,6 +232,7 @@ void ColorizeManager::LoadFile(const char * xmlFilename)
pNode = pNode->NextSibling();
}
}
SendMessage(EDN_MSG__COLOR_HAS_CHANGE);
}
Colorize *ColorizeManager::Get(const char *colorName)

View File

@ -28,6 +28,7 @@
#include "Singleton.h"
#include "Colorize.h"
#include "MsgBroadcast.h"
#include "Edn.h"
typedef enum {
@ -49,7 +50,7 @@ typedef enum {
class ColorizeManager: public Singleton<ColorizeManager>
class ColorizeManager: public Singleton<ColorizeManager>, public MsgBroadcast
{
friend class Singleton<ColorizeManager>;
// specific for sigleton system...
@ -57,6 +58,8 @@ class ColorizeManager: public Singleton<ColorizeManager>
// Constructeur
ColorizeManager(void);
~ColorizeManager(void);
public:
void OnMessage(int32_t id, int32_t dataID);
public:
void LoadFile(Edn::String &xmlFilename);
void LoadFile(const char * xmlFilename);
@ -68,6 +71,7 @@ class ColorizeManager: public Singleton<ColorizeManager>
void DisplayListOfColor(void);
private:
Edn::String m_fileColor;
Edn::VectorType<Colorize*> listMyColor; //!< List of ALL Color
Colorize * errorColor;
color_ts basicColors[COLOR_NUMBER_MAX];

View File

@ -138,6 +138,9 @@ gboolean BufferView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, g
EDN_INFO("Request a display of : " << self->m_shawableAreaX << "px * "<< self->m_shawableAreaY<<"px");
DrawerManager monDrawer(widget, self->m_shawableAreaX, self->m_shawableAreaY);
// clean buffer
monDrawer.Clean(self->m_colorManager->Get(COLOR_LIST_BG_1));
// get the number of buffer open
int32_t nbBufferOpen = self->m_bufferManager->Size();
int32_t i;

View File

@ -45,7 +45,7 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
#ifdef NDEBUG
iconeFile = "/usr/share/edn/images/icone.png";
#else
iconeFile = "./data/data/imagesSources/icone.png";
iconeFile = "./data/imagesSources/icone.png";
#endif
GdkPixbuf * icone = gdk_pixbuf_new_from_file(iconeFile.c_str(), &err);
@ -61,7 +61,10 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
g_signal_connect(G_OBJECT(m_mainWindow), "delete-event", G_CALLBACK(OnQuit), this);
g_signal_connect(G_OBJECT(m_mainWindow), "window-state-event", G_CALLBACK(OnStateChange), this);
//g_signal_connect(G_OBJECT(m_mainWindow), "destroy", G_CALLBACK(OnQuit), this);
// remove decoration
//gtk_window_set_decorated(GTK_WINDOW(m_mainWindow), FALSE);
// Create a vertical box for stacking the menu and editor widgets in.
GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER(m_mainWindow), vbox);
@ -70,8 +73,19 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
AccelKey::getInstance()->LinkCommonAccel(GTK_WINDOW(m_mainWindow));
// Create the menu bar.
#if 0
gtk_box_pack_start( GTK_BOX (vbox), m_MenuBar.GetWidget(), FALSE, FALSE, 0);
#else
GtkWidget *hboxMenu = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start( GTK_BOX (vbox), hboxMenu, FALSE, FALSE, 0);
// Add Exit boutton
// add the real menu bar
gtk_box_pack_start( GTK_BOX (hboxMenu), m_MenuBar.GetWidget(), FALSE, FALSE, 0);
// Add title
#endif
// **********************************************************
// * Horizontal ELEMENTS : *
// **********************************************************
@ -80,7 +94,7 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
gtk_container_add(GTK_CONTAINER (vbox), hbox);
// create the toolbar :
# if USE_GTK_VERSION_2_0
gtk_box_pack_start(GTK_BOX(hbox), m_ToolBar.GetWidget(), FALSE, FALSE, 0);
//gtk_box_pack_start(GTK_BOX(hbox), m_ToolBar.GetWidget(), FALSE, FALSE, 0);
# endif
// TreeView :
gtk_box_pack_start(GTK_BOX(hbox), m_BufferView.GetMainWidget(), FALSE, TRUE, 1);

View File

@ -36,7 +36,7 @@ const char * MSG_TogleAutoIndent = "Request a Togle of Auto Indent";
const char * MSG_SetCharsetIso559_1 = "Set ISO 5589-1";
const char * MSG_SetCharsetIso559_15 = "Set ISO 5589-15";
const char * MSG_SetCharsetUTF8 = "Set UTF 8";
#define MSG_LINK(data)
#define MSG_LINK(data)
static void CB_menuGenerique(GtkMenuItem *menu_item, gpointer data)
@ -230,15 +230,6 @@ MenuBar::MenuBar(void) : MsgBroadcast("Menu bar", EDN_CAT_GUI)
// tmp->AddGen(GTK_STOCK_PREFERENCES, NULL, EDN_MSG__GUI_SHOW_PREFERENCE, true);
m_listMenu.PushBack(tmp);
tmp = new MenuBarMain("Display", m_mainWidget);
tmp->AddInternal("Show space & tabs", NULL, MSG_TogleDisplayChar, true);
tmp->AddInternal("Show end of lines", NULL, MSG_TogleDisplayEOL, true);
tmp->AddInternal("Audo Indent", NULL, MSG_TogleAutoIndent, true);
tmp->AddInternal("Set charset Occidental (ISO-8859-1)", NULL, MSG_SetCharsetIso559_1, true);
tmp->AddInternal("Set charset Occidental (ISO-8859-15)", NULL, MSG_SetCharsetIso559_15, true);
tmp->AddInternal("Set charset Internationnal (UTF 8)", NULL, MSG_SetCharsetUTF8, true);
m_listMenu.PushBack(tmp);
tmp = new MenuBarMain("_Search", m_mainWidget);
tmp->AddGen(GTK_STOCK_FIND, "ctrl+f", EDN_MSG__GUI_SHOW_SEARCH, true);
tmp->AddGen(GTK_STOCK_FIND_AND_REPLACE, "ctrl+r", EDN_MSG__GUI_SHOW_REPLACE, true);
@ -252,6 +243,18 @@ MenuBar::MenuBar(void) : MsgBroadcast("Menu bar", EDN_CAT_GUI)
// tmp->AddSeparator();
// tmp->AddGen("Goto Line", "ctrl+l", EDN_MSG__CURRENT_GOTO_LINE, true);
m_listMenu.PushBack(tmp);
tmp = new MenuBarMain("Display", m_mainWidget);
tmp->AddInternal("Show space & tabs", NULL, MSG_TogleDisplayChar, true);
tmp->AddInternal("Show end of lines", NULL, MSG_TogleDisplayEOL, true);
tmp->AddInternal("Audo Indent", NULL, MSG_TogleAutoIndent, true);
tmp->AddSeparator();
tmp->AddInternal("Set charset Occidental (ISO-8859-1)", NULL, MSG_SetCharsetIso559_1, true);
tmp->AddInternal("Set charset Occidental (ISO-8859-15)", NULL, MSG_SetCharsetIso559_15, true);
tmp->AddInternal("Set charset Internationnal (UTF 8)", NULL, MSG_SetCharsetUTF8, true);
tmp->AddSeparator();
tmp->AddGen( "Reload Color File", NULL, EDN_MSG__RELOAD_COLOR_FILE, true);
m_listMenu.PushBack(tmp);
/*
tmp = new MenuBarMain("Project", m_mainWidget);
m_listMenu.PushBack(tmp);

View File

@ -135,6 +135,20 @@ Highlight::~Highlight(void)
m_listExtentions.Clear();
}
void Highlight::ReloadColor(void)
{
int32_t i;
for (i=0; i< m_listHighlightPass1.Size(); i++) {
if (NULL != m_listHighlightPass1[i]) {
m_listHighlightPass1[i]->ReloadColor();
}
}
for (i=0; i< m_listHighlightPass2.Size(); i++) {
if (NULL != m_listHighlightPass2[i]) {
m_listHighlightPass2[i]->ReloadColor();
}
}
}
bool Highlight::HasExtention(Edn::String &ext)
{

View File

@ -56,6 +56,7 @@ class Highlight {
bool HasExtention(Edn::String &ext);
bool FileNameCompatible(Edn::File &fileName);
void Display(void);
void ReloadColor(void);
void Parse(int32_t start,
int32_t stop,
Edn::VectorType<colorInformation_ts> &metaData,

View File

@ -30,7 +30,7 @@
#undef __class__
#define __class__ "HighlightManager"
HighlightManager::HighlightManager(void)
HighlightManager::HighlightManager(void) : MsgBroadcast("Hight-light Manager", EDN_CAT_HL)
{
}
@ -50,6 +50,21 @@ HighlightManager::~HighlightManager(void)
}
void HighlightManager::OnMessage(int32_t id, int32_t dataID)
{
switch (id)
{
case EDN_MSG__COLOR_HAS_CHANGE:
EDN_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 *HighlightManager::Get(Edn::File &fileName)
{
int32_t i;

View File

@ -29,10 +29,11 @@
class HighlightManager;
#include "Singleton.h"
#include "MsgBroadcast.h"
#include "Highlight.h"
class HighlightManager: public Singleton<HighlightManager>
class HighlightManager: public Singleton<HighlightManager>, public MsgBroadcast
{
friend class Singleton<HighlightManager>;
// specific for sigleton system...
@ -41,6 +42,8 @@ class HighlightManager: public Singleton<HighlightManager>
HighlightManager(void);
~HighlightManager(void);
public:
void OnMessage(int32_t id, int32_t dataID);
public:
void loadLanguages(void);
Highlight * Get(Edn::File &fileName);

View File

@ -87,6 +87,13 @@ bool HighlightPattern::IsEnable(void)
return true;
}
void HighlightPattern::ReloadColor(void)
{
ColorizeManager *myColorManager = ColorizeManager::getInstance();
m_color = myColorManager->Get(m_colorName);
}
/**
* @brief
*

View File

@ -51,23 +51,25 @@ class HighlightPattern {
HighlightPattern(void);
~HighlightPattern(void);
void SetName(Edn::String &name) { m_paternName = name;};
Edn::String GetName(void) { return m_paternName;};
void SetName(Edn::String &name) { m_paternName = name;};
Edn::String GetName(void) { return m_paternName;};
void SetPaternStart(Edn::String &regExp);
void SetPaternStop(Edn::String &regExp);
void SetColor(Edn::String &colorName);
void SetEscapeChar(Edn::String &EscapeChar);
void SetMultiline(bool enable) { m_multiline = enable; };
void SetPaternStart(Edn::String &regExp);
void SetPaternStop(Edn::String &regExp);
void SetColor(Edn::String &colorName);
void SetEscapeChar(Edn::String &EscapeChar);
void SetMultiline(bool enable) { m_multiline = enable; };
void SetLevel(int32_t newLevel) { m_level = newLevel; };
int32_t GetLevel(void) { return m_level; };
void SetLevel(int32_t newLevel) { m_level = newLevel; };
int32_t GetLevel(void) { return m_level; };
bool IsEnable(void);
void Display(void);
bool IsEnable(void);
void Display(void);
resultFind_te Find(int32_t start, int32_t stop, colorInformation_ts &resultat, EdnVectorBuf &buffer);
Colorize * GetColor(void) { return m_color; };
void ParseRules(TiXmlNode *child, int32_t level);
Colorize * GetColor(void) { return m_color; };
void ParseRules(TiXmlNode *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 ....

View File

@ -84,7 +84,8 @@ int main (int argc, char *argv[])
#else
homedir = "./data/";
#endif
homedir += "color_black.xml";
//homedir += "color_black.xml";
homedir += "color_white.xml";
myColorManager->LoadFile( homedir.c_str() );
myColorManager->DisplayListOfColor();

View File

@ -132,12 +132,18 @@ static char * GetMessageChar(messageType_te Id)
MACRO_DISPLAY_MSG(EDN_MSG__REFRESH_DISPLAY)
MACRO_DISPLAY_MSG(EDN_MSG__CURRENT_SET_CHARSET)
// Ctags MESSAGE :
// Ctags MESSAGE :
MACRO_DISPLAY_MSG(EDN_MSG__OPEN_CTAGS)
MACRO_DISPLAY_MSG(EDN_MSG__RELOAD_CTAGS)
MACRO_DISPLAY_MSG(EDN_MSG__JUMP_TO_CURRENT_SELECTION)
MACRO_DISPLAY_MSG(EDN_MSG__JUMP_BACK)
// HL message :
MACRO_DISPLAY_MSG(EDN_MSG__COLOR_HAS_CHANGE)
// Color message :
MACRO_DISPLAY_MSG(EDN_MSG__RELOAD_COLOR_FILE)
default:
return (char*)"??";
}
@ -163,6 +169,10 @@ static char * GetMessageTypeChar(messageCat_te Id)
return (char*)"C-TAGS_MANAGER";
case EDN_CAT_MENU_CONTEXT:
return (char*)"MENU CONTEXT";
case EDN_CAT_HL:
return (char*)"HIGHT-LIGHT";
case EDN_CAT_COLOR:
return (char*)"COLOR";
default:
return (char*)"??";
}
@ -204,6 +214,14 @@ void MsgBroadcastCore::SendMessage(MsgBroadcast * pointerOnSender, messageType_t
&& MSG_TO_CONTEXT__STOP >= id )
{
catDest = EDN_CAT_MENU_CONTEXT;
} else if( MSG_TO_HL__START <= id
&& MSG_TO_HL__STOP >= id )
{
catDest = EDN_CAT_HL;
} else if( MSG_TO_COLOR__START <= id
&& MSG_TO_COLOR__STOP >= id )
{
catDest = EDN_CAT_COLOR;
}
myStructMessage.localMessageID = m_messageID++;

View File

@ -125,6 +125,16 @@ typedef enum {
MSG_TO_CONTEXT__START,
MSG_TO_CONTEXT__STOP,
// DESTINATION : highlight system ...
MSG_TO_HL__START,
EDN_MSG__COLOR_HAS_CHANGE,
MSG_TO_HL__STOP,
// DESTINATION : Color System ...
MSG_TO_COLOR__START,
EDN_MSG__RELOAD_COLOR_FILE,
MSG_TO_COLOR__STOP,
}messageType_te;
@ -137,6 +147,8 @@ typedef enum {
EDN_CAT_GUI_MANAGER,
EDN_CAT_CTAGS,
EDN_CAT_MENU_CONTEXT,
EDN_CAT_HL,
EDN_CAT_COLOR,
}messageCat_te;

View File

@ -1,9 +1,9 @@
<?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_basicBackgroung" val="#151515"/>
<color name="CODE_cursor" val="#eadd05"/>
<color name="CODE_lineNumber" val="#fff725"/>
<!-- Buffer list property -->
@ -16,7 +16,6 @@
<syntax>
<color name="normal" FG="#EEEEEE"/>
<color name="SelectedText" FG="#AAAAAA" BG="#225a09"/>
<color name="SelectedNoText" BG="#124a00"/>
<color name="error" FG="#FF0000"/>
<color name="doubleQuoteText" FG="#00fF00"/>