def run(self, edit, rows=None, condition=None, enabled=None, filename=None): # Get filename in current view and check if is a valid filename if filename is None: filename = self.view.file_name() if not filename or not os.path.isfile(filename): return # Add entry for file in breakpoint data if filename not in S.BREAKPOINT: S.BREAKPOINT[filename] = {} # When no rows are defined, use selected rows (line numbers), filtering empty rows if rows is None: rows = V.region_to_rows(self.view.sel(), filter_empty=True) # Loop through rows for row in rows: expression = None if condition is not None and len(condition.strip()) > 0: expression = condition # Check if breakpoint exists breakpoint_exists = row in S.BREAKPOINT[filename] # Disable/Remove breakpoint if breakpoint_exists: if S.BREAKPOINT[filename][row][ 'id'] is not None and session.is_connected( show_status=True): async_session = session.SocketHandler( session.ACTION_REMOVE_BREAKPOINT, breakpoint_id=S.BREAKPOINT[filename][row]['id']) async_session.start() if enabled is False: S.BREAKPOINT[filename][row]['enabled'] = False elif enabled is None: del S.BREAKPOINT[filename][row] # Add/Enable breakpoint if not breakpoint_exists or enabled is True: if row not in S.BREAKPOINT[filename]: S.BREAKPOINT[filename][row] = { 'id': None, 'enabled': True, 'expression': expression } else: S.BREAKPOINT[filename][row]['enabled'] = True if condition is not None: S.BREAKPOINT[filename][row]['expression'] = expression else: expression = S.BREAKPOINT[filename][row]['expression'] if session.is_connected(show_status=True): async_session = session.SocketHandler( session.ACTION_SET_BREAKPOINT, filename=filename, lineno=row, expression=expression) async_session.start() # Render breakpoint markers V.render_regions() # Update breakpoint list try: if V.has_debug_view(V.TITLE_WINDOW_BREAKPOINT): V.show_content(V.DATA_BREAKPOINT) except: pass # Save breakpoint data to file util.save_breakpoint_data()
def is_enabled(self): return session.is_connected()
def is_visible(self): return session.is_connected()
def is_visible(self): return S.BREAKPOINT_ROW is not None and session.is_connected()