File: text.h

package info (click to toggle)
snapper 0.10.6-1.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,072 kB
  • sloc: cpp: 24,846; ansic: 1,466; sh: 1,410; makefile: 514; python: 127; ruby: 90
file content (52 lines) | stat: -rw-r--r-- 1,890 bytes parent folder | download | duplicates (4)
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
51
52
/*---------------------------------------------------------------------------*\
                          ____  _ _ __ _ __  ___ _ _
                         |_ / || | '_ \ '_ \/ -_) '_|
                         /__|\_, | .__/ .__/\___|_|
                             |__/|_|  |_|
\*---------------------------------------------------------------------------*/

#ifndef ZYPPER_UTILS_TEXT_H_
#define ZYPPER_UTILS_TEXT_H_

#include <string>
#include <iosfwd>

const char* _(const char* msgid) __attribute__ ((format_arg(1)));

const char* _(const char* msgid, const char* msgid_plural, unsigned long int n)
    __attribute__ ((format_arg(1))) __attribute__ ((format_arg(2)));

/** 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_ */