|
@@ -1,8 +1,4 @@
|
|
-using System.Diagnostics;
|
|
|
|
-using System.Management;
|
|
|
|
-using System.Runtime.InteropServices;
|
|
|
|
-
|
|
|
|
-namespace Terminal.Gui;
|
|
|
|
|
|
+namespace Terminal.Gui;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Provides a platform-independent API for managing ANSI escape sequences.
|
|
/// Provides a platform-independent API for managing ANSI escape sequences.
|
|
@@ -1019,42 +1015,6 @@ public static class EscSeqUtils
|
|
//}
|
|
//}
|
|
}
|
|
}
|
|
|
|
|
|
- // TODO: Move this out of here and into ConsoleDriver or somewhere else.
|
|
|
|
- /// <summary>
|
|
|
|
- /// Get the terminal that holds the console driver.
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="process">The process.</param>
|
|
|
|
- /// <returns>If supported the executable console process, null otherwise.</returns>
|
|
|
|
- public static Process GetParentProcess (Process process)
|
|
|
|
- {
|
|
|
|
- if (!RuntimeInformation.IsOSPlatform (OSPlatform.Windows))
|
|
|
|
- {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- string query = "SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = " + process.Id;
|
|
|
|
-
|
|
|
|
- using (var mos = new ManagementObjectSearcher (query))
|
|
|
|
- {
|
|
|
|
- foreach (ManagementObject mo in mos.Get ())
|
|
|
|
- {
|
|
|
|
- if (mo ["ParentProcessId"] is { })
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- var id = Convert.ToInt32 (mo ["ParentProcessId"]);
|
|
|
|
-
|
|
|
|
- return Process.GetProcessById (id);
|
|
|
|
- }
|
|
|
|
- catch
|
|
|
|
- { }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Ensures a console key is mapped to one that works correctly with ANSI escape sequences.
|
|
/// Ensures a console key is mapped to one that works correctly with ANSI escape sequences.
|
|
/// </summary>
|
|
/// </summary>
|