1 //
2 // Copyright (c) 2010-2018 Antmicro
3 //
4 // This file is licensed under the MIT License.
5 // Full license text is available in 'licenses/MIT.txt'.
6 //
7 #if PLATFORM_LINUX
8 using System.Diagnostics;
9 
10 namespace Antmicro.Renode.UI
11 {
12     [ConsoleBackendAnalyzerProvider("GnomeTerminal")]
13     public class GnomeTerminalProvider : ProcessBasedProvider
14     {
CreateProcess(string consoleName, string command)15         protected override Process CreateProcess(string consoleName, string command)
16         {
17             var p = new Process();
18             p.EnableRaisingEvents = true;
19             var position = WindowPositionProvider.Instance.GetNextPosition();
20 
21             var arguments = string.Format("--tab -e \"{3}\" --title '{0}' --geometry=+{1}+{2}", consoleName, (int)position.X, (int)position.Y, command);
22             p.StartInfo = new ProcessStartInfo("gnome-terminal", arguments)
23             {
24                 UseShellExecute = false,
25                 RedirectStandardError = true,
26                 RedirectStandardOutput = true,
27                 RedirectStandardInput = true
28             };
29             p.Exited += (sender, e) =>
30             {
31                 var proc = sender as Process;
32                 if (proc.ExitCode != 0)
33                 {
34                     LogError("gnome-terminal", arguments, proc.ExitCode);
35                 }
36                 // We do not call InnerOnClose here, because gnome-terminal closes immediately after spawning new window.
37             };
38             return p;
39         }
40     }
41 }
42 
43 #endif
44