Scratchpad plugin API
IPlugin interface
The entry point of your plugin implements this interface.
Properties
ID { get; }
Type: string
The ID of your plugin, a reverse FQDN.
Name { get; }
Type: string
The display name of your plugin. Displayed as the group header in the actions list.
Author { get; }
Type: (string Name, string URL)
Name and URL of plugin author.
ProvidedActions { get; }
Type: IEnumerable<IAction>
All actions provided by the plugin. The order of this list determines the order in the actions list.
IAction interface
The base interface of any action. Do not implement this interface directly, instead use one of the interfaces extending IAction.
Properties
LocalID { get; }
Type: string
The ID of your action. Must be unique within your plugin.
Name { get; }
Type: string
The display name of the action.
Description { get; }
Type: string
A short description of the action. Will be used as a tool tip in the actions list.
Icon { get; }
Type: Bitmap?
The icon displayed in the actions list next to this action.
DarkModeIcon { get => null; }
Type: Bitmap?
A different icon to use when dark mode is enabled.
ITransformation interface
Extends:
Sawblade.Scratchpad.PluginAPI.IAction
Implement this to provide a simple transformation action (turn string A into string B).
Methods
public string Transform(string @string);
This method gets called when the transformation is executed. It should return the transformed string.
Parameters
@string
Type: string
The string to transform. Either the selected text, or if none is selected, the entire buffer.
IGenerator interface
Extends:
Sawblade.Scratchpad.PluginAPI.IAction
Implement this to provide a simple generator action (return a new string).
Methods
public string Generate();
This method gets called when the generator is executed. It should return a new string.
Parameters
None
IConfigurableGenerator interface
Extends:
Sawblade.Scratchpad.PluginAPI.IAction
Implement this to provide an adavanced, configurable generator action (return a new string based on parameters).
Properties
ConfigurationType { get; }
Type: Type
A type implementing IGeneratorConfiguration that is used to configure the parameters for this generator.
Methods
public string Generate(IGeneratorConfiguration configuration);
This method gets called when the generator is executed. It should return a new string.
Parameters
configuration
Type: IGeneratorConfiguration
An instance of the type specified by the ConfigurationType property filled with the parameters configured by the user.
IGeneratorConfiguration interface
Implement this interface in a type to use for an IConfigurableGenerator instance. Declare new get+set properties on this to provide parameters.
ILogger interface
Added in version 1.1.0
Provides logging functionality for plugins to report messages at various severity levels. Use InteropHelper.Logger to access the global logger instance.
Methods
public void Log(LogLevel level, string message);
Logs a message at the specified severity level.
Parameters
level
Type: LogLevel
The severity level of the message.
message
Type: string
The message to log.
public void LogTrace(string message);
Logs a message at the Trace severity level.
Parameters
message
Type: string
The message to log.
public void LogDebug(string message);
Logs a message at the Debug severity level.
Parameters
message
Type: string
The message to log.
public void LogVerbose(string message);
Logs a message at the Verbose severity level.
Parameters
message
Type: string
The message to log.
public void LogInfo(string message);
Logs a message at the Info severity level.
Parameters
message
Type: string
The message to log.
public void LogWarning(string message);
Logs a message at the Warning severity level.
Parameters
message
Type: string
The message to log.
public void LogError(string message);
Logs a message at the Error severity level.
Parameters
message
Type: string
The message to log.
public void LogError(Exception exception);
Logs an exception at the Error severity level.
Parameters
exception
Type: Exception
The exception to log.
public void LogFatal(string message);
Logs a message at the Fatal severity level.
Parameters
message
Type: string
The message to log.
public void LogFatal(Exception exception);
Logs an exception at the Fatal severity level.
Parameters
exception
Type: Exception
The exception to log.
LogLevel enum
Added in version 1.1.0
Represents the severity level of a log message.
Values
Trace = 0
The most granular level, used for detailed diagnostic tracing.
Debug = 1
Used for information helpful during development and debugging.
Verbose = 2
Used for detailed informational messages beyond normal operation.
Info = 3
Used for general informational messages about normal operation. This is the default output log level.
Warn = 4
Used for potentially harmful situations that do not stop execution.
Error = 5
Used for error events that might still allow the plugin to continue running.
Fatal = 6
Used for severe errors that will likely lead to termination.