Function screenify (o2scl)

O2scl : Function List

template<class string_arr_t>
void o2scl::screenify(size_t nin, const string_arr_t &in_cols, std::vector<std::string> &out_rows, size_t max_size = 80)

Reformat the columns for output of width size.

Given a string array in_cols of size nin, screenify() reformats the array into columns creating a new string array out_rows which are formatted similar to the unix command ls.

For example, for an array of 10 strings

test1
test_of_string2
test_of_string3
test_of_string4
test5
test_of_string6
test_of_string77
test_of_string8
test_of_string9
test_of_string10
screenify() will create an array of 3 new strings:
test1            test_of_string4  test_of_string77 test_of_string10
test_of_string2  test5            test_of_string8
test_of_string3  test_of_string6  test_of_string9

If the value of max_size is less than the length of the longest input string (plus one for a space character), then the output strings may have a larger length than max_size.

Note that this function requires multiple passes through the input string array because it has to determine the maximum width ahead of time.