Lifecycle & Capabilities
TonCut Desktop treats plugins as long-lived integrations discovered at startup. The host loads every .plg, calls TcpInitializeV2, checks EngineVersion, applies UiScale, and then keeps the resulting ITcPlugin instance alive for extension matching and user-triggered actions.
Lifecycle
The Desktop host behavior inferred from the published wrapper is:
- Scan
Plugins\recursively for.plgfiles. - Load the binary and resolve
TcpInitializeV2. - Call
Initialize(aRegRoot, aLanguageId, aTonCut)and keep the returned object. - Compare
EngineVersionwith the current Desktop engine version shown in the header badge. - Push
UiScaleand current language into the plugin when state changes. - Call
LoadConfigwhile loading plugin settings andSaveConfigbefore shutdown. - Call
Finalizebefore releasing the plugin instance.
Use Configure and About only when the matching values are present. TonCut does not synthesize behavior for missing callbacks.
Lifecycle-sensitive members
function TCsvImportExportPlugin.GetEngineVersion(): Integer;
begin
Result := cEngineVersion;
end;
procedure TCsvImportExportPlugin.SetLanguageId(aLanguageId: Integer);
begin
FLanguageId := aLanguageId;
end;
procedure TCsvImportExportPlugin.SetUiScale(aScale: Single);
begin
FUiScale := aScale;
end;
These lifecycle members stay in native code for the split C# starter. The managed CSV library has no direct ITcPlugin state or engine-version contract.
Capability flags
advertises what the plugin can actually do:
| Feature | Expected callbacks |
|---|---|
EnumExtensions, IsMyFile, LoadFile | |
EnumExtensions, SaveFile | |
SaveResult | |
| / | BatchSaveResult |
| / | Plot, BatchPlot, optionally PlotterInfo |
| / / | SavePlot, BatchSavePlot, PlotterInfo |
Configure | |
About |
If a feature is absent, the matching callback should return rather than pretending it exists.
Advertise features
function TCsvImportExportPlugin.GetFeatures(): TTcpFeatures;
begin
Result := [feImport, feExport];
end;
The C# starter's native shim advertises features. The managed CSV library does not publish TTcpFeatures or a direct plugin interface.
Result codes
is the main control channel between the host and a plugin. The most important values in practice are:
| Result | Meaning in practice |
|---|---|
| The action completed successfully. | |
| The action failed in a normal, non-exceptional way. | |
| The plugin hit an exception and is reporting that explicitly. | |
| The user cancelled the operation in plugin-owned UI. | |
| The callback exists but the behavior is intentionally unsupported. | |
| File matching is possible but not certain. | |
| File matching says the file does not belong to this plugin. |
Return conservative match results
function TCsvImportExportPlugin.IsMyFile(const aFileName: WideString): TTcpResult;
begin
Result := ValidateHeader(aFileName);
end;
The native shim maps headerIsValid to the host's code.
IsMyFile is where matters most. TonCut prefers the first plugin that returns ; if nothing confirms ownership, it can fall back to a plugin that returned cprMaybe.