diff --git a/src/TextCopy/ClipboardService.cs b/src/TextCopy/ClipboardService.cs
index 4b2951ea..3e484326 100644
--- a/src/TextCopy/ClipboardService.cs
+++ b/src/TextCopy/ClipboardService.cs
@@ -28,6 +28,28 @@ public static partial class ClipboardService
return getFunc();
}
+ ///
+ /// Retrieves text data from the Clipboard and splits it into lines.
+ ///
+ public static async Task GetLinesAsync(Cancellation cancellation = default)
+ {
+ var text = await GetTextAsync(cancellation);
+ if (text == null)
+ return null;
+ return text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
+ }
+
+ ///
+ /// Retrieves text data from the Clipboard and splits it into lines.
+ ///
+ public static string[]? GetLines()
+ {
+ var text = GetText();
+ if (text == null)
+ return null;
+ return text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
+ }
+
static Func setAsyncAction;
static Action setAction;
@@ -60,4 +82,22 @@ public static void SetText(string text)
{
setAction(text);
}
+
+ ///
+ /// Clears the Clipboard and then adds lines of text data to it.
+ ///
+ public static Task SetLinesAsync(string[] lines, Cancellation cancellation = default)
+ {
+ var text = string.Join(Environment.NewLine, lines);
+ return SetTextAsync(text, cancellation);
+ }
+
+ ///
+ /// Clears the Clipboard and then adds lines of text data to it.
+ ///
+ public static void SetLines(string[] lines)
+ {
+ var text = string.Join(Environment.NewLine, lines);
+ SetText(text);
+ }
}
\ No newline at end of file