diff --git a/uppsrc/ide/Core/Host.cpp b/uppsrc/ide/Core/Host.cpp index f6cdca367..b7f630b19 100644 --- a/uppsrc/ide/Core/Host.cpp +++ b/uppsrc/ide/Core/Host.cpp @@ -181,8 +181,44 @@ void RemoveConsoleScripts() FileDelete(ff.GetPath()); } } + +String ResolveHostConsole() +{ + String lc; + + #ifdef PLATFORM_BSD + static const char *term[] = { + "/usr/local/bin/mate-terminal -x", + "/usr/local/bin/gnome-terminal --window -x", + "/usr/local/bin/konsole -e", + "/usr/local/bin/lxterminal -e", + "/usr/local/bin/io.elementary.terminal -n -x", + "/usr/local/bin/xterm -e", + }; + #else + static const char *term[] = { + "/usr/bin/mate-terminal -x", + "/usr/bin/gnome-terminal --window -x", + "/usr/bin/konsole -e", + "/usr/bin/lxterminal -e", + "/usr/bin/io.elementary.terminal -n -x", + "/usr/bin/xterm -e", + }; + #endif + int ii = 0; + for(;;) { // If (pre)defined terminal emulator is not available, try to find one + int c = HostConsole.Find(' '); + lc = c < 0 ? HostConsole : HostConsole.Left(c); + if(ii >= __countof(term) || FileExists(lc)) + break; + HostConsole = term[ii++]; + } + return lc; +} + #endif + void Host::Launch(const char *_cmdline, bool console) { String cmdline = FindCommand(exedirs, _cmdline); @@ -216,33 +252,7 @@ void Host::Launch(const char *_cmdline, bool console) if(console) cmdline = "/usr/bin/open " + script; #else - String lc; - - #ifdef PLATFORM_BSD - static const char *term[] = { - "/usr/local/bin/mate-terminal -x", - "/usr/local/bin/gnome-terminal --window -x", - "/usr/local/bin/konsole -e", - "/usr/local/bin/lxterminal -e", - "/usr/local/bin/xterm -e", - }; - #else - static const char *term[] = { - "/usr/bin/mate-terminal -x", - "/usr/bin/gnome-terminal --window -x", - "/usr/bin/konsole -e", - "/usr/bin/lxterminal -e", - "/usr/bin/xterm -e", - }; - #endif - int ii = 0; - for(;;) { // If (pre)defined terminal emulator is not available, try to find one - int c = HostConsole.FindFirstOf(" "); - lc = c < 0 ? HostConsole : HostConsole.Left(c); - if(ii >= __countof(term) || FileExists(lc)) - break; - HostConsole = term[ii++]; - } + String lc = ResolveHostConsole(); if(FileExists(lc)) { if(console) diff --git a/uppsrc/ide/Core/Host.h b/uppsrc/ide/Core/Host.h index a721c6a1a..2061ea6ac 100644 --- a/uppsrc/ide/Core/Host.h +++ b/uppsrc/ide/Core/Host.h @@ -50,5 +50,6 @@ private: }; #ifdef PLATFORM_POSIX -void RemoveConsoleScripts(); +void RemoveConsoleScripts(); +String ResolveHostConsole(); #endif \ No newline at end of file diff --git a/uppsrc/ide/Debug.cpp b/uppsrc/ide/Debug.cpp index d00b0cd4e..cfe068801 100644 --- a/uppsrc/ide/Debug.cpp +++ b/uppsrc/ide/Debug.cpp @@ -196,10 +196,13 @@ void Ide::LaunchTerminal(const char *dir) ; h.Launch("/usr/bin/open " + script); #else + ResolveHostConsole(); String c = HostConsole; - int q = c.Find(' '); + int q = c.ReverseFind(' '); if(q >= 0) c.Trim(q); + if(c.Find("io.elementary.terminal") >= 0) // elementary seems to ignore current dir + c << " -w \"" << dir << "\""; h.Launch(Nvl(c, "/usr/bin/xterm"), false); #endif } diff --git a/uppsrc/ide/ide.upp b/uppsrc/ide/ide.upp index 15c339699..86b255247 100644 --- a/uppsrc/ide/ide.upp +++ b/uppsrc/ide/ide.upp @@ -113,7 +113,7 @@ file theide.desktop, Repo readonly separator, urepo.h, - RepoConsole.cpp, + RepoConsole.cpp readonly, RepoSync.cpp, Credentials.cpp, Diff.cpp,