diff --git a/.gitignore b/.gitignore index 3e759b75..32544067 100644 --- a/.gitignore +++ b/.gitignore @@ -328,3 +328,4 @@ ASALocalRun/ # MFractors (Xamarin productivity tool) working folder .mfractor/ +*-claude*/ 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 diff --git a/src/build.ps1 b/src/build.ps1 index e5944190..df4d321a 100644 --- a/src/build.ps1 +++ b/src/build.ps1 @@ -1,7 +1,11 @@ -msbuild.exe src/TextCopy.sln /t:restore /p:Configuration=Release -verbosity:quiet +dotnet restore src/TextCopy/TextCopy.csproj --verbosity quiet -msbuild.exe src/TextCopy.sln /t:build /p:Configuration=Release -verbosity:quiet +dotnet build src/TextCopy/TextCopy.csproj --configuration Release --no-restore --verbosity quiet -msbuild.exe src/TextCopy.sln /t:pack /p:Configuration=Release -verbosity:quiet +dotnet pack src/TextCopy/TextCopy.csproj --configuration Release --no-restore --verbosity quiet -dotnet test src --configuration Release --no-build --no-restore --nologo \ No newline at end of file +dotnet restore src/Tests/Tests.csproj --verbosity quiet + +dotnet build src/Tests/Tests.csproj --configuration Release --no-restore --verbosity quiet + +dotnet test src/Tests/Tests.csproj --configuration Release --no-build --no-restore --nologo \ No newline at end of file