Provide some utility macros and functions for the KadanoffBaym library.
KadanoffBaym.COLORS
KadanoffBaym.MODES
KadanoffBaym.colorize
KadanoffBaym.line_to_array
KadanoffBaym.prompt
KadanoffBaym.sorry
KadanoffBaym.welcome
KadanoffBaym.@cswitch
KadanoffBaym.@pcs
KadanoffBaym.@time_call
Color Constants
KadanoffBaym.COLORS
— ConstantCOLORS
A global dict, which is used to specify the system colors.
KadanoffBaym.MODES
— ConstantMODES
A 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
end
KadanoffBaym.@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!" green
Colorful 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.