Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Windows Terminal to display DT stdout/stderr #17141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,18 @@ static int usage(const char *argv0)
#endif
"\n"
" If -d signal or -d all is specified, specify the signal action\n"
" to debug using this option.\n");
" to debug using this option.\n"
"\n");
#ifdef _WIN32
printf("\n\n");
printf("Debug log and output will be written to this file:\n");
printf("\n");
printf("Debug log and output will be written to this file (unless running in \n"
"Windows Terminal):\n\n");
printf(" %s\n", logfile);
#else
printf("\n");
#endif

printf("See %s for more detailed documentation.\n"
printf("\n"
"See %s for more detailed documentation.\n"
"See %s to report bugs.\n",
PACKAGE_DOCS,
PACKAGE_BUGREPORT);
Expand Down
37 changes: 28 additions & 9 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main(int argc, char *argv[])
#endif
#ifdef _WIN32
// on Windows we have a hard time showing stuff printed to stdout/stderr to the user.
// because of that we write it to a log file.
// because of that we write it to a log file (unless Windows Terminal is used)
char datetime[DT_DATETIME_EXIF_LENGTH];
dt_datetime_now_to_exif(datetime);

Expand All @@ -50,17 +50,36 @@ int main(int argc, char *argv[])
int err_type = GetFileType(GetStdHandle(STD_ERROR_HANDLE));
gboolean redirect_output = ((out_type != FILE_TYPE_DISK && out_type != FILE_TYPE_PIPE) &&
(err_type != FILE_TYPE_DISK && err_type != FILE_TYPE_PIPE));
const gboolean running_in_wt = (getenv("WT_SESSION") != NULL);

for(int k = 1; k < argc; k++)
if (running_in_wt)
{
// For simple arguments do not redirect stdout
if(!strcmp(argv[k], "--help") ||
!strcmp(argv[k], "-h") ||
!strcmp(argv[k], "/?") ||
!strcmp(argv[k], "--version"))
// Let's assume that Windows Terminal is good enough to display debug output, and perhaps that
// the user runs DT from a terminal because they actually expect to see something being printed out.
// Windows Terminal is available on Windows 11 by default.
redirect_output = FALSE;
}
else
{
for(int k = 1; k < argc; k++)
{
redirect_output = FALSE;
break;
// For simple arguments do not redirect stdout
if(!strcmp(argv[k], "--help") ||
!strcmp(argv[k], "-h") ||
!strcmp(argv[k], "/?") ||
!strcmp(argv[k], "--version"))
{
redirect_output = FALSE;
break;
}
if (strcmp(argv[k], "-d") || strcmp(argv[k], "--debug"))
{
if (running_in_wt)
{
redirect_output = FALSE;
break;
}
}
}
}

Expand Down