Index: include/cbstyledtextctrl.h
===================================================================
--- include/cbstyledtextctrl.h	(revision 6863)
+++ include/cbstyledtextctrl.h	(working copy)
@@ -9,6 +9,9 @@
 #include "wx/wxscintilla.h"
 #include <wx/longlong.h>
 
+#include <map>
+#include <set>
+
 class wxContextMenuEvent;
 class wxFocusEvent;
 class wxMouseEvent;
@@ -27,6 +30,11 @@
         bool IsComment(int style);
         void CallTipCancel();
 
+        static std::map<int, std::set<int> > &GetCharacterLexerStyles();
+        static std::map<int, std::set<int> > &GetStringLexerStyles();
+        static std::map<int, std::set<int> > &GetPreprocessorLexerStyles();
+        static std::map<int, std::set<int> > &GetCommentLexerStyles();
+
     private:
         void OnContextMenu(wxContextMenuEvent& event);
         void OnKillFocus(wxFocusEvent& event);
@@ -45,6 +53,8 @@
         int m_lastPosition;
         bool m_tabSmartJump;
 
+        static std::map<int, std::set<int> > CharacterLexerStyles, StringLexerStyles, PreprocessorLexerStyles, CommentLexerStyles;
+
         DECLARE_EVENT_TABLE()
 };
 
Index: include/editorcolourset.h
===================================================================
--- include/editorcolourset.h	(revision 6863)
+++ include/editorcolourset.h	(working copy)
@@ -13,6 +13,8 @@
 #include "settings.h"
 #include "globals.h" // HighlightLanguage
 
+#include <set>
+
 // forward decls
 class cbEditor;
 class cbStyledTextCtrl;
@@ -65,6 +67,7 @@
 
     CommentToken comment;
     bool m_CaseSensitive;
+    //std::set<int> CommentStyles, StringStyles, CharacterStyles, PreprocessorStyles;
 };
 WX_DECLARE_STRING_HASH_MAP(OptionSet, OptionSetsMap);
 
@@ -113,6 +116,10 @@
         void SetCommentToken(HighlightLanguage lang, CommentToken token);
         bool GetCaseSensitivity(HighlightLanguage lang);
         void SetCaseSensitivity(HighlightLanguage lang, bool CaseSensitive);
+        void SetStringLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
+        void SetCommentLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
+        void SetCharacterLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
+        void SetPreprocessorLexerStyles(HighlightLanguage lang, const std::set<int> &styles);
 	protected:
 	private:
 		void DoApplyStyle(cbStyledTextCtrl* control, int value, OptionColour* option);
Index: include/editorlexerloader.h
===================================================================
--- include/editorlexerloader.h	(revision 6863)
+++ include/editorlexerloader.h	(working copy)
@@ -26,6 +26,7 @@
         void DoSingleKeywordNode(HighlightLanguage language, TiXmlElement* node, const wxString& nodename);
         void DoSampleCode(HighlightLanguage language, TiXmlElement* node);
         void DoLangAttributes(HighlightLanguage language, TiXmlElement* node);
+        bool DoLangAttributesLexerStyles(TiXmlElement* attribs, const char *attributeName, std::set<int> &styles);
         EditorColourSet* m_pTarget;
 	private:
 };
Index: sdk/cbstyledtextctrl.cpp
===================================================================
--- sdk/cbstyledtextctrl.cpp	(revision 6863)
+++ sdk/cbstyledtextctrl.cpp	(working copy)
@@ -22,6 +22,11 @@
 static const wxString s_rightBrace(_T(")]}'\""));
 static const int s_indicHighlight(20);
 
+std::map<int, std::set<int> > cbStyledTextCtrl::CharacterLexerStyles;
+std::map<int, std::set<int> > cbStyledTextCtrl::StringLexerStyles;
+std::map<int, std::set<int> > cbStyledTextCtrl::PreprocessorLexerStyles;
+std::map<int, std::set<int> > cbStyledTextCtrl::CommentLexerStyles;
+
 BEGIN_EVENT_TABLE(cbStyledTextCtrl, wxScintilla)
     EVT_CONTEXT_MENU(cbStyledTextCtrl::OnContextMenu)
     EVT_KILL_FOCUS  (cbStyledTextCtrl::OnKillFocus)
