feature<OpenTerminal>: support Windows Terminal

This commit is contained in:
李通洲 2021-09-03 19:27:19 +08:00
parent f041adb2b3
commit 5e706588a0
6 changed files with 123 additions and 86 deletions

View file

@ -1,5 +1,7 @@
using Microsoft.Win32;
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
@ -14,6 +16,13 @@ namespace SourceGit.Views {
public string Email { get; set; }
public string CRLF { get; set; }
// https://docs.microsoft.com/en-us/windows/desktop/api/shlwapi/nf-shlwapi-pathfindonpathw
// https://www.pinvoke.net/default.aspx/shlwapi.PathFindOnPath
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode, SetLastError = false)]
private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs);
public bool EnableWindowsTerminal { get; set; } = PathFindOnPath(new StringBuilder("wt.exe"), null);
public Preference() {
if (Models.Preference.Instance.IsReady) {
User = new Commands.Config().Get("user.name");
@ -26,6 +35,10 @@ namespace SourceGit.Views {
CRLF = "false";
}
if (!EnableWindowsTerminal) {
Models.Preference.Instance.General.UseWindowsTerminal = false;
}
InitializeComponent();
}