Commit [bcf20b] Maximize Restore History

Adapt DMH for use in setup tool.

--HG--
rename : src/dmh.cpp => src/dmhcore.cpp
rename : src/guidmh.cpp => src/dmhguix.cpp

Keith Marshall Keith Marshall 2013-03-25

changed ChangeLog
changed Makefile.in
copied src/dmh.cpp -> src/dmhcore.cpp
copied src/guidmh.cpp -> src/dmhguix.cpp
ChangeLog Diff Switch to side-by-side view
Loading...
Makefile.in Diff Switch to side-by-side view
Loading...
src/dmh.cpp to src/dmhcore.cpp
--- a/src/dmh.cpp
+++ b/src/dmhcore.cpp
@@ -1,10 +1,10 @@
 /*
- * dmh.cpp
+ * dmhcore.cpp
  *
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2009, 2010, 2011, 2012, MinGW.org Project
+ * Copyright (C) 2009-2013, MinGW.org Project
  *
  *
  * Implementation of the core components of, and the CLI specific
@@ -30,6 +30,7 @@
 #include <stdarg.h>
 
 #include "dmhcore.h"
+#include "pkgimpl.h"
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -40,6 +41,15 @@
  */
 EXTERN_C void dmh_setpty( HWND );
 
+/* This pointer stores the address of the message handler
+ * class instance, after initialisation.
+ */
+static dmhTypeGeneric *dmh = NULL;
+
+/* Initialisation requires this constructor.
+ */
+dmhTypeGeneric::dmhTypeGeneric( const char* name ):progname( name ){}
+
 /* Implementation of the dmh_exception class.
  */
 static const char *unspecified_error = "Unspecified error";
@@ -60,6 +70,29 @@
 {
   return message;
 }
+
+/* Establish the format to be used for the prefix string, which is
+ * attached to TTY and PTY notifications.
+ */
+const char *dmhTypeGeneric::notification_format = "%s: *** %s *** ";
+
+const char *dmhTypeGeneric::severity_tag( dmh_severity code )
+{
+  /* Helper function to assign labels to the known severity codes.
+   */
+  static const char *severity[] =
+  {
+    /* Labels to identify message severity...
+     */
+    "INFO",		/* DMH_INFO */
+    "WARNING",		/* DMH_WARNING */
+    "ERROR",		/* DMH_ERROR */
+    "FATAL"		/* DMH_FATAL */
+  };
+  return severity[code];
+}
+
+#if IMPLEMENTATION_LEVEL == PACKAGE_BASE_COMPONENT
 
 class dmhTypeTTY: public dmhTypeGeneric
 {
@@ -75,17 +108,11 @@
     inline int emit_and_flush( int );
 };
 
-/* Constructors serve to initialise the message handler,
+/* Constructor serves to initialise the message handler,
  * simply creating the class instance, and storing the specified
- * program name within it.
- */
-dmhTypeGeneric::dmhTypeGeneric( const char* name ):progname( name ){}
+ * program name within its dmhTypeGeneric component.
+ */
 dmhTypeTTY::dmhTypeTTY( const char* name ):dmhTypeGeneric( name ){}
-
-/* This pointer stores the address of the message handler
- * class instance, after initialisation.
- */
-static dmhTypeGeneric *dmh = NULL;
 
 #define client GetModuleHandle( NULL )
 static inline dmhTypeGeneric *dmh_init_gui( const char *progname )
@@ -167,27 +194,6 @@
   return status;
 }
 
-const char *dmhTypeGeneric::severity_tag( dmh_severity code )
-{
-  /* Helper function to assign labels to the known severity codes.
-   */
-  static const char *severity[] =
-  {
-    /* Labels to identify message severity...
-     */
-    "INFO",		/* DMH_INFO */
-    "WARNING",		/* DMH_WARNING */
-    "ERROR",		/* DMH_ERROR */
-    "FATAL"		/* DMH_FATAL */
-  };
-  return severity[code];
-}
-
-/* Establish the format to be used for the prefix string, which is
- * attached to TTY and PTY notifications.
- */
-const char *dmhTypeGeneric::notification_format = "%s: *** %s *** ";
-
 int dmhTypeTTY::notify( const dmh_severity code, const char *fmt, va_list argv )
 {
   /* Message dispatcher for console class applications.
@@ -211,6 +217,8 @@
   return emit_and_flush( vfprintf( stderr, fmt, argv ) );
 }
 
+#endif /* IMPLEMENTATION_LEVEL == PACKAGE_BASE_COMPONENT */
+
 EXTERN_C uint16_t dmh_control( const uint16_t request, const uint16_t mask )
 {
   /* Public helper to access and manipulate the control channel for
src/guidmh.cpp to src/dmhguix.cpp
--- a/src/guidmh.cpp
+++ b/src/dmhguix.cpp
@@ -1,14 +1,14 @@
 /*
- * guidmh.cpp
+ * dmhguix.cpp
  *
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2009, 2010, 2011, 2012, MinGW.org Project
- *
- *
- * Implementation of the GUI specific API for the DMH_SUBSYSTEM_GUI
- * diagnostic message handling subsystem.
+ * Copyright (C) 2009-2013, MinGW.org Project
+ *
+ *
+ * Implementation of GUI specific API extensions, providing support
+ * for the DMH_SUBSYSTEM_GUI diagnostic message handling subsystem.
  *
  *
  * This is free software.  Permission is granted to copy, modify and
@@ -30,6 +30,7 @@
 #include <stdarg.h>
 
 #include "dmhcore.h"
+#include "pkgimpl.h"
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -166,8 +167,13 @@
    * terminate and flush it to the EDITTEXT control.
    */
   *caret = '\0';
-  SendMessage( console_hook, EM_SETSEL, 0, (LPARAM)(-1) );
-  SendMessage( console_hook, EM_REPLACESEL, FALSE, (LPARAM)(console_buffer) );
+  SendMessage( console_hook, WM_SETTEXT, 0, (LPARAM)(console_buffer) );
+
+  /* As we write it, ensure that the last line written remains visible,
+   * with the caret positioned after it.
+   */
+  SendMessage( console_hook, EM_SETSEL, caret - console_buffer, (LPARAM)(-1) );
+  SendMessage( console_hook, EM_SCROLLCARET, (WPARAM)(0), (LPARAM)(0) );
 
   /* Finally, we repaint the display window, and return the output
    * character count.
@@ -263,6 +269,8 @@
     dmhTypePTY *console_hook;
 };
 
+#if IMPLEMENTATION_LEVEL == PACKAGE_BASE_COMPONENT
+
 EXTERN_C
 dmhTypeGeneric *dmh_init_gui( const char * ) __declspec(dllexport);
 dmhTypeGeneric *dmh_init_gui( const char *progname )
@@ -272,6 +280,8 @@
    */
   return new dmhTypeGUI( progname );
 }
+
+#endif /* IMPLEMENTATION_LEVEL == PACKAGE_BASE_COMPONENT */
 
 /* Constructor serves to initialise the message handler,
  * creating the class instance, and storing the specified