From a92c38919fdc4b05ad0fbbfaa9127ee354194089 Mon Sep 17 00:00:00 2001 From: Rick Strahl Date: Wed, 4 Sep 2019 00:01:28 -0700 Subject: [PATCH] Update Terminal Handling code to explicitly change path to the target folder before launching the Terminal or Shell. This allows the new Windows Terminal to be used, but only if customizing the profile. More info: https://weblog.west-wind.com/posts/2019/Sep/03/Programmatically-Opening-Windows-Terminal-in-a-Specific-Folder --- .../_Classes/Commands/AppCommands.cs | 8 ++++- .../Configuration/ApplicationConfiguration.cs | 15 ++++----- .../_Classes/Utilities/mmFileUtils.cs | 29 +++++++++++++----- SupportAssemblies/Westwind.TypeImporter.dll | Bin 41984 -> 41984 bytes 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/MarkdownMonster/_Classes/Commands/AppCommands.cs b/MarkdownMonster/_Classes/Commands/AppCommands.cs index ad4aad34a..dd5b8ac33 100644 --- a/MarkdownMonster/_Classes/Commands/AppCommands.cs +++ b/MarkdownMonster/_Classes/Commands/AppCommands.cs @@ -2181,7 +2181,13 @@ void ViewInExternalBrowser() // EXTERNAL BROWSER VIEW ViewInExternalBrowserCommand = new CommandBase((p, e) => { - if (Model.ActiveDocument == null) return; + if (Model.ActiveEditor?.MarkdownDocument == null) + { + if(!string.IsNullOrEmpty(Model.ActiveTabFilename)) + mmFileUtils.ShowExternalBrowser(Model.ActiveTabFilename); + + return; + } Model.ActiveDocument.RenderHtmlToFile(); mmFileUtils.ShowExternalBrowser(Model.ActiveDocument.HtmlRenderFilename); diff --git a/MarkdownMonster/_Classes/Configuration/ApplicationConfiguration.cs b/MarkdownMonster/_Classes/Configuration/ApplicationConfiguration.cs index 545af1f8f..54767a032 100644 --- a/MarkdownMonster/_Classes/Configuration/ApplicationConfiguration.cs +++ b/MarkdownMonster/_Classes/Configuration/ApplicationConfiguration.cs @@ -268,13 +268,14 @@ public bool AlwaysUsePreviewRefresh /// public string OpenFolderCommand { get; set; } - /// - /// Command Processing Executable to bring up a terminal window - /// Command or Powershell, but could also be Console or ConEmu - /// cmd.exe /k \"cd {0}\" - /// powershell.exe -NoExit -Command "& cd 'c:\program files'" - /// - public string TerminalCommand { get; set; } + /// + /// Command Processing Executable to bring up a terminal window + /// Command or Powershell, but could also be Console or ConEmu + /// cmd.exe /k \"cd {0}\" + /// powershell.exe -NoExit -Command "& cd 'c:\program files'" + /// wt.exe (leave blank) & set Profile "startingDirectory" : "%__CD__%", + /// + public string TerminalCommand { get; set; } /// /// Terminal executable arguments to pass to bring up terminal diff --git a/MarkdownMonster/_Classes/Utilities/mmFileUtils.cs b/MarkdownMonster/_Classes/Utilities/mmFileUtils.cs index ca0f7bcee..6efc74bfa 100644 --- a/MarkdownMonster/_Classes/Utilities/mmFileUtils.cs +++ b/MarkdownMonster/_Classes/Utilities/mmFileUtils.cs @@ -457,8 +457,14 @@ public static bool OpenTerminal(string folder) { try { - Process.Start(mmApp.Configuration.TerminalCommand, - string.Format(mmApp.Configuration.TerminalCommandArgs, folder)); + var pi = new ProcessStartInfo + { + FileName = mmApp.Configuration.TerminalCommand, + Arguments = string.Format(mmApp.Configuration.TerminalCommandArgs, folder), + WorkingDirectory = folder, + UseShellExecute = false + }; + Process.Start(pi); } catch { @@ -475,15 +481,22 @@ public static bool OpenTerminal(string folder) /// public static void ShowExternalBrowser(string url) { - if (string.IsNullOrEmpty(mmApp.Configuration.WebBrowserPreviewExecutable) || - !File.Exists(mmApp.Configuration.WebBrowserPreviewExecutable)) + try { - mmApp.Configuration.WebBrowserPreviewExecutable = null; - ShellUtils.GoUrl(url); + if (string.IsNullOrEmpty(mmApp.Configuration.WebBrowserPreviewExecutable) || + !File.Exists(mmApp.Configuration.WebBrowserPreviewExecutable)) + { + mmApp.Configuration.WebBrowserPreviewExecutable = null; + ShellUtils.GoUrl(url); + } + else + { + ShellUtils.ExecuteProcess(mmApp.Configuration.WebBrowserPreviewExecutable, $"\"{url}\""); + } } - else + catch (Exception ex) { - ShellUtils.ExecuteProcess(mmApp.Configuration.WebBrowserPreviewExecutable, $"\"{url}\""); + mmApp.Log($"External Preview failed: {url}", ex, logLevel: LogLevels.Warning); } } diff --git a/SupportAssemblies/Westwind.TypeImporter.dll b/SupportAssemblies/Westwind.TypeImporter.dll index 2c93c9e4e0365eb8f09adb42efb28a640ae9a2bf..30b1bf482e19f6a378f0308e9c203cfa332dfd65 100644 GIT binary patch delta 2161 zcmb7Gdu&rx82?W1dhhMlt?kO%ZtWg0)^%$;TFRbfOk{=)(M?8~I548j2^-#V2nH3L z+jws%<1iW7A}|cfABv<75FeO;VLFXjG#H~1<^!Xkgv7*%F7rFL>#X<}ZF0`{`+d)I zzH{!q&kt*!AJ**MDZ~Yop00Fqs^@q;SnF+ z!?Rsu7uhSG9CDp~?3qP!*)7le1lVcsP`aG}ysiaEisZsX0KH`)PJ|))=O@Ry1K#aF;T5SZyXUo;a)CJq;Nz%MUo`29a0Kj7Oq1D4Rvu8qiC$ zk=v^akZl~FoWc?vN7*FO3f3K{B%N$DP@Q*QJW}zr38zSJRacYFWx#YT?l9|8=2!2k8<$@`(sYJIK;*CEUnN!<06XcDYFLRWt(yUgCw|@$O-QI1*&@V zviicTsK=H@PECqXHmi4;5*LM^S18dzqD z6rTaD`A9afUBwyZepDrtT*bv9rbb5*H(mPR^<#Z6s#jqLgb zSFDe0G`)r{7Hi~jkSGYX($v1)L=Enn?*IGtY)M5~Y(ItAej3z%3Tk7F#QmTU+t6|W z8~S^R)5@DC#55Ew6S1RVe`zIIVbbG@_z=D5>73w0lyGw*5JNO@qA`Zp$cfk(ot#M5 zv(YlEq$WW5Mp;%emraryT|GCHvFSkvImG4#9rqmKP6Qv`(Zt6&u_J~!eLHdScH%2` zD43VTIIZT=VXp9{U_42^t_R2t)xq9n07h(P_QFtgCC-P#f6i@AZhLJp%CHr-86Fik z!ou(CX8klsBDpumOj$tQMaXJsyhMxd|` z*1(gn3R++R>ek_Z72?$Z;b8ZuXxvhoF}`uz*rK-%?ifE}nHUQ@*cHixUjr+7LHyP0 zz}r}b-vU+r088pB>ssD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