mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
Merge pull request #480 from aikawayataro/terminal-fixes
Few terminal fixes
This commit is contained in:
commit
65c2087f6b
5 changed files with 41 additions and 6 deletions
|
@ -54,6 +54,7 @@ namespace SourceGit.Models
|
|||
new ShellOrTerminal("deepin-terminal", "Deepin Terminal", "deepin-terminal"),
|
||||
new ShellOrTerminal("mate-terminal", "MATE Terminal", "mate-terminal"),
|
||||
new ShellOrTerminal("foot", "Foot", "foot"),
|
||||
new ShellOrTerminal("custom", "Custom", ""),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,11 @@ namespace SourceGit.Native
|
|||
|
||||
public string FindTerminal(Models.ShellOrTerminal shell)
|
||||
{
|
||||
if (string.IsNullOrEmpty(shell.Exec))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var pathVariable = Environment.GetEnvironmentVariable("PATH") ?? string.Empty;
|
||||
var pathes = pathVariable.Split(Path.PathSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var path in pathes)
|
||||
|
@ -71,16 +76,24 @@ namespace SourceGit.Native
|
|||
|
||||
public void OpenTerminal(string workdir)
|
||||
{
|
||||
if (string.IsNullOrEmpty(OS.ShellOrTerminal) || !File.Exists(OS.ShellOrTerminal))
|
||||
if (string.IsNullOrEmpty(OS.ShellOrTerminal))
|
||||
{
|
||||
App.RaiseException(workdir, $"Can not found terminal! Please confirm that the correct shell/terminal has been configured.");
|
||||
App.RaiseException(workdir, $"Terminal is not specified! Please confirm that the correct shell/terminal has been configured.");
|
||||
return;
|
||||
}
|
||||
|
||||
var startInfo = new ProcessStartInfo();
|
||||
startInfo.WorkingDirectory = string.IsNullOrEmpty(workdir) ? "~" : workdir;
|
||||
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
startInfo.WorkingDirectory = string.IsNullOrEmpty(workdir) ? home : workdir;
|
||||
startInfo.FileName = OS.ShellOrTerminal;
|
||||
Process.Start(startInfo);
|
||||
try
|
||||
{
|
||||
Process.Start(startInfo);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
App.RaiseException(workdir, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenWithDefaultEditor(string file)
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace SourceGit.Native
|
|||
public static void OpenTerminal(string workdir)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ShellOrTerminal))
|
||||
App.RaiseException(workdir, $"Can not found terminal! Please confirm that the correct shell/terminal has been configured.");
|
||||
App.RaiseException(workdir, $"Terminal is not specified! Please confirm that the correct shell/terminal has been configured.");
|
||||
else
|
||||
_backend.OpenTerminal(workdir);
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace SourceGit.Native
|
|||
{
|
||||
if (string.IsNullOrEmpty(OS.ShellOrTerminal) || !File.Exists(OS.ShellOrTerminal))
|
||||
{
|
||||
App.RaiseException(workdir, $"Can not found terminal! Please confirm that the correct shell/terminal has been configured.");
|
||||
App.RaiseException(workdir, $"Terminal is not specified! Please confirm that the correct shell/terminal has been configured.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,22 @@ namespace SourceGit.ViewModels
|
|||
if (!_instance.IsGitConfigured())
|
||||
_instance.GitInstallPath = Native.OS.FindGitExecutable();
|
||||
|
||||
if (!_instance.IsTerminalConfigured())
|
||||
{
|
||||
for (var i = 0; i < Models.ShellOrTerminal.Supported.Count; i++)
|
||||
{
|
||||
_instance.ShellOrTerminal = i;
|
||||
if (string.IsNullOrEmpty(_instance.ShellOrTerminalPath))
|
||||
{
|
||||
_instance.ShellOrTerminal = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_instance.Workspaces.Count == 0)
|
||||
_instance.Workspaces.Add(new Workspace() { Name = "Default", Color = 4278221015 });
|
||||
|
||||
|
@ -380,6 +396,11 @@ namespace SourceGit.ViewModels
|
|||
return !string.IsNullOrEmpty(path) && File.Exists(path);
|
||||
}
|
||||
|
||||
public bool IsTerminalConfigured()
|
||||
{
|
||||
return ShellOrTerminal != -1;
|
||||
}
|
||||
|
||||
public bool ShouldCheck4UpdateOnStartup()
|
||||
{
|
||||
if (!_check4UpdatesOnStartup)
|
||||
|
|
Loading…
Reference in a new issue