Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Macros | Functions | Variables
lua_debugger_utils.cpp File Reference
#include <config.h>
#include "lua_debugger_utils.h"
#include "ui_lua_debugger_dialog.h"
#include <QAbstractItemModel>
#include <QAction>
#include <QApplication>
#include <QBrush>
#include <QCoreApplication>
#include <QFontMetricsF>
#include <QGuiApplication>
#include <QKeyEvent>
#include <QKeySequence>
#include <QList>
#include <QMetaObject>
#include <QObject>
#include <QPainter>
#include <QPalette>
#include <QPen>
#include <QPersistentModelIndex>
#include <QPixmap>
#include <QPointer>
#include <QSizePolicy>
#include <QStandardItem>
#include <QStandardItemModel>
#include <QStyle>
#include <QTimer>
#include <QToolButton>
#include <QTreeView>
#include <QWidget>
#include <algorithm>
#include <glib.h>
#include "app/application_flavor.h"
#include "lua_debugger_breakpoints.h"
#include "lua_debugger_code_editor.h"
#include "lua_debugger_dialog.h"
#include "lua_debugger_pause.h"
#include "wsutil/filesystem.h"
#include <epan/prefs.h>
#include <epan/wslua/wslua_debugger.h>
#include <ui/qt/utils/color_utils.h>
#include <ui/qt/utils/qt_ui_utils.h>

Macros

#define LUA_DEBUGGER_SETTINGS_FILE   "lua_debugger.json"
 

Functions

QString luaDebuggerSettingsFilePath ()
 
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.
 
const QKeySequence kLuaDbgCtxGoToLine (QKeySequence(Qt::CTRL|Qt::Key_G))
 
const QKeySequence kLuaDbgCtxRunToLine (QKeySequence(Qt::CTRL|Qt::Key_F10))
 
const QKeySequence kLuaDbgCtxWatchEdit (Qt::Key_F2)
 
const QKeySequence kLuaDbgCtxWatchCopyValue (QKeySequence(Qt::CTRL|Qt::SHIFT|Qt::Key_C))
 
const QKeySequence kLuaDbgCtxWatchDuplicate (QKeySequence(Qt::CTRL|Qt::SHIFT|Qt::Key_D))
 
const QKeySequence kLuaDbgCtxWatchRemoveAll (QKeySequence(Qt::CTRL|Qt::SHIFT|Qt::Key_K))
 
const QKeySequence kLuaDbgCtxAddWatch (QKeySequence(Qt::CTRL|Qt::SHIFT|Qt::Key_W))
 
const QKeySequence kLuaDbgCtxToggleBreakpoint (QKeySequence(Qt::CTRL|Qt::SHIFT|Qt::Key_B))
 
const QKeySequence kLuaDbgCtxReloadLuaPlugins (QKeySequence(Qt::CTRL|Qt::SHIFT|Qt::Key_L))
 
const QKeySequence kLuaDbgCtxRemoveAllBreakpoints (QKeySequence(Qt::CTRL|Qt::SHIFT|Qt::Key_F9))
 
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.
 
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)
 
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 luaDbgBreakpointHeaderIconForMode (const QFont *editorFont, LuaDbgBpHeaderIconMode mode, int headerSide, qreal dpr)
 
QIcon luaDbgPaintedGlyphIcon (const QString &glyph, int side, qreal dpr, const QFont &baseFont, const QColor &color, int margin)
 
QIcon luaDbgPaintedGlyphButtonIcon (const QString &glyph, int side, qreal dpr, const QFont &baseFont, const QPalette &palette, int margin)
 
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)
 
QIcon luaDbgMakeSelectionAwareIcon (const QIcon &base, const QPalette &palette)
 

Variables

const QString kLuaDbgHeaderPlus {QStringLiteral("\uFF0B")}
 
const QString kLuaDbgHeaderMinus {QStringLiteral("\uFF0D")}
 
const QString kLuaDbgHeaderEdit {QStringLiteral("\u2699")}
 
const QString kLuaDbgHeaderRemoveAll {QStringLiteral("\u24CD")}
 
const QString kLuaDbgRowLog {QStringLiteral("\u2630")}
 
const QString kLuaDbgRowExtras {QStringLiteral("\u2699")}
 
const QString kLuaDbgHeaderToolButtonStyle {QStringLiteral("QToolButton { border: none; padding: 0px; margin: 0px; }")}
 

Detailed Description

Shared helpers used across the debugger panels.

Function Documentation

◆ 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.

◆ luaDebuggerSettingsFilePath()

QString luaDebuggerSettingsFilePath ( )

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

Variable Documentation

◆ kLuaDbgHeaderEdit

const QString kLuaDbgHeaderEdit {QStringLiteral("\u2699")}

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

◆ kLuaDbgHeaderPlus

const QString kLuaDbgHeaderPlus {QStringLiteral("\uFF0B")}

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

◆ kLuaDbgHeaderRemoveAll

const QString kLuaDbgHeaderRemoveAll {QStringLiteral("\u24CD")}

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

◆ kLuaDbgRowExtras

const QString kLuaDbgRowExtras {QStringLiteral("\u2699")}

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

◆ kLuaDbgRowLog

const QString kLuaDbgRowLog {QStringLiteral("\u2630")}

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