(self, s, can_break=True)
Write string s to SCRN:
Write string s to SCRN:
Write string s to SCRN :
def write(self, s, can_break=True):
        """Write string s to SCRN: """
        if not s:
            return
        # writes to SCRN files should *not* be echoed
        do_echo = self._is_master
        self._col = self.console.current_col
        # take column 80+overflow into account
        if self.console.overflow:
            self._col += 1
        # only break lines at the start of a new string. width 255 means unlimited width
        s_width = 0
        newline = False
        # find width of first line in s
        for c in iterchar(s):
            if c in (b'\r', b'\n'):
                newline = True
                break
            if c == b'\b':
                # for lpt1 and files, nonprinting chars are not counted in LPOS;
                # but chr$(8) will take a byte out of the buffer
                s_width -= 1
            elif c >= b' ':
                # nonprinting characters including tabs are not counted for WIDTH
                s_width += 1
        if can_break and (self.width != 255 and self.console.current_row != self.console.height
                and self.col != 1 and self.col-1 + s_width > self.width and not newline):
            self.console.write_line(do_echo=do_echo)
            self._col = 1
        cwidth = self.console.width
        output = []
        for c in iterchar(s):
            if self.width <= cwidth and self.col > self.width:
                self.console.write_line(b''.join(output), do_echo=do_echo)
                output = []
                self._col = 1
            if self.col <= cwidth or self.width <= cwidth:
                output.append(c)
            if c in (b'\n', b'\r'):
                self.console.write(b''.join(output), do_echo=do_echo)
                output = []
                self._col = 1
            else:
                self._col += 1
        self.console.write(b''.join(output), do_echo=do_echo)
def write ( self , s , can_break = True ) : if not s : return # writes to SCRN files should *not* be echoed do_echo = self . _is_master self . _col = self . console . current_col # take column 80+overflow into account if self . console . overflow : self . _col += 1 # only break lines at the start of a new string. width 255 means unlimited width s_width = 0 newline = False # find width of first line in s for c in iterchar ( s ) : if c in ( b'\r' , b'\n' ) : newline = True break if c == b'\b' : # for lpt1 and files, nonprinting chars are not counted in LPOS; # but chr$(8) will take a byte out of the buffer s_width -= 1 elif c >= b' ' : # nonprinting characters including tabs are not counted for WIDTH s_width += 1 if can_break and ( self . width != 255 and self . console . current_row != self . console . height and self . col != 1 and self . col - 1 + s_width > self . width and not newline ) : self . console . write_line ( do_echo = do_echo ) self . _col = 1 cwidth = self . console . width output = [ ] for c in iterchar ( s ) : if self . width <= cwidth and self . col > self . width : self . console . write_line ( b'' . join ( output ) , do_echo = do_echo ) output = [ ] self . _col = 1 if self . col <= cwidth or self . width <= cwidth : output . append ( c ) if c in ( b'\n' , b'\r' ) : self . console . write ( b'' . join ( output ) , do_echo = do_echo ) output = [ ] self . _col = 1 else : self . _col += 1 self . console . write ( b'' . join ( output ) , do_echo = do_echo )