Currently all variables in the top-level are boring green. That's fine for larger files but if you just type a short script, you'd rather have them highlighted. A nice way to solve this would be to always use rainbow colors if there are no functions defined in the file, and the default otherwise. To achieve this, you'd want to look at pythonhighlighting.cpp:useRainbowColor, and return true from that function if the declaration's context() is a) the same as declaration's topContext(), so the declaration is a top-level declaration, and b) all declarations in the declaration's topContext() (use searchInParents=false for the allDeclarations() method call) have "isFunctionDeclaration()" set as false. Otherwise, just return the default. Since this function will be called quite often, the result of b) should be cached in a class member. Reproducible: Always
Correction: instead of looking at isFunctionDeclaration(), it'd be better to look if the declarations' internalContext() is 0 or not, since that'll also catch class declarations.
Git commit 6cc8c6bdfd3692f05d0fa0c4808efdda7efc53a9 by Sven Brauch, on behalf of Benjamin Kaiser. Committed on 26/11/2013 at 16:31. Pushed by brauch into branch 'master'. Rainbow color-highlighting for top-level variables Enable rainbow-color highlighting for top-level variables if there are no class or function declarations. Currently it's also disabled if there are imports, although more by accident than intentionally. REVIEW:114138 GCI-TASK:5846685427171328 M +23 -1 pythonhighlighting.cpp M +4 -0 pythonhighlighting.h http://commits.kde.org/kdev-python/6cc8c6bdfd3692f05d0fa0c4808efdda7efc53a9