(self, event=None)
Copy selected lines to the clipboard, with prompts.

        This makes the copied text useful for doc-tests and interactive
        shell code examples.

        This always copies entire lines, even if only part of the first
        and/or last lines is selected.
Copy selected lines to the clipboard, with prompts.
Copy selected lines to the clipboard with prompts .
def copy_with_prompts_callback(self, event=None):
        """Copy selected lines to the clipboard, with prompts.

        This makes the copied text useful for doc-tests and interactive
        shell code examples.

        This always copies entire lines, even if only part of the first
        and/or last lines is selected.
        """
        text = self.text

        selection_indexes = (
            self.text.index("sel.first linestart"),
            self.text.index("sel.last +1line linestart"),
        )
        if selection_indexes[0] is None:
            # There is no selection, so do nothing.
            return

        selected_text = self.text.get(*selection_indexes)
        selection_lineno_range = range(
            int(float(selection_indexes[0])),
            int(float(selection_indexes[1]))
        )
        prompts = [
            self.shell_sidebar.line_prompts.get(lineno)
            for lineno in selection_lineno_range
        ]
        selected_text_with_prompts = "\n".join(
            line if prompt is None else f"{prompt} {line}"
            for prompt, line in zip(prompts, selected_text.splitlines())
        ) + "\n"

        text.clipboard_clear()
        text.clipboard_append(selected_text_with_prompts)
def copy_with_prompts_callback ( self , event = None ) : text = self . text selection_indexes = ( self . text . index ( "sel.first linestart" ) , self . text . index ( "sel.last +1line linestart" ) , ) if selection_indexes [ 0 ] is None : # There is no selection, so do nothing. return selected_text = self . text . get ( * selection_indexes ) selection_lineno_range = range ( int ( float ( selection_indexes [ 0 ] ) ) , int ( float ( selection_indexes [ 1 ] ) ) ) prompts = [ self . shell_sidebar . line_prompts . get ( lineno ) for lineno in selection_lineno_range ] selected_text_with_prompts = "\n" . join ( line if prompt is None else f"{prompt} {line}" for prompt , line in zip ( prompts , selected_text . splitlines ( ) ) ) + "\n" text . clipboard_clear ( ) text . clipboard_append ( selected_text_with_prompts )