SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
rulesyntaxhighlighter.h File Reference

Slice BR Phase 6.8.2 — QSyntaxHighlighter for SWMM control rules. More...

#include <QPalette>
#include <QStringList>
#include <QSyntaxHighlighter>
#include <QTextCharFormat>
Include dependency graph for rulesyntaxhighlighter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  openswmmvis::controls::RuleSyntaxHighlighter
 

Namespaces

namespace  openswmmvis
 
namespace  openswmmvis::controls
 

Detailed Description

Slice BR Phase 6.8.2 — QSyntaxHighlighter for SWMM control rules.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
Date
2026
License\n GPL-3.0-or-later

Attached to RuleCodeEditor's QTextDocument. Token classes + palette roles:

  • Block keyword (RULE, IF, THEN, ELSE, AND, OR, NOT, PRIORITY) — bold, Highlight
  • Object type (NODE, LINK, CONDUIT, PUMP, ORIFICE, WEIR, OUTLET, SUBCATCH, SIMULATION, GAGE) — bold, LinkVisited
  • Variable (DEPTH, HEAD, FLOW, VOLUME, INFLOW, SETTING, STATUS, CLOCKTIME, DATE, MONTH, DAY, TIME, OVERFLOW) — italic, Link
  • Operator (=, <, >, <=, >=, <>, IS) — WindowText
  • Number (decimal + clock HH:MM[:SS]) — Text
  • Comment (; to EOL) — italic, Placeholder

The keyword/object/variable vocabularies are aligned with the engine's Controls.cpp tokeniser (the attr == / obj_type == ladders at lines 650–736 of that file) so the GUI and engine cannot drift. A small exposed keywordList() accessor lets RuleCodeEditor's QCompleter reuse the same vocabulary without duplication.

Theming. Colours come from the application palette via QPalette colour roles rather than hard-coded RGB, so dark / light themes Just Work. The highlighter rebuilds its QTextCharFormats on setPalette (called by the editor when the palette changes).