SF.net SVN: geany: [2137] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun Dec 30 15:54:01 UTC 2007
Revision: 2137
http://geany.svn.sourceforge.net/geany/?rev=2137&view=rev
Author: eht16
Date: 2007-12-30 07:54:00 -0800 (Sun, 30 Dec 2007)
Log Message:
-----------
Add debug console window when debug mode is enabled to get any text messages on Windows.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/main.c
trunk/src/win32.c
trunk/src/win32.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-12-30 15:31:45 UTC (rev 2136)
+++ trunk/ChangeLog 2007-12-30 15:54:00 UTC (rev 2137)
@@ -4,6 +4,11 @@
Don't parse in comments and fix wrong creation of tags including
non-tag characters(e.g. '=' sign).
* src/document.c: Avoid crash on Windows with enabled debug messages.
+ * src/main.c, src/win32.c, src/win32.h:
+ Add debug console window when debug mode is enabled to get any text
+ messages on Windows.
+ Fix wrong argument in win32_check_write_permission()
+ (reported by Jeff Pohlmeyer, thanks).
2007-12-28 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2007-12-30 15:31:45 UTC (rev 2136)
+++ trunk/src/main.c 2007-12-30 15:54:00 UTC (rev 2137)
@@ -471,6 +471,10 @@
app->debug_mode = debug_mode;
#endif
+#ifdef G_OS_WIN32
+ win32_init_debug_code();
+#endif
+
if (alternate_config)
{
geany_debug("alternate config: %s", alternate_config);
Modified: trunk/src/win32.c
===================================================================
--- trunk/src/win32.c 2007-12-30 15:31:45 UTC (rev 2136)
+++ trunk/src/win32.c 2007-12-30 15:54:00 UTC (rev 2137)
@@ -35,6 +35,7 @@
#include <commdlg.h>
#include <shlobj.h>
#include <io.h>
+#include <fcntl.h>
#include <string.h>
#include <ctype.h>
@@ -559,7 +560,8 @@
gint win32_check_write_permission(const gchar *dir)
{
static wchar_t w_dir[512];
- MultiByteToWideChar(CP_UTF8, 0, app->configdir, -1, w_dir, sizeof w_dir);
+ errno = 0; // to get sure it is clean
+ MultiByteToWideChar(CP_UTF8, 0, dir, -1, w_dir, sizeof w_dir);
_waccess(w_dir, R_OK | W_OK);
return errno;
}
@@ -597,4 +599,63 @@
ShellExecute(NULL, "open", uri, NULL, NULL, SW_SHOWNORMAL);
}
+
+static void debug_setup_console()
+{
+ static const WORD MAX_CONSOLE_LINES = 500;
+ gint hConHandle;
+ glong lStdHandle;
+ CONSOLE_SCREEN_BUFFER_INFO coninfo;
+ FILE *fp;
+
+ // allocate a console for this app
+ AllocConsole();
+
+ // set the screen buffer to be big enough to let us scroll text
+ GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
+ coninfo.dwSize.Y = MAX_CONSOLE_LINES;
+ SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
+
+ // redirect unbuffered STDOUT to the console
+ lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen(hConHandle, "w");
+ *stdout = *fp;
+ setvbuf(stdout, NULL, _IONBF, 0);
+
+ // redirect unbuffered STDERR to the console
+ lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen(hConHandle, "w");
+ *stderr = *fp;
+ setvbuf(stderr, NULL, _IONBF, 0);
+
+}
+
+
+static void debug_log_handler(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message,
+ gpointer user_data)
+{
+ if (log_domain != NULL)
+ fprintf(stderr, "%s: %s\n", log_domain, message);
+ else
+ fprintf(stderr, "%s\n", message);
+}
+
+
+void win32_init_debug_code()
+{
+#ifndef GEANY_DEBUG
+ if (app->debug_mode)
#endif
+ { // create a console window to get log messages on Windows
+ debug_setup_console();
+ // change the log handlers to output log messages in ther created console window
+ g_log_set_handler("GLib",
+ G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, debug_log_handler, NULL);
+ g_log_set_default_handler(debug_log_handler, NULL);
+ }
+}
+
+
+#endif
Modified: trunk/src/win32.h
===================================================================
--- trunk/src/win32.h 2007-12-30 15:31:45 UTC (rev 2136)
+++ trunk/src/win32.h 2007-12-30 15:54:00 UTC (rev 2137)
@@ -55,4 +55,7 @@
gint win32_check_write_permission(const gchar *dir);
+void win32_init_debug_code();
+
+
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list