def __init__(self): self._NONE = 0 self._ARROW = 1 self._TEXT = 2 self._TEXT_ARROW = 3 self._CIRCLE = 4 self.dispW = 0 self.dispH = 0 self.graph_height = 0 self.graph_height = 0 self.colours = [] self.hard_colours = self.populate_colours() self.undo_stack = UndoStack() self.session_dict = dict(_DICT_ELEMS) self.anime_annotations_list = None self.temp_session = None self.graph_axes = None self.legend = None self.parser = None self.draw_plot = None self.cell_segments = [] self.graph_canvas = None self.server = Sink() self.client = Sink() self.panels = [] self.lamport_clock = 0
def __init__(self, text: str): self.__text = text self.undo_stack = UndoStack()
def __init__(self, notebook, edit_only=False): # Chunk changed is emitted when the text or tokenization of a chunk # changes. Note that "changes" here specifically includes being # replaced by identical text, so if I have the two chunks # # if # if # # And I delete the from the first 'i' to the second f, the first # chunk is considered to change, even though it's text remains 'if'. # This is because text in a buffering that is shadowing us may # be tagged with fonts/styles. # self.sig_chunk_inserted = signals.Signal() self.sig_chunk_changed = signals.Signal() self.sig_chunk_deleted = signals.Signal() self.sig_chunk_status_changed = signals.Signal() self.sig_chunk_results_changed = signals.Signal() # text-* are emitted before we fix up our internal state, so what can be done # in them are limited. They are meant for keeping a UI in sync with the internal # state. self.sig_text_inserted = signals.Signal() self.sig_text_deleted = signals.Signal() self.sig_lines_inserted = signals.Signal() self.sig_lines_deleted = signals.Signal() # This is only for the convenience of the undo stack; otherwise we ignore cursor position self.sig_place_cursor = signals.Signal() self.notebook = notebook self.edit_only = edit_only self.__file = None self.sig_file = signals.Signal() self.__filename = None self.sig_filename_changed = signals.Signal() self.__code_modified = False self.sig_code_modified = signals.Signal() self.__state = NotebookFile.EXECUTE_SUCCESS self.sig_state = signals.Signal() self.global_scope = {} notebook.setup_globals(self.global_scope) exec _DEFINE_GLOBALS in self.global_scope self.__lines = [""] self.__chunks = [BlankChunk(0, 1)] # There's quite a bit of complexity knowing when a change to lines changes # adjacent chunks. We use a simple and slightly inefficient algorithm for this # and just scan everything that might have changed. But we don't want typing # within a line to cause an unlimited rescan, so we keep track if the only # changes we've made are inserting/deleting within a line without changing # that lines class self.__changes = ChangeRange() self.__scan_adjacent = False self.__changed_chunks = set() self.__deleted_chunks = set() self.__freeze_changes_count = 0 self.__user_action_count = 0 self.__undo_stack = UndoStack(self) self.__executor = None notebook._add_worksheet(self)