<commit_before>/*
 * Winlogon replacement - Mouse demo
 *
 * Copyright 2006-2008 <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include <windows.h>
#include <stdio.h>

int mouse_color = 0;

void dprintf( const char *format, ... )
{
	char str[0x100];
	va_list va;
	va_start( va, format );
	vsprintf( str, format, va );
	va_end( va );
	OutputDebugString( str );
}

void do_paint( HWND hwnd )
{
	PAINTSTRUCT ps;
	BeginPaint( hwnd, &ps );
	EndPaint( hwnd, &ps );
}

void do_leftbuttondown( HWND hwnd )
{
	mouse_color >>= 8;
	if (!mouse_color)
		mouse_color = 0xff0000;
}

void do_mousemove( HWND hwnd, INT x, INT y )
{
	HDC hdc = GetDC( hwnd );
	HBRUSH brush, old_brush;
	brush = CreateSolidBrush( mouse_color );
	old_brush = SelectObject( hdc, brush );
	Rectangle( hdc, x, y, x+10, y+10 );
	SelectObject( hdc, old_brush );
	ReleaseDC( hwnd, hdc );
}

LRESULT CALLBACK minitris_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	dprintf("minitris_wndproc %p %08x %08x %08lx", hwnd, msg, wparam, lparam);
	switch (msg)
	{
	case WM_PAINT:
		do_paint( hwnd );
		break;
	case WM_LBUTTONDOWN:
		do_leftbuttondown( hwnd );
		break;
	case WM_MOUSEMOVE:
		do_mousemove( hwnd, LOWORD(lparam), HIWORD(lparam));
		break;
	case WM_CLOSE:
		PostQuitMessage( 1 );
	}
	return DefWindowProc(hwnd, msg, wparam, lparam);
}

// normal windows program
int window_winmain( HINSTANCE Instance )
{
	WNDCLASS wc;
	MSG msg;
	HWND hwnd;

	wc.style = 0;
	wc.lpfnWndProc = minitris_wndproc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = Instance;
	wc.hIcon = 0;
	wc.hCursor = 0;
	wc.hbrBackground = GetStockObject( BLACK_BRUSH );
	wc.lpszMenuName = 0;
	wc.lpszClassName = "MOUSETRACK";
	if (!RegisterClass( &wc ))
	{
		MessageBox( NULL, "Failed to register class", "Error", MB_OK );
		return 0;
	}

	hwnd = CreateWindow("MOUSETRACK", "MouseTrack", WS_VISIBLE|WS_POPUP|WS_DLGFRAME,
		CW_USEDEFAULT, CW_USEDEFAULT, 300, 300,
		NULL, NULL, Instance, NULL);
	if (!hwnd)
	{
		MessageBox( NULL, "Failed to create window", "Error", MB_OK );
		return 0;
	}

	dprintf("Before GetMessage");
	while (GetMessage( &msg, 0, 0, 0 ))
	{
		dprintf("msg %08lx %p %08x %08lx", msg.message, msg.hwnd, msg.wParam, msg.lParam);
		DispatchMessage( &msg );
		dprintf("dispatched message");
	}

	return 0;<commit_msg>Improve debug output<commit_after>/*
 * Winlogon replacement - Mouse demo
 *
 * Copyright 2006-2009 <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include <windows.h>
#include <stdio.h>

int mouse_color = 0;

void dprintf( const char *format, ... )
{
	char str[0x100];
	va_list va;
	va_start( va, format );
	vsprintf( str, format, va );
	va_end( va );
	OutputDebugString( str );
}

void do_paint( HWND hwnd )
{
	PAINTSTRUCT ps;
	BeginPaint( hwnd, &ps );
	EndPaint( hwnd, &ps );
}

void do_leftbuttondown( HWND hwnd )
{
	dprintf("track: left button down");
	mouse_color >>= 8;
	if (!mouse_color)
		mouse_color = 0xff0000;
}

void do_mousemove( HWND hwnd, INT x, INT y )
{
	dprintf("track: mouse move");
	HDC hdc = GetDC( hwnd );
	HBRUSH brush, old_brush;
	brush = CreateSolidBrush( mouse_color );
	old_brush = SelectObject( hdc, brush );
	Rectangle( hdc, x, y, x+10, y+10 );
	SelectObject( hdc, old_brush );
	ReleaseDC( hwnd, hdc );
}

LRESULT CALLBACK track_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	dprintf("track: wndproc %p %08x %08x %08lx", hwnd, msg, wparam, lparam);
	switch (msg)
	{
	case WM_PAINT:
		do_paint( hwnd );
		break;
	case WM_LBUTTONDOWN:
		do_leftbuttondown( hwnd );
		break;
	case WM_MOUSEMOVE:
		do_mousemove( hwnd, LOWORD(lparam), HIWORD(lparam));
		break;
	case WM_CLOSE:
		PostQuitMessage( 1 );
	}
	return DefWindowProc(hwnd, msg, wparam, lparam);
}

// normal windows program
int window_winmain( HINSTANCE Instance )
{
	WNDCLASS wc;
	MSG msg;
	HWND hwnd;

	wc.style = 0;
	wc.lpfnWndProc = track_wndproc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = Instance;
	wc.hIcon = 0;
	wc.hCursor = 0;
	wc.hbrBackground = GetStockObject( BLACK_BRUSH );
	wc.lpszMenuName = 0;
	wc.lpszClassName = "MOUSETRACK";
	if (!RegisterClass( &wc ))
	{
		MessageBox( NULL, "Failed to register class", "Error", MB_OK );
		return 0;
	}

	hwnd = CreateWindow("MOUSETRACK", "MouseTrack", WS_VISIBLE|WS_POPUP|WS_DLGFRAME,
		CW_USEDEFAULT, CW_USEDEFAULT, 300, 300,
		NULL, NULL, Instance, NULL);
	if (!hwnd)
	{
		MessageBox( NULL, "Failed to create window", "Error", MB_OK );
		return 0;
	}

	dprintf("track: Before GetMessage");
	while (GetMessage( &msg, 0, 0, 0 ))
	{
		dprintf("track: msg %08lx %p %08x %08lx", msg.message, msg.hwnd, msg.wParam, msg.lParam);
		DispatchMessage( &msg );
		dprintf("track: dispatched message");
	}

	return 0;
{'fraction_non_alphanumeric': 0.11749174917491749, 'fraction_numerical': 0.022112211221122113, 'mean_word_length': 4.162691652470188, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4350760', 'n_tokens_mistral': 2400, 'n_tokens_neox': 2273, 'n_words': 708}