You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
show folding marks (purely based on indentation level increases rn)
classLineNumbers(Canvas):
def__init__(self, master, text=None, *args, **kwargs):
super().__init__(master, *args, **kwargs)
self.config(width=65, bd=0, highlightthickness=0)
self.text=textself.text.bind("<Configure>", self.redraw)
defget_indentation_level(self, line):
"""Get the indentation level of a given line."""returnlen(line) -len(line.lstrip())
defredraw(self, *_):
self.delete(tk.ALL)
prev_indent=0i=self.text.index("@0,0")
whileTrue:
dline=self.text.dlineinfo(i)
ifdlineisNone:
breaky=dline[1]
linenum=str(i).split(".")[0]
# Get the text content of the current lineline_content=self.text.get(f"{linenum}.0", f"{linenum}.end")
current_indent=self.get_indentation_level(line_content)
# Determine if the current line has more indentation than the previous lineifcurrent_indent>prev_indent:
line_num_with_indent=f"{linenum} +"else:
line_num_with_indent=linenum# to highlight the current linecurline=self.text.dlineinfo(tk.INSERT)
cur_y=curline[1] ifcurlineelseNoneifnotcur_y:
i=self.text.index(f"{i}+1line")
continueself.create_text(40, y, anchor=tk.NE, text=line_num_with_indent, font=("Consolas", 14), tag=i)
# Update the previous indentation levelprev_indent=current_indenti=self.text.index(f"{i}+1line")
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: