mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-02 10:07:15 +02:00
RobustToolbox projects should be named Robust.* This PR changes the RobustToolbox projects from SS14.* to Robust.* Updates SS14.* prefixes/namespaces to Robust.* Updates SpaceStation14.sln to RobustToolbox.sln Updates MSBUILD/SS14.* to MSBUILD/Robust.* Updates CSProject and MSBuild references for the above Updates git_helper.py Removes Runserver and Runclient as they are unusable
90 lines
2.6 KiB
C#
90 lines
2.6 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Text;
|
|
using Robust.Client.Interfaces.UserInterface;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Client.UserInterface
|
|
{
|
|
internal sealed class ClipboardManagerLinux : IClipboardManager
|
|
{
|
|
public bool Available { get; }
|
|
|
|
public string NotAvailableReason =>
|
|
// ReSharper disable once StringLiteralTypo
|
|
"Clipboard support on Linux is done with the 'xclip' utility. Please install it.";
|
|
|
|
public string GetText()
|
|
{
|
|
if (!Available)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
var startInfo = new ProcessStartInfo
|
|
{
|
|
FileName = "xclip",
|
|
Arguments = "-o -selection clipboard",
|
|
RedirectStandardOutput = true,
|
|
StandardOutputEncoding = EncodingHelpers.UTF8,
|
|
UseShellExecute = false,
|
|
};
|
|
|
|
var process = Process.Start(startInfo);
|
|
DebugTools.AssertNotNull(process);
|
|
process.WaitForExit();
|
|
return process.StandardOutput.ReadToEnd();
|
|
}
|
|
|
|
public void SetText(string text)
|
|
{
|
|
if (!Available)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
var startInfo = new ProcessStartInfo
|
|
{
|
|
FileName = "xclip",
|
|
Arguments = "-i -selection clipboard",
|
|
RedirectStandardInput = true,
|
|
UseShellExecute = false,
|
|
};
|
|
|
|
var process = Process.Start(startInfo);
|
|
DebugTools.AssertNotNull(process);
|
|
process.StandardInput.Write(text);
|
|
process.StandardInput.Close();
|
|
process.WaitForExit();
|
|
}
|
|
|
|
public ClipboardManagerLinux()
|
|
{
|
|
try
|
|
{
|
|
var process = Process.Start(
|
|
new ProcessStartInfo
|
|
{
|
|
FileName = "xclip",
|
|
Arguments = "-version",
|
|
RedirectStandardOutput = true,
|
|
RedirectStandardError = true,
|
|
UseShellExecute = false
|
|
});
|
|
if (process == null)
|
|
{
|
|
Available = false;
|
|
return;
|
|
}
|
|
|
|
process.WaitForExit();
|
|
Available = process.ExitCode == 0;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
Available = false;
|
|
}
|
|
}
|
|
}
|
|
}
|