Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
ByteViewTextCells Class Reference

Maps packet bytes to the character cells drawn in the text panel. More...

#include <byte_view_text_cells.h>

Classes

struct  Cell
 One displayed unit of text and the bytes it stands for. More...

Public Types

enum  Encoding { Ascii , Ebcdic , Utf8 }
 Character encoding of the data. More...
enum  CellKind { Printable , NonPrintable , Invalid }
 How a cell is displayed. More...

Public Member Functions

void decode (const QByteArray &data, Encoding encoding)
 Replace the cells with a decoding of data.
void clear ()
 Remove all cells.
int cellCount () const
Cell cellAt (int cell_index) const
 Return the cell at cell_index.
int cellIndexForByte (int offset) const
 Return the index of the cell that contains offset.
bool cellForByte (int offset, Cell &cell) const
 Return the cell that contains offset.

Static Public Attributes

static const int max_cell_bytes = 32
 Longest run of bytes kept as a single cell.

Detailed Description

Maps packet bytes to the character cells drawn in the text panel.

Every byte of the data belongs to exactly one cell. Single-byte encodings produce one cell per byte; those cells are computed on demand and take no memory. UTF-8 produces one cell per grapheme cluster, so combining marks, emoji modifier and ZWJ sequences, flags and keycap sequences stay together and their cell covers all of their bytes; those cells are decoded once and stored compactly.

Cells are listed in byte order. No bidirectional reordering or shaping is applied, so that the text panel keeps lining up with the hex panel.

Member Enumeration Documentation

◆ CellKind

How a cell is displayed.

Enumerator
Printable 

Drawn as-is.

NonPrintable 

Control, format or whitespace character; drawn as a dot.

Invalid 

Bytes that are not valid in the encoding; drawn as a dot.

◆ Encoding

Character encoding of the data.

Enumerator
Ascii 

7-bit ASCII; bytes >= 0x80 are not printable.

Ebcdic 

EBCDIC, mapped to ASCII before display.

Utf8 

UTF-8, one cell per grapheme cluster.

Member Function Documentation

◆ cellAt()

ByteViewTextCells::Cell ByteViewTextCells::cellAt ( int cell_index) const

Return the cell at cell_index.

Parameters
cell_indexA cell index in [0, cellCount()).

◆ cellCount()

int ByteViewTextCells::cellCount ( ) const
Returns
The number of cells.

◆ cellForByte()

bool ByteViewTextCells::cellForByte ( int offset,
Cell & cell ) const

Return the cell that contains offset.

Parameters
offsetA byte offset.
cellReceives the cell.
Returns
true if offset is in range.

◆ cellIndexForByte()

int ByteViewTextCells::cellIndexForByte ( int offset) const

Return the index of the cell that contains offset.

Parameters
offsetA byte offset.
Returns
The cell index, or -1 if offset is out of range.

◆ decode()

void ByteViewTextCells::decode ( const QByteArray & data,
Encoding encoding )

Replace the cells with a decoding of data.

Parameters
dataThe bytes to decode.
encodingThe character encoding to decode them with.

Member Data Documentation

◆ max_cell_bytes

const int ByteViewTextCells::max_cell_bytes = 32
static

Longest run of bytes kept as a single cell.

Grapheme clusters longer than this are split into one cell per code point.


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