terminal/simpleconsole

This is a stupidly simple and somewhat pretty console library. It has very minimal bells and whistles - just pretty output. Use the log module for a more powerful implementation.

Please be warned - if you use a non-monospace font then things might not perfectly line up.

Set this to whatever function you want to be called if fatal is fired.

Types

TraceInfo = object
  sCFunctionName*, sNimProcName*: string
  module*: string
  lineno*: int
  columnno*: int
TraceData = tuple[pname, module: string, lineno: int]

Vars

quitproc = do_quit

Procs

proc do_quit() {...}{.raises: [], tags: [].}
Simple stub do_quit implication - just calls quit(1)
proc fit_terminal(s: string): seq[string] {...}{.raises: [ValueError],
    tags: [ReadEnvEffect].}
Implementation detail leakage
proc traceoutimpl(trace: TraceData; prefix: string; msg: varargs[string, `$`]) {...}{.
    raises: [ValueError, IOError], tags: [WriteIOEffect, ReadEnvEffect].}
Implementation detail leakage.
proc fataloutimpl(trace: TraceData; msg: varargs[string, `$`]) {...}{.
    raises: [ValueError, IOError], tags: [WriteIOEffect, ReadEnvEffect].}
Implementation detail leakage.
proc info(msg: varargs[string, `$`]) {...}{.inline, raises: [ValueError, IOError],
                                       tags: [ReadEnvEffect, WriteIOEffect].}
Emit an info message
proc warn(msg: varargs[string, `$`]) {...}{.inline, raises: [ValueError, IOError],
                                       tags: [ReadEnvEffect, WriteIOEffect].}
Emit a warning message

Templates

template get_trace(): TraceData
Returns trace information for this frame
template debug(msg: varargs[string, `$`]): untyped
Emit a debug message with frame information.
template error(msg: varargs[string, `$`]): untyped
Emit an error message with frame information
template fatal(msg: varargs[string, `$`]): untyped
Emit a fatal message with frame information and invoke quitproc
template checkerror(outcome: bool; msg: string; okay = "success";
                    failed = "failed"): untyped
Helper to emit a specific message if outcome is true, otherwise the fail message. Error edition.
template checkwarn(outcome: bool; msg: string; okay = "success";
                   failed = "failed"): untyped
Helper to emit a specific message if outcome is true, otherwise the fail message. Warning edition.