(self, s, can_break=True)
Write a string to the printer buffer.
Write a string to the printer buffer.
Write a string to the printer buffer .
def write(self, s, can_break=True):
        """Write a string to the printer buffer."""
        assert isinstance(s, bytes), type(s)
        with safe_io():
            for c in iterchar(s):
                # don't replace CR or LF with
                self._fhandle.write(c)
                # col reverts to 1 on CR (\r) and LF (\n) but not FF (\f)
                if c in (b'\n', b'\r'):
                    self._settings.col = 1
                elif c == b'\b':
                    if self._settings.col > 1:
                        self._settings.col -= 1
                else:
                    # nonprinting characters including tabs are not counted for LPOS
                    if ord(c) >= 32:
                        self._settings.col += 1
                # width 255 means wrapping enabled
                if can_break and self.width != 255:
                    if self._settings.col > self.width:
                        self._fhandle.write(b'\r\n')
                        # GW-BASIC quirk: on LPT1 files the LPOS goes to width+1, then wraps to 2
                        if not self._bug:
                            self._settings.col = 1
                        elif self._settings.col > self.width + 1:
                            self._settings.col = 2
        self.col = self._settings.col
def write ( self , s , can_break = True ) : assert isinstance ( s , bytes ) , type ( s ) with safe_io ( ) : for c in iterchar ( s ) : # don't replace CR or LF with self . _fhandle . write ( c ) # col reverts to 1 on CR (\r) and LF (\n) but not FF (\f) if c in ( b'\n' , b'\r' ) : self . _settings . col = 1 elif c == b'\b' : if self . _settings . col > 1 : self . _settings . col -= 1 else : # nonprinting characters including tabs are not counted for LPOS if ord ( c ) >= 32 : self . _settings . col += 1 # width 255 means wrapping enabled if can_break and self . width != 255 : if self . _settings . col > self . width : self . _fhandle . write ( b'\r\n' ) # GW-BASIC quirk: on LPT1 files the LPOS goes to width+1, then wraps to 2 if not self . _bug : self . _settings . col = 1 elif self . _settings . col > self . width + 1 : self . _settings . col = 2 self . col = self . _settings . col