def create(self, filename='none'): """ This method creates a horizontal AreaVi widget. It returns the AreaVi widget that was created. It as well installs the plugins that appear in the vyrc file in the AreaVi widget. """ frame = Frame(master=self) scrollbar = Scrollbar(master=frame) area = AreaVi(filename, frame , border=3, relief=RAISED, yscrollcommand=scrollbar.set) scrollbar.config(command=area.yview) scrollbar.pack(side='right', fill=Y) from vyapp.plugins import HANDLE for handle, args, kwargs in HANDLE: handle(area, *args, **kwargs) area.focus_set() area.pack(expand=True, side='left', fill=BOTH) self.add(frame) def save_focus(event): self.master.focused_area = area self.master.focused_area = area area.bind('<FocusIn>', save_focus) return area
def load(plugin, *args, **kwargs): autoload(plugin, *args, **kwargs) for ind in AreaVi.areavi_widgets(root): plugin.install(ind, *args, **kwargs) root.status.set_msg('Plugin loaded!')
def handle_line(self, device, filename, line, args): """ """ try: area = AreaVi.get_opened_files(root)[filename] except KeyError: pass else: set_line(area, line)
def restore_area_focus(self): """ When an AreaVi is destroyed, the focused_area is a dead widget, so it gives focus to the first AreaVi in the active tab. """ wid = self.nametowidget(self.select()) seq = AreaVi.areavi_widgets(wid) area = next(seq) area.focus_set()
def delete_all_breakpoints(self): """ It deletes all added breakpoint tags. It is useful when restarting pdb as a different process. """ widgets = AreaVi.get_opened_files(root) for index, (filename, line) in self.map_index.items(): area = widgets.get(filename) if area: area.tag_delete('_breakpoint_%s' % index)
def findline(filename, line, col=0): files = AreaVi.get_opened_files(root) filename = abspath(filename) try: area = files[filename] except KeyError: area = root.note.open(filename) else: pass finally: root.note.set_line(area, line)
def update_instances(self, changes): """ After changes it updates all AreaVi instances which were changed. """ # Avoid having to calculate it multiple times. self.files = AreaVi.get_opened_files(root) for ind in changes.changes: if isinstance(ind, (MoveResource,)): self.on_move_resource(ind) else: self.on_general_case(ind)
def delete_all_breakpoints(self): """ It deletes all added breakpoint tags. It is useful when restarting pdb as a different process. """ for index, (filename, line) in self.map_index.iteritems(): try: area = AreaVi.get_opened_files(root)[filename] except KeyError: pass else: NAME = '_breakpoint_%s' % index area.tag_delete(NAME)
def e_pmsg(self, con, nick, user, host, target, msg): """ Private messages sent to the user are handled here. """ # Attempt to retrieve the areavi which corresponds # to the target/user. base = lambda key_value: (key_value[0].lower(), key_value[1]) files = iter(AreaVi.get_opened_files(root).items()) targets = dict(list(map(base, files))) try: area = targets[nick.lower()] except KeyError: area = self.create_private_channel(nick) area.append(H1 % (nick, msg))
def handle_breakpoint(self, device, index, filename, line): """ When a break point is added. """ self.map_index[index] = (filename, line) self.map_line[(filename, line)] = index map = AreaVi.get_opened_files(root) area = map[filename] NAME = '_breakpoint_%s' % index area.tag_add(NAME, '%s.0 linestart' % line, '%s.0 lineend' % line) area.tag_config(NAME, **self.setup)
def handle_deleted_breakpoint(self, device, index): """ When a break point is removed. """ filename, line = self.map_index[index] NAME = '_breakpoint_%s' % index area = None try: area = AreaVi.get_opened_files(root)[filename] except KeyError: return area.tag_delete(NAME)
def handle_line(self, device, filename, line): """ """ filename = abspath(filename) wids = AreaVi.get_opened_files(root) area = wids.get(filename) if area: root.note.set_line(area, line) area.tag_delete('(DebuggerBP)') area.tag_add('(DebuggerBP)', '%s.0 linestart' % line, '%s.0 lineend' % line) area.tag_config('(DebuggerBP)', **self.setup) root.status.set_msg('Debugger stopped at: %s:%s' % (filename, line))