Qt 4.8
Public Functions | Static Public Functions | Public Variables | Static Public Variables | Private Functions | Properties | List of all members
QPatternist::ColorOutputPrivate Class Reference

Public Functions

 ColorOutputPrivate ()
 
void write (const QString &msg)
 

Static Public Functions

static QString escapeCode (const QString &in)
 

Public Variables

bool coloringEnabled
 
ColorOutput::ColorMapping colorMapping
 
int currentColorID
 

Static Public Variables

static const char *const backgrounds []
 
static const char *const foregrounds []
 

Private Functions

bool isColoringPossible () const
 Returns true if it's suitable to send colored output to stderr. More...
 

Properties

QFile m_out
 

Detailed Description

Definition at line 65 of file qcoloroutput.cpp.

Constructors and Destructors

◆ ColorOutputPrivate()

QPatternist::ColorOutputPrivate::ColorOutputPrivate ( )
inline

Definition at line 68 of file qcoloroutput.cpp.

68  : currentColorID(-1)
69 
70  {
71  /* - QIODevice::Unbuffered because we want it to appear when the user actually calls, performance
72  * is considered of lower priority.
73  */
75 
77  }
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition: qfile.cpp:1064
bool isColoringPossible() const
Returns true if it's suitable to send colored output to stderr.

Functions

◆ escapeCode()

static QString QPatternist::ColorOutputPrivate::escapeCode ( const QString in)
inlinestatic

Definition at line 91 of file qcoloroutput.cpp.

Referenced by QPatternist::ColorOutput::colorify().

92  {
93  QString result;
94  result.append(QChar(0x1B));
95  result.append(QLatin1Char('['));
96  result.append(in);
97  result.append(QLatin1Char('m'));
98  return result;
99  }
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QString & append(QChar c)
Definition: qstring.cpp:1777
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ isColoringPossible()

bool QPatternist::ColorOutputPrivate::isColoringPossible ( ) const
inlineprivate

Returns true if it's suitable to send colored output to stderr.

Definition at line 107 of file qcoloroutput.cpp.

Referenced by ColorOutputPrivate().

108  {
109 # if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
110  /* Windows doesn't at all support ANSI escape codes, unless
111  * the user install a "device driver". See the Wikipedia links in the
112  * class documentation for details. */
113  return false;
114 # else
115  /* We use QFile::handle() to get the file descriptor. It's a bit unsure
116  * whether it's 2 on all platforms and in all cases, so hopefully this layer
117  * of abstraction helps handle such cases. */
118  return isatty(m_out.handle());
119 # endif
120  }
int handle() const
Returns the file handle of the file.
Definition: qfile.cpp:1419

◆ write()

void QPatternist::ColorOutputPrivate::write ( const QString msg)
inline

Definition at line 86 of file qcoloroutput.cpp.

Referenced by QPatternist::ColorOutput::write(), and QPatternist::ColorOutput::writeUncolored().

87  {
88  m_out.write(msg.toLocal8Bit());
89  }
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342

Properties

◆ backgrounds

const char *const ColorOutputPrivate::backgrounds
static
Initial value:
=
{
"0;40",
"0;44",
"0;42",
"0;46",
"0;41",
"0;45",
"0;43"
}

Definition at line 84 of file qcoloroutput.cpp.

Referenced by QPatternist::ColorOutput::colorify(), and isColoringPossible().

◆ coloringEnabled

bool QPatternist::ColorOutputPrivate::coloringEnabled

Definition at line 81 of file qcoloroutput.cpp.

Referenced by QPatternist::ColorOutput::colorify(), and ColorOutputPrivate().

◆ colorMapping

ColorOutput::ColorMapping QPatternist::ColorOutputPrivate::colorMapping

◆ currentColorID

int QPatternist::ColorOutputPrivate::currentColorID

Definition at line 80 of file qcoloroutput.cpp.

Referenced by QPatternist::ColorOutput::colorify().

◆ foregrounds

const char *const ColorOutputPrivate::foregrounds
static
Initial value:
=
{
"0;30",
"0;34",
"0;32",
"0;36",
"0;31",
"0;35",
"0;33",
"0;37",
"1;30",
"1;34",
"1;32",
"1;36",
"1;31",
"1;35",
"1;33",
"1;37"
}

Definition at line 83 of file qcoloroutput.cpp.

Referenced by QPatternist::ColorOutput::colorify(), and isColoringPossible().

◆ m_out

QFile QPatternist::ColorOutputPrivate::m_out
private

Definition at line 102 of file qcoloroutput.cpp.

Referenced by ColorOutputPrivate(), and write().


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