Lines Matching refs:self

11 For EditorWindows, <<toggle-code-context>> is bound to CodeContext(self).
49 def __init__(self, editwin):
53 self.text is the editor window text widget.
55 self.context displays the code context text above the editor text.
57 self.topvisible is the number of the top text line displayed.
58 self.info is a list of (line number, indent level, line text,
60 self.info[0] is initialized with a 'dummy' line which
63 self.t1 and self.t2 are two timer events on the editor text widget to
66 self.editwin = editwin
67 self.text = editwin.text
68 self._reset()
70 def _reset(self):
71 self.context = None
72 self.cell00 = None
73 self.t1 = None
74 self.topvisible = 1
75 self.info = [(0, -1, "", False)]
84 def __del__(self):
86 if self.t1 is not None:
88 self.text.after_cancel(self.t1)
91 self.t1 = None
93 def toggle_code_context_event(self, event=None):
96 If self.context doesn't exist, create it to match the size of the editor
100 if self.context is None:
106 widgets = self.editwin.text, self.editwin.text_frame
112 if widget is self.editwin.text
117 context = self.context = Text(
118 self.editwin.text_frame,
123 self.update_font()
124 self.update_highlight_colors()
125 context.bind('<ButtonRelease-1>', self.jumptoline)
127 self.timer_event()
133 self.cell00 = Frame(self.editwin.text_frame,
135 self.cell00.grid(row=0, column=0, sticky=NSEW)
138 self.context.destroy()
139 self.context = None
140 self.cell00.destroy()
141 self.cell00 = None
142 self.text.after_cancel(self.t1)
143 self._reset()
145 self.editwin.update_menu_label(menu='options', index='*ode*ontext',
149 def get_context(self, new_topvisible, stopline=1, stopindent=0):
165 codeline = self.text.get(f'{linenum}.0', f'{linenum}.end')
179 def update_code_context(self):
187 new_topvisible = self.editwin.getlineno("@0,0")
188 if self.topvisible == new_topvisible: # Haven't scrolled.
190 if self.topvisible < new_topvisible: # Scroll down.
191 lines, lastindent = self.get_context(new_topvisible,
192 self.topvisible)
195 while self.info[-1][1] >= lastindent:
196 del self.info[-1]
197 else: # self.topvisible > new_topvisible: # Scroll up.
198 stopindent = self.info[-1][1] + 1
201 while self.info[-1][0] >= new_topvisible:
202 stopindent = self.info[-1][1]
203 del self.info[-1]
204 lines, lastindent = self.get_context(new_topvisible,
205 self.info[-1][0]+1,
207 self.info.extend(lines)
208 self.topvisible = new_topvisible
210 context_strings = [x[2] for x in self.info[-self.context_depth:]]
213 self.context['height'] = len(context_strings) - showfirst
214 self.context['state'] = 'normal'
215 self.context.delete('1.0', 'end')
216 self.context.insert('end', '\n'.join(context_strings[showfirst:]))
217 self.context['state'] = 'disabled'
219 def jumptoline(self, event=None):
226 self.context.index("sel.first")
228 lines = len(self.info)
233 contextline = int(float(self.context.index('insert')))
235 offset = max(1, lines - self.context_depth) - 1
236 newtop = self.info[offset + contextline][0]
237 self.text.yview(f'{newtop}.0')
238 self.update_code_context()
240 def timer_event(self):
242 if self.context is not None:
243 self.update_code_context()
244 self.t1 = self.text.after(self.UPDATEINTERVAL, self.timer_event)
246 def update_font(self):
247 if self.context is not None:
248 font = idleConf.GetFont(self.text, 'main', 'EditorWindow')
249 self.context['font'] = font
251 def update_highlight_colors(self):
252 if self.context is not None:
254 self.context['background'] = colors['background']
255 self.context['foreground'] = colors['foreground']
257 if self.cell00 is not None:
260 self.cell00.config(bg=line_number_colors['background'])