16#ifndef LUA_DEBUGGER_DIALOG_H
17#define LUA_DEBUGGER_DIALOG_H
25#include <QKeySequence>
30#include <QPlainTextEdit>
36#include <QStandardItem>
37#include <QStandardItemModel>
42#include "epan/wslua/wslua_debugger.h"
70class LuaDebuggerDialog;
118 void enterReloadUiStateIfEnabled();
123 void exitReloadUiState();
128 void reloadAllScriptFilesFromDisk();
131 bool reloadDeferred_ =
false;
132 bool reloadUiActive_ =
false;
133 bool reloadUiRequestWasEnabled_ =
false;
240 void handlePause(
const char *file_path, int64_t line);
292 return changeHighlight_.changeHighlightAllowed(stackController_.selectionLevel());
304 changeHighlight_.applyChangedVisuals(
this, valueCell, changed);
532 void onDebuggerToggled(
bool checked);
541 void onMonospaceFontUpdated(
const QFont &font);
544 void onMainAppInitialized();
547 void onPreferencesChanged();
550 void onColorsChanged();
562 void drainPendingLogs();
578 void drainBreakpointStateUpdates();
584 void onEditorGoToLine();
591 void onVariablesCurrentItemChanged(
const QModelIndex ¤t,
const QModelIndex &previous);
598 void onWatchCurrentItemChanged(
const QModelIndex ¤t,
const QModelIndex &previous);
610 void updateLeftPanelStretch();
614 Ui::LuaDebuggerDialog *ui;
641 void wireFilesPanel();
643 void wireStackPanel();
645 void wireVariablesPanel();
647 void wireWatchPanel();
649 void wireBreakpointsPanel();
651 void wireEvaluatePanel();
698 void resetStackForPauseEntry();
700 void clearStackPanel();
703 QCheckBox *enabledCheckBox;
729 QTreeView *variablesTree;
731 QStandardItemModel *variablesModel;
733 QTreeView *watchTree;
735 QStandardItemModel *watchModel;
737 QTreeView *stackTree;
739 QStandardItemModel *stackModel;
743 QStandardItemModel *fileModel;
745 QTreeView *breakpointsTree;
747 QStandardItemModel *breakpointsModel;
751 QPlainTextEdit *evalInputEdit;
753 QPlainTextEdit *evalOutputEdit;
755 QPushButton *evalButton;
757 QPushButton *evalClearButton;
766 QSplitter *evalSplitter_ =
nullptr;
769 QToolButton *breakpointHeaderToggleButton_ =
nullptr;
771 QToolButton *breakpointHeaderRemoveButton_ =
nullptr;
773 QToolButton *breakpointHeaderRemoveAllButton_ =
nullptr;
775 QToolButton *breakpointHeaderBreakOnErrorButton_ =
nullptr;
782 QToolButton *breakpointHeaderEditButton_ =
nullptr;
785 QAction *actionRemoveAllBreakpoints_ =
nullptr;
792 void showAccordionFrame(
AccordionFrame *frame,
bool toggle =
false);
798 void installDescendantShortcutFilters();
801 void syncDebuggerToggleWithCore();
807 enum class DebuggerUiStatus
825 DebuggerUiStatus currentDebuggerUiStatus()
const;
828 void updateEnabledCheckboxIcon();
831 void updateStatusLabel();
834 void applyCodeViewThemes();
837 void updateStyleSheets();
842 void resumeDebuggerAndExitLoop();
853 void endPauseFreeze();
859 void runDebuggerStep(
void (*step_fn)(
void));
862 void createCollapsibleSections();
867 LuaDebuggerSettingsStore settingsStore_;
870 bool luaDebuggerJsonSaved_{
false};
875 void saveSettingsFile();
878 void applyDialogSettings();
881 void storeDialogSettings();
888 QStandardItem *findVariablesItemByPath(
const QString &path)
const;
895 QStandardItem *findWatchRootForVariablePath(
const QString &path)
const;
903 static void expandAncestorsOf(QTreeView *tree, QStandardItemModel *model, QStandardItem *item);
906 bool syncWatchVariablesSelection_ =
false;
909 LuaDebuggerChangeHighlightTracker changeHighlight_;
932 qlonglong pausedLine_ = 0;
935 int errorFrameHideEpoch_ = 0;
938 void refreshChangedValueBrushes() { changeHighlight_.refreshChangedValueBrushes(watchTree,
this); }
941 void snapshotBaselinesOnPauseEntry() { changeHighlight_.snapshotBaselinesOnPauseEntry(); }
944 void clearAllChangeBaselines() { changeHighlight_.clearAllChangeBaselines(); }
947 void pruneChangeBaselinesToLiveWatchSpecs() { changeHighlight_.pruneChangeBaselinesToLiveWatchSpecs(watchModel); }
950 void updatePauseEntryFrameIdentity() { changeHighlight_.updatePauseEntryFrameIdentity(); }
A QFrame that shows and hides itself with a slide animation.
Definition accordion_frame.h:21
A collapsible section widget for use in a QSplitter.
Definition collapsible_section.h:31
GeometryStateDialog(QWidget *parent, Qt::WindowFlags f=Qt::Window)
Constructs a new GeometryStateDialog with the specified parent and window flags.
Definition geometry_state_dialog.h:91
Owns the breakpoints panel: tree wiring, model rebuild from the engine, inline edit dispatch,...
Definition lua_debugger_breakpoints.h:349
"Value changed since last pause" highlighter for the Watch and Variables trees.
Definition lua_debugger_utils.h:895
Owns the script tab strip and the documents inside it.
Definition lua_debugger_code_editor.h:463
Editable code editor supporting gutter breakpoints and highlighting.
Definition lua_debugger_code_editor.h:84
Top-level dialog hosting the Lua debugger UI components.
Definition lua_debugger_dialog.h:189
LuaDebuggerBreakpointsController & breakpointsController()
Gets the breakpoints controller.
Definition lua_debugger_dialog.h:330
void refreshDebuggerStateUi()
Refresh checkbox sync + all debugger state chrome/widgets.
Definition lua_debugger_dialog.cpp:1498
LuaDebuggerLuaReloadCoordinator & reloadCoordinator()
Gets the Lua reload coordinator.
Definition lua_debugger_dialog.h:334
LuaDebuggerEvalController & evalController()
Gets the evaluation controller.
Definition lua_debugger_dialog.h:336
void syncVariablesTreeToCurrentWatch()
Select the Variables row matching the current Watch row, or clear the Variables selection when no mat...
Definition lua_debugger_watch.cpp:1982
static bool handleMainCloseIfPaused(QCloseEvent *event)
If the debugger is paused or owns unsaved scripts, defer the supplied main-window close event so the ...
Definition lua_debugger_dialog.cpp:454
void childEvent(QChildEvent *event) override
Handle child widget events.
Definition lua_debugger_dialog.cpp:1076
static LuaDebuggerDialog * instanceIfExists()
Like instance but never creates the dialog; returns nullptr when no instance exists yet....
Definition lua_debugger_dialog.cpp:449
void updateWidgets()
Update all widgets based on the current debugger state.
Definition lua_debugger_dialog.cpp:1664
void handleEscapeKey()
Escape: hide inline find/go accordions if shown, else close dialog. Invoked from the script editor be...
Definition lua_debugger_dialog.cpp:1047
bool changeHighlightAllowed() const
Combined "is the change-highlight cue allowed for paint this pass?" gate. Reads the tracker policy wi...
Definition lua_debugger_dialog.h:290
void handlePause(const char *file_path, int64_t line)
React to the debugger pausing execution at a breakpoint.
Definition lua_debugger_dialog.cpp:674
QString pausedFile() const
Source file path (normalized) of the line the debugger is paused on; empty when not paused....
Definition lua_debugger_dialog.h:346
bool isDebuggerPaused() const
True while the dialog is in a pause-entry / nested event-loop UI. Mirrors the C side's wslua_debugger...
Definition lua_debugger_dialog.h:281
bool tearDownPauseLoopForReload()
Tear down an active pause loop because the Lua engine is about to be reloaded under us....
Definition lua_debugger_dialog.cpp:1651
LuaDebuggerChangeHighlightTracker & changeHighlight()
Borrowed reference to the change-highlight tracker. Used by controllers that compute "changed since l...
Definition lua_debugger_dialog.h:264
void ensureDebuggerEnabledForActiveBreakpoints()
Enable the debugger if any active breakpoint requires it.
Definition lua_debugger_dialog.cpp:1680
void updateLuaEditorAuxFrames()
Point find / goto bars at the active code tab.
Definition lua_debugger_dialog.cpp:1155
void setSaveActionEnabled(bool enabled)
Toggle the toolbar Save Script action's enabled state. Surfaced as a typed setter so the code-tabs co...
Definition lua_debugger_dialog.cpp:1646
void clearPausedStateUi()
Remove paused-state UI artifacts like stacks and highlights.
Definition lua_debugger_dialog.cpp:1434
QCheckBox * enabledToggle()
Borrowed reference to the toggle that mirrors the core's enable/disable state; the reload coordinator...
Definition lua_debugger_dialog.h:361
LuaDebuggerFontPolicy & fontPolicy()
Gets the font policy.
Definition lua_debugger_dialog.h:338
void onCodeViewContextMenu(const QPoint &pos)
Build and show the editor context menu (right-click in a code tab). Routed through Qt's signal/slot m...
Definition lua_debugger_dialog.cpp:1242
void refreshVariablesForCurrentStackFrame()
Rebuild the variables tree after the stack frame for inspection changed.
Definition lua_debugger_variables.cpp:405
~LuaDebuggerDialog()
Destroy the dialog and disconnect debugger callbacks.
Definition lua_debugger_dialog.cpp:637
bool event(QEvent *event) override
Handle general events.
Definition lua_debugger_dialog.cpp:1015
bool eventFilter(QObject *obj, QEvent *event) override
Filter events for child objects to intercept shortcuts.
Definition lua_debugger_dialog.cpp:1092
void addWatchFromSpec(const QString &watchSpec)
Add a watch from an expression/path spec without opening the inline editor. Convenience used by the e...
Definition lua_debugger_watch.cpp:2042
static LuaDebuggerDialog * instance(QWidget *parent=nullptr)
Retrieve the singleton instance, creating it if needed.
Definition lua_debugger_dialog.cpp:660
QKeySequence addWatchShortcut() const
Shortcut bound to the Add Watch toolbar action. Watch / Variables context menus mirror it on their "A...
Definition lua_debugger_watch.cpp:2047
QString normalizedFilePath(const QString &file_path) const
Normalize a path by trimming prefixes and resolving symbolic components. Public so controllers and th...
Definition lua_debugger_dialog.cpp:1405
LuaDebuggerCodeTabsController & codeTabsController()
Gets the code tabs controller.
Definition lua_debugger_dialog.h:324
LuaDebuggerVariablesController & variablesController()
Gets the variables controller.
Definition lua_debugger_dialog.h:322
void updateContinueActionState()
Enable or disable the Continue action based on debugger state.
Definition lua_debugger_dialog.cpp:1634
void showEvent(QShowEvent *event) override
Handle widget show events.
Definition lua_debugger_dialog.cpp:1032
void runToCurrentLineInPausedEditor(LuaDebuggerCodeView *codeView, qint32 line)
Run-to-line dispatch from the focused paused editor. Public so LuaDebuggerKeyRouter can fire it from ...
Definition lua_debugger_dialog.cpp:1757
LuaDebuggerStackController & stackController()
Borrowed reference to the stack controller. Used by Watch / Variables / Eval to read the currently in...
Definition lua_debugger_dialog.h:272
void reject() override
Close from Esc or programmatic reject(); queues close() so closeEvent() runs (unsaved-scripts prompt ...
Definition lua_debugger_dialog.cpp:942
LuaDebuggerDialog(QWidget *parent=nullptr)
Construct the dialog and initialize all child widgets.
Definition lua_debugger_dialog.cpp:459
LuaDebuggerPauseController & pauseController()
Gets the pause controller.
Definition lua_debugger_dialog.h:332
void cancelErrorFrameHide()
Cancel any pending delayed hide token.
Definition lua_debugger_dialog.cpp:1200
LuaDebuggerWatchController & watchController()
Gets the watch controller.
Definition lua_debugger_dialog.h:328
qlonglong pausedLine() const
Line number of the pause; zero when the debugger is not paused. Paired with pausedFile.
Definition lua_debugger_dialog.h:353
void closeEvent(QCloseEvent *event) override
Flush state and resume execution when the dialog closes.
Definition lua_debugger_dialog.cpp:952
void scheduleErrorFrameHide(int delayMs)
Schedule a delayed hide to avoid hide/show flicker on rapid re-pauses.
Definition lua_debugger_dialog.cpp:1205
void applyChangedVisuals(QStandardItem *valueCell, bool changed)
Stamp valueCell with the change-highlight visuals; the dialog supplies itself as the timer owner so t...
Definition lua_debugger_dialog.h:302
void updatePausedErrorFrame()
Populate/hide the inline error frame for paused break-on-error states.
Definition lua_debugger_dialog.cpp:1162
LuaDebuggerFilesController & filesController()
Gets the files controller.
Definition lua_debugger_dialog.h:326
Manages the debugger's eval panel: enabling/disabling controls based on pause state,...
Definition lua_debugger_evaluate.h:30
Files panel: plugin/script indexing, hierarchical entries, open / reveal / copy gestures,...
Definition lua_debugger_files.h:36
Owns the dialog's font story end-to-end.
Definition lua_debugger_code_editor.h:362
Centralised keyboard-shortcut dispatcher for the Lua debugger dialog's eventFilter().
Definition lua_debugger_utils.h:827
Coordinates Lua plugin reload: pre/post core callbacks, deferred reload after pause,...
Definition lua_debugger_dialog.h:82
void handlePostReload()
Handles actions required after a Lua plugin reload.
Definition lua_debugger_dialog.cpp:1963
bool takeDeferredReload()
If reloadDeferred_ was set, clear it and return true.
Definition lua_debugger_dialog.cpp:1919
void handlePreReload()
Handles actions required before a Lua plugin reload.
Definition lua_debugger_dialog.cpp:1929
LuaDebuggerLuaReloadCoordinator(LuaDebuggerDialog *host)
Constructs a LuaDebuggerLuaReloadCoordinator.
Definition lua_debugger_dialog.cpp:1915
void onReloadLuaPluginsRequested()
Slot triggered when a request to reload Lua plugins is made.
Definition lua_debugger_dialog.cpp:2046
Owns the nested pause QEventLoop pointer and the application-wide freeze (disabled top-levels,...
Definition lua_debugger_pause.h:40
Stack trace panel: column layout, rebuild from the engine, selection → variables frame,...
Definition lua_debugger_stack.h:41
Variables panel: column sizing, expansion persistence, lazy child fill on expand, context menu,...
Definition lua_debugger_variables.h:45
Watch panel: column layout, expand/collapse tracking + lazy fill, runtime expansion-state map,...
Definition lua_debugger_watch.h:330
Pause-aware arbitration for main-window close while the Lua debugger is involved.
Definition lua_debugger_dialog.cpp:1839
bool handleMainCloseIfPaused(QCloseEvent *event)
Decide whether to defer a main-window close while the Lua debugger needs to arbitrate.
Definition lua_debugger_dialog.cpp:1851
void cancelPendingClose()
Cancel any pending deferred main close.
Definition lua_debugger_dialog.cpp:1908
void markQuitRequested()
Record a debugger-initiated quit (Ctrl+Q from the debugger window) so that the main window will be cl...
Definition lua_debugger_dialog.cpp:1903
void deliverDeferredMainCloseIfPending()
Re-deliver a previously deferred main-window close, if any. Idempotent.
Definition lua_debugger_dialog.cpp:1880
Opaque handle representing an active or pending capture session.
Definition capture_session.h:156