mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
refactor: rewrite external editor supports
* supported editors can be different on different platforms. * display founded editors only
This commit is contained in:
parent
bcb83af576
commit
111bf2966a
20 changed files with 417 additions and 220 deletions
14
README.md
14
README.md
|
@ -37,7 +37,6 @@ You can download the latest stable from [Releases](https://github.com/sourcegit-
|
|||
For **Windows** users:
|
||||
|
||||
* **MSYS Git is NOT supported**. Please use official [Git for Windows](https://git-scm.com/download/win) instead.
|
||||
* You can use `Visual Studio Code Insiders` as the same way as `Visual Studio Code` in this software.
|
||||
|
||||
For **macOS** users:
|
||||
|
||||
|
@ -54,10 +53,17 @@ For **Linux** users:
|
|||
* Maybe you need to set environment variable `AVALONIA_SCREEN_SCALE_FACTORS`. See https://github.com/AvaloniaUI/Avalonia/wiki/Configuring-X11-per-monitor-DPI.
|
||||
* Modify `SourceGit.desktop.template` (replace SOURCEGIT_LOCAL_FOLDER with real path) and move it into `~/.local/share/applications`.
|
||||
|
||||
Other tips:
|
||||
## External Editors
|
||||
|
||||
* You can set `VSCODE_PATH` environment variable if VSCode can NOT be found when you click `Open In Visual Studio Code`.
|
||||
* You can set `FLEET_PATH` environment variable if JetBrains Fleet can NOT be found when you click `Open In Fleet`.
|
||||
This app supports open repository in external editors listed in the table below.
|
||||
|
||||
| Editor | Windows | macOS | Linux | Environment Variable |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| Visual Studio Code | YES | YES | YES | VSCODE_PATH |
|
||||
| Visual Studio Code - Insiders | YES | YES | YES | VSCODE_INSIDERS_PATH |
|
||||
| JetBrains Fleet | YES | YES | YES | FLEET_PATH |
|
||||
|
||||
You can set the given environment variable for special editor if it can NOT be found by this app automatically.
|
||||
|
||||
## Screen Shots
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace SourceGit.Commands
|
|||
public bool Exec()
|
||||
{
|
||||
var start = new ProcessStartInfo();
|
||||
start.FileName = Native.OS.GitInstallPath;
|
||||
start.FileName = Native.OS.GitExecutable;
|
||||
start.Arguments = "--no-pager -c core.quotepath=off " + Args;
|
||||
start.UseShellExecute = false;
|
||||
start.CreateNoWindow = true;
|
||||
|
@ -144,7 +144,7 @@ namespace SourceGit.Commands
|
|||
public ReadToEndResult ReadToEnd()
|
||||
{
|
||||
var start = new ProcessStartInfo();
|
||||
start.FileName = Native.OS.GitInstallPath;
|
||||
start.FileName = Native.OS.GitExecutable;
|
||||
start.Arguments = "--no-pager -c core.quotepath=off " + Args;
|
||||
start.UseShellExecute = false;
|
||||
start.CreateNoWindow = true;
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace SourceGit.Commands
|
|||
{
|
||||
var starter = new ProcessStartInfo();
|
||||
starter.WorkingDirectory = repo;
|
||||
starter.FileName = Native.OS.GitInstallPath;
|
||||
starter.FileName = Native.OS.GitExecutable;
|
||||
starter.Arguments = $"show {revision}:\"{file}\"";
|
||||
starter.UseShellExecute = false;
|
||||
starter.CreateNoWindow = true;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace SourceGit.Commands
|
|||
{
|
||||
var starter = new ProcessStartInfo();
|
||||
starter.WorkingDirectory = repo;
|
||||
starter.FileName = Native.OS.GitInstallPath;
|
||||
starter.FileName = Native.OS.GitExecutable;
|
||||
starter.Arguments = $"diff --ignore-cr-at-eol --unified=4 {opt}";
|
||||
starter.UseShellExecute = false;
|
||||
starter.CreateNoWindow = true;
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace SourceGit.Commands
|
|||
{
|
||||
var starter = new ProcessStartInfo();
|
||||
starter.WorkingDirectory = repo;
|
||||
starter.FileName = Native.OS.GitInstallPath;
|
||||
starter.FileName = Native.OS.GitExecutable;
|
||||
starter.Arguments = args;
|
||||
starter.UseShellExecute = false;
|
||||
starter.CreateNoWindow = true;
|
||||
|
|
24
src/Models/ExternalEditor.cs
Normal file
24
src/Models/ExternalEditor.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace SourceGit.Models
|
||||
{
|
||||
public class ExternalEditor
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public Uri Icon { get; set; } = null;
|
||||
public string Executable { get; set; } = string.Empty;
|
||||
public string OpenCmdArgs { get; set; } = string.Empty;
|
||||
|
||||
public void Open(string repo)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo()
|
||||
{
|
||||
WorkingDirectory = repo,
|
||||
FileName = Executable,
|
||||
Arguments = string.Format(OpenCmdArgs, repo),
|
||||
UseShellExecute = false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,12 +20,13 @@ namespace SourceGit.Models
|
|||
{
|
||||
Supported = new List<ExternalMergeTools>() {
|
||||
new ExternalMergeTools(0, "Custom", "", "", ""),
|
||||
new ExternalMergeTools(1, "Visual Studio Code", "Code.exe;Code - Insiders.exe", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(2, "Visual Studio 2017/2019", "vsDiffMerge.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" /m", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(3, "Tortoise Merge", "TortoiseMerge.exe;TortoiseGitMerge.exe", "-base:\"$BASE\" -theirs:\"$REMOTE\" -mine:\"$LOCAL\" -merged:\"$MERGED\"", "-base:\"$LOCAL\" -theirs:\"$REMOTE\""),
|
||||
new ExternalMergeTools(4, "KDiff3", "kdiff3.exe", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(5, "Beyond Compare 4", "BComp.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(6, "WinMerge", "WinMergeU.exe", "-u -e \"$REMOTE\" \"$LOCAL\" \"$MERGED\"", "-u -e \"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(1, "Visual Studio Code", "Code.exe", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(2, "Visual Studio Code - Insiders", "Code - Insiders.exe", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(3, "Visual Studio 2017/2019", "vsDiffMerge.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" /m", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(4, "Tortoise Merge", "TortoiseMerge.exe;TortoiseGitMerge.exe", "-base:\"$BASE\" -theirs:\"$REMOTE\" -mine:\"$LOCAL\" -merged:\"$MERGED\"", "-base:\"$LOCAL\" -theirs:\"$REMOTE\""),
|
||||
new ExternalMergeTools(5, "KDiff3", "kdiff3.exe", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(6, "Beyond Compare 4", "BComp.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(7, "WinMerge", "WinMergeU.exe", "-u -e \"$REMOTE\" \"$LOCAL\" \"$MERGED\"", "-u -e \"$LOCAL\" \"$REMOTE\""),
|
||||
};
|
||||
}
|
||||
else if (OperatingSystem.IsMacOS())
|
||||
|
@ -34,8 +35,9 @@ namespace SourceGit.Models
|
|||
new ExternalMergeTools(0, "Custom", "", "", ""),
|
||||
new ExternalMergeTools(1, "FileMerge", "/usr/bin/opendiff", "\"$BASE\" \"$LOCAL\" \"$REMOTE\" -ancestor \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(2, "Visual Studio Code", "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(3, "KDiff3", "/Applications/kdiff3.app/Contents/MacOS/kdiff3", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(4, "Beyond Compare 4", "/Applications/Beyond Compare.app/Contents/MacOS/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(3, "Visual Studio Code - Insiders", "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(4, "KDiff3", "/Applications/kdiff3.app/Contents/MacOS/kdiff3", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(5, "Beyond Compare 4", "/Applications/Beyond Compare.app/Contents/MacOS/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
};
|
||||
}
|
||||
else if (OperatingSystem.IsLinux())
|
||||
|
@ -43,8 +45,9 @@ namespace SourceGit.Models
|
|||
Supported = new List<ExternalMergeTools>() {
|
||||
new ExternalMergeTools(0, "Custom", "", "", ""),
|
||||
new ExternalMergeTools(1, "Visual Studio Code", "/usr/share/code/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(2, "KDiff3", "/usr/bin/kdiff3", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(3, "Beyond Compare 4", "/usr/bin/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(2, "Visual Studio Code - Insiders", "/usr/share/code-insiders/code-insiders", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(3, "KDiff3", "/usr/bin/kdiff3", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
new ExternalMergeTools(4, "Beyond Compare 4", "/usr/bin/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
|
||||
};
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
|
@ -30,20 +31,47 @@ namespace SourceGit.Native
|
|||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindVSCode()
|
||||
public List<Models.ExternalEditor> FindExternalEditors()
|
||||
{
|
||||
var toolPath = "/usr/share/code/code";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
return string.Empty;
|
||||
}
|
||||
var editors = new List<Models.ExternalEditor>();
|
||||
|
||||
public string FindFleet()
|
||||
{
|
||||
var toolPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/.local/share/JetBrains/Toolbox/apps/fleet/bin/Fleet";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
return string.Empty;
|
||||
var vscode = FindVSCode();
|
||||
if (!string.IsNullOrEmpty(vscode) && File.Exists(vscode))
|
||||
{
|
||||
editors.Add(new Models.ExternalEditor
|
||||
{
|
||||
Name = "Visual Studio Code",
|
||||
Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode.png", UriKind.Absolute),
|
||||
Executable = vscode,
|
||||
OpenCmdArgs = "\"{0}\"",
|
||||
});
|
||||
}
|
||||
|
||||
var vscodeInsiders = FindVSCodeInsiders();
|
||||
if (!string.IsNullOrEmpty(vscodeInsiders) && File.Exists(vscodeInsiders))
|
||||
{
|
||||
editors.Add(new Models.ExternalEditor
|
||||
{
|
||||
Name = "Visual Studio Code - Insiders",
|
||||
Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode_insiders.png", UriKind.Absolute),
|
||||
Executable = vscodeInsiders,
|
||||
OpenCmdArgs = "\"{0}\"",
|
||||
});
|
||||
}
|
||||
|
||||
var fleet = FindFleet();
|
||||
if (!string.IsNullOrEmpty(fleet) && File.Exists(fleet))
|
||||
{
|
||||
editors.Add(new Models.ExternalEditor
|
||||
{
|
||||
Name = "JetBrains Fleet",
|
||||
Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/fleet.png", UriKind.Absolute),
|
||||
Executable = fleet,
|
||||
OpenCmdArgs = "\"{0}\"",
|
||||
});
|
||||
}
|
||||
|
||||
return editors;
|
||||
}
|
||||
|
||||
public void OpenBrowser(string url)
|
||||
|
@ -119,5 +147,46 @@ namespace SourceGit.Native
|
|||
|
||||
proc.Close();
|
||||
}
|
||||
|
||||
#region EXTERNAL_EDITORS_FINDER
|
||||
private string FindVSCode()
|
||||
{
|
||||
var toolPath = "/usr/share/code/code";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
|
||||
var customPath = Environment.GetEnvironmentVariable("VSCODE_PATH");
|
||||
if (!string.IsNullOrEmpty(customPath))
|
||||
return customPath;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string FindVSCodeInsiders()
|
||||
{
|
||||
var toolPath = "/usr/share/code/code";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
|
||||
var customPath = Environment.GetEnvironmentVariable("VSCODE_INSIDERS_PATH");
|
||||
if (!string.IsNullOrEmpty(customPath))
|
||||
return customPath;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string FindFleet()
|
||||
{
|
||||
var toolPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/.local/share/JetBrains/Toolbox/apps/fleet/bin/Fleet";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
|
||||
var customPath = Environment.GetEnvironmentVariable("FLEET_PATH");
|
||||
if (!string.IsNullOrEmpty(customPath))
|
||||
return customPath;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
|
@ -27,20 +28,47 @@ namespace SourceGit.Native
|
|||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindVSCode()
|
||||
public List<Models.ExternalEditor> FindExternalEditors()
|
||||
{
|
||||
var toolPath = "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
return string.Empty;
|
||||
}
|
||||
var editors = new List<Models.ExternalEditor>();
|
||||
|
||||
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;
|
||||
var vscode = FindVSCode();
|
||||
if (!string.IsNullOrEmpty(vscode) && File.Exists(vscode))
|
||||
{
|
||||
editors.Add(new Models.ExternalEditor
|
||||
{
|
||||
Name = "Visual Studio Code",
|
||||
Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode.png", UriKind.Absolute),
|
||||
Executable = vscode,
|
||||
OpenCmdArgs = "\"{0}\"",
|
||||
});
|
||||
}
|
||||
|
||||
var vscodeInsiders = FindVSCodeInsiders();
|
||||
if (!string.IsNullOrEmpty(vscodeInsiders) && File.Exists(vscodeInsiders))
|
||||
{
|
||||
editors.Add(new Models.ExternalEditor
|
||||
{
|
||||
Name = "Visual Studio Code - Insiders",
|
||||
Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode_insiders.png", UriKind.Absolute),
|
||||
Executable = vscodeInsiders,
|
||||
OpenCmdArgs = "\"{0}\"",
|
||||
});
|
||||
}
|
||||
|
||||
var fleet = FindFleet();
|
||||
if (!string.IsNullOrEmpty(fleet) && File.Exists(fleet))
|
||||
{
|
||||
editors.Add(new Models.ExternalEditor
|
||||
{
|
||||
Name = "JetBrains Fleet",
|
||||
Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/fleet.png", UriKind.Absolute),
|
||||
Executable = fleet,
|
||||
OpenCmdArgs = "\"{0}\"",
|
||||
});
|
||||
}
|
||||
|
||||
return editors;
|
||||
}
|
||||
|
||||
public void OpenBrowser(string url)
|
||||
|
@ -82,5 +110,46 @@ namespace SourceGit.Native
|
|||
{
|
||||
Process.Start("open", file);
|
||||
}
|
||||
|
||||
#region EXTERNAL_EDITORS_FINDER
|
||||
private string FindVSCode()
|
||||
{
|
||||
var toolPath = "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
|
||||
var customPath = Environment.GetEnvironmentVariable("VSCODE_PATH");
|
||||
if (!string.IsNullOrEmpty(customPath))
|
||||
return customPath;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string FindVSCodeInsiders()
|
||||
{
|
||||
var toolPath = "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
|
||||
var customPath = Environment.GetEnvironmentVariable("VSCODE_INSIDERS_PATH");
|
||||
if (!string.IsNullOrEmpty(customPath))
|
||||
return customPath;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string FindFleet()
|
||||
{
|
||||
var toolPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Applications/Fleet.app/Contents/MacOS/Fleet";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
|
||||
var customPath = Environment.GetEnvironmentVariable("FLEET_PATH");
|
||||
if (!string.IsNullOrEmpty(customPath))
|
||||
return customPath;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Avalonia;
|
||||
|
||||
|
@ -13,8 +12,7 @@ namespace SourceGit.Native
|
|||
void SetupApp(AppBuilder builder);
|
||||
|
||||
string FindGitExecutable();
|
||||
string FindVSCode();
|
||||
string FindFleet();
|
||||
List<Models.ExternalEditor> FindExternalEditors();
|
||||
|
||||
void OpenTerminal(string workdir);
|
||||
void OpenInFileManager(string path, bool select);
|
||||
|
@ -22,11 +20,8 @@ namespace SourceGit.Native
|
|||
void OpenWithDefaultEditor(string file);
|
||||
}
|
||||
|
||||
public static string GitInstallPath { get; set; }
|
||||
|
||||
public static string VSCodeExecutableFile { get; set; }
|
||||
|
||||
public static string FleetExecutableFile { get; set; }
|
||||
public static string GitExecutable { get; set; } = string.Empty;
|
||||
public static List<Models.ExternalEditor> ExternalEditors { get; set; } = new List<Models.ExternalEditor>();
|
||||
|
||||
static OS()
|
||||
{
|
||||
|
@ -47,13 +42,7 @@ namespace SourceGit.Native
|
|||
throw new Exception("Platform unsupported!!!");
|
||||
}
|
||||
|
||||
VSCodeExecutableFile = _backend.FindVSCode();
|
||||
if (string.IsNullOrEmpty(VSCodeExecutableFile))
|
||||
VSCodeExecutableFile = GetPathFromEnvironmentVar("VSCODE_PATH");
|
||||
|
||||
FleetExecutableFile = _backend.FindFleet();
|
||||
if (string.IsNullOrEmpty(FleetExecutableFile))
|
||||
FleetExecutableFile = GetPathFromEnvironmentVar("FLEET_PATH");
|
||||
ExternalEditors = _backend.FindExternalEditors();
|
||||
}
|
||||
|
||||
public static void SetupApp(AppBuilder builder)
|
||||
|
@ -86,51 +75,6 @@ namespace SourceGit.Native
|
|||
_backend.OpenWithDefaultEditor(file);
|
||||
}
|
||||
|
||||
public static void OpenInVSCode(string repo)
|
||||
{
|
||||
if (string.IsNullOrEmpty(VSCodeExecutableFile))
|
||||
{
|
||||
App.RaiseException(repo, "Visual Studio Code can NOT be found in your system!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
Process.Start(new ProcessStartInfo()
|
||||
{
|
||||
WorkingDirectory = repo,
|
||||
FileName = VSCodeExecutableFile,
|
||||
Arguments = $"\"{repo}\"",
|
||||
UseShellExecute = false,
|
||||
});
|
||||
}
|
||||
|
||||
public static void OpenInFleet(string repo)
|
||||
{
|
||||
if (string.IsNullOrEmpty(FleetExecutableFile))
|
||||
{
|
||||
App.RaiseException(repo, "Fleet can NOT be found in your system!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
Process.Start(new ProcessStartInfo()
|
||||
{
|
||||
WorkingDirectory = repo,
|
||||
FileName = FleetExecutableFile,
|
||||
Arguments = $"\"{repo}\"",
|
||||
UseShellExecute = false,
|
||||
});
|
||||
}
|
||||
|
||||
private static string GetPathFromEnvironmentVar(string key)
|
||||
{
|
||||
var customPath = Environment.GetEnvironmentVariable(key);
|
||||
if (!string.IsNullOrEmpty(customPath) && File.Exists(customPath))
|
||||
{
|
||||
return customPath;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private static readonly IBackend _backend;
|
||||
private static IBackend _backend = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
@ -113,54 +114,47 @@ namespace SourceGit.Native
|
|||
return null;
|
||||
}
|
||||
|
||||
public string FindVSCode()
|
||||
public List<Models.ExternalEditor> FindExternalEditors()
|
||||
{
|
||||
var localMachine = Microsoft.Win32.RegistryKey.OpenBaseKey(
|
||||
Microsoft.Win32.RegistryHive.LocalMachine,
|
||||
Microsoft.Win32.RegistryView.Registry64);
|
||||
var editors = new List<Models.ExternalEditor>();
|
||||
|
||||
// VSCode (system)
|
||||
var systemVScode = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1");
|
||||
if (systemVScode != null)
|
||||
var vscode = FindVSCode();
|
||||
if (!string.IsNullOrEmpty(vscode) && File.Exists(vscode))
|
||||
{
|
||||
return systemVScode.GetValue("DisplayIcon") as string;
|
||||
editors.Add(new Models.ExternalEditor
|
||||
{
|
||||
Name = "Visual Studio Code",
|
||||
Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode.png", UriKind.Absolute),
|
||||
Executable = vscode,
|
||||
OpenCmdArgs = "\"{0}\"",
|
||||
});
|
||||
}
|
||||
|
||||
// VSCode - Insiders (system)
|
||||
var systemVScodeInsiders = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1");
|
||||
if (systemVScodeInsiders != null)
|
||||
var vscodeInsiders = FindVSCodeInsiders();
|
||||
if (!string.IsNullOrEmpty(vscodeInsiders) && File.Exists(vscodeInsiders))
|
||||
{
|
||||
return systemVScodeInsiders.GetValue("DisplayIcon") as string;
|
||||
editors.Add(new Models.ExternalEditor
|
||||
{
|
||||
Name = "Visual Studio Code - Insiders",
|
||||
Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode_insiders.png", UriKind.Absolute),
|
||||
Executable = vscodeInsiders,
|
||||
OpenCmdArgs = "\"{0}\"",
|
||||
});
|
||||
}
|
||||
|
||||
var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey(
|
||||
Microsoft.Win32.RegistryHive.CurrentUser,
|
||||
Microsoft.Win32.RegistryView.Registry64);
|
||||
|
||||
// VSCode (user)
|
||||
var vscode = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{771FD6B0-FA20-440A-A002-3B3BAC16DC50}_is1");
|
||||
if (vscode != null)
|
||||
var fleet = FindFleet();
|
||||
if (!string.IsNullOrEmpty(fleet) && File.Exists(fleet))
|
||||
{
|
||||
return vscode.GetValue("DisplayIcon") as string;
|
||||
editors.Add(new Models.ExternalEditor
|
||||
{
|
||||
Name = "JetBrains Fleet",
|
||||
Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/fleet.png", UriKind.Absolute),
|
||||
Executable = fleet,
|
||||
OpenCmdArgs = "\"{0}\"",
|
||||
});
|
||||
}
|
||||
|
||||
// VSCode - Insiders (user)
|
||||
var vscodeInsiders = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{217B4C08-948D-4276-BFBB-BEE930AE5A2C}_is1");
|
||||
if (vscodeInsiders != null)
|
||||
{
|
||||
return vscodeInsiders.GetValue("DisplayIcon") as string;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindFleet()
|
||||
{
|
||||
var toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Fleet\\Fleet.exe");
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
|
||||
return string.Empty;
|
||||
return editors;
|
||||
}
|
||||
|
||||
public void OpenBrowser(string url)
|
||||
|
@ -172,10 +166,11 @@ namespace SourceGit.Native
|
|||
|
||||
public void OpenTerminal(string workdir)
|
||||
{
|
||||
var bash = Path.Combine(Path.GetDirectoryName(OS.GitInstallPath), "bash.exe");
|
||||
var binDir = Path.GetDirectoryName(OS.GitExecutable);
|
||||
var bash = Path.Combine(binDir, "bash.exe");
|
||||
if (!File.Exists(bash))
|
||||
{
|
||||
App.RaiseException(string.IsNullOrEmpty(workdir) ? "" : workdir, $"Can NOT found bash.exe under '{Path.GetDirectoryName(OS.GitInstallPath)}'");
|
||||
App.RaiseException(string.IsNullOrEmpty(workdir) ? "" : workdir, $"Can NOT found bash.exe under '{binDir}'");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -227,6 +222,89 @@ namespace SourceGit.Native
|
|||
Process.Start(start);
|
||||
}
|
||||
|
||||
#region EXTERNAL_EDITOR_FINDER
|
||||
private string FindVSCode()
|
||||
{
|
||||
var localMachine = Microsoft.Win32.RegistryKey.OpenBaseKey(
|
||||
Microsoft.Win32.RegistryHive.LocalMachine,
|
||||
Microsoft.Win32.RegistryView.Registry64);
|
||||
|
||||
// VSCode (system)
|
||||
var systemVScode = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1");
|
||||
if (systemVScode != null)
|
||||
{
|
||||
return systemVScode.GetValue("DisplayIcon") as string;
|
||||
}
|
||||
|
||||
var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey(
|
||||
Microsoft.Win32.RegistryHive.CurrentUser,
|
||||
Microsoft.Win32.RegistryView.Registry64);
|
||||
|
||||
// VSCode (user)
|
||||
var vscode = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{771FD6B0-FA20-440A-A002-3B3BAC16DC50}_is1");
|
||||
if (vscode != null)
|
||||
{
|
||||
return vscode.GetValue("DisplayIcon") as string;
|
||||
}
|
||||
|
||||
// ENV
|
||||
var customPath = Environment.GetEnvironmentVariable("VSCODE_PATH");
|
||||
if (!string.IsNullOrEmpty(customPath))
|
||||
{
|
||||
return customPath;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string FindVSCodeInsiders()
|
||||
{
|
||||
var localMachine = Microsoft.Win32.RegistryKey.OpenBaseKey(
|
||||
Microsoft.Win32.RegistryHive.LocalMachine,
|
||||
Microsoft.Win32.RegistryView.Registry64);
|
||||
|
||||
// VSCode - Insiders (system)
|
||||
var systemVScodeInsiders = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1");
|
||||
if (systemVScodeInsiders != null)
|
||||
{
|
||||
return systemVScodeInsiders.GetValue("DisplayIcon") as string;
|
||||
}
|
||||
|
||||
var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey(
|
||||
Microsoft.Win32.RegistryHive.CurrentUser,
|
||||
Microsoft.Win32.RegistryView.Registry64);
|
||||
|
||||
// VSCode - Insiders (user)
|
||||
var vscodeInsiders = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{217B4C08-948D-4276-BFBB-BEE930AE5A2C}_is1");
|
||||
if (vscodeInsiders != null)
|
||||
{
|
||||
return vscodeInsiders.GetValue("DisplayIcon") as string;
|
||||
}
|
||||
|
||||
// ENV
|
||||
var customPath = Environment.GetEnvironmentVariable("VSCODE_INSIDERS_PATH");
|
||||
if (!string.IsNullOrEmpty(customPath))
|
||||
{
|
||||
return customPath;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string FindFleet()
|
||||
{
|
||||
var toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Fleet\\Fleet.exe");
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
|
||||
var customPath = Environment.GetEnvironmentVariable("FLEET_PATH");
|
||||
if (!string.IsNullOrEmpty(customPath))
|
||||
return customPath;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void OpenFolderAndSelectFile(string folderPath)
|
||||
{
|
||||
var pidl = ILCreateFromPathW(folderPath);
|
||||
|
|
BIN
src/Resources/ExternalToolIcons/vscode_insiders.png
Normal file
BIN
src/Resources/ExternalToolIcons/vscode_insiders.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
35
src/Resources/Locales.Designer.cs
generated
35
src/Resources/Locales.Designer.cs
generated
|
@ -1600,7 +1600,7 @@ namespace SourceGit.Resources {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to GIT FLOW.
|
||||
/// Looks up a localized string similar to Git-Flow.
|
||||
/// </summary>
|
||||
public static string Text_GitFlow {
|
||||
get {
|
||||
|
@ -2985,15 +2985,6 @@ namespace SourceGit.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open In Fleet.
|
||||
/// </summary>
|
||||
public static string Text_Repository_Fleet {
|
||||
get {
|
||||
return ResourceManager.GetString("Text.Repository.Fleet", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to LOCAL BRANCHES.
|
||||
/// </summary>
|
||||
|
@ -3013,7 +3004,7 @@ namespace SourceGit.Resources {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to NEW BRANCH.
|
||||
/// Looks up a localized string similar to Create Branch.
|
||||
/// </summary>
|
||||
public static string Text_Repository_NewBranch {
|
||||
get {
|
||||
|
@ -3021,12 +3012,21 @@ namespace SourceGit.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open In {0}.
|
||||
/// </summary>
|
||||
public static string Text_Repository_OpenIn {
|
||||
get {
|
||||
return ResourceManager.GetString("Text.Repository.OpenIn", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open In External Tools.
|
||||
/// </summary>
|
||||
public static string Text_Repository_OpenWith {
|
||||
public static string Text_Repository_OpenWithExternalTools {
|
||||
get {
|
||||
return ResourceManager.GetString("Text.Repository.OpenWith", resourceCulture);
|
||||
return ResourceManager.GetString("Text.Repository.OpenWithExternalTools", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3147,15 +3147,6 @@ namespace SourceGit.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open In Visual Studio Code.
|
||||
/// </summary>
|
||||
public static string Text_Repository_VSCode {
|
||||
get {
|
||||
return ResourceManager.GetString("Text.Repository.VSCode", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to WORKSPACE.
|
||||
/// </summary>
|
||||
|
|
|
@ -339,11 +339,8 @@
|
|||
<data xml:space="preserve" name="Text.Repository.Explore">
|
||||
<value>Open In File Browser</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.VSCode">
|
||||
<value>Open In Visual Studio Code</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.Fleet">
|
||||
<value>Open In Fleet</value>
|
||||
<data xml:space="preserve" name="Text.Repository.OpenIn">
|
||||
<value>Open In {0}</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.Terminal">
|
||||
<value>Open In Terminal</value>
|
||||
|
@ -376,7 +373,7 @@
|
|||
<value>LOCAL BRANCHES</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.NewBranch">
|
||||
<value>NEW BRANCH</value>
|
||||
<value>Create Branch</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.Remotes">
|
||||
<value>REMOTES</value>
|
||||
|
@ -409,7 +406,7 @@
|
|||
<value>ABORT</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.GitFlow">
|
||||
<value>GIT FLOW</value>
|
||||
<value>Git-Flow</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.GitFlow.Init">
|
||||
<value>Initialize Git-Flow</value>
|
||||
|
@ -1293,7 +1290,7 @@
|
|||
<data name="Text.Preference.Appearance" xml:space="preserve">
|
||||
<value>APPEARANCE</value>
|
||||
</data>
|
||||
<data name="Text.Repository.OpenWith" xml:space="preserve">
|
||||
<data name="Text.Repository.OpenWithExternalTools" xml:space="preserve">
|
||||
<value>Open In External Tools</value>
|
||||
</data>
|
||||
<data name="Text.SelfUpdate.Title" xml:space="preserve">
|
||||
|
|
|
@ -339,11 +339,8 @@
|
|||
<data xml:space="preserve" name="Text.Repository.Explore">
|
||||
<value>Open In File Browser</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.VSCode">
|
||||
<value>Open In Visual Studio Code</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.Fleet">
|
||||
<value>Open In Fleet</value>
|
||||
<data xml:space="preserve" name="Text.Repository.OpenIn">
|
||||
<value>Open In {0}</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.Terminal">
|
||||
<value>Open In Terminal</value>
|
||||
|
@ -376,7 +373,7 @@
|
|||
<value>LOCAL BRANCHES</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.NewBranch">
|
||||
<value>NEW BRANCH</value>
|
||||
<value>Create Branch</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.Remotes">
|
||||
<value>REMOTES</value>
|
||||
|
@ -409,7 +406,7 @@
|
|||
<value>ABORT</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.GitFlow">
|
||||
<value>GIT FLOW</value>
|
||||
<value>Git-Flow</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.GitFlow.Init">
|
||||
<value>Initialize Git-Flow</value>
|
||||
|
@ -1293,7 +1290,7 @@
|
|||
<data name="Text.Preference.Appearance" xml:space="preserve">
|
||||
<value>Appearance</value>
|
||||
</data>
|
||||
<data name="Text.Repository.OpenWith" xml:space="preserve">
|
||||
<data name="Text.Repository.OpenWithExternalTools" xml:space="preserve">
|
||||
<value>Open In External Tools</value>
|
||||
</data>
|
||||
<data name="Text.SelfUpdate.Title" xml:space="preserve">
|
||||
|
|
|
@ -339,8 +339,8 @@
|
|||
<data xml:space="preserve" name="Text.Repository.Explore">
|
||||
<value>在文件浏览器中打开</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.VSCode">
|
||||
<value>在 Visual Studio Code 中打开</value>
|
||||
<data xml:space="preserve" name="Text.Repository.OpenIn">
|
||||
<value>在 {0} 中打开</value>
|
||||
</data>
|
||||
<data xml:space="preserve" name="Text.Repository.Terminal">
|
||||
<value>在终端中打开</value>
|
||||
|
@ -1317,15 +1317,12 @@
|
|||
<data name="Text.About.SubTitle" xml:space="preserve">
|
||||
<value>开源免费的Git客户端</value>
|
||||
</data>
|
||||
<data name="Text.Repository.OpenWith" xml:space="preserve">
|
||||
<data name="Text.Repository.OpenWithExternalTools" xml:space="preserve">
|
||||
<value>使用外部工具打开</value>
|
||||
</data>
|
||||
<data name="Text.About.SourceCode" xml:space="preserve">
|
||||
<value>• 项目源代码地址 </value>
|
||||
</data>
|
||||
<data name="Text.Repository.Fleet" xml:space="preserve">
|
||||
<value>在 Fleet 中打开</value>
|
||||
</data>
|
||||
<data name="Text.InProgress.CherryPick" xml:space="preserve">
|
||||
<value>挑选(Cherry-Pick)操作进行中。点击【终止】回滚到操作前的状态。</value>
|
||||
</data>
|
||||
|
|
|
@ -189,12 +189,12 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public string GitInstallPath
|
||||
{
|
||||
get => Native.OS.GitInstallPath;
|
||||
get => Native.OS.GitExecutable;
|
||||
set
|
||||
{
|
||||
if (Native.OS.GitInstallPath != value)
|
||||
if (Native.OS.GitExecutable != value)
|
||||
{
|
||||
Native.OS.GitInstallPath = value;
|
||||
Native.OS.GitExecutable = value;
|
||||
OnPropertyChanged(nameof(GitInstallPath));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ using System.Threading.Tasks;
|
|||
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Threading;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
@ -279,21 +282,43 @@ namespace SourceGit.ViewModels
|
|||
Native.OS.OpenInFileManager(_fullpath);
|
||||
}
|
||||
|
||||
public void OpenInVSCode()
|
||||
{
|
||||
Native.OS.OpenInVSCode(_fullpath);
|
||||
}
|
||||
|
||||
public void OpenInFleet()
|
||||
{
|
||||
Native.OS.OpenInFleet(_fullpath);
|
||||
}
|
||||
|
||||
public void OpenInTerminal()
|
||||
{
|
||||
Native.OS.OpenTerminal(_fullpath);
|
||||
}
|
||||
|
||||
public ContextMenu CreateContextMenuForExternalEditors()
|
||||
{
|
||||
var editors = Native.OS.ExternalEditors;
|
||||
if (editors.Count == 0)
|
||||
{
|
||||
App.RaiseException(_fullpath, "No available external editors found!");
|
||||
return null;
|
||||
}
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Placement = PlacementMode.BottomEdgeAlignedLeft;
|
||||
RenderOptions.SetBitmapInterpolationMode(menu, BitmapInterpolationMode.HighQuality);
|
||||
|
||||
foreach (var editor in editors)
|
||||
{
|
||||
var dupEditor = editor;
|
||||
var icon = AssetLoader.Open(dupEditor.Icon);
|
||||
var item = new MenuItem();
|
||||
item.Header = App.Text("Repository.OpenIn", dupEditor.Name);
|
||||
item.Icon = new Image { Width = 16, Height = 16, Source = new Bitmap(icon) };
|
||||
item.Click += (o, e) =>
|
||||
{
|
||||
dupEditor.Open(_fullpath);
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(item);
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
public void Fetch()
|
||||
{
|
||||
if (!PopupHost.CanCreatePopup())
|
||||
|
|
|
@ -22,22 +22,8 @@
|
|||
<Path Width="13" Height="13" Data="{StaticResource Icons.Terminal}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" ToolTip.Tip="{DynamicResource Text.Repository.OpenWith}">
|
||||
<Button Classes="icon_button" Width="32" Click="OnOpenWithExternalEditor" ToolTip.Tip="{DynamicResource Text.Repository.OpenWithExternalTools}">
|
||||
<Path Width="13" Height="13" Data="{StaticResource Icons.OpenWith}"/>
|
||||
<Button.Flyout>
|
||||
<MenuFlyout Placement="BottomEdgeAlignedLeft" VerticalOffset="-8">
|
||||
<MenuItem Header="{DynamicResource Text.Repository.Fleet}" Command="{Binding OpenInFleet}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="/Resources/ExternalToolIcons/fleet.png" Width="16" Height="16" RenderOptions.BitmapInterpolationMode="HighQuality"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="{DynamicResource Text.Repository.VSCode}" Command="{Binding OpenInVSCode}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="/Resources/ExternalToolIcons/vscode.png" Width="16" Height="16" RenderOptions.BitmapInterpolationMode="HighQuality"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
|
||||
<ToggleButton Width="32"
|
||||
|
|
|
@ -7,8 +7,6 @@ using Avalonia.Controls.Primitives;
|
|||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
using SourceGit.ViewModels;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public class RepositorySubView : Border
|
||||
|
@ -63,6 +61,19 @@ namespace SourceGit.Views
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnOpenWithExternalEditor(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button button && DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
var menu = repo.CreateContextMenuForExternalEditors();
|
||||
if (menu != null)
|
||||
{
|
||||
menu.Open(button);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLocalBranchTreeLostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is TreeView tree)
|
||||
|
@ -275,7 +286,7 @@ namespace SourceGit.Views
|
|||
|
||||
private void OnDoubleTappedLocalBranchNode(object sender, TappedEventArgs e)
|
||||
{
|
||||
if (!PopupHost.CanCreatePopup())
|
||||
if (!ViewModels.PopupHost.CanCreatePopup())
|
||||
return;
|
||||
|
||||
if (sender is Grid grid && DataContext is ViewModels.Repository repo)
|
||||
|
@ -287,7 +298,7 @@ namespace SourceGit.Views
|
|||
if (branch.IsCurrent)
|
||||
return;
|
||||
|
||||
PopupHost.ShowAndStartPopup(new ViewModels.Checkout(repo, branch.Name));
|
||||
ViewModels.PopupHost.ShowAndStartPopup(new ViewModels.Checkout(repo, branch.Name));
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue