MCPcopy Index your code
hub / github.com/python/cpython / update_sidebar_text

Method update_sidebar_text

Lib/idlelib/sidebar.py:331–356  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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])

Callers 1

init_widgetsMethod · 0.95

Calls 6

strFunction · 0.85
temp_enable_text_widgetFunction · 0.85
chainMethod · 0.80
joinMethod · 0.45
insertMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected