return 1;
}
-static HWND msw_console_hwnd = 0;
+static HWND mswindows_console_hwnd = 0;
#define KLUDGE_BUFSIZE 1024 /* buffer size for console window titles */
}
HWND
-msw_get_console_hwnd (void)
+mswindows_get_console_hwnd (void)
{
- if (!msw_console_hwnd)
- msw_console_hwnd = GetConsoleHwnd ();
- return msw_console_hwnd;
+ if (!mswindows_console_hwnd)
+ mswindows_console_hwnd = GetConsoleHwnd ();
+ return mswindows_console_hwnd;
}
-int
-msw_ensure_console_allocated (void)
+static int
+mswindows_ensure_console_allocated (void)
{
HWND fgwin = GetForegroundWindow ();
/* stupid mswin api won't let you create the console window
}
void
-msw_hide_console (void)
+mswindows_hide_console (void)
{
- ShowWindow (msw_get_console_hwnd (), SW_HIDE);
+ ShowWindow (mswindows_get_console_hwnd (), SW_HIDE);
}
void
-msw_show_console (void)
+mswindows_show_console (void)
{
- HWND hwnd = msw_get_console_hwnd ();
- ShowWindow (hwnd, SW_SHOWNA);
-
- /* I tried to raise the window to the top without activating
- it, but this fails. Apparently Windows just doesn't like
- having the active window not be on top. So instead, we
- at least put it just below our own window, where part of it
- will likely be seen. */
- SetWindowPos (hwnd, GetForegroundWindow (), 0, 0, 0, 0,
- SWP_NOSIZE | SWP_NOMOVE | SWP_NOSENDCHANGING |
- SWP_NOACTIVATE);
+ /* What I really want is for the console window to appear on top of other
+ windows, but NOT get the focus. This seems hard-to-impossible under
+ Windows. The following sequence seems to do the best possible, along
+ with keeping the console window on top when xemacs --help is used. */
+ HWND hwnd = mswindows_get_console_hwnd ();
+ HWND hwndf = GetFocus ();
+ ShowWindow (hwnd, SW_SHOW);
+ BringWindowToTop (hwnd);
+ SetFocus (hwndf);
}
-static int msw_console_buffered = 0;
-HANDLE msw_console_buffer;
+static int mswindows_console_buffered = 0;
+HANDLE mswindows_console_buffer;
static void
-msw_ensure_console_buffered (void)
+mswindows_ensure_console_buffered (void)
{
- if (!msw_console_buffered)
+ if (!mswindows_console_buffered)
{
COORD new_size;
new_size.X = 80;
new_size.Y = 1000;
- msw_ensure_console_allocated ();
- msw_console_buffer =
+ mswindows_ensure_console_allocated ();
+ mswindows_console_buffer =
CreateConsoleScreenBuffer (GENERIC_WRITE, 0, NULL,
CONSOLE_TEXTMODE_BUFFER, NULL);
- SetConsoleScreenBufferSize (msw_console_buffer, new_size);
- SetConsoleActiveScreenBuffer (msw_console_buffer);
- msw_console_buffered = 1;
+ SetConsoleScreenBufferSize (mswindows_console_buffer, new_size);
+ SetConsoleActiveScreenBuffer (mswindows_console_buffer);
+ mswindows_console_buffered = 1;
}
}
+int mswindows_message_outputted;
+
int
-msw_output_console_string (CONST Extbyte *str, Extcount len)
+mswindows_output_console_string (CONST Extbyte *str, Extcount len)
{
DWORD num_written;
- msw_ensure_console_buffered ();
- msw_show_console ();
- return WriteConsole (msw_console_buffer, str, len, &num_written, NULL);
+ mswindows_message_outputted = 1;
+ mswindows_ensure_console_buffered ();
+ mswindows_show_console ();
+ return WriteConsole (mswindows_console_buffer, str, len, &num_written, NULL);
}
/* Determine if running on Windows 9x and not NT */
int
-msw_windows9x_p (void)
+mswindows_windows9x_p (void)
{
return GetVersion () & 0x80000000;
}
+DEFUN ("mswindows-debugging-output", Fmswindows_debugging_output, 1, 1, 0, /*
+Write CHAR-OR-STRING to the Windows debugger, using OutputDebugString().
+This function can be used as the STREAM argument of Fprint() or the like.
+*/
+ (char_or_string))
+{
+ Extbyte *extstr;
+
+ if (STRINGP (char_or_string))
+ {
+ TO_EXTERNAL_FORMAT (LISP_STRING, char_or_string,
+ C_STRING_ALLOCA, extstr,
+ Qmswindows_tstr);
+ OutputDebugString (extstr);
+ }
+ else
+ {
+ Bufbyte str[MAX_EMCHAR_LEN + 1];
+ Bytecount len;
+
+ CHECK_CHAR_COERCE_INT (char_or_string);
+ len = set_charptr_emchar (str, XCHAR (char_or_string));
+ str[len] = '\0';
+ TO_EXTERNAL_FORMAT (C_STRING, str,
+ C_STRING_ALLOCA, extstr,
+ Qmswindows_tstr);
+ OutputDebugString (extstr);
+ }
+
+ return char_or_string;
+}
#ifdef DEBUG_XEMACS
/*
* Random helper functions for debugging.
* Intended for use in the MSVC "Watch" window which doesn't like
- * the aborts that the error_check_foo() functions can make.
+ * the ABORTs that the error_check_foo() functions can make.
*/
+struct lrecord_header *DHEADER (Lisp_Object obj);
struct lrecord_header *
DHEADER (Lisp_Object obj)
{
return LRECORDP (obj) ? XRECORD_LHEADER (obj) : NULL;
}
+void *DOPAQUE_DATA (Lisp_Object obj);
void *
DOPAQUE_DATA (Lisp_Object obj)
{
return OPAQUEP (obj) ? OPAQUE_DATA (XOPAQUE (obj)) : NULL;
}
+Lisp_Event *DEVENT (Lisp_Object obj);
Lisp_Event *
DEVENT (Lisp_Object obj)
{
return EVENTP (obj) ? XEVENT (obj) : NULL;
}
+Lisp_Cons *DCONS (Lisp_Object obj);
Lisp_Cons *
DCONS (Lisp_Object obj)
{
return CONSP (obj) ? XCONS (obj) : NULL;
}
+Lisp_Cons *DCONSCDR (Lisp_Object obj);
Lisp_Cons *
DCONSCDR (Lisp_Object obj)
{
return (CONSP (obj) && CONSP (XCDR (obj))) ? XCONS (XCDR (obj)) : 0;
}
+Bufbyte *DSTRING (Lisp_Object obj);
Bufbyte *
DSTRING (Lisp_Object obj)
{
return STRINGP (obj) ? XSTRING_DATA (obj) : NULL;
}
+Lisp_Vector *DVECTOR (Lisp_Object obj);
Lisp_Vector *
DVECTOR (Lisp_Object obj)
{
return VECTORP (obj) ? XVECTOR (obj) : NULL;
}
+Lisp_Symbol *DSYMBOL (Lisp_Object obj);
Lisp_Symbol *
DSYMBOL (Lisp_Object obj)
{
return SYMBOLP (obj) ? XSYMBOL (obj) : NULL;
}
+Bufbyte *DSYMNAME (Lisp_Object obj);
Bufbyte *
DSYMNAME (Lisp_Object obj)
{
Extbyte *titleout = 0;
UINT sty = 0;
- if (noninteractive)
- return Qcancel;
-
- if (!CONSP (flags))
+ if (!LISTP (flags))
{
CHECK_SYMBOL (flags);
flags = list1 (flags);
frob, errval, (char*)lpMsgBuf);
}
+static Lisp_Object
+msprinter_canonicalize_console_connection (Lisp_Object connection,
+ Error_behavior errb)
+{
+ /* If nil connection is specified, transform it into the name
+ of the default printer */
+ if (NILP (connection))
+ {
+ connection = msprinter_default_printer ();
+ if (NILP (connection))
+ {
+ if (ERRB_EQ (errb, ERROR_ME))
+ error ("There is no default printer in the system");
+ else
+ return Qunbound;
+ }
+ }
+
+ CHECK_STRING (connection);
+ return connection;
+}
+
+static Lisp_Object
+msprinter_canonicalize_device_connection (Lisp_Object connection,
+ Error_behavior errb)
+{
+ return msprinter_canonicalize_console_connection (connection, errb);
+}
+
\f
/************************************************************************/
/* initialization */
void
syms_of_console_mswindows (void)
{
+ DEFSUBR (Fmswindows_debugging_output);
+
defsymbol (&Qabortretryignore, "abortretryignore");
defsymbol (&Qapplmodal, "applmodal");
defsymbol (&Qdefault_desktop_only, "default-desktop-only");
/* CONSOLE_HAS_METHOD (mswindows, semi_canonicalize_device_connection); */
INITIALIZE_CONSOLE_TYPE (msprinter, "msprinter", "console-msprinter-p");
+ CONSOLE_HAS_METHOD (msprinter, canonicalize_console_connection);
+ CONSOLE_HAS_METHOD (msprinter, canonicalize_device_connection);
}
void