refactor: modularize text injection with a factory and dedicated backend implementations, including a new Wayland clipboard option.
This commit is contained in:
23
IO/TextInjectorFactory.cs
Normal file
23
IO/TextInjectorFactory.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Toak.Core.Interfaces;
|
||||
using Toak.IO.Injectors;
|
||||
|
||||
namespace Toak.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the correct <see cref="ITextInjector"/> implementation based on the configured backend name.
|
||||
/// </summary>
|
||||
public static class TextInjectorFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the appropriate <see cref="ITextInjector"/> for the given <paramref name="backend"/> string.
|
||||
/// Supported values: <c>wtype</c>, <c>wl-clipboard</c>, <c>ydotool</c>, <c>xdotool</c> (default).
|
||||
/// </summary>
|
||||
public static ITextInjector Create(string backend, INotifications notifications) =>
|
||||
backend.ToLowerInvariant() switch
|
||||
{
|
||||
"wtype" => new WtypeTextInjector(notifications),
|
||||
"wl-clipboard" => new WlClipboardTextInjector(notifications),
|
||||
"ydotool" => new YdotoolTextInjector(notifications),
|
||||
_ => new XdotoolTextInjector(notifications)
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user