diff options
author | nijtmans <nijtmans> | 2010-12-17 15:14:22 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2010-12-17 15:14:22 (GMT) |
commit | 2136011bcc829e697c8671b58ccc16bf7b52e87a (patch) | |
tree | 6709634c255afbf5eb36d05a4af81b5a53c1958c /win | |
parent | 52c6cf3289ecc22d178696fb22b0cff1604a27ce (diff) | |
download | tk-2136011bcc829e697c8671b58ccc16bf7b52e87a.zip tk-2136011bcc829e697c8671b58ccc16bf7b52e87a.tar.gz tk-2136011bcc829e697c8671b58ccc16bf7b52e87a.tar.bz2 |
refactor isatty() function for Windows
Let TkpDisplayWarning() send the message directly to the debugger, if available, otherwise do as before
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinImage.c | 5 | ||||
-rw-r--r-- | win/tkWinInit.c | 31 |
2 files changed, 23 insertions, 13 deletions
diff --git a/win/tkWinImage.c b/win/tkWinImage.c index aa8e66f..97ce065 100644 --- a/win/tkWinImage.c +++ b/win/tkWinImage.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinImage.c,v 1.13 2009/08/02 21:40:17 nijtmans Exp $ + * RCS: @(#) $Id: tkWinImage.c,v 1.14 2010/12/17 15:14:22 nijtmans Exp $ */ #include "tkWinInt.h" @@ -303,8 +303,7 @@ XGetImageZPixmap( BOOL ret; if (format != ZPixmap) { - TkpDisplayWarning( - "XGetImageZPixmap: only ZPixmap types are implemented", + TkpDisplayWarning("Only ZPixmap types are implemented", "XGetImageZPixmap Failure"); return NULL; } diff --git a/win/tkWinInit.c b/win/tkWinInit.c index 8742e48..128cfa9 100644 --- a/win/tkWinInit.c +++ b/win/tkWinInit.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinInit.c,v 1.17 2010/11/24 10:34:18 nijtmans Exp $ + * RCS: @(#) $Id: tkWinInit.c,v 1.18 2010/12/17 15:14:22 nijtmans Exp $ */ #include "tkWinInt.h" @@ -119,20 +119,31 @@ TkpDisplayWarning( const char *title) /* Title of warning. */ { #define TK_MAX_WARN_LEN 1024 - WCHAR msgString[TK_MAX_WARN_LEN + 5]; - WCHAR titleString[TK_MAX_WARN_LEN + 1]; + WCHAR titleString[TK_MAX_WARN_LEN]; + WCHAR *msgString; /* points to titleString, just after title, leaving space for ": " */ + int len; /* size of title, including terminating NULL */ - MultiByteToWideChar(CP_UTF8, 0, msg, -1, msgString, TK_MAX_WARN_LEN); - MultiByteToWideChar(CP_UTF8, 0, title, -1, titleString, TK_MAX_WARN_LEN); + len = MultiByteToWideChar(CP_UTF8, 0, title, -1, titleString, TK_MAX_WARN_LEN); + msgString = &titleString[len + 1]; + titleString[TK_MAX_WARN_LEN - 1] = L'\0'; + MultiByteToWideChar(CP_UTF8, 0, msg, -1, msgString, (TK_MAX_WARN_LEN - 1) - len); /* * Truncate MessageBox string if it is too long to not overflow the screen * and cause possible oversized window error. */ - memcpy(msgString + TK_MAX_WARN_LEN, L" ...", 5 * sizeof(WCHAR)); - titleString[TK_MAX_WARN_LEN] = L'\0'; - MessageBoxW(NULL, msgString, titleString, - MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL - | MB_SETFOREGROUND | MB_TOPMOST); + if (titleString[TK_MAX_WARN_LEN - 1] != L'\0') { + memcpy(titleString + (TK_MAX_WARN_LEN - 5), L" ...", 5 * sizeof(WCHAR)); + } + if (IsDebuggerPresent()) { + titleString[len - 1] = L':'; + titleString[len] = L' '; + OutputDebugStringW(titleString); + } else { + titleString[len - 1] = L'\0'; + MessageBoxW(NULL, msgString, titleString, + MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL + | MB_SETFOREGROUND | MB_TOPMOST); + } } /* |