@@ -247,61 +252,22 @@
 
 bool cbStyledTextCtrl::IsCharacter(int style)
 {
-    switch (GetLexer())
-    {
-    case wxSCI_LEX_CPP:
-        return style == wxSCI_C_CHARACTER;
-    case wxSCI_LEX_D:
-        return style == wxSCI_D_CHARACTER;
-    default:
-        return false;
-    }
-    return false;
+    return CharacterLexerStyles[GetLexer()].find(style) != CharacterLexerStyles[GetLexer()].end();
 }
 
 bool cbStyledTextCtrl::IsString(int style)
 {
-    switch (GetLexer())
-    {
-    case wxSCI_LEX_CPP:
-        return style == wxSCI_C_STRING;
-    case wxSCI_LEX_D:
-        return style == wxSCI_D_STRING;
-    default:
-        return false;
-    }
-    return false;
+    return StringLexerStyles[GetLexer()].find(style) != StringLexerStyles[GetLexer()].end();
 }
 
 bool cbStyledTextCtrl::IsPreprocessor(int style)
 {
-    if (GetLexer() == wxSCI_LEX_CPP)
-        return  style == wxSCI_C_PREPROCESSOR;
-    return false;
+    return PreprocessorLexerStyles[GetLexer()].find(style) != PreprocessorLexerStyles[GetLexer()].end();
 }
 
 bool cbStyledTextCtrl::IsComment(int style)
 {
-    switch (GetLexer())
-    {
-    case wxSCI_LEX_CPP:
-        return  style == wxSCI_C_COMMENT ||
-                style == wxSCI_C_COMMENTLINE ||
-                style == wxSCI_C_COMMENTDOC ||
-                style == wxSCI_C_COMMENTDOCKEYWORD ||
-                style == wxSCI_C_COMMENTDOCKEYWORDERROR ||
-                style == wxSCI_C_COMMENTLINEDOC;
-    case wxSCI_LEX_D:
-        return  style == wxSCI_D_COMMENT ||
-                style == wxSCI_D_COMMENTLINE ||
-                style == wxSCI_D_COMMENTDOC ||
-                style == wxSCI_D_COMMENTDOCKEYWORD ||
-                style == wxSCI_D_COMMENTDOCKEYWORDERROR ||
-                style == wxSCI_D_COMMENTLINEDOC;
-    default:
-        return false;
-    }
-    return false;
+    return CommentLexerStyles[GetLexer()].find(style) != CommentLexerStyles[GetLexer()].end();
 }
 
 void cbStyledTextCtrl::CallTipCancel()
@@ -395,3 +361,20 @@
     m_bracePosition = GetCurrentPos();
     HighlightRightBrace();
 }
+
+std::map<int, std::set<int> > &cbStyledTextCtrl::GetCharacterLexerStyles()
+{
+    return CharacterLexerStyles;
+}
+std::map<int, std::set<int> > &cbStyledTextCtrl::GetStringLexerStyles()
+{
+    return StringLexerStyles;
+}
+std::map<int, std::set<int> > &cbStyledTextCtrl::GetPreprocessorLexerStyles()
+{
+    return PreprocessorLexerStyles;
+}
+std::map<int, std::set<int> > &cbStyledTextCtrl::GetCommentLexerStyles()
+{
+    return CommentLexerStyles;
+}
Index: sdk/editorcolourset.cpp
===================================================================
--- sdk/editorcolourset.cpp	(revision 6863)
+++ sdk/editorcolourset.cpp	(working copy)
@@ -852,3 +852,35 @@
         return false;
     return m_Sets[lang].m_CaseSensitive;
 }
+
+void EditorColourSet::SetStringLexerStyles(HighlightLanguage lang, const std::set<int> &styles)
+{
+    if ( lang == HL_NONE )
+        return;
+   // m_Sets[lang].StringStyles = styles;
+   cbStyledTextCtrl::GetStringLexerStyles()[m_Sets[lang].m_Lexers] = styles;
+}
+
+void EditorColourSet::SetCommentLexerStyles(HighlightLanguage lang, const std::set<int> &styles)
+{
+    if ( lang == HL_NONE )
+        return;
+    //m_Sets[lang].CommentStyles = styles;
+   cbStyledTextCtrl::GetCommentLexerStyles()[m_Sets[lang].m_Lexers] = styles;
+}
+
+void EditorColourSet::SetCharacterLexerStyles(HighlightLanguage lang, const std::set<int> &styles)
+{
+    if ( lang == HL_NONE )
+        return;
+    //m_Sets[lang].CharacterStyles = styles;
+   cbStyledTextCtrl::GetCharacterLexerStyles()[m_Sets[lang].m_Lexers] = styles;
+}
+
+void EditorColourSet::SetPreprocessorLexerStyles(HighlightLanguage lang, const std::set<int> &styles)
+{
+    if ( lang == HL_NONE )
+        return;
+    //m_Sets[lang].PreprocessorStyles = styles;
+   cbStyledTextCtrl::GetPreprocessorLexerStyles()[m_Sets[lang].m_Lexers] = styles;
+}
Index: sdk/editorlexerloader.cpp
===================================================================
--- sdk/editorlexerloader.cpp	(revision 6863)
+++ sdk/editorlexerloader.cpp	(working copy)
@@ -223,4 +223,37 @@
     token.boxCommentEnd = wxString( attribs->Attribute("BoxCommentEnd"), wxConvUTF8 );
 
     m_pTarget->SetCommentToken(language, token);
