<commit_before>import pygame
import pygame.locals
import random


X,Y = 512,384
LEN = 20
FONT_SIZE = 40
RANDOM_FONT = False

def make_label(text, cx, cy):
    rect = text.get_rect()
    rect.centerx = cx
    rect.centery = cy
    return (text, rect)

def render(render, font, *args):
    return getattr(font, render)(*args)


pygame.display.init()
screen = pygame.display.set_mode((X,Y), (pygame.locals.NOFRAME | pygame.locals.FULLSCREEN))
colors = {
          'red': (255,0,0),
          'blue': (0,0,255),
          'green': (0,255,0),
          'yellow': (255,255,0),
          'white': (255,255,255),
          'grey': (128,128,128),
          }
all_colors = colors.keys()

pygame.font.init()
all_fonts = pygame.font.get_fonts()
fonts = {}
for font in all_fonts:
    path = pygame.font.match_font(font)
    if path:
        fonts[font] = pygame.font.Font(path, FONT_SIZE)

default_font = pygame.font.get_default_font()
default_font = (f for f in all_fonts if default_font.startswith(f)).next()

if RANDOM_FONT: next_font = lambda: random.choice(all_fonts)
else: next_font = lambda: default_font

quit = False
text = "RubenWriter"
font = next_font()
color = random.choice(all_colors)

while not quit:
    screen.fill((0,0,0))

    # draw screen
    rendered = fonts[font].render(text, True, colors[color])
    screen.blit(*make_label(rendered,X/2,Y/2))

    rendered = fonts[font].render('CTRL+SHIFT+ESC to exit', True, colors[color])
    screen.blit(*make_label(rendered,X/2,Y-FONT_SIZE))
    
    pygame.display.flip()
    
    # get keyboard input
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE and shift and ctrl:
                quit = True
            elif event.key == pygame.K_BACKSPACE:
                text = text[:-1]
            else:
                try: char = event.unicode
                except: char = ''
                
                shift = event.mod&pygame.KMOD_SHIFT
                ctrl = event.mod&pygame.KMOD_CTRL
                
                if char:
                    text = text[-(LEN-1):] + char
                    font = next_font()
                    color = random.choice(all_colors)
            
<commit_msg>Optional random colors.<commit_after>import pygame
import pygame.locals
import random


X,Y = 512,384
LEN = 20
FONT_SIZE = 40
RANDOM_FONT = False
RANDOM_COLOR = True

def make_label(text, cx, cy):
    rect = text.get_rect()
    rect.centerx = cx
    rect.centery = cy
    return (text, rect)

def render(render, font, *args):
    return getattr(font, render)(*args)


pygame.display.init()
screen = pygame.display.set_mode((X,Y), (pygame.locals.NOFRAME | pygame.locals.FULLSCREEN))
colors = {
          'red': (255,0,0),
          'blue': (0,0,255),
          'green': (0,255,0),
          'yellow': (255,255,0),
          'white': (255,255,255),
          'grey': (128,128,128),
          }
all_colors = colors.keys()

pygame.font.init()
all_fonts = pygame.font.get_fonts()
fonts = {}
for font in all_fonts:
    path = pygame.font.match_font(font)
    if path:
        fonts[font] = pygame.font.Font(path, FONT_SIZE)

default_font = pygame.font.get_default_font()
default_font = (f for f in all_fonts if default_font.startswith(f)).next()

if RANDOM_FONT: next_font = lambda: random.choice(all_fonts)
else: next_font = lambda: default_font

if RANDOM_COLOR: next_color = lambda: random.choice(all_colors)
else: next_color = lambda: 'white'

quit = False
text = "RubenWriter"
font = next_font()
color = next_color()

while not quit:
    screen.fill((0,0,0))

    # draw screen
    rendered = fonts[font].render(text, True, colors[color])
    screen.blit(*make_label(rendered,X/2,Y/2))

    rendered = fonts[font].render('CTRL+SHIFT+ESC to exit', True, colors[color])
    screen.blit(*make_label(rendered,X/2,Y-FONT_SIZE))
    
    pygame.display.flip()
    
    # get keyboard input
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE and shift and ctrl:
                quit = True
            elif event.key == pygame.K_BACKSPACE:
                text = text[:-1]
            else:
                try: char = event.unicode
                except: char = ''
                
                shift = event.mod&pygame.KMOD_SHIFT
                ctrl = event.mod&pygame.KMOD_CTRL
                
                if char:
                    text = text[-(LEN-1):] + char
                    font = next_font()
                    color = next_color()
            

{'fraction_non_alphanumeric': 0.1299298860648554, 'fraction_numerical': 0.025416301489921123, 'mean_word_length': 2.2889048991354466, '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': '6133581', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1515, 'n_words': 329}