Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
lua_debugger_utils.h File Reference
#include <QBrush>
#include <QChar>
#include <QFont>
#include <QHash>
#include <QIcon>
#include <QKeySequence>
#include <QModelIndex>
#include <QSet>
#include <QStandardItem>
#include <QStandardItemModel>
#include <QString>
#include <QStringList>
#include <QTreeView>
#include <QVariant>
#include <QtGlobal>
#include "epan/wslua/wslua_debugger.h"

Go to the source code of this file.

Classes

struct  LuaDbgTreeSectionExpansionState
 
struct  LuaDebuggerPath::VariableRowFields
 
class  LuaDebuggerKeyRouter
 Centralised keyboard-shortcut dispatcher for the Lua debugger dialog's eventFilter(). More...
 
class  LuaDebuggerChangeHighlightTracker
 "Value changed since last pause" highlighter for the Watch and Variables trees. More...
 

Typedefs

using LuaDebuggerPath::TreePathKeyFinder = QStandardItem *(*)(QStandardItem *, const QString &)
 

Enumerations

enum class  LuaDbgBpHeaderIconMode { NoBreakpoints , ActivateAll , DeactivateAll }
 

Functions

QStandardItem * luaDbgWatchRootItem (QStandardItem *item)
 
void luaDbgRecordTreeSectionRootExpansion (QHash< QString, LuaDbgTreeSectionExpansionState > &map, const QString &rootKey, bool expanded)
 Record / clear root-level expansion for rootKey in map. Mutates map in place; collapsing a root with no remembered subpaths drops the entry entirely so the map stays minimal.
 
void luaDbgRecordTreeSectionSubpathExpansion (QHash< QString, LuaDbgTreeSectionExpansionState > &map, const QString &rootKey, const QString &key, bool expanded)
 Add / remove one descendant subpath key under rootKey in map. Mirrors luaDbgRecordTreeSectionRootExpansion: removing the last subpath of a collapsed root erases the root entry too.
 
QStringList luaDbgTreeSectionExpandedSubpaths (const QHash< QString, LuaDbgTreeSectionExpansionState > &map, const QString &rootKey)
 Expanded-descendant subpaths recorded for rootKey, or empty.
 
QString luaDebuggerSettingsFilePath ()
 
QKeySequence luaDbgSeqFromKeyEvent (const QKeyEvent *ke)
 Build a key sequence from a key event for matching against QAction shortcuts. Wraps the Qt5/Qt6 modifier-encoding split so callers do not have to repeat the version check.
 
QString LuaDebuggerItems::rowColumnDisplayText (const QModelIndex &indexInRow, int col)
 
QStandardItem * LuaDebuggerItems::rowCol0 (QStandardItemModel *model, QStandardItem *cell)
 
QStandardItem * LuaDebuggerItems::cellAt (QStandardItemModel *model, QStandardItem *col0, int col)
 
QString LuaDebuggerItems::text (QStandardItemModel *model, QStandardItem *col0, int col)
 
void LuaDebuggerItems::setText (QStandardItemModel *model, QStandardItem *col0, int col, const QString &t)
 
void LuaDebuggerItems::setToolTip (QStandardItemModel *model, QStandardItem *col0, int col, const QString &tip)
 
void LuaDebuggerItems::setFont (QStandardItemModel *model, QStandardItem *col0, int col, const QFont &font)
 
void LuaDebuggerItems::setForeground (QStandardItemModel *model, QStandardItem *col0, int col, const QBrush &brush)
 
void LuaDebuggerItems::setBackground (QStandardItemModel *model, QStandardItem *col0, int col, const QBrush &brush)
 
void LuaDebuggerItems::setIcon (QStandardItemModel *model, QStandardItem *col0, int col, const QIcon &icon)
 
void LuaDebuggerItems::setTextAlignment (QStandardItemModel *model, QStandardItem *col0, int col, Qt::Alignment align)
 
QModelIndex LuaDebuggerItems::indexCol0 (QStandardItemModel *model, QStandardItem *col0)
 
bool LuaDebuggerItems::isExpanded (QTreeView *tree, QStandardItemModel *model, QStandardItem *col0)
 
void LuaDebuggerItems::setExpanded (QTreeView *tree, QStandardItemModel *model, QStandardItem *col0, bool expanded)
 
bool LuaDebuggerPath::watchSpecIsGlobalScoped (const QString &spec)
 
bool LuaDebuggerPath::variablesPathIsGlobalScoped (const QString &path)
 
QString LuaDebuggerPath::changeKey (int stackLevel, const QString &path)
 
