From 1b99168f51c4f78327ac4f61ea063b6ba99278b5 Mon Sep 17 00:00:00 2001 From: BDisp Date: Mon, 12 Aug 2024 13:44:09 +0100 Subject: [PATCH] V1 Fixes #3541. Checking if clipboard is available on windows. (#3658) * V1 Fixes #3541. Checking if clipboard is available on windows. * Fix nuget packages with vulnerabilities. --- Terminal.Gui/ConsoleDrivers/WindowsDriver.cs | 16 +++++++++++++++- UICatalog/UICatalog.csproj | 2 +- UnitTests/UnitTests.csproj | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index f575de14b..01d13b80d 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -1970,7 +1970,21 @@ namespace Terminal.Gui { class WindowsClipboard : ClipboardBase { public WindowsClipboard () { - IsSupported = IsClipboardFormatAvailable (cfUnicodeText); + IsSupported = CheckClipboardIsAvailable (); + } + + private static bool CheckClipboardIsAvailable () + { + // Attempt to open the clipboard + if (OpenClipboard (IntPtr.Zero)) { + // Clipboard is available + // Close the clipboard after use + CloseClipboard (); + + return true; + } + // Clipboard is not available + return false; } public override bool IsSupported { get; } diff --git a/UICatalog/UICatalog.csproj b/UICatalog/UICatalog.csproj index 89dcd4c0c..a05ebdf02 100644 --- a/UICatalog/UICatalog.csproj +++ b/UICatalog/UICatalog.csproj @@ -21,7 +21,7 @@ - + diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index d7e5c2d2a..63f2ba107 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -19,10 +19,10 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive