10

For my C++ development I am running KDevelop on Ubuntu Natty, I have two questions:

1) It highlights all my variables in random rainbow colors - how can I change that? I want all my variables in light blue.

2) The functions color is always purple, how can I change that?

I'd appreciate if someone knows the answer.

Thank you!!

vincegata
  • 121
  • 1
  • 5
  • I didn't know people were actually using KDevelop. How is that working out for you? – Arlen Jun 16 '11 at 01:12
  • 2
    I am evaluating the switch to KDevelop after having tried many other alternatives for PHP development. I am sick of Eclipse, Netbeans and the others, which are all Java-based, slow as hell, and complicated like no other software on earth... It's quite good. Only showstopper is that you can't debug PHP projects... – Palantir May 19 '12 at 08:49

3 Answers3

7

The answer to both your questions is simple: at the moment you cannot.

You can make sure that all variables are highlighted in the same color, but this color will be black and cannot be changed. Go to

Settings -> Configure KDevelop... -> Language Support

And make sure that in the Semantic Code Highlighting part both Local Colorization Intensity and Global Colorization Intensity are set to zero (i.e. slide the slider to the left).

However, why would you want this? Personally, I find it very convenient to have a different color for every variable. It lets you very easily spot all occurrences of a particular variable.

mtvec
  • 17,846
  • 5
  • 52
  • 83
  • The default setting gave me a bit of a headache :) Sliding those cursors just a bit to the left and the pain was gone. Thanks for sharing this, would have never figured out... – Palantir May 19 '12 at 08:50
  • even set to 0, the variables are not black :/ quite weird such a functionality couldn't be disabled O.O – hl037_ Oct 23 '14 at 16:24
  • I find it very annoying honestly, too many colors on screen and the syntax becomes a mess to make out. I personally prefer things more like what IDEA delivers, but IDEA can't work with C/++. – Tcll Oct 31 '20 at 11:08
  • Can't believe after 11 years this is still a question.. > However, why would you want this? Personally, Exactly.. "personally" - people are different. I was tearing (what remains of) my hair out trying to figure out why the syntax highlighting scheme I created wasn't being reflected in the editor. This setting needs to be moved to (or at least linked to) the colour scheme editor. – Micha Oct 20 '22 at 06:32
0

Yeah... the source code is quite "poor"... there are many hard coded values with no options to change them... Fortunately, it's open source ;)