QString LuaDebuggerPath::watchSpecFromChangeKey (const QString &key)
 
QString LuaDebuggerPath::stripWatchExpressionErrorPrefix (const QString &errStr)
 
template<class Key , class Map >
bool LuaDebuggerPath::shouldMarkChanged (const Map &baseline, const Key &key, const QString &newVal, bool flashNew=false)
 
QString LuaDebuggerPath::variableSectionRootKeyFromItem (const QStandardItem *item)
 
bool LuaDebuggerPath::watchSpecUsesPathResolution (const QString &spec)
 
QString LuaDebuggerPath::variableTreeChildPath (const QString &parentPath, const QString &nameText)
 
QString LuaDebuggerPath::expressionWatchChildSubpath (const QString &parentSubpath, const QString &nameText)
 
bool LuaDebuggerPath::variableChildrenShouldSortByName (const QString &parentPath)
 
VariableRowFields LuaDebuggerPath::readVariableRowFields (const wslua_variable_t &v, const QString &parentPath)
 
void LuaDebuggerPath::applyVariableExpansionIndicator (QStandardItem *anchor, bool canExpand, bool enabledOnlyPlaceholder, int columnCount)
 
QString LuaDebuggerPath::watchVariablePathForSpec (const QString &spec)
 
QString LuaDebuggerPath::watchResolvedVariablePathForTooltip (const QString &spec)
 
void LuaDebuggerPath::watchRootSetVariablePathRoleFromSpec (QStandardItem *row, const QString &spec)
 
QString LuaDebuggerPath::watchPathOriginSuffix (const QStandardItem *item, const QString &spec)
 
QString LuaDebuggerPath::capWatchTooltipText (const QString &s)
 
QString LuaDebuggerPath::watchPathParentKey (const QString &path)
 
void LuaDebuggerPath::applyWatchChildRowTextAndTooltip (QStandardItem *specItem, const QString &rawVal, const QString &typeText)
 
int LuaDebuggerPath::watchSubpathBoundaryCount (const QString &subpath)
 
QStandardItem * LuaDebuggerPath::findWatchItemBySubpathOrPathKey (QStandardItem *subtree, const QString &key)
 
QStandardItem * LuaDebuggerPath::findVariableTreeItemByPathKey (QStandardItem *subtree, const QString &key)
 
void LuaDebuggerPath::reexpandTreeDescendantsByPathKeys (QTreeView *tree, QStandardItemModel *model, QStandardItem *subtree, QStringList pathKeys, TreePathKeyFinder findByKey)
 
void LuaDebuggerPath::reexpandWatchDescendantsByPathKeys (QTreeView *tree, QStandardItemModel *model, QStandardItem *subtree, QStringList pathKeys)
 
void LuaDebuggerPath::clearWatchFilterErrorChrome (QStandardItem *specItem, QTreeView *tree)
 
void LuaDebuggerPath::applyWatchFilterErrorChrome (QStandardItem *specItem, QTreeView *tree)
 
void LuaDebuggerPath::setupWatchRootItemFromSpec (QStandardItem *specItem, QStandardItem *valueItem, const QString &spec)
 
QStandardItem * LuaDebuggerPath::findVariableItemByPathRecursive (QStandardItem *node, const QString &path)
 
QString LuaDebuggerPath::watchItemExpansionKey (const QStandardItem *item)
 
QIcon luaDbgMakeSelectionAwareIcon (const QIcon &base, const QPalette &palette)
 
QIcon luaDbgPaintedGlyphIcon (const QString &glyph, int side, qreal dpr, const QFont &baseFont, const QColor &color, int margin=1)
 
QIcon luaDbgPaintedGlyphButtonIcon (const QString &glyph, int side, qreal dpr, const QFont &baseFont, const QPalette &palette, int margin=2)
 
QIcon luaDbgBreakpointHeaderIconForMode (const QFont *editorFont, LuaDbgBpHeaderIconMode mode, int headerSide, qreal dpr)
 
void styleLuaDebuggerHeaderBreakpointToggleButton (QToolButton *btn, int side)
 
void styleLuaDebuggerHeaderFittedTextButton (QToolButton *btn, int side, const QFont &titleFont, const QStringList &glyphs)
 
void styleLuaDebuggerHeaderPlusMinusButton (QToolButton *btn, int side, const QFont &titleFont)
 
void styleLuaDebuggerHeaderIconOnlyButton (QToolButton *btn, int side)
 

Variables

constexpr const char * LuaDebuggerSettingsKeys::Theme = "theme"
 
