Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ This app supports open repository in external tools listed in the table below.
| VSCodium | YES | YES | YES |
| Cursor | YES | YES | YES |
| Sublime Text | YES | YES | YES |
| Kate | YES | YES | YES |
| Zed | YES | YES | YES |
| Visual Studio | YES | NO | NO |

Expand Down
8 changes: 8 additions & 0 deletions THIRD-PARTY-LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ The project uses the following third-party libraries or assets
- **Version**: 2.30.15
- **License**: Public Domain

## Icons

### Kate

- **Author**: Tyson Tan for the Kate project
- **Source**: [Kate's 32×32 application icon](https://github.com/KDE/kate/blob/master/apps/kate/icons/unix/32-apps-kate.png), included unchanged
- **License**: [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/), as offered by the [Kate project](https://kate-editor.org/post/2020/2020-01-25-new-kate-icon/)

## Fonts

### JetBrainsMono
Expand Down
27 changes: 26 additions & 1 deletion src/Models/ExternalTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public LaunchOption(string title, string args)
public string ExecFile { get; }
public Bitmap IconImage { get; }
public bool SupportOpenFolder { get; }
public bool SupportOpenUnrealProject { get; init; }

public ExternalTool(string name, string icon, string execFile, Func<string, List<LaunchOption>> optionsGenerator, bool supportOpenFolder)
{
Expand All @@ -54,6 +55,22 @@ public List<LaunchOption> MakeLaunchOptions(string repo)
return _optionsGenerator?.Invoke(repo);
}

public List<LaunchOption> MakeUnrealProjectLaunchOptions(string repo)
{
if (!SupportOpenUnrealProject)
return null;

var root = new DirectoryInfo(repo);
var options = new List<LaunchOption>();
root.WalkFiles(file =>
{
if (file.EndsWith(".uproject", StringComparison.OrdinalIgnoreCase))
options.Add(new(Path.GetRelativePath(root.FullName, file), file.Quoted()));
}, maxDepth: 1);
options.Sort((left, right) => StringComparer.Ordinal.Compare(left.Title, right.Title));
return options;
}

public void Launch(string args)
{
if (File.Exists(ExecFile))
Expand Down Expand Up @@ -175,6 +192,11 @@ public void SublimeText(Func<string> platformFinder)
TryAdd("Sublime Text", "sublime_text", platformFinder);
}

public void Kate(Func<string> platformFinder)
{
TryAdd("Kate", "kate", platformFinder);
}

public void Zed(Func<string> platformFinder)
{
TryAdd("Zed", "zed", platformFinder);
Expand Down Expand Up @@ -205,7 +227,10 @@ public void FindJetBrainsFromToolbox(Func<string> platformFinder)
$"JetBrains/{tool.ProductCode}",
Path.Combine(tool.InstallLocation, tool.LaunchCommand),
null,
true));
true)
{
SupportOpenUnrealProject = tool.ProductCode == "RD",
});
}
}
catch
Expand Down
1 change: 1 addition & 0 deletions src/Native/Linux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public string FindTerminal(Models.ShellOrTerminal shell)
finder.Cursor(() => FindExecutable("cursor"));
finder.FindJetBrainsFromToolbox(() => Path.Combine(localAppDataDir, "JetBrains/Toolbox"));
finder.SublimeText(() => FindExecutable("subl"));
finder.Kate(() => FindExecutable("kate"));
finder.Zed(() =>
{
var exec = FindExecutable("zeditor");
Expand Down
9 changes: 9 additions & 0 deletions src/Native/MacOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ public string FindTerminal(Models.ShellOrTerminal shell)
finder.Cursor(() => "/Applications/Cursor.app/Contents/Resources/app/bin/cursor");
finder.FindJetBrainsFromToolbox(() => Path.Combine(home, "Library/Application Support/JetBrains/Toolbox"));
finder.SublimeText(() => "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl");
finder.Kate(() =>
{
const string bundleExecutable = "kate.app/Contents/MacOS/kate";
var executable = "/Applications/" + bundleExecutable;
if (File.Exists(executable))
return executable;

return string.IsNullOrEmpty(home) ? string.Empty : Path.Combine(home, "Applications", bundleExecutable);
});
finder.Zed(() => File.Exists("/usr/local/bin/zed") ? "/usr/local/bin/zed" : "/Applications/Zed.app/Contents/MacOS/cli");
return finder.Tools;
}
Expand Down
28 changes: 28 additions & 0 deletions src/Native/Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using Avalonia.Platform;
using Avalonia.Threading;

using Microsoft.Win32;

namespace SourceGit.Native
{
[SupportedOSPlatform("windows")]
Expand Down Expand Up @@ -157,6 +159,7 @@ public string FindTerminal(Models.ShellOrTerminal shell)
finder.Cursor(() => Path.Combine(localAppDataDir, @"Programs\Cursor\Cursor.exe"));
finder.FindJetBrainsFromToolbox(() => Path.Combine(localAppDataDir, @"JetBrains\Toolbox"));
finder.SublimeText(FindSublimeText);
finder.Kate(FindKate);
finder.Zed(FindZed);
return finder.Tools;
}
Expand Down Expand Up @@ -410,6 +413,31 @@ private void FindVisualStudio(Models.ExternalToolsFinder finder)
}
}

private string FindKate()
{
var registryLocations = new[]
{
(RegistryHive.CurrentUser, RegistryView.Default),
(RegistryHive.LocalMachine, RegistryView.Registry64),
(RegistryHive.LocalMachine, RegistryView.Registry32),
};

foreach (var (hive, view) in registryLocations)
{
using var baseKey = RegistryKey.OpenBaseKey(hive, view);
using var kate = baseKey.OpenSubKey(@"SOFTWARE\KDE\Kate");
if (kate?.GetValue("Install_Dir") is not string installDir || !Path.IsPathFullyQualified(installDir))
continue;

var executable = Path.Combine(installDir, "bin", "kate.exe");
if (File.Exists(executable))
return executable;
}

var findInPath = new StringBuilder("kate.exe", 512);
return PathFindOnPath(findInPath, null) ? findInPath.ToString() : string.Empty;
}

private string FindZed()
{
var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey(
Expand Down
Binary file added src/Resources/Images/ExternalToolIcons/kate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions src/Views/RepositoryToolbar.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ private void OpenWithExternalTools(object sender, RoutedEventArgs ev)
}

menu.Items.Add(item);

if (CreateUnrealProjectMenuItem(dupTool, fullpath) is { } unrealProjectItem)
menu.Items.Add(unrealProjectItem);
}
}

Expand Down Expand Up @@ -153,6 +156,35 @@ private void OpenWithExternalTools(object sender, RoutedEventArgs ev)
}
}

private static MenuItem CreateUnrealProjectMenuItem(Models.ExternalTool tool, string repositoryPath)
{
var projects = tool.MakeUnrealProjectLaunchOptions(repositoryPath);
if (projects == null || projects.Count == 0)
return null;

var item = new MenuItem();
item.Header = App.Text("Repository.OpenIn", $"{tool.Name} (uproject)");
item.Icon = new Image { Width = 16, Height = 16, Source = tool.IconImage };

foreach (var project in projects)
{
var target = item;
if (projects.Count > 1)
{
target = new MenuItem { Header = project.Title };
item.Items.Add(target);
}

target.Click += (_, e) =>
{
tool.Launch(project.Args);
e.Handled = true;
};
}

return item;
}

private async void OpenStatistics(object _, RoutedEventArgs e)
{
if (DataContext is ViewModels.Repository repo)
Expand Down