A lightweight RAD Studio (Delphi 12 Athens) IDE plugin that shows a color swatch in the editor gutter next to every color literal in your source — like the color decorators in VS Code — and lets you Shift+click a swatch to pick a new color, rewriting the literal directly in your code.
-
Color swatches in the left gutter, on every line that contains a color literal.
-
Recognizes three Delphi color forms:
Form Example Notes clXXXclRed,clBtnFaceVCL named constants; system colors resolved to their real RGB $00BBGGRR$00FF8040TColorhex (BGR byte order); 6–8 hex digitsRGB(r,g,b)RGB(255, 128, 0)integer-literal arguments only -
Edit colors straight from the gutter (see Usage).
-
No configuration, no toolbar, no menu — build, install, done.
- RAD Studio 12 Athens (Delphi, compiler 36.0 / package version
290). - Win32 design-time package (the IDE host is a 32-bit process).
- Open
DelphiColorPreview.dprojin RAD Studio 12. - Build the project.
- Right-click the project in the Project Manager → Install.
That's it — the swatches show up in the editor gutter immediately. To uninstall, right-click the project → Uninstall (or remove it from Component → Install Packages…).
Prefer the command line? Run
build.bat(it callsrsvars.bat+msbuild, Win32 / Debug) and then do step 3 in the IDE.
- A color swatch appears in the gutter next to every line that has a color literal — with or without a breakpoint on that line.
- Shift+click a swatch to open a color picker. Choosing a color rewrites the
literal in your code, keeping the original form:
$00BBGGRRstays a hex literal,RGB(r, g, b)stays anRGB()call,clXXXbecomes the matching named constant when one exists (otherwise a hex literal).
- The edit goes through the editor buffer, so Ctrl+Z undoes it like any other change.
- A plain (non-Shift) click is left untouched, so the gutter still works for breakpoints.
The package registers a single global INTACodeEditorEvents notifier through
(BorlandIDEServices as INTACodeEditorServices).AddEditorEventsNotifier.
- Swatches are painted at the
pgsEndPaintgutter stage, which runs once after the whole gutter is drawn with a clip covering the entire gutter. The plugin enumerates the visible lines (EditorState.TopLine..BottomLine→LineState[]) and draws a swatch in each line'sGutterRect. Using the line's own gutter rectangle means there is no column-to-pixel math, so the swatch never drifts. - Line text and geometry come straight from
INTACodeEditorLineState(.Text,.GutterRect). - Editing goes through
IOTAEditView.Buffer.EditPosition(Move/Delete/InsertText) so the IDE records a normal, undoable edit.
| File | Responsibility |
|---|---|
ColorPreview.Parser.pas |
FindColorTokens — scans one line into color tokens |
ColorPreview.Notifier.pas |
TColorPreviewNotifier — paints swatches, handles the click |
ColorPreview.Register.pas |
registers / unregisters the notifier on package load |
DelphiColorPreview.dpk |
the design-only package (requires rtl, vcl, designide) |