constexpr const char * LuaDebuggerSettingsKeys::DebuggerEnabled = "debuggerEnabled"
 
constexpr const char * LuaDebuggerSettingsKeys::MainSplitter = "mainSplitterState"
 
constexpr const char * LuaDebuggerSettingsKeys::LeftSplitter = "leftSplitterState"
 
constexpr const char * LuaDebuggerSettingsKeys::EvalSplitter = "evalSplitterState"
 
constexpr const char * LuaDebuggerSettingsKeys::SectionVariables = "sectionVariables"
 
constexpr const char * LuaDebuggerSettingsKeys::SectionStack = "sectionStack"
 
constexpr const char * LuaDebuggerSettingsKeys::SectionFiles = "sectionFiles"
 
constexpr const char * LuaDebuggerSettingsKeys::SectionBreakpoints = "sectionBreakpoints"
 
constexpr const char * LuaDebuggerSettingsKeys::SectionEval = "sectionEval"
 
constexpr const char * LuaDebuggerSettingsKeys::SectionSettings = "sectionSettings"
 
constexpr const char * LuaDebuggerSettingsKeys::SectionWatch = "sectionWatch"
 
constexpr const char * LuaDebuggerSettingsKeys::Breakpoints = "breakpoints"
 
constexpr const char * LuaDebuggerSettingsKeys::Watches = "watches"
 
constexpr qint32 FileTreePathRole = static_cast<qint32>(Qt::UserRole)
 
constexpr qint32 FileTreeIsDirectoryRole = static_cast<qint32>(Qt::UserRole + 1)
 
constexpr qint32 BreakpointFileRole = static_cast<qint32>(Qt::UserRole + 2)
 
constexpr qint32 BreakpointLineRole = static_cast<qint32>(Qt::UserRole + 3)
 
constexpr qint32 BreakpointConditionRole = static_cast<qint32>(Qt::UserRole + 30)
 
constexpr qint32 BreakpointHitCountRole = static_cast<qint32>(Qt::UserRole + 31)
 
constexpr qint32 BreakpointHitTargetRole = static_cast<qint32>(Qt::UserRole + 32)
 
constexpr qint32 BreakpointConditionErrRole = static_cast<qint32>(Qt::UserRole + 33)
 
constexpr qint32 BreakpointLogMessageRole = static_cast<qint32>(Qt::UserRole + 34)
 
constexpr qint32 BreakpointHitModeRole = static_cast<qint32>(Qt::UserRole + 35)
 
constexpr qint32 BreakpointLogAlsoPauseRole = static_cast<qint32>(Qt::UserRole + 36)
 
constexpr qint32 StackItemFileRole = static_cast<qint32>(Qt::UserRole + 4)
 
constexpr qint32 StackItemLineRole = static_cast<qint32>(Qt::UserRole + 5)
 
constexpr qint32 StackItemNavigableRole = static_cast<qint32>(Qt::UserRole + 6)
 
constexpr qint32 StackItemLevelRole = static_cast<qint32>(Qt::UserRole + 7)
 
constexpr qint32 VariablePathRole = static_cast<qint32>(Qt::UserRole + 8)
 
constexpr qint32 VariableTypeRole = static_cast<qint32>(Qt::UserRole + 9)
 
constexpr qint32 VariableCanExpandRole = static_cast<qint32>(Qt::UserRole + 10)
 
constexpr qint32 WatchSpecRole = static_cast<qint32>(Qt::UserRole + 11)
 
constexpr qint32 WatchSubpathRole = static_cast<qint32>(Qt::UserRole + 13)
 
constexpr qint32 WatchPendingNewRole = static_cast<qint32>(Qt::UserRole + 15)
 
constexpr qint32 ChangedFlashSerialRole = static_cast<qint32>(Qt::UserRole + 20)
 
constexpr qsizetype WATCH_TOOLTIP_MAX_CHARS = 4096
 
constexpr int WATCH_EXPR_MAX_CHARS = 65536
 
constexpr int CHANGED_FLASH_MS = 500
 
constexpr int WATCH_PLACEHOLDER_DEFER_MS = 250
 
constexpr QChar CHANGE_KEY_SEP = QChar(0x1F)
 
constexpr int kLuaDbgEvalOutputMaxLines = 5000
 
const QKeySequence kLuaDbgCtxGoToLine
 
const QKeySequence kLuaDbgCtxRunToLine
 
const QKeySequence kLuaDbgCtxWatchEdit
 
const QKeySequence kLuaDbgCtxWatchCopyValue
 
const QKeySequence kLuaDbgCtxWatchDuplicate
 
