Added 'no wait' option (-w) for command line (Windows only), Issue 2314

This commit is contained in:
Ingo
2014-04-02 19:12:42 +02:00
parent 18a349636f
commit d79d3c3f7a

View File

@@ -158,36 +158,46 @@ int main(int argc, char **argv)
bool stdoutRedirectedtoFile = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == 0x0001); bool stdoutRedirectedtoFile = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == 0x0001);
bool stderrRedirectedtoFile = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == 0x0001); bool stderrRedirectedtoFile = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == 0x0001);
// no console, if stdout and stderr both are redirected to file // no console, if stdout and stderr both are redirected to file
if( !(stdoutRedirectedtoFile && stderrRedirectedtoFile)) { if( !(stdoutRedirectedtoFile && stderrRedirectedtoFile)) {
AllocConsole(); // check if parameter -w was passed.
AttachConsole( GetCurrentProcessId() ) ; // We have to do that in this step, because it controls whether to open a console to show the output of following steps
// Don't allow CTRL-C in console to terminate RT bool Console = true;
SetConsoleCtrlHandler( NULL, true ); for(int i=1;i<argc;i++)
// Set title of console if(!strcmp(argv[i],"-w")) {
char consoletitle[128]; Console = false;
sprintf(consoletitle, "RawTherapee %s Console",VERSION); break;
SetConsoleTitle(consoletitle); }
// increase size of screen buffer if(Console) {
COORD c; AllocConsole();
c.X = 200; AttachConsole( GetCurrentProcessId() ) ;
c.Y = 1000; // Don't allow CTRL-C in console to terminate RT
SetConsoleScreenBufferSize( GetStdHandle( STD_OUTPUT_HANDLE ), c ); SetConsoleCtrlHandler( NULL, true );
// Disable console-Cursor // Set title of console
CONSOLE_CURSOR_INFO cursorInfo; char consoletitle[128];
cursorInfo.dwSize = 100; sprintf(consoletitle, "RawTherapee %s Console",VERSION);
cursorInfo.bVisible = false; SetConsoleTitle(consoletitle);
SetConsoleCursorInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &cursorInfo ); // increase size of screen buffer
if(!stdoutRedirectedtoFile) COORD c;
freopen( "CON", "w", stdout ) ; c.X = 200;
if(!stderrRedirectedtoFile) c.Y = 1000;
freopen( "CON", "w", stderr ) ; SetConsoleScreenBufferSize( GetStdHandle( STD_OUTPUT_HANDLE ), c );
freopen( "CON", "r", stdin ) ; // Disable console-Cursor
CONSOLE_CURSOR_INFO cursorInfo;
cursorInfo.dwSize = 100;
cursorInfo.bVisible = false;
SetConsoleCursorInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &cursorInfo );
if(!stdoutRedirectedtoFile)
freopen( "CON", "w", stdout ) ;
if(!stderrRedirectedtoFile)
freopen( "CON", "w", stderr ) ;
freopen( "CON", "r", stdin ) ;
consoleOpened = true; consoleOpened = true;
// printing RT's version in all case, particularly useful for the 'verbose' mode, but also for the batch processing // printing RT's version in every case, particularly useful for the 'verbose' mode, but also for the batch processing
std::cout << "RawTherapee, version " << VERSION << std::endl; std::cout << "RawTherapee, version " << VERSION << std::endl;
std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl; std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl;
}
} }
} }
@@ -423,7 +433,11 @@ int processLineParams( int argc, char **argv )
inputFiles.push_back( safe_filename_to_utf8 (argv[iArg]) ); inputFiles.push_back( safe_filename_to_utf8 (argv[iArg]) );
} }
} }
break; break;
#ifdef WIN32
case 'w': // This case is handled outside this function
break;
#endif
case 'h': case 'h':
case '?': case '?':
default: default:
@@ -432,7 +446,10 @@ int processLineParams( int argc, char **argv )
std::cout << "Usage:" << std::endl; std::cout << "Usage:" << std::endl;
std::cout << " " << Glib::path_get_basename(argv[0]) << " [<selected dir>] Start File Browser inside directory." << std::endl; std::cout << " " << Glib::path_get_basename(argv[0]) << " [<selected dir>] Start File Browser inside directory." << std::endl;
std::cout << " " << Glib::path_get_basename(argv[0]) << " <file> Start Image Editor with file." << std::endl; std::cout << " " << Glib::path_get_basename(argv[0]) << " <file> Start Image Editor with file." << std::endl;
std::cout << " " << Glib::path_get_basename(argv[0]) << " -c <dir>|<files> Convert files in batch with default parameters." << std::endl << std::endl; std::cout << " " << Glib::path_get_basename(argv[0]) << " -c <dir>|<files> Convert files in batch with default parameters." << std::endl << std::endl;
#ifdef WIN32
std::cout << " -w Do not open the Windows console" << std::endl;
#endif
std::cout << "Other options used with -c (-c must be the last option):" << std::endl; std::cout << "Other options used with -c (-c must be the last option):" << std::endl;
std::cout << Glib::path_get_basename(argv[0]) << " [-o <output>|-O <output>] [-s|-S] [-p <files>] [-d] [-j[1-100]|-t|-t1|-n] -Y -c <input>" << std::endl; std::cout << Glib::path_get_basename(argv[0]) << " [-o <output>|-O <output>] [-s|-S] [-p <files>] [-d] [-j[1-100]|-t|-t1|-n] -Y -c <input>" << std::endl;
std::cout << " -o <file>|<dir> Select output file or directory." << std::endl; std::cout << " -o <file>|<dir> Select output file or directory." << std::endl;