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:

  1. Scan Plugins\ recursively for .plg files.
  2. Load the binary and resolve TcpInitializeV2.
  3. Call Initialize(aRegRoot, aLanguageId, aTonCut) and keep the returned object.
  4. Compare EngineVersion with the current Desktop engine version shown in the header badge.
  5. Push UiScale and current language into the plugin when state changes.
  6. Call LoadConfig while loading plugin settings and SaveConfig before shutdown.
  7. Call Finalize before 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:

FeatureExpected 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:

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

Was this page helpful?