- else{
- StringOutputStream path( 256 );
- StringOutputStream modpath( 256 );
- const char* gamename = GlobalRadiant().getGameName();
- const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue( "basegame" );
- const char* enginePath = GlobalRadiant().getEnginePath();
- path << enginePath << basegame << '/' << filename;
- modpath << enginePath << gamename << '/' << filename;
- if ( file_exists( modpath.c_str() ) ){
- globalOutputStream() << "opening file '" << modpath.c_str() << "' (line " << cursorpos << " info ignored)\n";
- DoGtkTextEditor( modpath.c_str(), cursorpos, length );
- }
- else if ( file_exists( path.c_str() ) ){
- globalOutputStream() << "opening file '" << path.c_str() << "' (line " << cursorpos << " info ignored)\n";
- DoGtkTextEditor( path.c_str(), cursorpos, length );
+
+ if( goodpath ){
+ globalOutputStream() << "opening file '" << goodpath->c_str() << "' (line " << cursorpos << " info ignored)\n";
+ if( external_editor ){
+ if( g_TextEditor_editorCommand.empty() ){
+#ifdef WIN32
+ ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), 0, goodpath->c_str(), 0, 0, SW_SHOWNORMAL );
+// SHELLEXECUTEINFO ShExecInfo;
+// ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
+// ShExecInfo.fMask = 0;
+// ShExecInfo.hwnd = (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window );
+// ShExecInfo.lpVerb = NULL;
+// ShExecInfo.lpFile = goodpath->c_str();
+// ShExecInfo.lpParameters = NULL;
+// ShExecInfo.lpDirectory = NULL;
+// ShExecInfo.nShow = SW_SHOWNORMAL;
+// ShExecInfo.hInstApp = NULL;
+// ShellExecuteEx(&ShExecInfo);
+#else
+ globalOutputStream() << "Failed to open '" << goodpath->c_str() << "'\nSet Shader Editor Command in preferences\n";
+#endif
+ }
+ else{
+ StringOutputStream strEditCommand( 256 );
+ strEditCommand << g_TextEditor_editorCommand.c_str() << " \"" << goodpath->c_str() << "\"";
+
+ globalOutputStream() << "Launching: " << strEditCommand.c_str() << "\n";
+ // note: linux does not return false if the command failed so it will assume success
+ if ( Q_Exec( 0, const_cast<char*>( strEditCommand.c_str() ), 0, true, false ) == false ) {
+ globalOutputStream() << "Failed to execute " << strEditCommand.c_str() << "\n";
+ }
+ else
+ {
+ // the command (appeared) to run successfully, no need to do anything more
+ return;
+ }
+ }