

def write(self, text, x=None, y=None, fgcolor=None, bgcolor=None):
    if (x is not None):
        self.cursorx = x
    if (y is not None):
        self.cursory = y
    fgcolor = (((fgcolor is None) and self._fgcolor) or getpygamecolor(fgcolor))
    bgcolor = (((bgcolor is None) and self._bgcolor) or getpygamecolor(bgcolor))
    tempcursorx = (self._cursorx - 1)
    for (i, ch) in enumerate(text):
        if (ch == '\n'):
            tempcursorx = 0
        elif (ch == '\t'):
            numspaces = (self._tabsize - ((i + 1) + (tempcursorx % self._tabsize)))
            if ((tempcursorx + numspaces) >= self._width):
                text = ((text[:i] + (' ' * ((self._width - tempcursorx) + 1))) + text[(i + 1):])
                tempcursorx += ((self._width - tempcursorx) + 1)
            else:
                text = ((text[:i] + (' ' * numspaces)) + text[(i + 1):])
                tempcursorx += numspaces
        else:
            tempcursorx += getcharwidth(ch)
        if (tempcursorx >= self._width):
            tempcursorx = 0
    "\n        # create a cache of surface objects for each letter in text\n        letterSurfs = {}\n        for letter in text:\n            if ord(letter) in range(33, 127) and letter not in letterSurfs:\n                letterSurfs[letter] = self._font.render(letter, 1, fgcolor, bgcolor)\n                #letterSurfs[letter] = letterSurfs[letter].convert_alpha() # TODO - wait a sec, I don't think pygame lets fonts have transparent backgrounds.\n            elif letter == ' ':\n                continue\n            elif letter not in letterSurfs and '?' not in letterSurfs:\n                letterSurfs['?'] = self._font.render('?', 1, fgcolor, bgcolor)\n                #letterSurfs['?'] = letterSurfs['?'].convert_alpha()\n        "
    for ch in text:
        if (ch in ('\n', '\r')):
            self._cursory += 1
            x._cursorx = 0
        else:
            if (iswide(ch) and ((self._cursorx + 1) == self._width)):
                self._cursory += 1
                self._cursorx = 0
            self._screenchar[self._cursorx][self._cursory] = ch
            self._screenfgcolor[self._cursorx][self._cursory] = fgcolor
            self._screenbgcolor[self._cursorx][self._cursory] = bgcolor
            self._screendirty[self._cursorx][self._cursory] = True
            '\n                r = pygame.Rect(self._cellwidth * self._cursorx, self._cellheight * self._cursory, self._cellwidth, self._cellheight)\n                self._surfaceobj.fill(bgcolor, r)\n                charsurf = letterSurfs[ch]\n                charrect = charsurf.get_rect()\n                charrect.centerx = self._cellwidth * self._cursorx + int(self._cellwidth / 2)\n                charrect.bottom = self._cellheight * (self._cursory+1)\n                self._surfaceobj.blit(charsurf, charrect)\n                self._screendirty[self._cursorx][self._cursory] = False\n                '
            self._cursorx += getcharwidth(ch)
            if (self._cursorx >= self._width):
                self._cursorx = 0
                self._cursory += 1
        if (self._cursory >= self._height):
            self._scroll()
            self._cursory = (self._height - 1)
    if self._autoupdate:
        self.update()

dataset/ETHPy150Open asweigart/pygcurse/pygcurse/__init__.py PygcurseSurface.write/VarMisuse@338/691 `self`->`x`