<commit_before>/* Public Domain Curses */

#include "pdcwin.h"
#include "curses.h"

void PDC_beep(void)
{
    PDC_LOG(("PDC_beep() - called\n"));

/*  MessageBeep(MB_OK); */
    MessageBeep(0XFFFFFFFF);
}


void PDC_napms(int ms)     /* 'ms' = milli,  _not_ microseconds! */
{
    /* RR: keep GUI window responsive while PDCurses sleeps */
    MSG msg;
    DWORD milliseconds_sleep_limit = ms + GetTickCount();
    extern bool PDC_bDone;

    PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));

    /* Pump all pending messages from WIN32 to the window handler */
    while( !PDC_bDone && GetTickCount() < milliseconds_sleep_limit )
    {
        while( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
        {
           TranslateMessage(&msg);
           DispatchMessage(&msg);
        }
        Sleep(1);
    }

    /* Sleep(ms); */
}

const char *PDC_sysname(void)
{
   return "Win32a";
}

const PDC_version_info PDC_version = { PDC_PORT_WIN32A,
          PDC_VER_MAJOR, PDC_VER_MINOR, PDC_VER_CHANGE,
          sizeof( chtype),
#ifdef PDC_WIDE
          TRUE,
#else<commit_msg>Updated PDCurses's message pump to use way fewer CPU cycles.<commit_after>/* Public Domain Curses */

#include "pdcwin.h"
#include "curses.h"

void PDC_beep(void)
{
    PDC_LOG(("PDC_beep() - called\n"));

/*  MessageBeep(MB_OK); */
    MessageBeep(0XFFFFFFFF);
}


void PDC_napms(int ms)     /* 'ms' = milli,  _not_ microseconds! */
{
    /* RR: keep GUI window responsive while PDCurses sleeps */
    MSG msg;
    int start, end, sleepMs;
    extern bool PDC_bDone;

    start = (int) GetTickCount();

    //PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));

    /* Pump all pending messages from WIN32 to the window handler */
    while( !PDC_bDone && PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    end = (int) GetTickCount();
    sleepMs = ms - (end - start);
    sleepMs = (sleepMs < 0) ? 0 : sleepMs;
    Sleep((DWORD) sleepMs);
}

const char *PDC_sysname(void)
{
   return "Win32a";
}

const PDC_version_info PDC_version = { PDC_PORT_WIN32A,
          PDC_VER_MAJOR, PDC_VER_MINOR, PDC_VER_CHANGE,
          sizeof( chtype),
#ifdef PDC_WIDE
          TRUE,
#else
{'fraction_non_alphanumeric': 0.13570784490532012, 'fraction_numerical': 0.009467989179440937, 'mean_word_length': 2.8726003490401397, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '5551593', 'n_tokens_mistral': 871, 'n_tokens_neox': 828, 'n_words': 188}