nimcx/cx

Search:
Group by:

::

Library     : nimcx.nim

Module      : cx.nim

Status      : stable

License     : MIT opensource

ProjectStart: 2015-06-20

Latest      : 2023-09-17

Compiler    : latest stable or devel branch

OS          : Linux

Description :
              
              nimcx.nim is a collection of simple procs and templates
              
              for easy colored display in a linux terminal and also contains
              
              a wide selection of utility routines and useable snippets for
              
              your projects , experimentations and tinkering .
              
              The emphasize is on tinkering !
              
              Currently the library consists of
              
              cx.nim , cxconsts.nim , cxglobal.nim , cxprint.nim , cxhash.nim ,
              
              cxtime.nim , cxstats.nim  , cxfont.nim , cxfontconsts.nim , cxzenity.nim
              
              except cxfont , cxfontconsts and cxzenity all files are automatically imported
              
              
              
              if you need cxzenity for gtk3 style data input, it can be imported with
              
              import nimcx/cxzenity

Usage       : import nimcx

Project     : [NimCx](https://github.com/qqtop/NimCx)

Docs        : [Documentation](https://qqtop.github.io/cx.html)

Tested      : Debian , Parrot (Debian Testing)
              
              Terminal set encoding to UTF-8
              
              with var. terminal font : hack,monospace size 9.0 - 15
              
              xterm,konsole,gnome terminals, mate terminal etc. support truecolor ok
              
              for currently best color support use konsole in a qt based system like Tumbleweed

Important   : If the color effects are not here ... change the terminal.
              
              Gnome terminals auto adjust colors not in colorNames see cxConsts.nim
              
              so a command like :
              
              printLn("Nice color 123",newColor(990,9483,88))
              
              may give you a deep red fontcolor in konsole , but may only show in
              
              boring white on a gnome based terminal.
              
              a bash script to show colors and see how your terminal does:
              just paste this into your terminal and press enter ....
              
              for i in {0..255}; do     printf "\x1b[38;5;${i}mcolour${i}\x1b[0m\n"; done


Related     :
             
             * see examples (may or may not be available in current state of tinkering)
             
             * demo library: cxDemo.nim   (rough demos lib) if not found I have forgotton to upload again
             
             * tests       : cxtest.nim   (run some rough demos from cxDemo)


Programming : qqTop

Note        : mileage may vary depending on the available
              
              unicode libraries and terminal support in your system
              
              terminal x-axis position starts with 1 (mostly)
              
              proc fmtx a simple formatting utility has been added and works with strformat too
              
              for printing of multiple columns in the terminal the print,printLn,printBiCol,printLnBiCol
              
              routines should be used for other printjobs see cxprint,cxprintLn
              
              Due to the flurry of updates in the development branch occasional carnage may occur.
              
              Nimcx compiles with --mm:arc and --mm:orc
              
              Nimcx brings in most of the stdlib modules for convenience at the cost
              
              of slightly longer compile times, due to recent changes some modules
              
              will have to be nimble installed if something breaks
              
              
              if you have cloned nimcx lib somewhere you can try one of this compile commands
              
              nim c --cc:clang -d:danger --mm:arc -r cx.nim      (may need sudo apt install libomp-dev)
              
              for a 386 compile on a 86_64 machine try
              
              nim c --cincludes:/usr/include/x86_64-linux-gnu --os:linux --cpu:i386 --passC:-m32 --passL:-m32  --mm:arc -d:release -r cx.nim
              and see it die with
              /usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11: fatal error: gnu/stubs-32.h: No such file or directory
              If this or similar is the case you need to find any missing xxx-32.h files and put them
              into the include path or check the NIM forum for the latest compile information
              Compiling on a pure i386 or arm machine (Raspberry Pi 4) was totally fine  the last time I tried.
              
              Are there parts which could be more efficient  ?  Yes
              Are there parts which could be improved        ?  Yes
              Can naming of variables or procs be better     ?  Yes
              Can this be done better by yourself            ?  Yes
              Is some functionality also available in stdlib ?  Yes
              Do I need this library ? If you enjoy tinkering:  Maybe
              Has it been updated to compile since 2015      ?  Yes
              Does it compile on Android and run in termux   ?  Yes  sometimes

Will you ever need all functions ? No but then you never know

Installation: nimble install nimcx

Optional : xclip (linux clipboard utility)

unicode font libraries as needed

Latest : Restructuring and cleanup is always in progress. Deprecating/removing unused or unnecessary code due to improvements in stdlib is done occasionally

cxfont.nim and cxfontconsts.nim are available for import , but not longer imported in nimcx to avoid code bloat

cxzenity.nim is available but not imported with nimcx it utilises

the OS zenity install do show graphical messageboxes etc

added cxcat proc 2023-09-15

Compile ideas :

nim c --gc:orc --threads:on -d:ssl -d:release --stackTrace:on --lineTrace:on -f -r cx.nim

nim c -d:threads:on -d:ssl -d:danger --gc:arc -d:useMalloc -r -f cx

Fast : nim c --gc:arc --threads:on -d:ssl --stackTrace:off -d:release --d:nimdrnim --passC:-flto -f -r cx

nim c -d:danger --panics:on --threads:on --passC:"-flto -fopt-info-missed" -r -f cx

Small : nim --mm:orc --mm:orc -d:useMalloc --threads:on -d:ssl --define:blas=openblas -d:nimExperimentalLinenoiseExtra -d:danger --stackTrace:off --passC:" -flto " -f -r c cx

Hardcore : nim c --gc:arc --debuginfo -d:useMalloc cx.nim && valgrind -s --leak-check=full ./cx

Debug with gdb: nim c --gc:arc --opt:none --debugger:native disables optimizations and enables debug symbols

Anything nimble : https://github.com/nim-lang/nimble#creating-packag

Types

Benchmarkres = tuple[bname, cpu, epoch, gett, repeats: string]

Vars

benchmarkresults = newSeq(Natural(0))
cxtmpfilenames = newSeq(Natural(0))

Lets

cxarrowseq = @["\e[38;2;253;205;172m→\e[37m", "\e[38;2;173;255;47m↑\e[37m",
               "\e[38;2;0;255;0m↑↑\e[37m", "\e[38;2;255;0;0m↓↓\e[37m",
               "\e[38;2;0;255;255m→↑\e[37m",
               "\e[38;2;255;255;0m→↓\e[37m"]
cxstart = epochTime()
cxstartmTime = getMonoTime()

Procs

proc add(co: ref Cxcounter) {....raises: [], tags: [], forbids: [].}
proc checkClip(sel: string = "primary"): string {.
    ...raises: [OSError, IOError, ValueError],
    tags: [ExecIOEffect, ReadIOEffect, RootEffect], forbids: [].}

checkClip

returns the newest entry from the Clipboard requires xclip to be installed , works provided string does not have special utf8 etc chars experimental since more than one clipboard maybe installed

printLnBiCol("Last Clipboard Entry : " & checkClip())
func checkColor(colname: string): bool {....raises: [], tags: [], forbids: [].}

checkColor

returns true if colname is a known color name in colorNames constants.nim

proc cleanClip() {....raises: [ValueError],
                   tags: [ExecIOEffect, ReadIOEffect, RootEffect], forbids: [].}
cleans the xclip but not other exisiting clipBoards ,which still may contain content
proc colorio() {....raises: [IOError, ValueError, Exception, Exception, IOError,
                          ValueError], tags: [WriteIOEffect, ReadEnvEffect],
                 forbids: [].}

colorio

Displays name,hex code and rgb of colors available in cx.nim

proc cxAlert(xpos: int = 1) {....raises: [IOError, ValueError],
                              tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}

cxAlert

issues an alert

also available printAlertMsg see cxprint.nim

proc cxAlertLn(text: string; xpos: int = 0) {....raises: [IOError, ValueError],
    tags: [WriteIOEffect, TimeEffect], forbids: [].}
simple alert line with timestamp and errormessage
proc cxAlertLn(xpos: int = 1) {....raises: [IOError, ValueError],
                                tags: [WriteIOEffect, ReadEnvEffect],
                                forbids: [].}

cxAlertLn

issues an alert line

also available printLnAlertMsg see cxprint.nim

import nimcx
# try to change the width of the terminal  window
while true:
   if tw < 100:
       infoproc(cxAlertLn(2))
       showTerminalSize()
   else:
       infoproc(printLnOkMsg($(tw),2))
   sleepy(0.5)
proc cxAlertLnFlagMsg(alertmsg: string; xpos: int = 1) {.
    ...raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect],
    forbids: [].}
cxAlertLnFlagMsg requires an alertmsg
func cxBell() {....raises: [], tags: [ExecIOEffect, ReadIOEffect, RootEffect],
                forbids: [].}

cxBell

ring system bell may or may not work

proc cxcat(curFile: string; countphrase: seq[string] = @[];
           linesFlg: bool = true) {....raises: [IOError, ValueError, OSError,
    Exception], tags: [ReadDirEffect, WriteIOEffect, ReadEnvEffect], forbids: [].}

cxcat

same as nimcat but does not specialise for nim if no extension found A simple file lister which shows all rows and some stats. It also allows counting of tokens. A file name without extension will be assuemed to be .nim Countphrase is case sensitive This proc uses memfiles for speed and has an added linesFlg to show or not show Line numbers

cxcat("ducknotes.csv",linesFlg=false)                          # show all lines
cxcat("bigdatafile.csv",linesFlg=false)     # do not show line numbrs
cxcat("/data5/notes.txt",countphrase = @["nice" , "hanya", "88"],linesFlg=true) # also count how often a token appears in the file
proc cxChecked() {....raises: [IOError, ValueError],
                   tags: [WriteIOEffect, TimeEffect], forbids: [].}
simple timestamp line line
proc cxcolor[T](apal: T): string

cxcolor

returns a color from a cxpal , which can be used in cxprintLn and other print routines

cxprintln(3,cxcolor(cxredpal[8]),cxcolorBg(cxgreypal[6]),"NimCx Pallet")
proc cxcolorBg[T](apal: T): string

cxcolorBg

returns a color from a cxpal to be used as background color in cxprintLn and other print routines

cxprintln(3,cxcolor(cxyellowpal[x]),cxcolorBg(cxbluepal[5]),"NimCx Pallet")
proc cxDescribe(text: string) {....raises: [IOError, ValueError],
                                tags: [WriteIOEffect], forbids: [].}
simple info line
proc cxDoubleLine(xpos: int = 0; width: int = tw; fgcol: string = cxgrey1;
                  bgcol: string = cxgrey8; newLine: bool = true) {.
    ...raises: [IOError, ValueError], tags: [WriteIOEffect], forbids: [].}
proc cxFinish(notify: bool = true) {....raises: [IOError, ValueError, Exception,
    OSError], tags: [WriteIOEffect, ReadEnvEffect, ReadIOEffect, TimeEffect,
                     ExecIOEffect, RootEffect, WriteDirEffect], forbids: [].}
proc cxHelp(s: openArray[string]; xpos: int = 2) {.
    ...raises: [IOError, ValueError], tags: [ReadEnvEffect, WriteIOEffect],
    forbids: [].}

cxHelp

a help generator which can easily be called from within or on app start with ability to include code blocks

cxHelp(["Help system for " & extractFileName(getAppFilename()),
     "",
    "1) Read the book",
    "2) use more data",
    "3) have a beer",
    cxcodestart,
    "Example 1",
    "",
    "let abc = @[1,2,3]",
    "    ",
    "var xfg = mysupergenerator(abc,3)",
    cxcodeend,
    "this should be help style again",
    cxcodestart,
    "Example 2  ",
    "",
    "for x in 0..<n:",
    """   printLn("Something Nice  ",blue)"""",
    cxcodeend,
    "Have a nice day"])
proc cxhostnamectl() {....raises: [OSError, IOError, ValueError], tags: [
    ExecIOEffect, ReadIOEffect, RootEffect, WriteIOEffect, ReadEnvEffect],
                       forbids: [].}

cxhostnamectl

wrapper to display hostnamectl output

hostnamectl is available on many systems

proc cxIsNumber(x: string): bool {....raises: [], tags: [], forbids: [].}
isNumber checks if a string can be parsed as a float or an integer
proc cxSingleLine(xpos: int = 0; width: int = tw; fgcol: string = cxgrey1;
                  bgcol: string = cxgrey8; newLine: bool = true) {.
    ...raises: [IOError, ValueError], tags: [WriteIOEffect], forbids: [].}
proc cxSound(soundfile: string = "/usr/lib/libreoffice/share/gallery/sounds/romans.wav") {.
    ...raises: [], tags: [ReadDirEffect, ExecIOEffect, ReadIOEffect, RootEffect],
    forbids: [].}

cxSound

play a sound file with aplay , default is receive.wav , if file and aplay is avaialble

proc dec(co: ref Cxcounter) {....raises: [], tags: [], forbids: [].}
proc doByeBye(xpos: int = 1) {....raises: [IOError, ValueError], tags: [
    WriteDirEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

doByeBye

a simple end program routine do give some feedback when exiting

proc doCxEnd() {....raises: [IOError, ValueError, ValueError, IOError], tags: [
    WriteIOEffect, ReadEnvEffect, TimeEffect, ReadIOEffect, ReadDirEffect,
    ExecIOEffect, RootEffect], forbids: [].}

doCxEnd

short testing routine of cx.nim if run as main

proc doInfo() {....raises: [], tags: [ReadIOEffect, ReadEnvEffect, WriteIOEffect,
                                   TimeEffect, ReadDirEffect], forbids: [].}

doInfo

A more than you want to know information proc

proc generateSysRand(): string {....raises: [OSError], tags: [], forbids: [].}
proc getColorName[T](sc: T): string

getColorName

this functions returns the colorname based on a color escape sequence

usually used with randcol() to see what color was actually returned

referenced colornames defined in cxconstants.nim

import nimcx
for x in 0 ..< 10:
   let acol = randcol()
   let acolname = getColorName(acol)
   printLn(acolname,acol)
proc handler() {.noconv, ...raises: [IOError, ValueError, Exception], tags: [
    WriteIOEffect, WriteDirEffect, ReadEnvEffect, TimeEffect, ReadIOEffect],
                 forbids: [].}

handler

exit handler this runs if ctrl-c is pressed

and provides some feedback upon exit

just by using this module your project will have an automatic

exit handler via ctrl-c

this handler may not work if code compiled into a .dll or .so file

or under some circumstances like being called during readLineFromStdin

proc infoLine(xpos: int = 0) {....raises: [IOError, ValueError, Exception, OSError], tags: [
    WriteIOEffect, ReadEnvEffect, ReadIOEffect], forbids: [].}

infoLine

prints some info about current application

proc lastCompile() {....raises: [IOError, ValueError],
                     tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}
proc makeColor(r: int = getrndint(0, 2550); g: int = getrndint(0, 2550);
               b: int = getrndint(1000, 2550); xpos: int = 1) {.
    ...raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect],
    forbids: [].}

makeColor

a utility function to show random effect of rgb changes see makeColorTest or makeGreyScaleTest for example use

proc makeColorTest() {....raises: [IOError, ValueError],
                       tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}

makeColorTest

testing makeColor proc need to be run in a KDE konsole to see all the colors

proc makeGreyScaleTest(astart: int = 0; aend: int = 255; astep: int = 5) {.
    ...raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect],
    forbids: [].}

makeGreyScaleTest

shows a greyscale table with desired params

proc newColor(r, g, b: int): string {....raises: [IOError, ValueError],
                                      tags: [WriteIOEffect], forbids: [].}

newColor

creates a new color string from r,g,b values. Passed in colors can be used as foregroundcolor in print,printLn routines and as bgr in cxPrint,cxprintLn .

Example

import nimcx
printLn("Test for rgb color 12345  " & efb2 * 10,newColor(27354,4763,1089))
decho()
printLn("Test for rgb color 12345  " & efb2 * 10,newColor(73547,4873,4888))
decho()
printLn("Test for rgb color 12345  " & efb2 * 10,newColor(990,483,38),bgblue)
decho()
# or save it
let mymystiquecolor = newColor2(93547,84873,77888)
printLn("Here we go",mymystiquecolor)
doFinish()
func newColor2(r, g, b: int): string {....raises: [ValueError], tags: [],
                                       forbids: [].}

newColor2

creates a new color string from r,g,b values passed in with styleReverse effect for text best used as backgroundcolor in print, printLn etc. routines

proc newCxCounter(): ref (Cxcounter) {....raises: [], tags: [], forbids: [].}

newCxcounter

set up a new cxcounter

simple counter with add,dec and reset procs

var counter1 = newCxcounter()
counter1.add   # add 1
counter1.dec   # dec 1
counter1.reset # set to 0
echo counter1.value # show current value
proc newDir(dirname: string) {....raises: [ValueError, IOError], tags: [
    ReadDirEffect, WriteDirEffect, WriteIOEffect], forbids: [].}

newDir

creates a new directory and provides some feedback

proc nimcat(curFile: string; countphrase: seq[string] = @[]) {.
    ...raises: [IOError, ValueError, OSError, Exception],
    tags: [ReadDirEffect, WriteIOEffect, ReadEnvEffect], forbids: [].}

nimcat

A simple file lister which shows all rows and some stats. It also allows counting of tokens. A file name without extension will be assuemed to be .nim Countphrase is case sensitive This proc uses memfiles for speed alternatively use cxcat where any line numbers can be omitted

nimcat("notes.txt")                   # show all lines
nimcat("bigdatafile.csv")
nimcat("/data5/notes.txt",countphrase = @["nice" , "hanya", "88"]) # also count how often a token appears in the file
proc printTest(astring: string = "") {....raises: [IOError, ValueError], tags: [
    WriteIOEffect, ReadEnvEffect, ReadIOEffect], forbids: [].}

printTest

prints TEST,the current filename and an optional string

proc qqtop(year: bool = false) {....raises: [IOError, ValueError], tags: [
    WriteIOEffect, ReadEnvEffect, TimeEffect], forbids: [].}
proc qqTopOrig() {....raises: [IOError], tags: [WriteIOEffect], forbids: [].}

qqTop

prints qqTop in custom color

proc remDir(dirname: string): bool {.discardable, ...raises: [IOError, ValueError,
    ValueError, IOError], tags: [WriteIOEffect, ReadEnvEffect, ReadDirEffect,
                                 WriteDirEffect], forbids: [].}

remDir

deletes an existing directory , all subdirectories and files and provides some feedback

root and home directory removal is disallowed

this obviously is a dangerous proc handle with care !!

proc reset(co: ref Cxcounter) {....raises: [], tags: [], forbids: [].}
proc rmTmpFilenames() {....raises: [IOError, ValueError],
                        tags: [WriteDirEffect, WriteIOEffect], forbids: [].}
proc setTerminalTitle(s: string) {....raises: [ValueError], tags: [ExecIOEffect,
    ReadIOEffect, RootEffect], forbids: [].}
Adjust terminal title during long processes
proc showBashZshRc() {....raises: [ValueError, IOError, OSError, Exception], tags: [
    ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect], forbids: [].}
shows bashrc or zshrc without line numbers
proc showBench() {....raises: [IOError, ValueError, Exception],
                   tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}

showBench

Displays results of all benchmarks

proc showColors() {....raises: [IOError, ValueError, Exception],
                    tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}

showColors

display all colorNames in color !

proc showCxPallets() {....raises: [IOError, ValueError], tags: [WriteIOEffect],
                       forbids: [].}
proc showHexColors[T](hcolors: seq[T])

showHexColors

pass in a seq of hexcolors like: myhexcols = @"#F5F5F5","#FFFF00","#9ACD32"

proc showPalette(coltype: string = "white") {.
    ...raises: [IOError, ValueError, Exception],
    tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}

:: showPalette

Displays palette with all coltype as found in colorNames coltype examples : "red","blue","medium","dark","light","pastel" etc..

proc showTerminalSize() {....raises: [IOError, ValueError],
                          tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}

showTerminalSize

displays current terminal dimensions

width is always available via tw

height is always available via th

proc spellFloat(n: float64; currency: bool = false; sep: string = ".";
                sepname: string = " dot "): string {.
    ...raises: [Exception, ValueError], tags: [RootEffect], forbids: [].}

spellFloat

writes out a float number in english with up to 14 positions after the dot currency denotes spelling of an amount sep and sepname can be adjusted as needed default sep = "." default sepname = " dot "

import nimcx
printLn spellFloat(0.00)
printLn spellFloat(234)
printLn spellFloat(-2311.345)
printLn spellFloat(5212311.00).replace("dot","and") & "hundreds"
printLn spellFloat(122311.34,true).replace("dot","dollars and") & " cents"
proc spellInteger(n: int64): string {....raises: [Exception], tags: [RootEffect],
                                      forbids: [].}
proc spellInteger2(n: string): string {....raises: [Exception, ValueError],
                                        tags: [RootEffect], forbids: [].}

spellInteger2

used in after comma part of a float , we just put out the numbers one by one

code adapted from rosettacode and updated

proc tmpFilename(): string {....raises: [IOError, ValueError], tags: [
    ReadEnvEffect, ReadIOEffect, TimeEffect, WriteIOEffect], forbids: [].}
proc tmpFilename(filename: string): string {....raises: [],
    tags: [ReadEnvEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc toClip[T](s: T)

toClip

send a string to the Clipboard using xclip only error messages will shown if any. required xclip to be installed

Converters

converter toChar(x: int): char {....raises: [], tags: [], forbids: [].}
converter toInt(x: char): int {....raises: [], tags: [], forbids: [].}

Templates

template `as`[T, U](x: T; _: typedesc[U]): U
as a type change template
for x in 33..126:
  echo(fmtx(["<3","","","",""],x,spaces(2),x as char,spaces(2),ff2(x as float,3)))
template benchmark(benchmarkName: string; code: typed)

benchmark

a quick benchmark template showing cpu and epoch times without repeat

benchmark("whatever"):
  let z = 0.. 1000
  loopy(z,printLn("Kami makan tiga kali setiap hari.",randcol()))
proc doit() =
     var s = createSeqFloat(10,9)
     var cc = newCxCounter()
     s.sort(system.cmp,order = Descending)
     for x in s:
         cc.add
         cxprintLn(0,fmtx(["",">4","<6","","<f15.7"],yellowgreen,cc.value," :",beige,$x))
 
 var bx = newCxCounter()
 benchmark("doit",10000):
         doit()
         bx.add
         cxprintLn(3,fmtx(["","","","",">8"],greenyellow, " " , uparrow , " Run " , bx.value))
         echo()
 showBench() 
template benchmark(benchmarkName: string; repeatcount: int = 1; code: typed)

benchmark

a quick benchmark template showing cpu and epoch times with repeat looping param suitable for quick in-program timing of procs

benchmark("whatever",1000):
    printLn("Kami makan tiga kali setiap hari.",randcol())
import nimcx,algorithm

proc doit() =
    var s = createSeqFloat(10,9)
    var c = 0
    s.sort(system.cmp,order = Descending)
    for x in s:
        inc c
        printLnBiCol(fmtx([">4","<6","<f15.7"],$c," :",$x))

template cxcounter(bx:int):int =
        inc bx
        bx

var x = 0
benchmark("doit",10000):
        doit()
        hline(30)
        printLn( " " & uparrow & " Run " & $cxcounter(x),greenyellow)
        echo()

showBench()
template checkLocals()

checkLocals

check name,type and value of local variables needs to be called inside a proc ,calling from toplevel has no effect best placed at bottom end of a proc to pick up all Variables

template currentFile(): string

currentFile

returns path and current filename

template cx45Down(): untyped
template cx45Up(): untyped
template cxbg(body: untyped): untyped

cxbg

used to set background colors from cxpallets see cxconsts.nim .. code-block:: nim cxbg(cxbluepal3) cxbg(cxblue3) # is the same , declarations in cxconsts.nim

template cxBlockRegion(name, body: untyped)
cxBlockRegion
template cxDoubleDown(): untyped
template cxDoubleUp(): untyped
template cxfg(body: untyped): untyped

cxfg

to set foreground colors from cxpallets see cxconsts.nim

template cxflat(): untyped
template cxRegion(name, body: untyped)
cxRegion
template cxrv(s: untyped): string

cxrv

color reverser

Example: .. code-block:: nim cxprintln(0,"Nice number ",white,redbg,78.cxrv," test finished ! ",truetomato,"Good test .".cxrv, yellowgreen,"OK".cxrv )

template cxSingleDown(): untyped
template cxSingleUp(): untyped
template cxTimed(body: untyped)
cxTimed simple timing template
template hextoRGB(hexstring: untyped): untyped
template hextoRGBbg(hexstring: untyped): untyped
template infoProc(code: untyped)

infoProc

shows from where a specific function has been called and combined with checkLocals gives a nice formatted output for debugging

proc test1[T](ff:varargs[T,`$`]) =
  let yu1 = @["test"]
  var yu2 = "sdfsdf"
  var yu3 = parseInt(ff[1]) * 3  # ff[1] has been converted to string we change it back to int and multiply
  print("test output    : ",lime)
  for x in ff: print(x & spaces(1)) # print the passed in varargs
  checklocals()

proc test2(s:string,b:int) : string =
   var bb = b * getRndInt(10,200)
   result = s & $bb
   checklocals()

infoproc(test1("zz",1234,789.88))
infoproc:
    printLnBiCol(fmtx(["","",""],"Test2 output  : ",rightarrow & spaces(1),test2("nice",2000)),colLeft = cyan,colRight=gold,":",0,false,{})
doFinish()
template release(): untyped
template toCxOpenarray(aseq: seq[untyped]): untyped

toCxOpenarray

used to pass seqs to procs expecting an openarray type as input, passing a seq would work too but openarray is faster

template uname(): untyped
template zipWith[T1, T2](f: untyped; xs: openArray[T1]; ys: openArray[T2]): untyped
zipWith
var s1 = createSeqInt(5)
var s2 = createSeqInt(5)
var zs = zipWith(`/`,s1,s2)   # try with +,-,*,/,div...
echo zs

original code ex Nim Forum

Exports

CXLIBVERSION, SP, green, tabbutton, indianredbg, cxgrey0, darkgraybg, ghostwhitebg, flag, cpgdn, cxcodeend, cxindigo5, emojis, floralwhitebg, brightblue, rxCol, gainsboro, midnightbluebg, cxteal4, yellowgreen, moccasin, yellowbg, indigobg, oe, cxItalic, termblack, greenbg, mediumpurple, lightslategraybg, cxpink1, cxUnderscore, truetomatobg, dollar, northeastarrow, bigdipbg, cxred1, aqua, termBold, darkkhakibg, southwestarrow, cxred5, kitty, lefttop, bcyan, small, efs2, termmagenta, greenery, zippi, cxpink5, cornsilk, cxblue3, black, cxpink7, cyanbg, mediumblue, lightsalmonbg, cxorange3, efb3, bgreen, cdown, cxgreen2, lightgoldenrodyellow, cfb4, cow, lightskybluebg, leftrightarrow, cshow, blueviolet, clearbos, royalblue, cxpurplepal, cxred4, snowflake, cyan, pastelpinkbg, goldbg, termblue, mediumorchidbg, dodgerbluebg, darkslateblue, CR, pastelblue, violet, cxindigo8, slategraybg, lime, cxReverse, springgreenbg, crimson, powderbluebg, lavenderblushbg, coral, khaki, ivorybg, darkblue, darkgoldenrodbg, leftbottom, lightblue, darkgreenbg, termred, tomato, aquabg, linechar, downarrow, getBg, alicebluebg, rxPastelCol, honeydew, lightgreybg, navajowhite, bred, iso_8601_aws, darkgreen, searrow, uparrow, greenyellow, chocolatebg, truebluebg, sandybrownbg, cxteal7, cxred6, salmonbg, maroonbg, mediumorchid, mediumseagreen, cxblue2, lavender, rightarrow, palegreenbg, scissors, huge, mediumaquamarine, blove, olivebg, brownbg, firebrick, bluebg, purple, gold, cxpurple3, sienna, hand, cxpurple6, rxCards, cxyellow3, lol, cxred8, papayawhip, pastelSet, midnightblue, cxindigo4, paleturquoisebg, smile, rosybrownbg, mediumturquoisebg, perubg, fuchsiabg, darkorangebg, cxpink3, tongue, darkmagentabg, rslash, darkred, navajowhitebg, deeppink, chide, darkolivegreenbg, cxred7, bottomcross, getFg, sun, lightcyanbg, darkorchidbg, beige, udarrow, azure, cxbluepal, ghostwhite, cxDim, deepskyblue, yaleblue, txCol, siennabg, burlywoodbg, cxtodo, cxpink0, darkviolet, cxgrey2, mediumseagreenbg, cxpurple4, bluevioletbg, cpos1, cxyellow5, cxyellow8, cxyellow4, cxpink4, cxblue1, clearbol, plum, bbrightgreen, cend, teal, blush, moccasinbg, cxpalnames, cxteal1, darkstar, backspacebutton, pastelyellow, cxColorNames, southeastarrow, cxindigo6, pink, cxBright, cfb2, lemonchiffon, enterkey, saddlebrown, pastelwhite, azurebg, cxcodestart, cxpinkpal, nwarrow, cxgrey5, bbrightcyan, turquoise, salmon, cornsilkbg, cadetbluebg, magenta, cins, cxteal8, wideDot, whitesmokebg, colorNames, cxteal6, bbrightblack, termcyan, mediumpurplebg, pastelbeige, cxteal5, mintcream, goldenrod, khakibg, brightcyan, pastelwhitebg, yellow, wheat, pastelbluebg, zippibg, cat, mistyrose, cxgreenpal, cxpink8, tanbg, northwestarrow, lightsalmon, cadetblue, truetomato, lightyellowbg, mediumturquoise, aquamarine, lawngreenbg, enterbutton, lrarrow, forestgreenbg, cxyellow6, cornflowerblue, pastelyellowbg, peachpuff, cxblue0, nearrow, cup, bigdip, blueybg, cxpurple1, seagreenbg, topcross, silver, aquamarinebg, seashellbg, cxpurple5, mediumvioletred, cxpals, thistle, roof, palegreen, darkslategray, vertlinechar, yellowgreenbg, cxorange7, goldenrodbg, cxpurple7, righttop, darkseagreen, lavenderbg, cxgrey4, cxgrey7, greenerybg, lawngreen, cright, kotakp, graybg, cxgreen6, bbrightmagenta, whitebg, brightgreen, blanchedalmond, cxorange6, pastelorange, termNegative, peru, pastelgreenbg, magentabg, lemonchiffonbg, lightskyblue, navybg, termItalic, palegoldenrod, byellow, gray, silverbg, snowbg, nimcxl, cleareol, cxblue7, firebrickbg, ue, pastelpink, cxyellow1, darkcyan, darkturquoise, mistyrosebg, floralwhite, yalebluebg, brightwhite, LF, skybluebg, saddlebrownbg, termyellow, bbrightblue, cxtealpal, bblack, red, cxindigo1, sandybrown, csave, check, antiquewhite, wheatbg, cxorange0, cxred2, cxgrey3, paleturquoise, xmark, RuneEmpty, slatebluebg, violetbg, bwhite, cxgrey8, termwhite, efb1, mediumspringgreenbg, cxblue4, gainsborobg, cxteal3, darkgoldenrod, euro, blanchedalmondbg, orchidbg, lightgrey, cry, termBlink, darkgray, linenbg, updownaarrow, lightpinkbg, redbg, ae, slategray, cross, steelblue, cxpurple2, kotakk, cxorange4, fuchsia, lavenderblush, lightcoralbg, skull, sigma, termUnderline, palevioletredbg, cxwarn, darksalmon, darkcyanbg, hexColorNames, umbrella, phone, mediumslatebluebg, darksalmonbg, trademark, pastelyellowgreen, beigebg, darrow, resetcols, dimgray, seagreen, efl1, royalbluebg, darkvioletbg, white, orange, cxyellow2, navy, cards, lightgoldenrodyellowbg, whitesmoke, termStrikethrough, tealbg, chartreusebg, mintcreambg, rcross, honeydewbg, swarrow, dodgerblue, palegoldenrodbg, brown, cxindigo7, lightslategray, antiquewhitebg, cxindigo2, indianred, sad, pastelorangebg, brightred, cleareos, satblue, darkbluebg, peachpuffbg, lightsteelblue, chocolate, music, cxblue5, ael, turquoisebg, seashell, aliceblue, cxgreen7, bisque, olivedrab, earthTones, termClear, cxpink6, pastelgreen, olive, darkslatebluebg, darkslategraybg, forestgreen, indigo, mediumbluebg, bmagenta, cxReverseDim, plumbg, smiley, lightpink, cxgreen0, cfb5, efb2, cxgrey6, lightseagreen, cxindigo3, bbrightred, larrow, thistlebg, cxindigopal, cxgreen3, darkseagreenbg, coralbg, mediumaquamarinebg, cxReverseBright, deeppinkbg, clearline, cxgreen5, darkkhaki, cxpurple8, bisquebg, cxred3, cxgreen8, hotpink, cxorange1, orangered, mediumslateblue, cxgreypal, rosybrown, darkmagenta, darkolivegreen, cxyellowpal, cxgreen4, steelbluebg, heart, mediumvioletredbg, brightsatbluebg, crestore, lightgreen, oel, cxredpal, cpgup, brightmagenta, star, rightbottom, darkorchid, orangebg, pastelbeigebg, CRLF, burlywood, chartreuse, zyclambg, cxgrey1, fullflag, pinkbg, cxorange8, copyright, skyblue, darkredbg, limebg, darkorange, cxblue6, lightbluebg, termgreen, cxgreen1, mediumspringgreen, cxorangepal, limegreenbg, cxteal2, dimgraybg, cxred0, lightseagreenbg, cxblue8, zyclam, rage, brightblack, loopedsquare, darkturquoisebg, uel, cxpurple0, deepskybluebg, oldlace, limegreen, bluey, cleft, cornflowerbluebg, cxindigo0, bbrightwhite, cxNoStyle, powderblue, oldlacebg, purplebg, olivedrabbg, clearscreen, cxorange2, lightgreenbg, cxblack, cdel, lightsteelbluebg, pastelyellowgreenbg, ejm3, palevioletred, ejm4, tens, efr1, bbrightyellow, ivory, uarrow, tomatobg, orchid, cxyellow0, linen, hotpinkbg, trueblue, brightsatblue, bblue, efr2, tan, greenyellowbg, lightcyan, innocent, cxorange5, errorsymbol2, lcross, crimsonbg, orangeredbg, cxpink2, blue, cxBlink, slateblue, monkey, cxteal0, lightyellow, cxyellow7, yen, brightyellow, blackbg, lightcoral, snow, papayawhipbg, springgreen, satbluebg, maroon, leftarrow, reverseMe, colPaletteName, getEmojisSmall, curSet, rndStr, getRndInt, cxPos, clearup, centerPos, toki, showSeq, getPrimeSeq, newWord3, cxVideoInfo, withFile, product, loopy2, cxtoLower, curOff, genMacAddress, getAscii, quickPw, isEmpty, createSeqBool, showRune, newWord, fmtx, checkMemFull, *, showRandomCard, uniform, spiralBoxy2, getRandomFloat, getRndBool, cxnormal, sumc, remapFloatToInt, toTwInt, cxnormal, getCard, fibi, aPaletteSample, getRandomPoint, cxLpdx, randPastelCol, unquote, memCheck, getProjectDir, remapToString, utf8info, randpos, isBlank, span, newLine, fullGcStats, createSeqIching, tupleTypes, cpuInfo, showRuler, createSeqBinary, createSeqHiragana, cxLpadN, createSeqCJK, distanceTo, fromCString, cxYesNo, shift, colPaletteLen, getRandomSignF, getRndFloat, cxgetType, rndCol, colPalette, superHeader, reverseIter, boxy, hdx, newWordCJK, unidecodeU, getPointInSphere, boxy2, colPaletteIndexer, superHeader, createSeqAll, centerX, [], primey, fastWrite, curBk, cxind, th, getUserName, createSeqFloat, pathsandsettings, getRandomSignI, curFw, ff2, stripper, procName, createSeqInt, cxBinomialCoeff, newWord2, lowerCase, tupleToStr, newHiragana, curSetx, cxpad, RpointFloat, currentLine, reverseText, ff, styledEchoPrint, doFlag, ff2Eu, paletix, quickClean, checkPrime, cxIsDigit, centerMark, showHostNameCtl, isNumeric, doSomething, getPassword, createRandomDataFile, pswwaux, cxCpuInfo, bitCheck, showCpuCores, reverse, loopy, fastsplit, createSeqKatakana, seqRight, spiralBoxy, sum, getRandomPointInCircle, splitty, cxpdx, seqLeft, rndRGB, newText, upperCase, checkMem, getRandomPoint, cxLpad, showEmojisSmall, createSeqApl, rndSample, cxLpadN, curUp, randCol, colorsPalette, streamFile, quickBinaryString, curMove, sampleSeq, createSeqGeoshapes, curDn, toEnum, RpointInt, cxInput, tw, createSeqFractur, reverseString, stripFirstLast, cxlastN, quickLargeInt, remapIntToFloat, randCol2, seqHighLite, <>, curOn, cleanScreen, cxSeqToStr, newKatakana, createSeqBoxChars, showCpuInfo, cxDayOfWeek, cxDuration, printLnDateMsg, day, Cxtimerres, showTimerResults, printLnDTimeMsg, cxToday, cxTz, saveTimerResults, plusDays, lapTimer, resetTimer, getNextMonday, getMsecs, validDate, createSeqDate, clearTimerResults, cxLocal, getRndDate, cxSystemUptime, month, createSeqDate, year, cxDateTime, compareDates, printDTimeMsg, printLnTimeMsg, sleepy, isoweek, duration, printDateMsg, cxTimeZone, CxTimer, getAmzDateString, cxHRTimer, datetimeunpack, cxTime, newCxtimer, printTimeMsg, clearAllTimerResults, cxNow, minusDays, cxtimerresults, startTimer, Cxcounter, stopTimer, showTimerResults, printCodeMsg, printErrorMsg, singleLine, printLnEelpMsg, printLnHelpMsg, printInfoMsg, printBErrorMsg, cxHorizontal, printLnFailMsg, Cxline, printEelpMsg, printStatusMsg, printHelpMsg, printf, printLnBelpMsg, doubleLine, printBiCol, msgLeftWidth, printRainbow, cxprint, newCxlineText, newCxLine, printLn, dprint, printLnBAlertMsg, printLnStatusMsg, dlineLn, printPassMsg, cxwriteLn, printLnInfoMsg, hline, printAlertMsg, printFailMsg, printLnErrorMsg, printLnAlertMsg, cxwrite, cxVertical, printLnOkMsg, hlineLn, printCxLine, printLnRainbow, printLnCodeMsg, dotyLn, CxlineText, printBAlertMsg, CxLineType, printLnBiCol, print, printLnHL, printLnPassMsg, decho, cxprintxy, printHL, pdebug, printBelpMsg, printLnBErrorMsg, printOKMsg, cxprintLn, dline, doty, checkHash, createHash, verifyHash, getGitHash, localRouterIp, showDig, showLocalIpInfo, cxDig, showMyIdentIP, myIdentIP, getWanIp2, localIp, cxDns, parseIps, showDns, showIpInfo, getWanIP, pingy, getHosts, getIpInfo, cxPortCheck, wifiStatus, showHosts, showWanIpInfo, median, showRegression, zscore, showStats, rolling_zscore, showRegression