Provide some utility macros and functions for the KadanoffBaym library.

Color Constants

KadanoffBaym.COLORSConstant
COLORS

A global dict, which is used to specify the system colors.

KadanoffBaym.MODESConstant
MODES

A global dict, which is used to specify the mode for output characters.

Macros

KadanoffBaym.@cswitchMacro
@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_callMacro
@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.@pcsMacro
@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

See also: COLORS, welcome.

Colorful Outputs

KadanoffBaym.welcomeFunction
welcome()

Print out the welcome messages to the screen.

Arguments

N/A

Returns

N/A

KadanoffBaym.promptFunction
prompt(msg::String)

Print a stylized KadanoffBaym message to the screen.

Input/Output Operations

KadanoffBaym.line_to_arrayFunction
line_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.colorizeFunction
colorize(
    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.