KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cprintf.m File Reference

CPRINTF displays styled formatted text in the Command Window. More...

Go to the source code of this file.

Functions

function count = cprintf (style, format, varargin)
 CPRINTF displays styled formatted text in the Command Window. More...
 
function [
underlineFlag ,
boldFlag , style ] = 
cprintf>processStyleInfo (style)
 
function
styleName = 
cprintf>getColorStyle (rgb)
 
function delta = cprintf>getUrlsFix (docElement)
 
function  cprintf>fixHyperlink (docElement)
 
function  cprintf>setElementStyle (docElement, style, specialFlag, majorVersion, minorVersion)
 
function  cprintf>dumpElement (docElements)
 
function cells = cprintf>m2c (data)
 
function  cprintf>showDemo (majorVersion, minorVersion)
 

Detailed Description

CPRINTF displays styled formatted text in the Command Window.

Definition in file cprintf.m.

Function Documentation

function count = cprintf (   style,
  format,
  varargin 
)

CPRINTF displays styled formatted text in the Command Window.

Syntax
count = cprintf(style,format,...)
Description
CPRINTF processes the specified text using the exact same FORMAT arguments accepted by the built-in SPRINTF and FPRINTF functions.

CPRINTF then displays the text in the Command Window using the specified STYLE argument. The accepted styles are those used for Matlab's syntax highlighting (see: File / Preferences / Colors / M-file Syntax Highlighting Colors), and also user-defined colors.

The possible pre-defined STYLE names are
   <tt>Text</tt>                 - default: black
   <tt>Keywords</tt>             - default: blue
   <tt>Comments</tt>             - default: green
   <tt>Strings</tt>              - default: purple
   <tt>UnterminatedStrings</tt>  - default: dark red
   <tt>SystemCommands</tt>       - default: orange
   <tt>Errors</tt>               - default: light red
   <tt>Hyperlinks</tt>           - default: underlined blue

   <tt>Black</tt>,<tt>Cyan</tt>,<tt>Magenta</tt>,<tt>Blue</tt>,<tt>Green</tt>,<tt>Red</tt>,<tt>Yellow</tt>,<tt>White</tt>
STYLE beginning with - or _ will be underlined. For example
-Blue is underlined blue, like Hyperlinks; _Comments is underlined green etc.
STYLE beginning with * will be bold (R2011b+ only). For example
*Blue is bold blue; *Comments is bold green etc. Note: Matlab does not currently support both bold and underline, only one of them can be used in a single cprintf command. But of course bold and underline can be mixed by using separate commands.

STYLE also accepts a regular Matlab RGB vector, that can be underlined and bolded: -[0,1,1] means underlined cyan, *[1,0,0] is bold red.

STYLE is case-insensitive and accepts unique partial strings just like handle property names.

CPRINTF by itself, without any input parameters, displays a demo

Example
cprintf; % displays the demo cprintf(text, regular black text); cprintf(hyper, followed s,by); cprintf(key, d colored, 4); cprintf(-comment,& underlined); cprintf(err, elements
); cprintf(cyan, cyan); cprintf(_green, underlined green); cprintf(-[1,0,1], underlined magenta); cprintf([1,0.5,0],and multi-
line orange
); cprintf(*blue, and bold (R2011b+ only)
); cprintf(string); % same as fprintf(string) and cprintf(text,string)
Bugs and suggestions
Please send to Yair Altman (altmany at gmail dot com)
Warning
This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7+, but use at your own risk!
A technical description of the implementation can be found at
http://UndocumentedMatlab.com/blog/cprintf/
Limitations
  1. In R2011a and earlier, a single space char is inserted at the beginning of each CPRINTF text segment (this is ok in R2011b+).
  2. In R2011a and earlier, consecutive differently-colored multi-line CPRINTFs sometimes display incorrectly on the bottom line.
As far as I could tell this is due to a Matlab bug. Examples
>> cprintf(-str,under
^line
); cprintf(err,red
); % hidden red, unhidden _ >> cprintf(str,regu
lar
); cprintf(err,red
); % underline red (not purple) lar
  1. Sometimes, non newline (
    )-terminated segments display unstyled (black) when the command prompt chevron (>>) regains focus on the continuation of that line (I can't pinpoint when this happens). To fix this, simply newline-terminate all command-prompt messages.
  2. In R2011b and later, the above errors appear to be fixed. However, the last character of an underlined segment is not underlined for some unknown reason (add an extra space character to make it look better)
  3. In old Matlab versions (e.g., Matlab 7.1 R14), multi-line styles only affect the first line. Single-line styles work as expected. R14 also appends a single space after underlined segments.
  4. Bold style is only supported on R2011b+, and cannot also be underlined.
Change log
2012-08-09: Graceful degradation support for deployed (compiled) and non-desktop applications; minor bug fixes 2012-08-06: Fixes for R2012b; added bold style; accept RGB string (non-numeric) style 2011-11-27: Fixes for R2011b 2011-08-29: Fix by Danilo (FEX comment) for non-default text colors 2011-03-04: Performance improvement 2010-06-27: Fix for R2010a/b; fixed edge case reported by Sharron; CPRINTF with no args runs the demo 2009-09-28: Fixed edge-case problem reported by Swagat K 2009-05-28: corrected nargout behavior sugegsted by Andreas G�b 2009-05-13: First version posted on MathWorks File Exchange
See Also
sprintf, fprintf

Definition at line 17 of file cprintf.m.

References all().

Referenced by MUnit.RunClassTests(), models.BaseFirstOrderSystem.setConfig(), and approx.BaseApprox.test_ApproxProjections().

Here is the call graph for this function:

Here is the caller graph for this function:

function cprintf>dumpElement (   docElements)

Definition at line 521 of file cprintf.m.

References t.

function cprintf>fixHyperlink (   docElement)

Definition at line 407 of file cprintf.m.

function styleName = cprintf>getColorStyle (   rgb)

Definition at line 385 of file cprintf.m.

function delta = cprintf>getUrlsFix (   docElement)

Definition at line 395 of file cprintf.m.

function cells = cprintf>m2c (   data)

Definition at line 577 of file cprintf.m.

function [underlineFlag , boldFlag , style ] = cprintf>processStyleInfo (   style)

Definition at line 298 of file cprintf.m.

References all().

Here is the call graph for this function:

function cprintf>setElementStyle (   docElement,
  style,
  specialFlag,
  majorVersion,
  minorVersion 
)

Definition at line 437 of file cprintf.m.

function cprintf>showDemo (   majorVersion,
  minorVersion 
)

Definition at line 583 of file cprintf.m.