def redirect_stdout(area): try: sys.stdout.remove(area) except ValueError: pass sys.stdout.append(Stdout(area)) set_status_msg('Output redirected to %s' % area.index('insert'))
def start_debug_args(self, area): ask = Ask(area) ARGS = 'python -u -m pdb %s %s' % (area.filename, ask.data) ARGS = shlex.split(ARGS) self.kill_debug_process() self.create_process(ARGS) set_status_msg('Debug started ! Args: %s' % ask.data)
def del_data(self, area): """ """ self.data[-1] = self.data[-1][:-1] if not self.data[-1] and len(self.data) > 1: self.data.pop() set_status_msg('Pattern:%s' % '.+?'.join(self.data)) area.tag_remove('sel', *self.start_range(area)) area.pick_next_down('sel', self.make_pattern(), *self.start_range(area))
def save_quit(area): """ It saves the contents of the text area then quits. """ try: area.save_data() except Exception: set_status_msg('It failed to save data.') else: area.quit()
def save(area): """ It just saves the text area contents into the actual opened file. """ try: area.save_data() except Exception: set_status_msg('It failed to save data.') else: set_status_msg('Data saved.')
def add_data(self, area, char): """ """ try: char = chr(char) except ValueError: return else: self.data[-1] = self.data[-1] + char set_status_msg('Pattern:%s' % '.+?'.join(self.data)) area.tag_remove('sel', *self.start_range(area)) area.pick_next_down('sel', self.make_pattern(), *self.start_range(area))
def install(area): area.install( (-1, '<FocusIn>', lambda event: update_mode(event.widget)), (-1, '<FocusIn>', lambda event: update_cursor_pos(event.widget)), (-1, '<Control-F9>', lambda event: root.status.switch()), (-1, '<Escape>', lambda event: set_status_msg('')), (-1, '<<SaveData>>', lambda event: root.title('Vy %s' % event.widget.filename)), (-1, '<<LoadData>>', lambda event: root.title('Vy %s' % event.widget.filename)), (-1, '<<ClearData>>', lambda event: root.title('Vy %s' % event.widget.filename)), (-1, '<FocusIn>', lambda event: root.title('Vy %s' % event.widget.filename)), (-1, '<<SaveData>>', lambda event: root.note.tab(get_area_tab_index(event.widget), text=basename(event.widget.filename))), (-1, '<<LoadData>>', lambda event: root.note.tab(get_area_tab_index(event.widget), text=basename(event.widget.filename))), (-1, '<<ClearData>>', lambda event: root.note.tab(get_area_tab_index(event.widget), text=basename(event.widget.filename))), (-1, '<FocusIn>', lambda event: root.note.tab( root.note.select(), text=basename(event.widget.filename))))
def save_as(area): """ It pops a asksaveasfilename window to save the contents of the text area. """ filename = asksaveasfilename() # If the user presses cancel it returns ''. if not filename: return try: area.save_data_as(filename) except Exception: set_status_msg('It failed to save data.') else: set_status_msg('Data saved.')
def load_tab(): """ It pops a askopenfilename window to drop the contents of a file into another tab's text area. """ filename = askopenfilename() # If i don't check it ends up cleaning up # the text area when one presses cancel. if not filename: return try: root.note.load([[filename]]) except Exception: set_status_msg('It failed to load.') else: set_status_msg('File loaded.')
def load_tab(): """ It pops a askopenfilename window to drop the contents of a file into another tab's text area. """ filename = askopenfilename() # If i don't check it ends up cleaning up # the text area when one presses cancel. if not filename: return try: root.note.load([ [filename] ]) except Exception: set_status_msg('It failed to load.') else: set_status_msg('File loaded.')
def load(area): """ It pops a askopenfilename to find a file to drop the contents in the focused text area. """ filename = askopenfilename() # If i don't check it ends up cleaning up # the text area when one presses cancel. if not filename: return try: area.load_data(filename) except Exception: set_status_msg('It failed to load.') else: set_status_msg('File loaded.')
def install(area): area.install((-1, '<FocusIn>', lambda event: update_mode(event.widget)), (-1, '<FocusIn>', lambda event: update_cursor_pos(event.widget)), (-1, '<Control-F9>', lambda event: root.status.switch()), (-1, '<Escape>', lambda event: set_status_msg('')), (-1, '<<SaveData>>', lambda event: root.title('Vy %s' % event.widget.filename)), (-1, '<<LoadData>>', lambda event: root.title('Vy %s' % event.widget.filename)), (-1, '<<ClearData>>', lambda event: root.title('Vy %s' % event.widget.filename)), (-1, '<FocusIn>', lambda event: root.title('Vy %s' % event.widget.filename)), (-1, '<<SaveData>>', lambda event: root.note.tab(get_area_tab_index(event.widget), text=basename(event.widget.filename))), (-1, '<<LoadData>>', lambda event: root.note.tab(get_area_tab_index(event.widget), text=basename(event.widget.filename))), (-1, '<<ClearData>>', lambda event: root.note.tab(get_area_tab_index(event.widget), text=basename(event.widget.filename))), (-1, '<FocusIn>', lambda event: root.note.tab(root.note.select(), text=basename(event.widget.filename))))
def set_target(area): area.active() set_status_msg('Target set !')
def start_mode(self, area): self.data = [''] set_status_msg('') area.chmode('QUICK_SEARCH')
def start_debug(self, area): self.kill_debug_process() self.create_process(['python', '-u', '-m', 'pdb', area.filename]) set_status_msg('Debug started !')
def terminate_process(self): self.kill_debug_process() set_status_msg('Debug finished !')
def drop_start_mark(area): area.start_block_selection() set_status_msg('Dropped block selection mark.')
def clip_ph(area): """ Sends filename path to clipboard. """ area.clipboard_clear() area.clipboard_append(area.filename) set_status_msg('File path copied to the clipboard.')
def restart(self): self.child.kill() self.start() set_status_msg('Process killed and started !')
def no_match(self, area): set_status_msg('No pattern found!') area.chmode('NORMAL')
def drop_selection_mark(area): area.start_selection() set_status_msg('Dropped selection mark.')
def drop_selection_mark(area): area.start_selection() set_status_msg("Dropped selection mark.")