1
0

refactor: modularize text injection with a factory and dedicated backend implementations, including a new Wayland clipboard option.

This commit is contained in:
2026-03-03 12:15:52 +01:00
parent ffba480d28
commit 9bf72169db
13 changed files with 379 additions and 147 deletions

23
IO/TextInjectorFactory.cs Normal file
View 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)
};
}