+
+    std::set<int> CommentLexerStyles, CharacterLexerStyles, StringLexerStyles, PreprocessorLexerStyles;
+    bool hasLexerStylesSet = false;
+    hasLexerStylesSet |= DoLangAttributesLexerStyles(attribs, "LexerCommentStyles", CommentLexerStyles);
+    hasLexerStylesSet |= DoLangAttributesLexerStyles(attribs, "LexerCharacterStyles", CharacterLexerStyles);
+    hasLexerStylesSet |= DoLangAttributesLexerStyles(attribs, "LexerStringStyles", StringLexerStyles);
+    hasLexerStylesSet |= DoLangAttributesLexerStyles(attribs, "LexerPreprocessorStyles", PreprocessorLexerStyles);
+
+    // only set styles if configured. Since different languages use the same lexer.
+    // So if any of the languages has these styles configured we use them.
+    // If another language has not configured them the previously defined wont get lost.
+    if ( hasLexerStylesSet )
+    {
+        m_pTarget->SetCommentLexerStyles(language, CommentLexerStyles);
+        m_pTarget->SetStringLexerStyles(language, StringLexerStyles);
+        m_pTarget->SetCharacterLexerStyles(language, CharacterLexerStyles);
+        m_pTarget->SetPreprocessorLexerStyles(language, PreprocessorLexerStyles);
+    }
 }
+bool EditorLexerLoader::DoLangAttributesLexerStyles(TiXmlElement* attribs, const char *attributeName, std::set<int> &styles)
+{
+    styles.clear();
+    wxString str = wxString ( attribs->Attribute(attributeName), wxConvUTF8 );
+    wxArrayString strarray = GetArrayFromString(str, _T(","));
+
+    for ( unsigned int i = 0; i < strarray.Count(); ++i )
+    {
+        long style;
+        strarray[i].ToLong(&style);
+        styles.insert((unsigned int)style);
+    }
+
+    return !str.IsEmpty();
+}
Index: sdk/resources/lexers/lexer_bibtex.xml
===================================================================
--- sdk/resources/lexers/lexer_bibtex.xml	(revision 0)
+++ sdk/resources/lexers/lexer_bibtex.xml	(revision 0)
@@ -0,0 +1,77 @@
+<?xml version="1.0"?>
+<!DOCTYPE CodeBlocks_lexer_properties>
+<CodeBlocks_lexer_properties>
+  <Lexer name="BibTeX"
+         index="100"
+         filemasks="*.bib">
+<!--#define SCE_BIBTEX_DEFAULT 0-->
+    <Style name="Default"
+           index="0"
+           fg="0,0,0"
+           bg="255,255,255"
+           bold="0"
+           italics="0"
+           underlined="0" />
+<!--#define SCE_BIBTEX_ENTRY 1-->
+    <Style name="Entry"
+           index="1"
+           fg="0,0,128"
+           bold="1" />
+<!--#define SCE_BIBTEX_UNKNOWN_ENTRY 2-->
+    <Style name="Unknown Entry"
+           index="2"
+           fg="255,0,0"
+           bold="1" />
+<!--#define SCE_BIBTEX_KEY 3-->
+    <Style name="Key"
+           index="3"
+           fg="160,882,45" />
+<!--#define SCE_BIBTEX_PARAMETER 4-->
+    <Style name="Parameter"
+           index="4"
+           fg="0,0,255" />
+<!--#define SCE_BIBTEX_VALUE 5-->
+    <Style name="Value"
+           index="5"
+           fg="0,0,160"
+           bold="0" />
+<!--#define SCE_BIBTEX_COMMENT 6-->
+    <Style name="Comment"
+           index="6"
+           fg="34,138,34" />
+
+    <Style name="Selection"
+           index="-99"
+           bg="192,192,192" />
+    <Style name="Active line"
+           index="-98"
+           bg="255,255,160" />
+    <Style name="Breakpoint line"
+           index="-2"
+           bg="255,160,160" />
+    <Style name="Debugger active line"
+           index="-3"
+           bg="160,160,255" />
+    <Style name="Compiler error line"
+           index="-4"
+           bg="255,128,0" />
+    <Style name="Matching brace highlight"
+           index="34"
+           bg="128,255,255"
+           bold="1" />
+    <Style name="No matching brace highlight"
+           index="35"
+           fg="255,255,255"
+           bg="255,0,0"
+           bold="1" />
+    <SampleCode value="lexer_bibtex.sample"/>
+<!--    <LanguageAttributes-->
+<!--        LineComment=""-->
+<!--        StreamCommentStart=""-->
+<!--        StreamCommentEnd=""-->
+<!--        BoxCommentStart=""-->
+<!--        BoxCommentMid=""-->
+<!--        BoxCommentEnd=""-->
+<!--        CaseSensitive="1"/>-->
+  </Lexer>
+</CodeBlocks_lexer_properties>
Index: sdk/resources/lexers/lexer_cpp.xml
===================================================================
--- sdk/resources/lexers/lexer_cpp.xml	(revision 6863)
+++ sdk/resources/lexers/lexer_cpp.xml	(working copy)
@@ -124,6 +124,10 @@
                     BoxCommentStart="/* "
                     BoxCommentMid=" * "
                     BoxCommentEnd=" */"