I ran out with the same problem : I agree, the rainbow color increase readability in some ways but personally, it distracts me... So I did this patch to kdevplatform :

  diff -aur -x '*.user' -x CMakeFiles kdevplatform-1.7.0-o/language/highlighting/colorcache.cpp kdevplatform-1.7.0-n/language/highlighting/colorcache.cpp
  --- kdevplatform-1.7.0-o/language/highlighting/colorcache.cpp 2014-08-26 19:49:48.000000000 +0000
  +++ kdevplatform-1.7.0-n/language/highlighting/colorcache.cpp 2014-10-23 19:50:37.667559094 +0000
  @@ -43,37 +43,38 @@

  #define ifDebug(x)

  -// ######### start interpolation
  +//// ######### start interpolation

  -uint totalColorInterpolationStepCount = 6;
  -uint interpolationWaypoints[] = {0xff0000, 0xff9900, 0x00ff00, 0x00aaff, 0x0000ff, 0xaa00ff};
  -//Do less steps when interpolating to/from green: Green is very dominant, and different mixed green tones are hard to distinguish(and always seem green).
  -uint interpolationLengths[] = {0xff, 0xff, 0xbb, 0xbb, 0xbb, 0xff};
  -
  -uint totalGeneratedColors = 10;
  -
  -uint totalColorInterpolationSteps()
  -{
  -  uint ret = 0;
  -  for(uint a = 0; a < totalColorInterpolationStepCount; ++a)
  -    ret += interpolationLengths[a];
  -  return ret;
  -}
  -
  -///Generates a color from the color wheel. @param step Step-number, one of totalColorInterpolationSteps
  -QColor interpolate(uint step)
  -{
  -  uint waypoint = 0;
  -  while(step > interpolationLengths[waypoint]) {
  -    step -= interpolationLengths[waypoint];
  -    ++waypoint;
  -  }
  -
  -  uint nextWaypoint = (waypoint + 1) % totalColorInterpolationStepCount;
  -
  -  return KColorUtils::mix( QColor(interpolationWaypoints[waypoint]), QColor(interpolationWaypoints[nextWaypoint]),
  -                           float(step) / float(interpolationLengths[waypoint]) );
  -}
  +//uint totalColorInterpolationStepCount = 6;
  +//uint interpolationWaypoints[] = {0xff0000, 0xff9900, 0x00ff00, 0x00aaff, 0x0000ff, 0xaa00ff};
  +////Do less steps when interpolating to/from green: Green is very dominant, and different mixed green tones are hard to distinguish(and always seem green).
  +//uint interpolationLengths[] = {0xff, 0xff, 0xbb, 0xbb, 0xbb, 0xff};
  +
  +//uint totalGeneratedColors = 10;
  +
  +//uint totalColorInterpolationSteps()
  +//{
  +//  uint ret = 0;
  +//  for(uint a = 0; a < totalColorInterpolationStepCount; ++a)
  +//    ret += interpolationLengths[a];
  +//  return ret;
  +//}
  +
  +/////Generates a color from the color wheel. @param step Step-number, one of totalColorInterpolationSteps
  +
  +//QColor interpolate(uint step)
  +//{
  +//  uint waypoint = 0;
  +//  while(step > interpolationLengths[waypoint]) {
  +//    step -= interpolationLengths[waypoint];
  +//    ++waypoint;
  +//  }
  +
  +//  uint nextWaypoint = (waypoint + 1) % totalColorInterpolationStepCount;
  +
  +//  return KColorUtils::mix( QColor(interpolationWaypoints[waypoint]), QColor(interpolationWaypoints[nextWaypoint]),
  +//                           float(step) / float(interpolationLengths[waypoint]) );
  +//}

  // ######### end interpolation
  namespace KDevelop {
  @@ -144,6 +145,7 @@
     m_defaultColors = new CodeHighlightingColors(this);

     m_colors.clear();
  +  /*
     uint step = totalColorInterpolationSteps() / totalGeneratedColors;
     uint currentPos = m_colorOffset;
     ifDebug(kDebug() << "text color:" << m_foregroundColor;)
  @@ -152,6 +154,7 @@
     ifDebug(kDebug() << "color" << a << "interpolated from" << currentPos << " < " << totalColorInterpolationSteps() << ":" << (void*) m_colors.last().rgb();)
     currentPos += step;
     }
  +  */
     m_validColorCount = m_colors.count();
     m_colors.append(m_foregroundColor);
  }

it removes the color generated, so that variables are now really black (foreground color).

for the 2) it seems the current version respects the kate syntax color (not sure).

on Archlinux I also did this PKGBUILD :

  pkgname=kdevplatform-no-rainbow-highlight
  _pkgname=kdevplatform without rainbow colors highlighting
  pkgver=1.7.0
  _pkgver=4.7.0
  pkgrel=2
  pkgdesc="A C/C++ development platform for KDE"
  arch=('i686' 'x86_64')
  url="http://www.kdevelop.org/"
  license=('GPL')
  provides=('kdevplatform')
  conflicts=('kdevplatform')
  depends=('kdelibs' 'subversion' 'qjson')
  optdepends=("kdesdk-kompare: difference checking")
  makedepends=('cmake' 'automoc4' 'boost')
  install="${_pkgname}.install"
  source=("http://download.kde.org/stable/kdevelop/${_pkgver}/src/${_pkgname}-${pkgver}.tar.xz"
        "no-rainbow-color.patch"
  )
  sha1sums=('9fc196e7cb09ab33fd5cfbf5af19aa7c513efdc9'
           'bed3c7e470a6a5a56bf1611e0effd7b8a8761e33')

  prepare() {
  cd ${_pkgname}-${pkgver}
  patch -p1 -i ${srcdir}/no-rainbow-color.patch
  cd ${srcdir}
  mkdir build
  }

  build() {
  cd build
  cmake ../${_pkgname}-${pkgver} \
     -DCMAKE_INSTALL_PREFIX=/usr \
     -DCMAKE_SKIP_RPATH=ON \
     -DCMAKE_BUILD_TYPE=Release
  make
  }

  package() {
  cd build
  make DESTDIR="${pkgdir}" install
  }
hl037_
  • 3,520
  • 1
  • 27
  • 58
-2

Do not get rid of variables with different colors, you will ask yourself how you did in the past without it.

Gaetano Mendola
  • 1,344
  • 3
  • 12
  • 27
  • 7
    For future reference, only answer a question if you actually plan on answering the question at hand. If you want to share your opinion go to chat. – Randy the Dev Jan 28 '13 at 22:21