Perform the following action: Each line sidebar_text contains the linenumber for that line Synchronize with editwin.text so that both sidebar_text and editwin.text contain the same number of lines
(self, end)
| 329 | ) |
| 330 | |
| 331 | def update_sidebar_text(self, end): |
| 332 | """ |
| 333 | Perform the following action: |
| 334 | Each line sidebar_text contains the linenumber for that line |
| 335 | Synchronize with editwin.text so that both sidebar_text and |
| 336 | editwin.text contain the same number of lines""" |
| 337 | if end == self.prev_end: |
| 338 | return |
| 339 | |
| 340 | width_difference = len(str(end)) - len(str(self.prev_end)) |
| 341 | if width_difference: |
| 342 | cur_width = int(float(self.sidebar_text['width'])) |
| 343 | new_width = cur_width + width_difference |
| 344 | self.sidebar_text['width'] = self._sidebar_width_type(new_width) |
| 345 | |
| 346 | with temp_enable_text_widget(self.sidebar_text): |
| 347 | if end > self.prev_end: |
| 348 | new_text = '\n'.join(itertools.chain( |
| 349 | [''], |
| 350 | map(str, range(self.prev_end + 1, end + 1)), |
| 351 | )) |
| 352 | self.sidebar_text.insert(f'end -1c', new_text, 'linenumber') |
| 353 | else: |
| 354 | self.sidebar_text.delete(f'{end+1}.0 -1c', 'end -1c') |
| 355 | |
| 356 | self.prev_end = end |
| 357 | |
| 358 | def yscroll_event(self, *args, **kwargs): |
| 359 | self.sidebar_text.yview_moveto(args[0]) |
no test coverage detected