Skip to content

Commit

Permalink
Fixes gui-cs#3541. Checking if clipboard is available on windows. (gu…
Browse files Browse the repository at this point in the history
  • Loading branch information
BDisp authored Aug 12, 2024
1 parent 1f310fd commit a893169
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2343,7 +2343,22 @@ internal class WindowsClipboard : ClipboardBase
{
private const uint CF_UNICODE_TEXT = 13;

public override bool IsSupported { get; } = IsClipboardFormatAvailable (CF_UNICODE_TEXT);
public override bool IsSupported { get; } = CheckClipboardIsAvailable ();

private static bool CheckClipboardIsAvailable ()
{
// Attempt to open the clipboard
if (OpenClipboard (nint.Zero))
{
// Clipboard is available
// Close the clipboard after use
CloseClipboard ();

return true;
}
// Clipboard is not available
return false;
}

protected override string GetClipboardDataImpl ()
{
Expand Down

0 comments on commit a893169

Please sign in to comment.