Provide some utility macros and functions for the KadanoffBaym library.
KadanoffBaym.COLORSKadanoffBaym.MODESKadanoffBaym.colorizeKadanoffBaym.line_to_arrayKadanoffBaym.promptKadanoffBaym.sorryKadanoffBaym.welcomeKadanoffBaym.@cswitchKadanoffBaym.@pcsKadanoffBaym.@time_call
Color Constants
KadanoffBaym.COLORS — ConstantCOLORSA global dict, which is used to specify the system colors.
KadanoffBaym.MODES — ConstantMODESA global dict, which is used to specify the mode for output characters.
Macros
KadanoffBaym.@cswitch — Macro@cswitch(constexpr, body)Provides a C-like switch statement with the falling through behavior. This implementation was borrowed from the following github repository:
- https://github.com/Gnimuc/CSyntax.jl
Examples
engine = get_d("engine")
@cswitch engine begin
@case "vasp"
just_do_it()
break
@default
sorry()
break
endKadanoffBaym.@time_call — Macro@time_call(ex)Evaluate a function call (ex), and then print the elapsed time (number of seconds) it took to execute.
This macro is a variation of the standard @elapsed macro.
KadanoffBaym.@pcs — Macro@pcs(x...)Try to print colorful strings. Here x is a combination of strings and colors. Its format likes string1 color1 string2 color2 (repeat). For the supported colors, please check the global dict COLORS.
Examples
julia> @pcs "Hello world!" blue
julia> @pcs "Hello " red "world!" greenColorful Outputs
KadanoffBaym.welcome — Functionwelcome()Print out the welcome messages to the screen.
Arguments
N/A
Returns
N/A
KadanoffBaym.sorry — Functionsorry()Print an error message to the screen.
KadanoffBaym.prompt — Functionprompt(msg::String)Print a stylized KadanoffBaym message to the screen.
Input/Output Operations
KadanoffBaym.line_to_array — Functionline_to_array(io::IOStream)Convert a line (reading from an IOStream) to a string array.
line_to_array(str::AbstractString)Convert a string (AbstractString) to a string array.
Color Tools
KadanoffBaym.colorize — Functioncolorize(
c::String,
s::String;
bg::String = "default",
m::String = "default"
)Return some escape sequences, which will be displayed as colorized texts in the terminal.
Arguments
- c -> Color names.
- s -> The string that want to be printed.
- bg -> Background color.
- m -> Mode for output string.
colorize(
c::Symbol,
s::String;
bg::String = "default",
m::String = "default"
)Return some escape sequences, which will be displayed as colorized texts in the terminal.