diff --git a/uppsrc/ide/Config.cpp b/uppsrc/ide/Config.cpp index 1ef69e323..3da264bb1 100644 --- a/uppsrc/ide/Config.cpp +++ b/uppsrc/ide/Config.cpp @@ -308,7 +308,7 @@ void Ide::Serialize(Stream& s) String dummy; s % dummy; } - s % LinuxHostConsole; + s % HostConsole; editor.SerializeNavigator(s); s % showtime; s % DiffFs(); @@ -320,6 +320,11 @@ void Ide::Serialize(Stream& s) if(version >= 19) { s % gui_font % gui_font_override; } + +#ifdef PLATFORM_WIN32 + if(s.IsLoading() && HostConsole == "/usr/bin/xterm -e") + HostConsole = "powershell.exe"; +#endif } Time Ide::ConfigTime() diff --git a/uppsrc/ide/Core/Host.cpp b/uppsrc/ide/Core/Host.cpp index ca3b51610..c27d2e3a6 100644 --- a/uppsrc/ide/Core/Host.cpp +++ b/uppsrc/ide/Core/Host.cpp @@ -195,7 +195,11 @@ void sCleanZombies(int signal_number) } #endif -String LinuxHostConsole = "/usr/bin/xterm -e"; +#ifdef PLATFORM_WIN32 +String HostConsole = "powershell.exe"; +#else +String HostConsole = "/usr/bin/xterm -e"; +#endif void LocalHost::Launch(const char *_cmdline, bool console) { @@ -240,19 +244,19 @@ void LocalHost::Launch(const char *_cmdline, bool console) }; int ii = 0; for(;;) { // If (pre)defined terminal emulator is not available, try to find one - int c = LinuxHostConsole.FindFirstOf(" "); - lc = c < 0 ? LinuxHostConsole : LinuxHostConsole.Left(c); + int c = HostConsole.FindFirstOf(" "); + lc = c < 0 ? HostConsole : HostConsole.Left(c); if(ii >= __countof(term) || FileExists(lc)) break; - LinuxHostConsole = term[ii++]; + HostConsole = term[ii++]; } if(FileExists(lc)) { if(console) - cmdline = LinuxHostConsole + " sh " + script; + cmdline = HostConsole + " sh " + script; } else - if(LinuxHostConsole.GetCount()) + if(HostConsole.GetCount()) PutConsole("Warning: Terminal '" + lc + "' not found, executing in background."); #endif diff --git a/uppsrc/ide/Core/Host.h b/uppsrc/ide/Core/Host.h index aed8bcb68..a583fd30a 100644 --- a/uppsrc/ide/Core/Host.h +++ b/uppsrc/ide/Core/Host.h @@ -1,6 +1,6 @@ enum { REMOTE_TIMEOUT = 2000 }; -extern String LinuxHostConsole; +extern String HostConsole; class Host { public: diff --git a/uppsrc/ide/Debug.cpp b/uppsrc/ide/Debug.cpp index 701deaa8a..ed2492370 100644 --- a/uppsrc/ide/Debug.cpp +++ b/uppsrc/ide/Debug.cpp @@ -178,6 +178,13 @@ void Ide::ExecuteBinary() } } +void Ide::LaunchTerminal(const char *dir) +{ + One h = CreateHostRunDir(); + h->ChDir(dir); + h->Launch(Nvl(HostConsole, "powershell.exe"), false); +} + class SelectAndroidDeviceDlg : public WithSelectAndroidDeviceLayout { typedef SelectAndroidDeviceDlg CLASSNAME; diff --git a/uppsrc/ide/Setup.cpp b/uppsrc/ide/Setup.cpp index a3e0b8338..fff0aadaa 100644 --- a/uppsrc/ide/Setup.cpp +++ b/uppsrc/ide/Setup.cpp @@ -392,21 +392,6 @@ void Ide::SetupFormat() { WithSetupAssistLayout assist; WebSearchTab web_search; AStyleSetupDialog ast(this); -#ifdef PLATFORM_WIN32 - ide.console_txt.Hide(); - ide.console.Hide(); - ide.kde.Hide(); - ide.gnome.Hide(); - ide.xterm.Hide(); - ide.mate.Hide(); - ide.lxde.Hide(); -#endif - ide.kde <<= callback2(SetConsole, &ide.console, "/usr/bin/konsole -e"); - ide.gnome <<= callback2(SetConsole, &ide.console, "/usr/bin/gnome-terminal -x"); - ide.mate <<= callback2(SetConsole, &ide.console, "/usr/bin/mate-terminal -x"); - ide.lxde <<= callback2(SetConsole, &ide.console, "/usr/bin/lxterminal -e"); - ide.xterm <<= callback2(SetConsole, &ide.console, "/usr/bin/xterm -e"); - edt.lineends .Add(LF, "LF") .Add(CRLF, "CRLF") @@ -434,6 +419,22 @@ void Ide::SetupFormat() { dlg.Add(web_search, "Web search"); dlg.WhenClose = dlg.Acceptor(IDEXIT); +#ifdef PLATFORM_WIN32 + ide.xterm.SetLabel("powershell"); + ide.xterm << [&] { ide.console <<= "powershell.exe"; }; + ide.gnome.SetLabel("cmd"); + ide.gnome << [&] { ide.console <<= "cmd.exe"; }; + ide.kde.Hide(); + ide.mate.Hide(); + ide.lxde.Hide(); +#else + ide.kde <<= callback2(SetConsole, &ide.console, "/usr/bin/konsole -e"); + ide.gnome <<= callback2(SetConsole, &ide.console, "/usr/bin/gnome-terminal -x"); + ide.mate <<= callback2(SetConsole, &ide.console, "/usr/bin/mate-terminal -x"); + ide.lxde <<= callback2(SetConsole, &ide.console, "/usr/bin/lxterminal -e"); + ide.xterm <<= callback2(SetConsole, &ide.console, "/usr/bin/xterm -e"); +#endif + FontSelectManager ed, vf, con, f1, f2, tf, gui; ed.Set(fnt.face, fnt.height, fnt.bold, fnt.italic); vf.Set(fnt.vface, fnt.vheight, fnt.vbold, fnt.vitalic); @@ -518,7 +519,7 @@ void Ide::SetupFormat() { (ide.wrap_console_text, wrap_console_text) (ide.hydra1_threads, hydra1_threads) (ide.chstyle, chstyle) - (ide.console, LinuxHostConsole) + (ide.console, HostConsole) (ide.output_per_assembly, output_per_assembly) (ide.setmain_newide, setmain_newide) (ide.gui_font, gui_font_override) diff --git a/uppsrc/ide/UppDlg.h b/uppsrc/ide/UppDlg.h index 03f917faf..ff33b2609 100644 --- a/uppsrc/ide/UppDlg.h +++ b/uppsrc/ide/UppDlg.h @@ -312,6 +312,7 @@ struct WorkspaceWork { virtual void FileRename(const String& nm) {} virtual bool FileRemove() { return true; } virtual void SyncSvnDir(const String& working) {} + virtual void LaunchTerminal(const char *dir) {} void ScanWorkspace(); void SavePackage(); diff --git a/uppsrc/ide/UppWspc.cpp b/uppsrc/ide/UppWspc.cpp index 3b8d6b78f..1b8cf82c3 100644 --- a/uppsrc/ide/UppWspc.cpp +++ b/uppsrc/ide/UppWspc.cpp @@ -885,6 +885,7 @@ void WorkspaceWork::FileMenu(Bar& menu) menu.Separator(); menu.Add("Open File Directory",THISBACK(OpenFileFolder)); menu.Add("Copy File Path", callback1(WriteClipboardText, GetActiveFilePath())); + menu.Add("Terminal at File Directory", [=] { LaunchTerminal(GetFileDirectory(GetActiveFilePath())); }); menu.Separator(); menu.Add(filelist.GetCursor() > 0, "Move up", THISBACK1(MoveFile, -1)) .Key(organizer ? K_CTRL_UP : K_SHIFT_CTRL_UP) @@ -1059,6 +1060,7 @@ void WorkspaceWork::PackageMenu(Bar& menu) menu.Separator(); BuildPackageMenu(menu); menu.Add("Open Package Directory",THISBACK(OpenPackageFolder)); + menu.Add("Terminal at Package Directory", [=] { LaunchTerminal(GetFileDirectory(GetActivePackagePath())); }); } } } diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index dec440239..01154f42d 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -1022,6 +1022,8 @@ public: String GetTargetLogPath(); String GetIdeLogPath(); void OpenLog(const String& logFilePath); + + virtual void LaunchTerminal(const char *dir); // Console& GetConsole(); diff --git a/uppsrc/ide/ide.lay b/uppsrc/ide/ide.lay index 05fc45c7f..a65c45c04 100644 --- a/uppsrc/ide/ide.lay +++ b/uppsrc/ide/ide.lay @@ -606,13 +606,13 @@ LAYOUT(SetupIdeLayout, 512, 336) ITEM(Upp::Option, bold, SetLabel(t_("Bold")).LeftPosZ(322, 44).TopPosZ(192, 19)) ITEM(Upp::Option, italic, SetLabel(t_("Italic")).LeftPosZ(370, 44).TopPosZ(192, 19)) ITEM(Upp::Label, dv___19, SetLabel(t_("(needs restart)")).LeftPosZ(416, 88).TopPosZ(192, 19)) - ITEM(Upp::Label, console_txt, SetLabel(t_("Use console in Linux")).LeftPosZ(4, 112).TopPosZ(216, 19)) - ITEM(Upp::EditString, console, LeftPosZ(120, 296).TopPosZ(216, 19)) - ITEM(Upp::Button, xterm, SetLabel(t_("xterm")).LeftPosZ(120, 56).TopPosZ(240, 20)) - ITEM(Upp::Button, gnome, SetLabel(t_("Gnome")).LeftPosZ(180, 56).TopPosZ(240, 20)) - ITEM(Upp::Button, kde, SetLabel(t_("KDE")).LeftPosZ(240, 56).TopPosZ(240, 20)) - ITEM(Upp::Button, mate, SetLabel(t_("Mate")).LeftPosZ(300, 56).TopPosZ(240, 20)) - ITEM(Upp::Button, lxde, SetLabel(t_("LXDE")).LeftPosZ(360, 56).TopPosZ(240, 20)) + ITEM(Upp::Label, console_txt, SetLabel(t_("Console binary")).LeftPosZ(4, 112).TopPosZ(216, 19)) + ITEM(Upp::EditString, console, LeftPosZ(120, 376).TopPosZ(216, 19)) + ITEM(Upp::Button, xterm, SetLabel(t_("xterm")).LeftPosZ(120, 72).TopPosZ(240, 20)) + ITEM(Upp::Button, gnome, SetLabel(t_("Gnome")).LeftPosZ(196, 72).TopPosZ(240, 20)) + ITEM(Upp::Button, kde, SetLabel(t_("KDE")).LeftPosZ(272, 72).TopPosZ(240, 20)) + ITEM(Upp::Button, mate, SetLabel(t_("Mate")).LeftPosZ(348, 72).TopPosZ(240, 20)) + ITEM(Upp::Button, lxde, SetLabel(t_("LXDE")).LeftPosZ(424, 72).TopPosZ(240, 20)) ITEM(Upp::Option, output_per_assembly, SetLabel(t_("Use unique output directory per assembly (append assembly name to output directory)")).HSizePosZ(4, 4).TopPosZ(268, 16)) ITEM(Upp::Label, dv___28, SetLabel(t_("In editor mode, path for .usc files")).LeftPosZ(4, 192).TopPosZ(288, 20)) ITEM(Upp::EditString, uscpath, HSizePosZ(172, 28).TopPosZ(288, 19)) diff --git a/uppsrc/ide/idebar.cpp b/uppsrc/ide/idebar.cpp index 49afdf65d..9d0e1be1c 100644 --- a/uppsrc/ide/idebar.cpp +++ b/uppsrc/ide/idebar.cpp @@ -680,10 +680,9 @@ void Ide::BuildMenu(Bar& menu) .Help("Find next " + hh + "according to console pane"); menu.Add(ffb, AK_FINDPREVERROR, THISBACK(FindPrevError)) .Help("Find previous " + hh + "according to console pane"); -#if defined(PLATFORM_WIN32) || defined(PLATFORM_POSIX) menu.MenuSeparator(); menu.Add(!IsNull(target), AK_OPENOUTDIR, THISBACK(OpenOutputFolder)); -#endif + menu.Add(!IsNull(target), "Terminal at output directory", [=] { LaunchTerminal(GetFileFolder(target)); }); } void Ide::DebugMenu(Bar& menu)