Separated Ninja theme with correct handling of scale
Add a flag for user defined colormaps in the context. Do not overload the colormap if the user changed it. Inherit the Ninja theme from the cmake one. Explanations about themes in the README.
This commit is contained in:
parent
200f1cd1f3
commit
9fd0df9963
4 changed files with 47 additions and 9 deletions
19
README.md
19
README.md
|
|
@ -266,3 +266,22 @@ cmake and g++ themes:
|
|||
You then can use the `cm` alias as a prefix to your build command,
|
||||
for example: `cm make test`
|
||||
|
||||
|
||||
### Themes
|
||||
|
||||
You can easily add your own theme to colout.
|
||||
A theme is basically a module with a function named `theme` that take the configuration context as an argument and
|
||||
return back the (modified) context and a list of triplets.
|
||||
Each triplet figures the same arguments than those of the command line interface.
|
||||
|
||||
def theme(context):
|
||||
return context,[ [regexp, colors, styles] ]
|
||||
|
||||
With the context dictionary at hand, you have access to the internal configuration of colout, you can thus change colormaps for
|
||||
special keywords, the scale, even the available colors, styles or themes.
|
||||
|
||||
See the cmake theme for how to modify an existing colormap if (and only if) the user didn't ask for an
|
||||
alternative one.
|
||||
See the ninja theme for how to extend an existing theme with more regexps and a different configuration.
|
||||
See the gcc theme for an example of how to use the localization of existing softwares to build translated regexp.
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ context["colormaps"]["Hash"] = context["colormaps"]["Rainbow"]
|
|||
context["colormaps"]["default"] = context["colormaps"]["spectrum"]
|
||||
context["colormaps"]["Default"] = context["colormaps"]["Spectrum"]
|
||||
|
||||
context["user_defined_colormaps"] = False
|
||||
|
||||
context["colormap_idx"] = 0
|
||||
|
||||
context["scale"] = (0,100)
|
||||
|
|
@ -100,6 +102,7 @@ def set_special_colormaps( cmap ):
|
|||
context["colormaps"]["Default"] = cmap
|
||||
context["colormaps"]["random"] = cmap
|
||||
context["colormaps"]["Random"] = cmap
|
||||
context["user_defined_colormaps"] = True
|
||||
logging.debug("user-defined special colormap: %s" % ",".join([str(i) for i in cmap]) )
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,11 @@ def theme(context):
|
|||
# actions taking an unknown time
|
||||
untimed="blue"
|
||||
|
||||
# A palette that goes: purple, orange, white
|
||||
percs = [45, 39, 33, 27, 21, 57, 63, 62, 98, 97, 133, 132, 138, 173, 172, 208, 214, 220, 226, 228, 229, 230, 231, 255]
|
||||
context["colormaps"]["Scale"] = percs
|
||||
# If the user do not ask for his own colormap
|
||||
if not context["user_defined_colormaps"]:
|
||||
# A palette that goes: purple, orange, white
|
||||
percs = [45, 39, 33, 27, 21, 57, 63, 62, 98, 97, 133, 132, 138, 173, 172, 208, 214, 220, 226, 228, 229, 230, 231, 255]
|
||||
context["colormaps"]["Scale"] = percs
|
||||
|
||||
return context,[
|
||||
# Configure...
|
||||
|
|
@ -31,9 +33,6 @@ def theme(context):
|
|||
# Link (make)
|
||||
[ "^(Linking .* )(library|executable) (.*/)*(.+(\.[aso]+)*)$",
|
||||
untimed, "normal,normal,bold" ],
|
||||
# Link (ninja)
|
||||
[ "^\[[0-9/]+\]\s?(Linking .* )(library|executable) (.*/)*(.+(\.[aso]+)*)$",
|
||||
untimed, "normal,normal,bold" ],
|
||||
# [percent] Built
|
||||
[ "^\[\s*[0-9/]+%?\]\s(Built target)(\s.*)$",
|
||||
performed, "normal,bold" ],
|
||||
|
|
@ -47,7 +46,5 @@ def theme(context):
|
|||
[ "make\[[0-9]+\].*", "yellow"],
|
||||
[ "(make: \*\*\* \[.+\] )(.* [0-9]+)", "red", "normal,bold"],
|
||||
# progress percentage (make)
|
||||
[ "^(\[\s*[0-9]+%\])","Scale" ],
|
||||
# progress percentage (ninja)
|
||||
[ "^(\[[0-9]+/[0-9]+\])","Scale" ]
|
||||
[ "^(\[\s*[0-9]+%\])","Scale" ]
|
||||
]
|
||||
|
|
|
|||
19
colout/colout_ninja.py
Normal file
19
colout/colout_ninja.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
import colout_cmake
|
||||
|
||||
def theme(context):
|
||||
# Ninja theme
|
||||
|
||||
# Inherit from the CMake theme
|
||||
context,th = colout_cmake.theme(context)
|
||||
|
||||
# Because Ninja note progress as a fraction, we do not want the scale of a percentage
|
||||
context["scale"] = (0,1)
|
||||
|
||||
# Link (ninja)
|
||||
th.append( [ "^\[[0-9/]+\]\s?(Linking .* )(library|executable) (.*/)*(.+(\.[aso]+)*)$",
|
||||
"blue", "normal,normal,bold" ] )
|
||||
# progress percentage (ninja)
|
||||
th.append( [ "^(\[[0-9]+/[0-9]+\])","Scale" ] )
|
||||
|
||||
return context,th
|
||||
Loading…
Add table
Add a link
Reference in a new issue