like call but write to a temporary buffer
(
self, toktype: int, toktext: str, start_pos: tuple[int, int]
)
| 537 | return (None, error) |
| 538 | |
| 539 | def _inner_call_( |
| 540 | self, toktype: int, toktext: str, start_pos: tuple[int, int] |
| 541 | ) -> str: |
| 542 | """like call but write to a temporary buffer""" |
| 543 | srow, scol = start_pos |
| 544 | |
| 545 | # calculate new positions |
| 546 | oldpos = self.pos |
| 547 | newpos = self.lines[srow] + scol |
| 548 | self.pos = newpos + len(toktext) |
| 549 | |
| 550 | # send the original whitespace, if needed |
| 551 | if newpos > oldpos: |
| 552 | acc = self.raw[oldpos:newpos] |
| 553 | else: |
| 554 | acc = "" |
| 555 | |
| 556 | # skip indenting tokens |
| 557 | if toktype in [token.INDENT, token.DEDENT]: |
| 558 | self.pos = newpos |
| 559 | return acc |
| 560 | |
| 561 | # map token type to a color group |
| 562 | if token.LPAR <= toktype <= token.OP: |
| 563 | toktype = token.OP |
| 564 | elif toktype == token.NAME and keyword.iskeyword(toktext): |
| 565 | toktype = _KEYWORD |
| 566 | pyg_tok_type = _pygment_token_mapping.get(toktype, Token.Text) |
| 567 | |
| 568 | # send text, pygments should take care of splitting on newline and resending |
| 569 | # the correct self.colors after the new line, which is necessary for pagers |
| 570 | acc += theme_table[self.theme_name].format([(pyg_tok_type, toktext)]) |
| 571 | return acc |
| 572 | |
| 573 | def __call__( |
| 574 | self, |