Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::svg::TerminalImageViewer Class Reference

Terminal image sampler for quarter- and half-pixel block glyphs. More...

#include "donner/svg/renderer/TerminalImageViewer.h"

Public Member Functions

TerminalImage sampleImage (const TerminalImageView &image, const TerminalImageViewerConfig &config) const
void render (const TerminalImageView &image, std::ostream &output, const TerminalImageViewerConfig &config={}) const
int calculateITermImageRows (int imageWidth, int imageHeight, int widthPercent, const TerminalSize &terminalSize, const TerminalCellSize &cellSize) const
 Calculate how many terminal rows an iTerm inline image will occupy.

Static Public Member Functions

static TerminalImageViewerConfig DetectConfigFromEnvironment ()
 Probe environment variables to infer terminal config and capabilities.
static TerminalSize DetectTerminalSize ()
 Detect terminal size using ioctl (TIOCGWINSZ).
static TerminalCellSize DetectTerminalCellSize ()
 Detect terminal cell size using ioctl (TIOCGWINSZ).

Detailed Description

Terminal image sampler for quarter- and half-pixel block glyphs.

Member Function Documentation

◆ calculateITermImageRows()

int donner::svg::TerminalImageViewer::calculateITermImageRows ( int imageWidth,
int imageHeight,
int widthPercent,
const TerminalSize & terminalSize,
const TerminalCellSize & cellSize ) const

Calculate how many terminal rows an iTerm inline image will occupy.

Parameters
imageWidthWidth of the image in pixels
imageHeightHeight of the image in pixels
widthPercentWidth percentage parameter passed to iTerm (e.g., 30 for "30%")
terminalSizeTerminal size in columns and rows
cellSizeTerminal cell size in pixels
Returns
Number of terminal rows the image will occupy

◆ DetectTerminalCellSize()

TerminalCellSize donner::svg::TerminalImageViewer::DetectTerminalCellSize ( )
static

Detect terminal cell size using ioctl (TIOCGWINSZ).

Returns
Terminal cell size in pixels, with defaults if detection fails.

◆ DetectTerminalSize()

TerminalSize donner::svg::TerminalImageViewer::DetectTerminalSize ( )
static

Detect terminal size using ioctl (TIOCGWINSZ).

Returns
Terminal size in columns and rows, with defaults if detection fails.

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