For those who want KDevelop support highlight for C/C++ symbols.

Huy Cuong Nguyen huyc at iquebec.com
Sat Jul 24 16:40:52 BST 1999


Hi !

I think it would be cool if KDevelop support highlight for C++ symbols. If you
think so and if you want, here is what you should do :

- Get KDevelop code source (version 0.4).
- In file : /path_to_code/kdevelop/kwrite/highlight.h, line 100, add :

class HlCSymbol : public HlItemWw {
  public:
    HlCSymbol(int attribute, int context);
    virtual const char *checkHgl(const char *);
};

- In file : /path_to_code/kdevelop/kwrite/highlight.cpp, line 260 , add :

HlCSymbol::HlCSymbol(int attribute, int context)
: HlItemWw(attribute,context) {
}

bool isCSymbol(char c) {
static char data[]={255,255,255,255,28,128,255,3,255,255,255,151,255,255,255,7};
if (c & 128) return false;
return !(data[c >> 3] & (1 << (c & 7)));
}

const char *HlCSymbol::checkHgl(const char *str) {
  const char *s = str;
  while ( isCSymbol(*s) ) s++;
  if (s > str) return s;
  return 0L;
}

- Now , in this file (highlight.cpp), go to line 785, we are in function void
   GenHighlight::doHighlight (int ctxNum, TextLine *textLine), replace :

       if (item->startEnable(lastChar)) {

by :

       if (item->startEnable(lastChar) || isCSymbol(*s1)) {

and at line 788, replace :

        if (item->endEnable(*s2)) {

by :

         if (item->endEnable(*s2) || isCSymbol(*s1)) {

- Now, in function void CHighlight::createItemData(ItemDataList &list), after
the line 847 :
list.append(new ItemData("Prep.Lib",dsOthers,darkYellow,yellow,false,false)); 
you add :

       list.append(new ItemData("Symbole", dsNormal));

- Last, go to the line 856, after the line:
contextList[0] = c = new HlContext(0,0);
you add :

       c->items.append(new HlCSymbol(13, 0));

- Save the files, recompile KDevelop and replace /usr/bin/kdevelop by the new.
If the compilation has error with kdlgloaker, no problem, you already have the
new exec. file kdevelop in directory /path_to_code/kdevelop/kdevelop

That's all.

Have fun !

________________
Huy Cuong Nguyen
huyc at iquebec.com



More information about the KDevelop mailing list