Color highlighting of xmake plug-in development

2016/07/14 18:04
Reading 437

I have nothing to do recently. I played with the color highlight output of the game terminal, and also supported xmake..

At present, when xmake develops plug-in scripts, in addition to using the built-in print of lua for terminal output, it can also use another interface: cprint Realize color highlight output of terminal

For example:

 cprint('$ {bright}hello  xmake') cprint('$ {red}hello  xmake') cprint('${bright green}hello $ {clear}xmake ') cprint('${blue onyellow underline}hello xmake${clear}') cprint('$ {red}hello  $ {magenta}xmake ') cprint('$ {cyan}hello  ${dim yellow}xmake')

The display results are as follows:

 cprint_colors

Color related descriptions are placed in ${ } Multiple different attributes can be set at the same time, such as:

 ${bright red underline onyellow}

Represented by: highlighted red, yellow background, and sliding line

All these descriptions will affect the following whole line of characters. If you want to display only part of the color text, you can insert it at the end ${clear} Clear front color description

For example:

 $ {red}hello  $ {clear}xmake

In this case, only hello is displayed in red, and others are displayed in black by default.

Other colors belong to. I won't introduce them here one by one, but just paste the attribute list in the xmake code:

 colors.keys =  { --Properties Reset=0 -- Reset attribute , clear=0 -- clear attribute , default=0 -- default attribute , bright=1 -- highlight , dim=2 -- dark , underline=4 -- underline , blink=5 -- blinking , reverse=7 -- reverse color , hidden=8 -- hidden text --Foreground color ,   black       = 30 ,   red         = 31 ,   green       = 32 ,   yellow      = 33 ,   blue        = 34 ,   magenta     = 35  ,   cyan        = 36 ,   white       = 37 --Background color ,   onblack     = 40 ,   onred       = 41 ,   ongreen     = 42 ,   onyellow    = 43 ,   onblue      = 44 ,   onmagenta   = 45 ,   oncyan      = 46 ,   onwhite     = 47

In addition to color highlighting, if your terminal is in a system above lion under Macosx, xmake can also support the display of emoji expressions. For systems that do not support emoji expressions, the display will be ignored, for example:

 cprint("hello xmake${beer}") cprint("hello${ok_hand} xmake")

In the above two lines of code, I printed a classic beer symbol in homebrew, and the following line printed an ok gesture symbol. Isn't it cool..

 cprint_emoji

All emoji expressions and the corresponding keys in xmake can be accessed through Emoji symbol Inside..

Finally, let's go to Zhang and highlight the main menu interface of xmake..

 mainmenu


Expand to read the full text
Loading
Click to join the discussion 🔥 (1) Post and join the discussion 🔥
Reward
one comment
zero Collection
zero fabulous
 Back to top
Top