2024-03-27 23:58:55 -07:00
|
|
|
|
using System;
|
2024-04-05 22:14:22 -07:00
|
|
|
|
using System.Collections.Generic;
|
2024-03-27 23:58:55 -07:00
|
|
|
|
using System.Diagnostics;
|
2024-02-05 23:08:37 -08:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Runtime.Versioning;
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
using Avalonia;
|
|
|
|
|
|
|
|
|
|
namespace SourceGit.Native
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
[SupportedOSPlatform("macOS")]
|
2024-03-17 18:37:06 -07:00
|
|
|
|
internal class MacOS : OS.IBackend
|
|
|
|
|
{
|
|
|
|
|
public void SetupApp(AppBuilder builder)
|
|
|
|
|
{
|
2024-05-04 22:01:04 -07:00
|
|
|
|
builder.With(new MacOSPlatformOptions()
|
|
|
|
|
{
|
|
|
|
|
DisableDefaultApplicationMenuItems = true,
|
|
|
|
|
});
|
2024-03-07 20:22:22 -08:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public string FindGitExecutable()
|
|
|
|
|
{
|
2024-04-15 02:48:52 -07:00
|
|
|
|
return File.Exists("/usr/bin/git") ? "/usr/bin/git" : string.Empty;
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
|
|
|
|
|
2024-09-13 21:09:50 -07:00
|
|
|
|
public string FindTerminal(Models.ShellOrTerminal shell)
|
|
|
|
|
{
|
|
|
|
|
switch (shell.Type)
|
|
|
|
|
{
|
|
|
|
|
case "mac-terminal":
|
|
|
|
|
return "Terminal";
|
|
|
|
|
case "iterm2":
|
|
|
|
|
return "iTerm";
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-18 00:19:24 -07:00
|
|
|
|
return string.Empty;
|
2024-09-13 21:09:50 -07:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-08 02:39:52 -07:00
|
|
|
|
public List<Models.ExternalTool> FindExternalTools()
|
2024-03-17 18:37:06 -07:00
|
|
|
|
{
|
2024-04-08 02:39:52 -07:00
|
|
|
|
var finder = new Models.ExternalToolsFinder();
|
2024-04-07 02:56:53 -07:00
|
|
|
|
finder.VSCode(() => "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code");
|
|
|
|
|
finder.VSCodeInsiders(() => "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code");
|
2024-05-03 06:54:10 -07:00
|
|
|
|
finder.VSCodium(() => "/Applications/VSCodium.app/Contents/Resources/app/bin/codium");
|
2024-04-07 02:56:53 -07:00
|
|
|
|
finder.Fleet(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Applications/Fleet.app/Contents/MacOS/Fleet");
|
2024-04-27 00:12:03 -07:00
|
|
|
|
finder.FindJetBrainsFromToolbox(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Library/Application Support/JetBrains/Toolbox");
|
2024-04-15 02:48:52 -07:00
|
|
|
|
finder.SublimeText(() => "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl");
|
2024-09-17 19:00:32 -07:00
|
|
|
|
finder.Zed(() => File.Exists("/usr/local/bin/zed") ? "/usr/local/bin/zed" : "/Applications/Zed.app/Contents/MacOS/cli");
|
2024-04-08 02:39:52 -07:00
|
|
|
|
return finder.Founded;
|
2024-03-27 22:49:32 -07:00
|
|
|
|
}
|
2024-02-05 23:08:37 -08:00
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public void OpenBrowser(string url)
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
Process.Start("open", url);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public void OpenInFileManager(string path, bool select)
|
|
|
|
|
{
|
|
|
|
|
if (Directory.Exists(path))
|
2024-08-18 00:53:54 -07:00
|
|
|
|
Process.Start("open", $"\"{path}\"");
|
2024-03-17 18:37:06 -07:00
|
|
|
|
else if (File.Exists(path))
|
2024-02-18 03:00:42 -08:00
|
|
|
|
Process.Start("open", $"\"{path}\" -R");
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public void OpenTerminal(string workdir)
|
|
|
|
|
{
|
2024-09-09 09:49:31 -07:00
|
|
|
|
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
|
|
|
|
var dir = string.IsNullOrEmpty(workdir) ? home : workdir;
|
2024-09-13 21:09:50 -07:00
|
|
|
|
Process.Start("open", $"-a {OS.ShellOrTerminal} \"{dir}\"");
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
2024-08-20 04:32:52 -07:00
|
|
|
|
|
2024-08-20 05:44:54 -07:00
|
|
|
|
public void OpenWithDefaultEditor(string file)
|
2024-08-20 04:32:52 -07:00
|
|
|
|
{
|
2024-08-20 05:44:54 -07:00
|
|
|
|
Process.Start("open", $"\"{file}\"");
|
2024-08-20 04:32:52 -07:00
|
|
|
|
}
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|