<commit_before>""" Core functions and classes for a libtcod game. Not game-specific. """
import time

import tcod
from game import config, events, widgets

def slow_print(widget, text, y=1):
    label = widgets.Label(parent=widget, y=y, text=text)
    label.center_in_parent(vertical=False)
    label.text = ""

    for char in text:
        label.text = label.text + char

        widget.render()
        tcod.flush() # Relying on the tcod.set_fps_limit() from earlier to limit our render rate

def get_input():
    """ Grab the mouse and all the key events from libtcod and {events.post} them. """
    key, mouse = tcod.check_for_event(tcod.event.KEY_PRESS | tcod.event.MOUSE)
    events.post(events.MOUSE, mouse)
    while key.vk != tcod.key.NONE:
        events.post(events.KEY, key)
        key, mouse = tcod.check_for_event(tcod.event.KEY_PRESS)

def main_loop(top, dialog=False):
    while True:
        top.render()
        tcod.flush()

        # Get the input...
        get_input()
        if tcod.is_window_closed():
            events.post(events.QUIT)

        # ...and handle it:<commit_msg>Make it possible to skip the slow_write()<commit_after>""" Core functions and classes for a libtcod game. Not game-specific. """
import time

import tcod
from game import config, events, widgets

def slow_print(widget, text, y=1):
    label = widgets.Label(parent=widget, y=y, text=text)
    label.center_in_parent(vertical=False)
    label.text = ""

    for char in text:
        label.text = label.text + char

        widget.render()
        tcod.flush() # Relying on the tcod.set_fps_limit() from earlier to limit our render rate
        key, mouse = tcod.check_for_event(tcod.event.KEY_PRESS | tcod.event.MOUSE_PRESS)
        if key.vk != tcod.key.NONE or mouse.lbutton or mouse.rbutton:
            label.text = text
            widget.render()
            return

def get_input():
    """ Grab the mouse and all the key events from libtcod and {events.post} them. """
    key, mouse = tcod.check_for_event(tcod.event.KEY_PRESS | tcod.event.MOUSE)
    events.post(events.MOUSE, mouse)
    while key.vk != tcod.key.NONE:
        events.post(events.KEY, key)
        key, mouse = tcod.check_for_event(tcod.event.KEY_PRESS)

def main_loop(top, dialog=False):
    while True:
        top.render()
        tcod.flush()

        # Get the input...
        get_input()
        if tcod.is_window_closed():
            events.post(events.QUIT)

        # ...and handle it:
{'fraction_non_alphanumeric': 0.11429725363489499, 'fraction_numerical': 0.0008077544426494346, 'mean_word_length': 2.6533923303834808, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4354254', 'n_tokens_mistral': 807, 'n_tokens_neox': 800, 'n_words': 214}