Ejemplo n.º 1
0
class VirtualCodeBox:
    """Specifies a box to contain code. This implementation is not meant to be
    associated with a :class:`Screen`. Used for "rendering" off screen,
    manipulating code either for export or copying to a concrete code box
    later

    :param starting_line_number: -1 means no line numbers, anything larger will 
                                 be the first line number displayed.  Defaults 
                                 to -1
    """
    def __init__(self, starting_line_number=-1, display_mode='plain'):
        self.starting_line_number = starting_line_number
        self.listing = Listing(starting_line_number=starting_line_number)
        self.widget = VirtualCodeWidget()

        self.listing.set_display(display_mode, self.widget)

    def perform_actions(self, actions):
        """Performs the list of actions on the code in the box. Done separtely
        from the main event loop so it has no interactions like Wait,
        typewriters, etc. Everything is done in fast-forward mode.

        :param actions: list of actions to perfrom on the code in this box
        """
        for action in actions:
            for step in action.steps():
                step.render_step()
Ejemplo n.º 2
0
 def test_rtf(self):
     RTFColourizer.reset_background_colour()
     code = Code(text=self.py_source, lexer_name='py3')
     listing = Listing(code)
     listing.set_display('rtf')
     self.file_compare('print_rtf_nobg.out', print_rtf, listing)
     self.file_compare('print_rtf_bg.out', print_rtf, listing, 'ccc')
Ejemplo n.º 3
0
 def __init__(self, starting_line_number=-1, auto_scroll=True, height=0, 
         compact=False):
     self.starting_line_number = starting_line_number
     self.auto_scroll = auto_scroll
     self.height = height
     self.compact = compact
     self.listing = Listing(starting_line_number=starting_line_number)
Ejemplo n.º 4
0
    def __init__(self, starting_line_number=-1, display_mode='plain'):
        self.starting_line_number = starting_line_number
        self.listing = Listing(starting_line_number=starting_line_number)
        self.widget = VirtualCodeWidget()

        self.listing.set_display(display_mode, self.widget)
Ejemplo n.º 5
0
 def test_html(self):
     code = Code(text=self.py_source, lexer_name='py3')
     listing = Listing(code)
     listing.set_display('html')
     self.file_compare('print_html_snippet.out', print_html, listing, True)
     self.file_compare('print_html_full.out', print_html, listing, False)
Ejemplo n.º 6
0
 def test_ansi(self):
     code = Code(text=self.py_source, lexer_name='py3')
     listing = Listing(code)
     listing.set_display('ansi')
     self.file_compare('print_ansi.out', print_ansi, listing)
Ejemplo n.º 7
0
    def test_tokens(self):
        code = Code(text=self.py_source, lexer_name='py3')
        listing = Listing(code)

        self.file_compare('print_tokens_ansi.out', print_tokens, listing, True)
        self.file_compare('print_tokens_bw.out', print_tokens, listing, False)