OpenMS
|
#include <OpenMS/APPLICATIONS/ConsoleUtils.h>
Public Member Functions | |
ConsoleUtils (const ConsoleUtils &)=delete | |
Copy C'tor (deleted) More... | |
void | operator= (ConsoleUtils const &)=delete |
Assignment operator (deleted) More... | |
int | getConsoleWidth () const |
width of the console (or INTMAX on internal error) More... | |
Static Public Member Functions | |
static const ConsoleUtils & | getInstance () |
returns the singleton – the only instanciation of this class More... | |
static StringList | breakStringList (const String &input, const Size indentation, const Size max_lines, const Size first_line_prefill=0) |
static String | breakString (const String &input, const Size indentation, const Size max_lines, const Size first_line_prefill=0) |
same as breakStringList(), but concatenates the result using ' ' for convenience More... | |
Private Member Functions | |
ConsoleUtils () | |
C'tor (private) – use ConsoleUtils::getInstance() More... | |
int | readConsoleSize_ () |
read console settings for output shaping More... | |
StringList | breakString_ (const String &input, const Size indentation, const Size max_lines, Size first_line_prefill) const |
returns a console friendly version of input More... | |
Private Attributes | |
int | console_width_ = std::numeric_limits<int>::max() |
width of console we are currently in (if not determinable, set to INTMAX, i.e. not breaks) More... | |
Friends | |
struct | ConsoleWidthTest |
allows us to set console_width to a fixed value for testing More... | |
Determines the width of the console automatically.
To manually force a certain width set the environment variable 'COLUMNS' to a desired value.
|
private |
C'tor (private) – use ConsoleUtils::getInstance()
|
delete |
Copy C'tor (deleted)
|
static |
same as breakStringList(), but concatenates the result using '
' for convenience
|
private |
returns a console friendly version of input
|
static |
Make a string console-friendly by breaking it into multiple lines according to the console width. The 'indentation' gives the number of spaces which is prepended beginning at the second (!) line, so one gets a left aligned block which has some space to the left. An indentation of 0 results in the native console's default behaviour: just break at the end of its width and start a new line. max_lines
gives the upper limit of lines returned after breaking is finished. Excess lines are removed and replaced by '...', BUT the last line will be preserved.
input | String to be split |
indentation | Number of spaces to use for lines 2 until last line (should not exceed the console width) |
max_lines | Limit of output lines (all others are removed) |
first_line_prefill | Assume this many chars were already written in the current line of the console (should not exceed the console width) |
|
inline |
width of the console (or INTMAX on internal error)
|
static |
returns the singleton – the only instanciation of this class
|
delete |
Assignment operator (deleted)
|
private |
read console settings for output shaping
|
friend |
allows us to set console_width to a fixed value for testing
|
private |
width of console we are currently in (if not determinable, set to INTMAX, i.e. not breaks)