def write(self, data): if self.block is None: self.block = get_console_block() self.parent.Children.Add(self.block) block = self.block if data.endswith('\n'): data = data[:-1] self.block = None block.Text += data
def print_lines(self, data): code = data.replace('\r\n', '\n').replace('\r', '\n') _debug('code', repr(code)) self.block = get_console_block() self.parent.Children.Add(self.block) ps1 = sys.ps1 ps2 = sys.ps2 if not isinstance(ps1, str): ps1 = str(ps1) ps2 = str(ps2) for run in colorize(code, ps1, ps2): self.block.Inlines.Add(run) color = run.Foreground.Color #_debug("Printing run", repr(run.Text), color.R, color.G, color.B) #_debug(repr(self.block.Text)) self.block = None