<commit_before>/* 25 july 2014 */

#include "winapi_windows.h"
#include "_cgo_export.h"

/* provided for cgo's benefit */
LPCWSTR xWC_TABCONTROL = WC_TABCONTROL;

static LRESULT CALLBACK tabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR id, DWORD_PTR data)
{
	NMHDR *nmhdr = (NMHDR *) lParam;
	LRESULT r;

	switch (uMsg) {
	case msgNOTIFY:
		switch (nmhdr->code) {
		case TCN_SELCHANGING:
			r = SendMessageW(hwnd, TCM_GETCURSEL, 0, 0);
			if (r == (LRESULT) -1)	/* no tab currently selected */
				return FALSE;
			tabChanging((void *) data, r);
			return FALSE;			/* allow change */
		case TCN_SELCHANGE:
			tabChanged((void *) data, SendMessageW(hwnd, TCM_GETCURSEL, 0, 0));
			return 0;
		}
		return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
	case WM_NCDESTROY:
		if ((*fv_RemoveWindowSubclass)(hwnd, tabSubProc, id) == FALSE)
			xpanic("error removing Tab subclass (which was for its own event handler)", GetLastError());
		return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
	default:
		return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
	}
	xmissedmsg("Tab", "tabSubProc()", uMsg);
	return 0;		/* unreached */
}

void setTabSubclass(HWND hwnd, void *data)
{
	if ((*fv_SetWindowSubclass)(hwnd, tabSubProc, 0, (DWORD_PTR) data) == FALSE)
		xpanic("error subclassing Tab to give it its own event handler", GetLastError());
}

void tabAppend(HWND hwnd, LPCWSTR name)
{
	TCITEM item;
	LRESULT n;

	ZeroMemory(&item, sizeof (TCITEM));
	item.mask = TCIF_TEXT;
	/* TODO the C means const; change everything to use LPWSTR instead */
	item.pszText = name;
	/* MSDN's example code uses the first invalid index directly for this */
	n = SendMessageW(hwnd, TCM_GETITEMCOUNT, 0, 0);
	if (SendMessageW(hwnd, TCM_INSERTITEM, (WPARAM) n, (LPARAM) (&item)) == (LRESULT) -1)
		xpanic("error adding tab to Tab", GetLastError());
}

extern void tabGetContentRect(HWND hwnd, RECT *r)
{
	/* not &r; already a pointer (thanks MindChild in irc.efnet.net/#winprog for spotting my failure) */
	SendMessageW(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM) r);
}<commit_msg>Removed extern from C function definitions in containers_windows.c.<commit_after>/* 25 july 2014 */

#include "winapi_windows.h"
#include "_cgo_export.h"

/* provided for cgo's benefit */
LPCWSTR xWC_TABCONTROL = WC_TABCONTROL;

static LRESULT CALLBACK tabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR id, DWORD_PTR data)
{
	NMHDR *nmhdr = (NMHDR *) lParam;
	LRESULT r;

	switch (uMsg) {
	case msgNOTIFY:
		switch (nmhdr->code) {
		case TCN_SELCHANGING:
			r = SendMessageW(hwnd, TCM_GETCURSEL, 0, 0);
			if (r == (LRESULT) -1)	/* no tab currently selected */
				return FALSE;
			tabChanging((void *) data, r);
			return FALSE;			/* allow change */
		case TCN_SELCHANGE:
			tabChanged((void *) data, SendMessageW(hwnd, TCM_GETCURSEL, 0, 0));
			return 0;
		}
		return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
	case WM_NCDESTROY:
		if ((*fv_RemoveWindowSubclass)(hwnd, tabSubProc, id) == FALSE)
			xpanic("error removing Tab subclass (which was for its own event handler)", GetLastError());
		return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
	default:
		return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
	}
	xmissedmsg("Tab", "tabSubProc()", uMsg);
	return 0;		/* unreached */
}

void setTabSubclass(HWND hwnd, void *data)
{
	if ((*fv_SetWindowSubclass)(hwnd, tabSubProc, 0, (DWORD_PTR) data) == FALSE)
		xpanic("error subclassing Tab to give it its own event handler", GetLastError());
}

void tabAppend(HWND hwnd, LPCWSTR name)
{
	TCITEM item;
	LRESULT n;

	ZeroMemory(&item, sizeof (TCITEM));
	item.mask = TCIF_TEXT;
	/* TODO the C means const; change everything to use LPWSTR instead */
	item.pszText = name;
	/* MSDN's example code uses the first invalid index directly for this */
	n = SendMessageW(hwnd, TCM_GETITEMCOUNT, 0, 0);
	if (SendMessageW(hwnd, TCM_INSERTITEM, (WPARAM) n, (LPARAM) (&item)) == (LRESULT) -1)
		xpanic("error adding tab to Tab", GetLastError());
}

void tabGetContentRect(HWND hwnd, RECT *r)
{
	/* not &r; already a pointer (thanks MindChild in irc.efnet.net/#winprog for spotting my failure) */
	SendMessageW(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM) r);
}
{'fraction_non_alphanumeric': 0.13273287508888362, 'fraction_numerical': 0.008058781701825076, 'mean_word_length': 4.725915875169607, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2941533', 'n_tokens_mistral': 1679, 'n_tokens_neox': 1582, 'n_words': 450}