libyui-ncurses
Loading...
Searching...
No Matches
NCWordWrapper Class Reference

#include <NCWordWrapper.h>

Collaboration diagram for NCWordWrapper:

Public Member Functions

 NCWordWrapper ()
 
void setText (const std::wstring &origText)
 
void setLineWidth (int width)
 
int lines ()
 
const std::wstring & wrappedText ()
 
const std::wstring & origText () const
 
int lineWidth () const
 
void wrap ()
 
void clear ()
 

Static Public Member Functions

static std::wstring normalizeWhitespace (const std::wstring &orig)
 

Protected Member Functions

void ensureWrapped ()
 
std::wstring nextLine (std::wstring &unwrapped)
 

Protected Attributes

std::wstring _origText
 
std::wstring _wrappedText
 
int _lineWidth
 
int _lines
 
bool _dirty
 

Detailed Description

Helper class to word-wrap text into a specified maximum line width. Whitespace is normalized in the process, i.e. any sequence of whitespace (blanks, newlines, tabs, ...) is replaced by a single blank. All lines end with a single newline character except the last one which has no newline.

Constructor & Destructor Documentation

◆ NCWordWrapper()

NCWordWrapper::NCWordWrapper ( )

Constructor.

Member Function Documentation

◆ clear()

void NCWordWrapper::clear ( )

Clear the old content.

◆ ensureWrapped()

void NCWordWrapper::ensureWrapped ( )
protected

Do the wrapping if necessary.

◆ lines()

int NCWordWrapper::lines ( )

Return the number of lines after wrapping the original text.

◆ lineWidth()

int NCWordWrapper::lineWidth ( ) const
inline

Return the last used maximum line width.

◆ nextLine()

wstring NCWordWrapper::nextLine ( std::wstring &  unwrapped)
protected

Return the next line that fits into the line width and removed it from 'unwrapped'.

◆ normalizeWhitespace()

wstring NCWordWrapper::normalizeWhitespace ( const std::wstring &  orig)
static

Return a string where any sequence of whitespace in the original text is replaced with a single blank and without leading or trailing whitespace.

◆ origText()

const std::wstring & NCWordWrapper::origText ( ) const
inline

Return the original unwrapped text.

◆ setLineWidth()

void NCWordWrapper::setLineWidth ( int  width)

Set the maximum line width to wrap into.

◆ setText()

void NCWordWrapper::setText ( const std::wstring &  origText)

Set the original text to wrap.

◆ wrap()

void NCWordWrapper::wrap ( )

Do the wrapping.

This normally doesn't need to be called manually; it is done automatically when retrieving the wrapped text or the number of wrapped lines (and when the internal 'dirty' flag is set).

But it can be useful to call it manually for debugging and testing.

◆ wrappedText()

const wstring & NCWordWrapper::wrappedText ( )

Wrap the original text and return the wrapped text.


The documentation for this class was generated from the following files: