mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
project: reorganize the structure of the project.
* remove dotnet-tool.json because the project does not rely on any dotnet tools. * remove Directory.Build.props because the solution has only one project. * move src/SourceGit to src. It's not needed to put all sources into a subfolder of src since there's only one project.
This commit is contained in:
parent
96e60da7ad
commit
96d4150d26
319 changed files with 37 additions and 53 deletions
86
src/Native/MacOS.cs
Normal file
86
src/Native/MacOS.cs
Normal file
|
@ -0,0 +1,86 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Native
|
||||
{
|
||||
[SupportedOSPlatform("macOS")]
|
||||
internal class MacOS : OS.IBackend
|
||||
{
|
||||
public void SetupApp(AppBuilder builder)
|
||||
{
|
||||
builder.With(new FontManagerOptions()
|
||||
{
|
||||
DefaultFamilyName = "PingFang SC",
|
||||
});
|
||||
}
|
||||
|
||||
public string FindGitExecutable()
|
||||
{
|
||||
if (File.Exists("/usr/bin/git"))
|
||||
return "/usr/bin/git";
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindVSCode()
|
||||
{
|
||||
var toolPath = "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindFleet()
|
||||
{
|
||||
var toolPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Applications/Fleet.app/Contents/MacOS/Fleet";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public void OpenBrowser(string url)
|
||||
{
|
||||
Process.Start("open", url);
|
||||
}
|
||||
|
||||
public void OpenInFileManager(string path, bool select)
|
||||
{
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
Process.Start("open", path);
|
||||
}
|
||||
else if (File.Exists(path))
|
||||
{
|
||||
Process.Start("open", $"\"{path}\" -R");
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenTerminal(string workdir)
|
||||
{
|
||||
var dir = string.IsNullOrEmpty(workdir) ? "~" : workdir;
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendLine("on run argv");
|
||||
builder.AppendLine(" tell application \"Terminal\"");
|
||||
builder.AppendLine($" do script \"cd '{dir}'\"");
|
||||
builder.AppendLine(" activate");
|
||||
builder.AppendLine(" end tell");
|
||||
builder.AppendLine("end run");
|
||||
|
||||
var tmp = Path.GetTempFileName();
|
||||
File.WriteAllText(tmp, builder.ToString());
|
||||
|
||||
var proc = Process.Start("/usr/bin/osascript", $"\"{tmp}\"");
|
||||
proc.Exited += (o, e) => File.Delete(tmp);
|
||||
}
|
||||
|
||||
public void OpenWithDefaultEditor(string file)
|
||||
{
|
||||
Process.Start("open", file);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue