File: text.h

package info (click to toggle)
snapper 0.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,576 kB
  • ctags: 2,049
  • sloc: cpp: 15,605; sh: 11,424; ansic: 1,401; makefile: 287; python: 159
file content (50 lines) | stat: -rw-r--r-- 1,789 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*---------------------------------------------------------------------------*\
                          ____  _ _ __ _ __  ___ _ _
                         |_ / || | '_ \ '_ \/ -_) '_|
                         /__|\_, | .__/ .__/\___|_|
                             |__/|_|  |_|
\*---------------------------------------------------------------------------*/

#ifndef ZYPPER_UTILS_TEXT_H_
#define ZYPPER_UTILS_TEXT_H_

#include <string>
#include <iosfwd>

std::string _(const char* msgid);
std::string _(const char* msgid, const char* msgid_plural, unsigned long int n);

/** Returns the column width of a multi-byte character string \a str */
unsigned mbs_width (const std::string & str);

/**
 * Wrap and indent given \a text and write it to the output stream \a out.
 *
 * TODO
 * - delete whitespace at the end of lines
 * - keep one-letter words with the next
 *
 * \param out       output stream to write to
 * \param test      text to wrap
 * \param indent    number of columns by which to indent the whole text
 * \param wrap_width number of columns the text should be wrapped into
 * \param initial   number of columns by which the first line should be indented
 *                  by default, the first line is indented by \a indent
 *
 */
void mbs_write_wrapped (
    std::ostream & out,
    const std::string & text,
    unsigned indent, unsigned wrap_width, int initial = -1);

/**
 * Returns a substring of a multi-byte character string \a str starting
 * at screen column \a pos and being \a n columns wide, as far as possible
 * according to the multi-column characters found in \a str.
 */
std::string mbs_substr_by_width(
    const std::string & str,
    std::string::size_type pos,
    std::string::size_type n = std::string::npos);

#endif /* ZYPPER_UTILS_TEXT_H_ */