| 460 | self.update_sidebar() |
| 461 | |
| 462 | def update_sidebar(self): |
| 463 | text = self.text |
| 464 | text_tagnames = text.tag_names |
| 465 | canvas = self.canvas |
| 466 | line_prompts = self.line_prompts = {} |
| 467 | |
| 468 | canvas.delete(tk.ALL) |
| 469 | |
| 470 | index = text.index("@0,0") |
| 471 | if index.split('.', 1)[1] != '0': |
| 472 | index = text.index(f'{index}+1line linestart') |
| 473 | while (lineinfo := text.dlineinfo(index)) is not None: |
| 474 | y = lineinfo[1] |
| 475 | prev_newline_tagnames = text_tagnames(f"{index} linestart -1c") |
| 476 | prompt = ( |
| 477 | '>>>' if "console" in prev_newline_tagnames else |
| 478 | '...' if "stdin" in prev_newline_tagnames else |
| 479 | None |
| 480 | ) |
| 481 | if prompt: |
| 482 | canvas.create_text(2, y, anchor=tk.NW, text=prompt, |
| 483 | font=self.font, fill=self.colors[0]) |
| 484 | lineno = get_lineno(text, index) |
| 485 | line_prompts[lineno] = prompt |
| 486 | index = text.index(f'{index}+1line') |
| 487 | |
| 488 | def yscroll_event(self, *args, **kwargs): |
| 489 | """Redirect vertical scrolling to the main editor text widget. |