Pretty Diagnostics
Create your own pretty diagnostics
Loading...
Searching...
No Matches
pretty_diagnostics Namespace Reference

Namespaces

namespace  color
 
namespace  Colors
 
namespace  Glyphs
 

Data Structures

struct  ColorSet
 Collection of color styles used for semantic highlighting. More...
 
struct  Config
 Configuration options for the TextRenderer. More...
 
class  FileGroup
 Groups LineGroups belonging to the same Source More...
 
class  FileSource
 A Source implementation that reads from a file on disk. More...
 
struct  GlyphSet
 Collection of glyphs used for rendering text-based UI elements. More...
 
class  IReporterRenderer
 Interface implemented by renderers that turn reports into output (e.g., text) More...
 
class  Label
 Represents a short textual annotation attached to a Span in a source. More...
 
class  LineGroup
 A set of labels that belong to the same 0-based line number. More...
 
class  Location
 A position inside a Source, expressed as (row, column, index) More...
 
class  Report
 Represents a fully constructed diagnostic report to be rendered. More...
 
class  Source
 Abstract interface for reading and mapping source text. More...
 
class  Span
 Represents a contiguous region within a Source More...
 
class  StringSource
 A Source implementation that reads from an in-memory string. More...
 
class  TextRenderer
 A plain-text renderer for diagnostic Reports. More...
 
struct  VisualChar
 A structure to contian the return values from get_visual_char More...
 

Enumerations

enum class  Severity { Error , Warning , Info , Unknown }
 Indicates the importance of a diagnostic. More...
 

Functions

std::string escape_string (std::string_view input)
 Escapes control characters and quotes in a string for safe display. For example, converts newlines to "\\n" and tabs to "\\t". More...
 
template<typename T >
max (T first)
 Returns the maximum of a single value. More...
 
template<typename T , typename... Ts>
max (T first, Ts... rest)
 Returns the maximum of multiple values. More...
 
template<typename T >
min (T first)
 Returns the minimum of a single value. More...
 
template<typename T , typename... Ts>
min (T first, Ts... rest)
 Returns the minimum of multiple values. More...
 
size_t get_stream_width (const std::ostream &stream)
 
VisualChar get_visual_char (std::string_view input, size_t index)
 Returns the visual width and byte count of a given UTF8 character. More...
 
size_t visual_width (std::string_view input)
 Calculates the visual display width of a UTF-8 string (for terminal display) More...
 
size_t to_visual_column (std::string_view line, size_t byte_column)
 Returns the visual column of a specific byte column in a UTF-8 string. More...
 
size_t from_visual_column (std::string_view line, size_t visual_column)
 Maps a visual column to a UTF-8 byte index in a line. More...
 

Enumeration Type Documentation

◆ Severity

enum class pretty_diagnostics::Severity
strong

Indicates the importance of a diagnostic.

Enumerator
Error 

Serious problem that usually prevents progress.

Warning 

Suspicious or suboptimal situation.

Info 

Informational message.

Unknown 

Unspecified or not set.

Function Documentation

◆ escape_string()

std::string pretty_diagnostics::escape_string ( std::string_view  input)

Escapes control characters and quotes in a string for safe display. For example, converts newlines to "\\n" and tabs to "\\t".

Parameters
inputInput string view to escape
Returns
A newly allocated escaped string suitable for diagnostics output

◆ from_visual_column()

size_t pretty_diagnostics::from_visual_column ( std::string_view  line,
size_t  visual_column 
)

Maps a visual column to a UTF-8 byte index in a line.

Parameters
lineInput UTF-8 string view (usually a single line)
visual_column0-based visual column into line
Returns
0-based visual column index

◆ get_stream_width()

size_t pretty_diagnostics::get_stream_width ( const std::ostream &  stream)

◆ get_visual_char()

VisualChar pretty_diagnostics::get_visual_char ( std::string_view  input,
size_t  index 
)

Returns the visual width and byte count of a given UTF8 character.

Parameters
inputThe input stringview that contains the UTF8 character
indexThe index at which the character is located
Returns

◆ max() [1/2]

template<typename T >
T pretty_diagnostics::max ( first)

Returns the maximum of a single value.

Template Parameters
TType of the value (supports <)
Parameters
firstThe value
Returns
The value itself

◆ max() [2/2]

template<typename T , typename... Ts>
T pretty_diagnostics::max ( first,
Ts...  rest 
)

Returns the maximum of multiple values.

Template Parameters
TType of the first argument (supports <)
TsTypes of remaining arguments
Parameters
firstFirst argument
restRemaining arguments
Returns
Maximum value among all arguments

◆ min() [1/2]

template<typename T >
T pretty_diagnostics::min ( first)

Returns the minimum of a single value.

Template Parameters
TType of the value (supports <)
Parameters
firstThe value
Returns
The value itself

◆ min() [2/2]

template<typename T , typename... Ts>
T pretty_diagnostics::min ( first,
Ts...  rest 
)

Returns the minimum of multiple values.

Template Parameters
TType of the first argument (supports <)
TsTypes of remaining arguments
Parameters
firstFirst argument
restRemaining arguments
Returns
Minimum value among all arguments

◆ to_visual_column()

size_t pretty_diagnostics::to_visual_column ( std::string_view  line,
size_t  byte_column 
)

Returns the visual column of a specific byte column in a UTF-8 string.

Parameters
lineInput UTF-8 string view (usually a single line)
byte_column0-based byte column into line
Returns
0-based visual column index

◆ visual_width()

size_t pretty_diagnostics::visual_width ( std::string_view  input)

Calculates the visual display width of a UTF-8 string (for terminal display)

ASCII characters count as 1, most 3- and 4-byte characters (CJK, emojis) as 2. Invalid UTF-8 bytes are counted as width 1.

Parameters
inputInput UTF-8 string view
Returns
Visual width in terminal columns