-                    CaseSensitive="1"/>
+                    CaseSensitive="1"
+                    LexerCommentStyles="1,2,3,15,17,18"
+                    LexerCharacterStyles="7"
+                    LexerStringStyles="6,12"
+                    LexerPreprocessorStyles="9"/>
 		</Lexer>
 </CodeBlocks_lexer_properties>
Index: sdk/resources/lexers/lexer_d.xml
===================================================================
--- sdk/resources/lexers/lexer_d.xml	(revision 6863)
+++ sdk/resources/lexers/lexer_d.xml	(working copy)
@@ -75,25 +75,25 @@
 						bg="255,0,0"/>
 				<Keywords>
 						<Language index="0"
-								value="abstract alias align asm assert auto 
-								body bool break byte 
-								case cast catch cdouble cent cfloat char 
-								class const continue creal 
-								dchar debug default delegate delete 
-								deprecated do double 
-								else enum export extern 
-								false final finally float for foreach foreach_reverse function 
-								goto 
-								idouble if ifloat import in inout int interface invariant ireal is 
-								lazy long 
-								macro mixin module 
-								new null out override 
-								package pragma private protected public 
+								value="abstract alias align asm assert auto
+								body bool break byte
+								case cast catch cdouble cent cfloat char
+								class const continue creal
+								dchar debug default delegate delete
+								deprecated do double
+								else enum export extern
+								false final finally float for foreach foreach_reverse function
+								goto
+								idouble if ifloat import in inout int interface invariant ireal is
+								lazy long
+								macro mixin module
+								new null out override
+								package pragma private protected public
 								real ref return
 								scope short static struct super switch synchronized
-								template this throw true try typedef typeid typeof 
-								ubyte ucent uint ulong union unittest ushort 
-								version void volatile 
+								template this throw true try typedef typeid typeof
+								ubyte ucent uint ulong union unittest ushort
+								version void volatile
 								wchar while with"/>
 						<User index="1"/>
 						<Documentation index="2"
@@ -119,6 +119,10 @@
                     BoxCommentStart="/* "
                     BoxCommentMid=" * "
                     BoxCommentEnd=" */"
-                    CaseSensitive="1"/>
+                    CaseSensitive="1"
+                    LexerCommentStyles="1,2,3,4,15,17,18"
+                    LexerCharacterStyles="12"
+                    LexerStringStyles="10,11,18,19"
+                    LexerPreprocessorStyles=""/>
 		</Lexer>
 </CodeBlocks_lexer_properties>
Index: sdk/resources/lexers/lexer_verilog.xml
===================================================================
--- sdk/resources/lexers/lexer_verilog.xml	(revision 6863)
+++ sdk/resources/lexers/lexer_verilog.xml	(working copy)
@@ -119,6 +119,10 @@
         BoxCommentStart="/* "
         BoxCommentMid=" * "
         BoxCommentEnd=" */"
-        CaseSensitive="1"/>
+        CaseSensitive="1"
+        LexerCommentStyles="1,2,3"
+        LexerCharacterStyles=""
+        LexerStringStyles="6,12"
+        LexerPreprocessorStyles="9"/>
   </Lexer>
 </CodeBlocks_lexer_properties>
Index: sdk/resources/lexers/lexer_vhdl.xml
===================================================================
--- sdk/resources/lexers/lexer_vhdl.xml	(revision 6863)
+++ sdk/resources/lexers/lexer_vhdl.xml	(working copy)
@@ -124,9 +124,13 @@
         LineComment="--"
         StreamCommentStart=""
         StreamCommentEnd=""
-        BoxCommentStart=""
-        BoxCommentMid=""
-        BoxCommentEnd=""
-        CaseSensitive="0"/>
+        BoxCommentStart="--"
+        BoxCommentMid="--"
+        BoxCommentEnd="--"
+        CaseSensitive="0"
+        LexerCommentStyles="1,2"
+        LexerCharacterStyles=""
+        LexerStringStyles="4,7"
+        LexerPreprocessorStyles=""/>
   </Lexer>
 </CodeBlocks_lexer_properties>
