Back

1     //------------------------------------------------------------------------------
2     // Module ItemStyle.cpp                                                       //
3     //                                                                            //
4     //    Class TItemStyle which represents a syntax highlighting style           //
5     //                                                                            //
6     //    Copyright (c) 2000-2004 by Lars Haendel                                 //
7     //    Home: http://www.newty.de                                               //
8     //                                                                            //
9     //    This program is free software and can be used under the terms of the    //
10    //    GNU licence. See header-file for further information and disclaimer.    //
11    //                                                                            //
12    //------------------------------------------------------------------------------
13
14
15    #include "ItemStyle.h"
16
17    #include <string.h>        // due to:  strcpy
18
19
20    //----------------------------------------------------------------------------------------------------------------------
21    // names of known code items (used to save/load styles)
22    static char szItemName[nItemType][MAX_TYPE_LEN] =
23
24       {  "Background", "Comment", "Keyword", "Identifier", "Symbol", "String", "Number",
25          "Character", "Preprocessor", "Custom1", "Custom2", "Custom3", "Custom4" };
26
27    //----------------------------------------------------------------------------------------------------------------------
28    // Try to identify string as valid item name. Return index if match found, '-1' otherwise.
29    int IdentifyItemName(const char*const& szString)
30    {
31       for(int i=0;i<nItemType;i++)
32          if(strcmp(szItemName[i], szString)==0)
33             return i;
34
35       return -1;
36    }
37
38
39    //----------------------------------------------------------------------------------------------------------------------
40    // return i'th item's name
41    const char* GetItemName(const TItemStyle::ItemType& type)
42    {
43       return szItemName[type];
44    }
45
46
47    //----------------------------------------------------------------------------------------------------------------------
48    // constructor
49    TItemStyle::TItemStyle()
50    {
51       strcpy(szName, "Default");                                 // style's name
52
53       // default bold and italic flags - all false
54       for(int i=0;i<nItemType;i++)
55          f_Bold[i] = f_Italic[i] = false;
56
57
58       // default color strings for the different code items
59       strcpy(szColor[Bkgnd],      /* black        */ "#000000");   // background
60       strcpy(szColor[Comment],    /* light-grey   */ "#cfcfcf");   // comment
61       strcpy(szColor[Keyword],    /* light-cyan   */ "#00ffff");   // keyword
62       strcpy(szColor[Identifier], /* white        */ "#ffffff");   // identifier
63       strcpy(szColor[Symbol],     /* light-cyan   */ "#00ffff");   // symbol
64       strcpy(szColor[String],     /* yellow       */ "#ffff00");   // string
65       strcpy(szColor[Number],     /* lila         */ "#ff00ff");   // number
66       strcpy(szColor[Character],  /* navy         */ "#000080");   // character
67       strcpy(szColor[Preproc],    /* dark-green   */ "#008000");   // preprocessor
68       strcpy(szColor[Custom1],    /* red          */ "#ff0000");   // custom 1
69       strcpy(szColor[Custom2],    /* white        */ "#ffffff");   // custom 2
70       strcpy(szColor[Custom3],    /* white        */ "#ffffff");   // custom 3
71       strcpy(szColor[Custom4],    /* white        */ "#ffffff");   // custom 4
72    }

Top