const QKeySequence kLuaDbgCtxWatchRemoveAll
 
const QKeySequence kLuaDbgCtxAddWatch
 
const QKeySequence kLuaDbgCtxToggleBreakpoint
 
const QKeySequence kLuaDbgCtxReloadLuaPlugins
 
const QKeySequence kLuaDbgCtxRemoveAllBreakpoints
 
const QString kLuaDbgHeaderPlus
 
const QString kLuaDbgHeaderMinus
 
const QString kLuaDbgHeaderEdit
 
const QString kLuaDbgRowLog
 
const QString kLuaDbgRowExtras
 
const QString kLuaDbgHeaderRemoveAll
 
const QString kLuaDbgHeaderToolButtonStyle
 

Detailed Description

Shared helpers used across the debugger panels.

Function Documentation

◆ cellAt()

QStandardItem * LuaDebuggerItems::cellAt ( QStandardItemModel *  model,
QStandardItem *  col0,
int  col 
)
inline

Cell in column col for a row whose column-0 anchor is col0.

◆ luaDbgMakeSelectionAwareIcon()

QIcon luaDbgMakeSelectionAwareIcon ( const QIcon &  base,
const QPalette &  palette 
)

Selected-row tint for tree icons (breakpoints / variables / watch).

◆ luaDbgPaintedGlyphButtonIcon()

QIcon luaDbgPaintedGlyphButtonIcon ( const QString &  glyph,
int  side,
qreal  dpr,
const QFont &  baseFont,
const QPalette &  palette,
int  margin = 2 
)

Returns a header-button-flavoured QIcon with two pixmaps painted from glyph: a Normal pixmap in palette.color(Active, ButtonText) and a Disabled pixmap in palette.color(Disabled, ButtonText). The Disabled pixmap is added so QToolButton renders it directly when the button is disabled instead of falling back to QStyle::generatedIcon- Pixmap()'s synthesised filter (which on Linux produces a darker tone than the palette's disabled-text gray used by neighbouring text-only buttons).

◆ luaDbgPaintedGlyphIcon()

QIcon luaDbgPaintedGlyphIcon ( const QString &  glyph,
int  side,
qreal  dpr,
const QFont &  baseFont,
const QColor &  color,
int  margin = 1 
)

Paints glyph centred into a square side x side pixmap (scaled by dpr for HiDPI), sized so the glyph's inked extent fills the cell, and returns it as a QIcon.

◆ luaDbgWatchRootItem()

QStandardItem * luaDbgWatchRootItem ( QStandardItem *  item)
inline

Walk watch-tree items to the top-level row (same row family as WatchSpecRole root).

◆ luaDebuggerSettingsFilePath()

QString luaDebuggerSettingsFilePath ( )

Global personal config path — debugger settings are not profile-specific.

◆ rowCol0()

QStandardItem * LuaDebuggerItems::rowCol0 ( QStandardItemModel *  model,
QStandardItem *  cell 
)
inline

Column-0 item for the same row as cell.

◆ rowColumnDisplayText()

QString LuaDebuggerItems::rowColumnDisplayText ( const QModelIndex &  indexInRow,
int  col 
)
inline

Qt::DisplayRole text for column col in the same row as indexInRow.

Variable Documentation

◆ DebuggerEnabled

constexpr const char* LuaDebuggerSettingsKeys::DebuggerEnabled = "debuggerEnabled"
constexpr

Last toolbar "Enable debugger" checkbox state (persisted across dialog instances).

◆ kLuaDbgEvalOutputMaxLines

constexpr int kLuaDbgEvalOutputMaxLines = 5000
constexpr

Maximum number of lines the Evaluate / logpoint output retains.

◆ kLuaDbgHeaderEdit

const QString kLuaDbgHeaderEdit
extern

Gear (U+2699 + U+FE0E text presentation) for the Edit Breakpoint header button.

◆ kLuaDbgHeaderPlus

const QString kLuaDbgHeaderPlus
extern

Fullwidth +/- and flat tool button style for section headers.

◆ kLuaDbgHeaderRemoveAll

const QString kLuaDbgHeaderRemoveAll
extern

Circled Latin capital letter X (U+24CD) for the Remove All header buttons (Watch and Breakpoints).

◆ kLuaDbgRowExtras

const QString kLuaDbgRowExtras
extern

Reference mark (U+203B) for the Active-column condition / hit-count row indicator.

◆ kLuaDbgRowLog

const QString kLuaDbgRowLog
extern

Three stacked horizontal lines (U+2630 trigram for heaven) for the Active-column logpoint row indicator.